added protection for salt-call process terminating after returning the prompt (and making exit error, and stoppign everything after)
authorPaul Tonelli <paul.tonelli@logilab.fr>
Fri, 19 Apr 2013 11:10:50 +0200
changeset 123 781848b55b43
parent 122 5b091aab6bd3
child 124 bba5d6e1d088
added protection for salt-call process terminating after returning the prompt (and making exit error, and stoppign everything after)
others/rc.local
--- a/others/rc.local	Fri Apr 19 10:24:23 2013 +0200
+++ b/others/rc.local	Fri Apr 19 11:10:50 2013 +0200
@@ -12,16 +12,25 @@
 # By default this script does nothing.
 
 ### Specific to salt-call machine creation
-
 ## parse the user-data for ami related information
 /usr/bin/env python /etc/salt/srv/others/ec2_ami_parser.py
 
 ## get updated code if necessary 
-/usr/bin/env salt-call state.highstate &> /dev/ttyS0
-## update host 
-/usr/bin/env salt-call state.highstate &> /dev/ttyS0
-## should source everything up to date in /var/salt
-/usr/bin/env salt-call state.highstate &> /dev/ttyS0
+for i in `seq 3`
+do
+    while [ `ps auxf |grep salt-call |grep -v grep|wc -l` -ne 0 ]
+    do
+        sleep 1
+    done
+    ## wait until no more salt-call is running
+    /usr/bin/env salt-call state.highstate &> /dev/ttyS0
+done
+
+while [ `ps auxf |grep salt-call |grep -v grep|wc -l` -ne 0 ]
+do
+    sleep 1
+done
+## wait until no more salt-call is running
 ## download, untar, resize and mount
 ## update modify image depending on variation.sls file
 /usr/bin/env salt-call state.sls ami_creator &> /dev/ttyS0