I'm setting up a Teamspeak 3 server on an AWS EC2 instance. In the "user data" script, which is run when the instance is created, I am trying to create a shell script file that fetches the latest Teamspeak 3 version and installs it:
tee install.sh << END
#!/bin/bash -xe
TEAMSPEAK_VERSION=$(wget https://teamspeak.com/versions/server.json -qO - | jq -r '.linux.x86_64.version')
wget https://files.teamspeak-services.com/releases/server/$TEAMSPEAK_VERSION/teamspeak3-server_linux_amd64-$TEAMSPEAK_VERSION.tar.bz2
tar -xjf teamspeak3-server_linux_amd64-$TEAMSPEAK_VERSION.tar.bz2 -C server --strip-components 1
rm teamspeak3-server_linux_amd64-$TEAMSPEAK_VERSION.tar.bz2
END
Now when I output the contents of install.sh using cat it shows me a resolved value for the TEAMSPEAK_VERSION variable which is obviously not what I want. I want it to be resolved when I run the script. The following is the contents of install.sh file:
[root@ip-xxx-xxx-xxx-xxx bin]# cat /home/teamspeak/install.sh
#!/bin/bash -xe
TEAMSPEAK_VERSION=3.13.7
wget https://files.teamspeak-services.com/releases/server//teamspeak3-server_linux_amd64-.tar.bz2
tar -xjf teamspeak3-server_linux_amd64-.tar.bz2 -C server --strip-components 1
rm teamspeak3-server_linux_amd64-.tar.bz2
So what am I doing wrong here?