Commit 598f03ea by Bach Dániel

improve manager scripts

parent ce6ccdf2
......@@ -49,3 +49,13 @@ portal.conf:
- group: root
- template: jinja
- 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 @@
cd /home/{{ pillar['user'] }}/circle/circle/
source /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/activate
source /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/postactivate
MANAGE="python /home/{{ pillar['user'] }}/circle/circle/manage.py"
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
sudo stop manager
sudo stop portal
source /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/activate
source /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/postactivate
python /home/{{ pillar['user'] }}/circle/circle/manage.py syncdb --all --noinput
python /home/{{ pillar['user'] }}/circle/circle/manage.py migrate acl
python /home/{{ pillar['user'] }}/circle/circle/manage.py migrate firewall
python /home/{{ pillar['user'] }}/circle/circle/manage.py migrate storage
python /home/{{ pillar['user'] }}/circle/circle/manage.py syncdb --migrate --noinput
python /home/{{ pillar['user'] }}/circle/circle/manage.py migrate vm --merge
sudo stop manager >/dev/null 2>&1
sudo stop portal >/dev/null 2>&1
source /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/activate >/dev/null 2>&1
source /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/postactivate >/dev/null 2>&1
MANAGE="python /home/{{ pillar['user'] }}/circle/circle/manage.py"
OUT=$( ($MANAGE syncdb --noinput &&
$MANAGE migrate acl &&
$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:
cmd.script:
- template: jinja
- user: {{ pillar['user'] }}
- stateful: true
- require:
- virtualenv: virtualenv_manager
- file: /home/{{ pillar['user'] }}/.virtualenvs/circle/bin/postactivate
......@@ -24,6 +25,7 @@ salt://manager/files/compile.sh:
cmd.script:
- template: jinja
- user: {{ pillar['user'] }}
- stateful: true
- require:
- virtualenv: virtualenv_manager
- 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