Last active
January 25, 2018 08:08
-
-
Save Cinedin/2bfdd2fa3b045817896ad16ef5fca099 to your computer and use it in GitHub Desktop.
Download last Local DynamoDB and execute as daemon
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
#!/bin/sh | |
# | |
# chkconfig: 35 99 01 | |
# description: java application | |
# | |
if [ -z "$JRE_HOME" ]; then | |
JRE_HOME="$JAVA_HOME" | |
fi | |
if [ -z "$JRE_HOME" ]; then | |
echo No JRE_HOME or JAVA_HOME environment variable is set - attempting to just run 'java' command | |
JAVABIN=java | |
else | |
JAVABIN="$JRE_HOME"/bin/java | |
fi | |
service=aws_dynamodb_local | |
dynamodbDir=/var/lib/aws_dynamodb_local | |
jarFile=$dynamodbDir/DynamoDBLocal.jar | |
javaOptions="-Djava.library.path=$dynamodbDir" | |
pidfile=/tmp/${service}.pid | |
logfile=/tmp/${service}.log | |
lockfile=/tmp/${service}.lock | |
cmdline="${JAVABIN} ${javaOptions} -jar ${jarFile}" | |
RETVAL=0 | |
# System configuration | |
unset TMPDIR | |
if [ -f /etc/sysconfig/${service} ]; then | |
. /etc/sysconfig/${service} | |
fi | |
# Source function library | |
if [ -f /etc/init.d/functions ]; then | |
. /etc/init.d/functions | |
elif [ -f /etc/rc.d/init.d/functions ]; then | |
. /etc/rc.d/init.d/functions | |
else | |
exit 1 | |
fi | |
cd $dynamodbDir | |
start() { | |
echo -n $"Starting ${service} services: " | |
daemon --pidfile=${pidfile} "${cmdline} > /dev/null &" | |
RETVAL=$? | |
pgrep -f "${jarFile}" > ${pidfile} | |
echo | |
[ $RETVAL -eq 0 ] && touch ${lockfile} || RETVAL=1 | |
return $RETVAL | |
} | |
stop() { | |
echo -n $"Stopping ${service} service: " | |
killproc -p ${pidfile} ${service} | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && rm -f ${lockfile} ${pidfile} | |
return $RETVAL | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status -p ${pidfile} ${service} | |
RETVAL=$? | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo $"Usage: ${service} {start|stop|status|restart}: " | |
RETVAL=2 | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment