Commit 598f03ea by Bach Dániel

improve manager scripts

parent ce6ccdf2
...@@ -49,3 +49,13 @@ portal.conf: ...@@ -49,3 +49,13 @@ portal.conf:
- group: root - group: root
- template: jinja - template: jinja
- source: file:///home/{{ pillar['user'] }}/circle/miscellaneous/slowcelery.conf - source: file:///home/{{ pillar['user'] }}/circle/miscellaneous/slowcelery.conf
salt://manager/files/init.sh:
cmd.script:
- template: jinja
- user: {{ pillar['user'] }}
- stateful: true
- require:
- virtualenv: virtualenv_manager
- file: /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/postactivate
- user: {{ pillar['user'] }}
...@@ -2,6 +2,21 @@ ...@@ -2,6 +2,21 @@
cd /home/{{ pillar['user'] }}/circle/circle/ cd /home/{{ pillar['user'] }}/circle/circle/
source /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/activate source /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/activate
source /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/postactivate source /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/postactivate
MANAGE="python /home/{{ pillar['user'] }}/circle/circle/manage.py"
bower install bower install
python /home/{{ pillar['user'] }}/circle/circle/manage.py collectstatic --noinput
python /home/{{ pillar['user'] }}/circle/circle/manage.py compilemessages COLLECTED=$($MANAGE collectstatic --noinput |
awk '/static files copied to/ {print $1}')
OLD_SHA=$(sha1sum locale/hu/LC_MESSAGES/*.mo)
$MANAGE compilemessages
NEW_SHA=$(sha1sum locale/hu/LC_MESSAGES/*.mo)
echo "$COLLECTED $NEW_SHA $OLD_SHA"
if [ "$NEW_SHA" != "$OLD_SHA" -o "$COLLECTED" -ne 0 ]; then
CHANGED=yes
else
CHANGED=no
fi
echo "changed=$CHANGED comment='copied: $COLLECTED'"
#!/bin/bash
source /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/activate
source /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/postactivate
{% set fw = pillar['fwdriver'] %}
exec python /home/{{ pillar['user'] }}/circle/circle/manage.py init \
--portal-ip={{ fw['portal_ip'] }} \
--external-net={{ fw['external_net'] }} \
--management-net={{ fw['management_net'] }} \
--vm-net={{ fw['vm_net'] }} \
--admin-user={{ pillar['admin_user'] }} \
--admin-pass={{ pillar['admin_pass'] }} \
--datastore-queue={{ pillar['storagedriver']['queue_name'] }} \
--firewall-queue={{ fw['queue_name'] }} \
--external-if={{ fw['external_if'] }} \
--management-if={{ fw['management_if'] }} \
--trunk-if={{ fw['trunk_if'] }}
#!/bin/bash #!/bin/bash
sudo stop manager
sudo stop portal sudo stop manager >/dev/null 2>&1
source /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/activate sudo stop portal >/dev/null 2>&1
source /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/postactivate source /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/activate >/dev/null 2>&1
python /home/{{ pillar['user'] }}/circle/circle/manage.py syncdb --all --noinput source /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/postactivate >/dev/null 2>&1
python /home/{{ pillar['user'] }}/circle/circle/manage.py migrate acl MANAGE="python /home/{{ pillar['user'] }}/circle/circle/manage.py"
python /home/{{ pillar['user'] }}/circle/circle/manage.py migrate firewall
python /home/{{ pillar['user'] }}/circle/circle/manage.py migrate storage OUT=$( ($MANAGE syncdb --noinput &&
python /home/{{ pillar['user'] }}/circle/circle/manage.py syncdb --migrate --noinput $MANAGE migrate acl &&
python /home/{{ pillar['user'] }}/circle/circle/manage.py migrate vm --merge $MANAGE migrate firewall &&
$MANAGE migrate storage &&
$MANAGE syncdb --migrate --noinput &&
$MANAGE migrate vm --merge) 2>&1)
if [ $? -ne 0 ]; then
/usr/bin/python -c "import sys; import json; sys.stdout.write(json.dumps({'changed': False, 'comment': sys.stdin.read()}) + '\n')" <<< "$OUT"
exit 1
fi
COUNT=$(/bin/egrep "Migrating forwards to" -c <<< "$OUT")
if [ $? -eq 0 ]; then
CHANGED=yes
else
CHANGED=no
fi
echo "changed=$CHANGED comment='Migrated: $COUNT'"
...@@ -15,6 +15,7 @@ salt://manager/files/syncdb.sh: ...@@ -15,6 +15,7 @@ salt://manager/files/syncdb.sh:
cmd.script: cmd.script:
- template: jinja - template: jinja
- user: {{ pillar['user'] }} - user: {{ pillar['user'] }}
- stateful: true
- require: - require:
- virtualenv: virtualenv_manager - virtualenv: virtualenv_manager
- file: /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/postactivate - file: /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/postactivate
...@@ -24,6 +25,7 @@ salt://manager/files/compile.sh: ...@@ -24,6 +25,7 @@ salt://manager/files/compile.sh:
cmd.script: cmd.script:
- template: jinja - template: jinja
- user: {{ pillar['user'] }} - user: {{ pillar['user'] }}
- stateful: true
- require: - require:
- virtualenv: virtualenv_manager - virtualenv: virtualenv_manager
- file: /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/postactivate - file: /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/postactivate
......
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 sign in to comment