Last active
February 15, 2017 17:26
-
-
Save bcavagnolo/26cc0843a51d67b345c0 to your computer and use it in GitHub Desktop.
A script to install dynamodb local
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 | |
set -e | |
set -x | |
[ "${DYNAMODB_HOME}" = "" ] && DYNAMODB_HOME=/opt/dynamodb | |
DYNAMODB_FILE=dynamodb_local_latest.tar.gz | |
DYNAMODB_URL=http://dynamodb-local.s3-website-us-west-2.amazonaws.com/${DYNAMODB_FILE} | |
DYNAMODB_JAR=DynamoDBLocal.jar | |
DYNAMODB_LOG=/var/log/dynamodb.log | |
mkdir -p ${DYNAMODB_HOME} | |
pushd ${DYNAMODB_HOME} | |
export DEBIAN_FRONTEND=noninteractive | |
[ ! -z $(which java) ] || apt-get -y install openjdk-7-jre | |
[ -f ${DYNAMODB_FILE} ] || curl -L -s ${DYNAMODB_URL} -o ${DYNAMODB_FILE} | |
[ -f ${DYNAMODB_JAR} ] || tar xzf ${DYNAMODB_FILE} | |
cat <<EOF > ./dynamodb.sh | |
#!/usr/bin/env bash | |
DYNAMODB_HOME=${DYNAMODB_HOME} | |
echo '=========================' >> ${DYNAMODB_LOG} | |
date >> ${DYNAMODB_LOG} | |
cd ${DYNAMODB_HOME} | |
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb >> ${DYNAMODB_LOG} 2>&1 | |
EOF | |
chmod +x ./dynamodb.sh | |
echo Launching dynamodb | |
CMD="start-stop-daemon --oknodo --start --pidfile /tmp/dynamodb.pid -b -m --startas ${DYNAMODB_HOME}/dynamodb.sh" | |
echo "#!/bin/sh -e" > /etc/rc.local | |
echo $CMD >> /etc/rc.local | |
/etc/init.d/rc.local start | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment