I'm creating a new instance in AWS and adding some user data, but part of the job is to create an sh file and then executed.
I'm trying:
#!/bin/bash -x
cd /tmp
INSTANCE_ID=$(curl http://169.254.169.254/latest/meta-data/instance-id)
sudo wget -O ethminer.tar.gz https://github.com/ethereum-mining/ethminer/releases/download/v0.18.0/ethminer-0.18.0-cuda-9-linux-x86_64.tar.gz
sudo tar xvfz ethminer.tar.gz
cd bin
cat > runner.sh << __EOF__
#!/bin/bash -x
SERVERS=(us1 us2 eu1 asia1)
while (true); do
PREFERRED_SERVER=\${!SERVERS[\${!RANDOM} % \${!#SERVERS[@]}]}
./ethminer \
-P stratums://xxx.${!INSTANCE_ID}@\${!PREFERRED_SERVER}.ethermine.org:5555 \
-P stratums://xxx.${!INSTANCE_ID}@us1.ethermine.org:5555 \
-P stratums://xxx.${!INSTANCE_ID}@us2.ethermine.org:5555 \
-P stratums://xxx.${!INSTANCE_ID}@eu1.ethermine.org:5555 \
-P stratums://xxx.${!INSTANCE_ID}@asia1.ethermine.org:5555 \
>> /tmp/ethminer.log 2>&1
done
__EOF__
sudo chmod +x runner.sh
sudo nohup ./runner.sh &
Everything works except the sh, my command creates the runner.sh script but it is empty.