mardi 25 août 2015

How to run different command on aws instance while launching new instance

I am launching new instance from aws console. I want to run few commands on launching of my instances. Below commands are to be run-

#!/bin/bash
cd api/
sudo chown -R my-user:my-user .
git fetch
git checkout -b branch-1 origin/branch-1
git branch
git pull origin branch-1
ps uax | grep greamand
sudo /usr/local/sbin/gearmand -d -j 3 -l /var/log/gm.log > /dev/null
sudo php cli.php -e development -d

while using

cd api/
echo 'Woot!' > /home/my-user/user-script-output.txt

this works fine and will create new file but not in api folder, it creates out from api folder. I think

cd api/

is not working. It is not taking me in to the folder. Can you please confirm regarding this command that this will work and then i am fetching my branch in it. this works or not. or any other way to do so..

I am doing right now manually but after success i want this to be done from php-sdk. so i will use this commands in UserData parameter.

http://ift.tt/1JiTxXn




Aucun commentaire:

Enregistrer un commentaire