Commit 93804130 authored by Romain Courteaud's avatar Romain Courteaud

End script if database is created.

parent da0db1f5
...@@ -40,33 +40,32 @@ def updateMysql(args): ...@@ -40,33 +40,32 @@ def updateMysql(args):
conf = args[0] conf = args[0]
sleep = 30 sleep = 30
is_succeed = False is_succeed = False
while True: while not is_succeed:
if not is_succeed: mysql_upgrade_list = [conf['mysql_upgrade_binary'], '--no-defaults', '--user=root', '--socket=%s' % conf['socket']]
mysql_upgrade_list = [conf['mysql_upgrade_binary'], '--no-defaults', '--user=root', '--socket=%s' % conf['socket']] mysql_upgrade = subprocess.Popen(mysql_upgrade_list, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
mysql_upgrade = subprocess.Popen(mysql_upgrade_list, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) result = mysql_upgrade.communicate()[0]
result = mysql_upgrade.communicate()[0] if mysql_upgrade.returncode is None:
if mysql_upgrade.returncode is None: mysql_upgrade.kill()
mysql_upgrade.kill() if mysql_upgrade.returncode != 0 and not 'is already upgraded' in result:
if mysql_upgrade.returncode != 0 and not 'is already upgraded' in result: print "Command %r failed with result:\n%s" % (mysql_upgrade_list, result)
print "Command %r failed with result:\n%s" % (mysql_upgrade_list, result) print 'Sleeping for %ss and retrying' % sleep
else:
if mysql_upgrade.returncode == 0:
print "MySQL database upgraded with result:\n%s" % result
else:
print "No need to upgrade MySQL database"
mysql_list = [conf['mysql_binary'].strip(), '--no-defaults', '-B', '--user=root', '--socket=%s' % conf['socket']]
mysql = subprocess.Popen(mysql_list, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
result = mysql.communicate(conf['mysql_script'])[0]
if mysql.returncode is None:
mysql.kill()
if mysql.returncode != 0:
print 'Command %r failed with:\n%s' % (mysql_list, result)
print 'Sleeping for %ss and retrying' % sleep print 'Sleeping for %ss and retrying' % sleep
else: else:
if mysql_upgrade.returncode == 0: is_succeed = True
print "MySQL database upgraded with result:\n%s" % result print 'SlapOS initialisation script succesfully applied on database.'
else:
print "No need to upgrade MySQL database"
mysql_list = [conf['mysql_binary'].strip(), '--no-defaults', '-B', '--user=root', '--socket=%s' % conf['socket']]
mysql = subprocess.Popen(mysql_list, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
result = mysql.communicate(conf['mysql_script'])[0]
if mysql.returncode is None:
mysql.kill()
if mysql.returncode != 0:
print 'Command %r failed with:\n%s' % (mysql_list, result)
print 'Sleeping for %ss and retrying' % sleep
else:
is_succeed = True
print 'SlapOS initialisation script succesfully applied on database.'
sys.stdout.flush() sys.stdout.flush()
sys.stderr.flush() sys.stderr.flush()
time.sleep(sleep) time.sleep(sleep)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment