Created
March 10, 2014 14:22
-
-
Save hawaku/9465800 to your computer and use it in GitHub Desktop.
EC2にDynamic-DynamoDBをインストールする ref: http://qiita.com/treeclad/items/138da162cf8bb9fecf08
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
### BEGIN INIT INFO | |
# Provides: dynamic-dynamodb | |
# Required-Start: $remote_fs $syslog | |
# Required-Stop: $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
### END INIT INFO | |
NAME=dynamic-dynamodb | |
DAEMON=/usr/bin/dynamic-dynamodb | |
DRY_RUN=$2 | |
DAEMON_START_ARGS="--config /etc/dynamic-dynamodb/dynamic-dynamodb.conf --daemon start" | |
DAEMON_STOP_ARGS="--config /etc/dynamic-dynamodb/dynamic-dynamodb.conf --daemon stop" | |
SCRIPTNAME=/etc/init.d/$NAME | |
SERVICE_LOG_FILE=/var/log/dynamic-dynamodb/service.log | |
if [ "$DRY_RUN" == "--dry-run" ]; then | |
DAEMON_START_ARGS="--config /etc/dynamic-dynamodb/dynamic-dynamodb.conf --dry-run --daemon start" | |
DAEMON_STOP_ARGS="--config /etc/dynamic-dynamodb/dynamic-dynamodb.conf --dry-run --daemon stop" | |
elif [ "$2" != "" ]; then | |
echo $2 | |
echo "Second parameter has to be --dry-run and is used only when running start/restart/force-reload commands" | |
exit 1 | |
fi | |
# Exit if the package is not installed | |
[ -x $DAEMON ] || exit 1 | |
. /etc/rc.d/init.d/functions | |
log(){ | |
timenow=`date +%Y-%m-%dT%H:%M:%S.%N` | |
echo "$timenow: $1" | |
echo "$timenow: $1" >> $SERVICE_LOG_FILE | |
} | |
error_exit(){ | |
log "$1" | |
exit 1 | |
} | |
do_start() | |
{ | |
if [ "$DRY_RUN" == "--dry-run" ]; then | |
log "do_start:Dry run mode" | |
else | |
log "do_start:Firstly" | |
fi | |
log "do_start:Starting $NAME" | |
daemon $DAEMON $DAEMON_START_ARGS || error_exit "Failed in starting $NAME service" | |
} | |
do_stop() | |
{ | |
log "do_stop:Stopping $NAME" | |
daemon $DAEMON $DAEMON_STOP_ARGS || error_exit "Failed in stopping $NAME service" | |
} | |
case "$1" in | |
start) | |
do_start | |
;; | |
stop) | |
do_stop | |
;; | |
status) | |
status "$DAEMON" "$NAME" && exit 0 || exit $? | |
;; | |
restart|force-reload) | |
do_stop | |
do_start | |
#*) | |
;; | |
*) | |
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 | |
exit 3 | |
;; | |
esac | |
: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws-access-key-id: AWSAccessKey | |
aws-secret-access-key-id: AWSSecretKey | |
region: ap-northeast-1 | |
log-file: /var/log/dynamic-dynamodb.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo pip install dynamic-dynamodb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo mkdir /etc/dynamic-dynamodb | |
$ cd /etc/dynamic-dynamodb | |
$ sudo wget https://github.com/sebdah/dynamic-dynamodb/blob/master/example-dynamic-dynamodb.conf | |
$ sudo mv example-dynamic-dynamodb.conf dynamic-dynamodb.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo mkdir /var/log/dynamic-dynamodb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo chkconfig --add dynamic-dynamodb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo service dynamic-dynamodb start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo service dynamic-dynamodb stop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment