Skip to content

Commit

Permalink
use IMDSv2 queries in init script
Browse files Browse the repository at this point in the history
  • Loading branch information
burak-58 authored Dec 23, 2024
1 parent c71d8f2 commit da4b3e5
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
INITIALIZED=/usr/local/antmedia/conf/initialized
if [ ! -f "$INITIALIZED" ]
then
TOKEN=`curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"`
## Local IPV4

export LOCAL_IPv4=`curl -s http://169.254.169.254/latest/meta-data/local-ipv4`
export LOCAL_IPv4=`curl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/local-ipv4`

# $HOSTNAME ip-172-30-0-216
HOST_NAME=`hostname`
Expand All @@ -27,7 +28,7 @@ then
fi
fi
## Instance ID
export INSTANCE_ID=`curl -s http://169.254.169.254/latest/meta-data/instance-id`
export INSTANCE_ID=`curl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/instance-id`

## Add Initial User with curl
RESULT=`curl -s -X POST -H "Content-Type: application/json" -d '{"email": "JamesBond", "password": "'$INSTANCE_ID'", "scope": "system", "userType": "ADMIN"}' http://localhost:5080/rest/v2/users/initial`
Expand All @@ -46,8 +47,4 @@ then

fi
touch $INITIALIZED
## Add default ServerSecretKey
SECRET_KEY=$(openssl rand -base64 32 | head -c 32)
sudo sed -i "/^server.jwtServerControlEnabled=/s|.*|server.jwtServerControlEnabled=true|" /usr/local/antmedia/conf/red5.properties
sudo sed -i "/^server.jwtServerSecretKey=/s|.*|server.jwtServerSecretKey=$SECRET_KEY|" /usr/local/antmedia/conf/red5.properties
fi

0 comments on commit da4b3e5

Please sign in to comment.