Last active
February 28, 2018 06:48
-
-
Save mekya/0e7f014623630ba5d3d08c97d7391083 to your computer and use it in GitHub Desktop.
AWS_Server_Initialization_Helpers.md
This file contains hidden or 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/bash | |
# Copy below commented out lines to /etc/init.d/antmedia | |
# jsvc_exec function | |
# | |
# INITIALIZED=/usr/local/antmedia/conf/initialized | |
## if [ ! -f "$INITIALIZED" ] | |
## then | |
## echo "sleep 3 ; /usr/local/antmedia/conf/init.sh" | at now | |
## fi | |
# remove line /etc/hosts if added | |
# rm conf/instanceId | |
# rm conf/initialized | |
# rm server.db, liveapp.db, webrtcapp.db if exist | |
INITIALIZED=/usr/local/antmedia/conf/initialized | |
if [ ! -f "$INITIALIZED" ] | |
then | |
## Local IPV4 | |
export LOCAL_IPv4=`curl -s http://169.254.169.254/latest/meta-data/local-ipv4` | |
# $HOSTNAME ip-172-30-0-216 | |
HOST_NAME=`hostname` | |
HOST_LINE="$LOCAL_IPv4 $HOST_NAME" | |
grep -Fxq "$HOST_LINE" /etc/hosts | |
OUT=$? | |
if [ $OUT -ne 0 ]; then | |
echo "$HOST_LINE" | tee -a /etc/hosts | |
OUT=$? | |
if [ $OUT -ne 0 ]; then | |
echo "Cannot write hosts file" | |
exit $OUT | |
fi | |
fi | |
## Instance ID | |
export INSTANCE_ID=`curl -s http://169.254.169.254/latest/meta-data/instance-id` | |
## Add Initial User with curl | |
RESULT=`curl -s -H "Content-Type: application/json" -X POST -d '{"email":"JamesBond","password":"'$INSTANCE_ID'","fullName":"Bond James Bond"}' http://localhost:5080/ConsoleApp/rest/addInitialUser` | |
echo ${RESULT} | grep --quiet ":true" | |
if [ $? = 1 ] | |
then | |
echo "Cannot create initial user" | |
echo "sleep 3 ; /usr/local/antmedia/conf/init.sh" | at now | |
exit $OUT | |
fi | |
touch $INITIALIZED | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment