aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/tasks/config_files.rake18
-rwxr-xr-xscript/site-specific-install.sh9
2 files changed, 23 insertions, 4 deletions
diff --git a/lib/tasks/config_files.rake b/lib/tasks/config_files.rake
index 33e4a9e00..d0e4001f0 100644
--- a/lib/tasks/config_files.rake
+++ b/lib/tasks/config_files.rake
@@ -48,5 +48,23 @@ namespace :config_files do
end
end
+ desc 'Convert Debian .ugly crontab file in config to a form suitable for installing in /etc/cron.d'
+ task :convert_crontab => :environment do
+ example = 'rake config_files:convert_crontab DEPLOY_USER=deploy VHOST_DIR=/dir/above/alaveteli VCSPATH=alaveteli SITE=alaveteli CRONTAB=config/crontab-example'
+ check_for_env_vars(['DEPLOY_USER',
+ 'VHOST_DIR',
+ 'VCSPATH',
+ 'SITE',
+ 'CRONTAB'], example)
+ replacements = {
+ :user => ENV['DEPLOY_USER'],
+ :vhost_dir => ENV['VHOST_DIR'],
+ :vcspath => ENV['VCSPATH'],
+ :site => ENV['SITE']
+ }
+ convert_ugly(ENV['CRONTAB'], replacements).each do |line|
+ puts line
+ end
+ end
end
diff --git a/script/site-specific-install.sh b/script/site-specific-install.sh
index d7cce0dfb..da1b08b74 100755
--- a/script/site-specific-install.sh
+++ b/script/site-specific-install.sh
@@ -130,14 +130,15 @@ fi
cd "$REPOSITORY"
+echo -n "Creating /etc/cron.d/alaveteli... "
+(su -c "cd '$REPOSITORY' && bundle exec rake config_files:convert_crontab DEPLOY_USER='$UNIX_USER' VHOST_DIR='$DIRECTORY' VCSPATH='$SITE' SITE='$SITE' CRONTAB=config/crontab-example" "$UNIX_USER") > /etc/cron.d/alaveteli
+# There are some other parts to rewrite, so just do them with sed:
sed -r \
-e "/foi-purge-varnish/d" \
-e "s,^(MAILTO=).*,\1root@$HOST," \
- -e "s,\!\!\(\*= .user \*\)\!\!,$UNIX_USER,g" \
- -e "s,/data/vhost/\!\!\(\*= .vhost \*\)\!\!/\!\!\(\*= .vcspath \*\)\!\!,$REPOSITORY,g" \
- -e "s,/data/vhost/\!\!\(\*= .vhost \*\)\!\!,$DIRECTORY,g" \
-e "s,run-with-lockfile,$REPOSITORY/commonlib/bin/run-with-lockfile.sh,g" \
- config/crontab-example > /etc/cron.d/alaveteli
+ -i /etc/cron.d/alaveteli
+echo $DONE_MSG
echo -n "Creating /etc/init.d/foi-alert-tracks... "
(su -c "cd '$REPOSITORY' && bundle exec rake config_files:convert_init_script DEPLOY_USER='$UNIX_USER' VHOST_DIR='$DIRECTORY' SCRIPT_FILE=config/alert-tracks-debian.ugly" "$UNIX_USER") > /etc/init.d/foi-alert-tracks