others/rc.local
author Julien Cristau <julien.cristau@logilab.fr>
Fri, 06 Sep 2013 14:34:17 +0200
changeset 197 f84de149155d
parent 193 918f0ec4d4f5
permissions -rw-r--r--
Drop useless use of /usr/bin/env

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

### Specific to salt-call machine creation
## parse the user-data for ami related information
python /srv/salt/others/user_data_parser.py

## get updated code if necessary 
for i in `seq 3`
do
    while [ `pgrep -c salt-call` -ne 0 ]
    do
        sleep 1
    done
    ## wait until salt-call is not running any longer
    salt-call --no-color --local state.highstate | tee -a /var/log/ami-builder.log > /dev/console 2>&1
done

while [ `pgrep -c salt-call` -ne 0 ]
do
    sleep 1
done
## wait until salt-call is not running any longer
## download, untar, resize and mount
## update modify image depending on variation.sls file
salt-call --no-color --local state.sls ami_builder | tee -a /var/log/ami-builder.log > /dev/console 2>&1
## umount, resize and upload if possible

exit 0