Skip to content
Snippets Groups Projects
Commit 45e2a043 authored by jurgenhaas's avatar jurgenhaas
Browse files

ansible-inventories/arocom#2783 Change the mechanics of the update script

parent c204b765
No related branches found
No related tags found
No related merge requests found
......@@ -3,13 +3,16 @@
- block:
- name: "Create Update Script"
- name: "Create Update Scripts"
template:
src='scripts/update/gitscript.jinja2'
dest='{{ webRoot }}/.update'
src='scripts/update/{{ item }}.jinja2'
dest='{{ webRoot }}/.{{ item }}'
owner='root'
group='root'
mode='755'
with_items:
- 'update'
- 'update-loop'
- name: "Crontab for Update Script"
cron:
......@@ -19,7 +22,7 @@
weekday='{{ drupal.src.cron.weekday|default(omit) }}'
hour='{{ drupal.src.cron.hour|default(omit) }}'
minute='{{ drupal.src.cron.minute|default(omit) }}'
job='{{ webRoot }}/.update >>{{ webRoot }}/../log/git-update.log 2>&1'
job='{{ webRoot }}/.update-loop >>{{ webRoot }}/../log/git-update.log 2>&1'
user='root'
disabled='{{ crons_disabled|default(false) }}'
......
#!/usr/bin/env bash
# Get our own process ID.
mypid="$$";
if [ "$mypid" = "" ] || ! echo "$mypid" | grep "^[0-9][0-9]*$" >/dev/null; then
echo "Error getting current PID.";
exit 1;
fi;
# Check if there are other .update-loop processes.
if ps -eo pid,cmd | grep "\/\.update-loop$" | grep -v "grep\|sudo\|^\s*$mypid\s" >/dev/null; then
echo "Skip: .update-loop is already running.";
exit 0;
fi;
# Get path to the actual update script.
scriptfile="$0";
scriptdir="$(dirname "$scriptfile")";
subscript="$scriptdir/.update";
# Run the actual update script in a loop.
while true; do
if ! "$subscript"; then
# In case the .update script returns an error wait the full 2 minutes.
# This way we have a chance to fix something and not get interfered / overrun by errors.
sleep 115;
fi;
sleep 5;
done;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment