Browse Source

[enh] Use cron job for background tasks (close #406)

pull/4/head
Jérôme Lebleu 10 years ago
parent
commit
25698019e7
  1. 1
      conf/owncloud.cron
  2. 1
      scripts/backup
  3. 8
      scripts/install
  4. 4
      scripts/remove
  5. 3
      scripts/restore
  6. 8
      scripts/upgrade

1
conf/owncloud.cron

@ -0,0 +1 @@
*/15 * * * * #USER# /usr/bin/php -f #DESTDIR#/cron.php

1
scripts/backup

@ -29,6 +29,7 @@ ynh_backup "$DATADIR" "data" 1
mkdir ./conf
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "conf/nginx.conf"
ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "conf/php-fpm.conf"
ynh_backup "/etc/cron.d/${app}" "conf/cron"
# Dump the database
mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./db.sql

8
scripts/install

@ -163,3 +163,11 @@ ynh_app_setting_set "$app" skipped_regex \
# Reload services
sudo service php5-fpm restart || true
sudo service nginx reload || true
# Add cron job
cron_path="/etc/cron.d/$app"
sed -i "s@#USER#@${app}@g" ../conf/owncloud.cron
sed -i "s@#DESTDIR#@${DESTDIR}@g" ../conf/owncloud.cron
sudo cp ../conf/owncloud.cron "$cron_path"
sudo chmod 644 "$cron_path"
_exec_occ background:cron

4
scripts/remove

@ -13,6 +13,10 @@ dbuser=$app
# Source app helpers
. /usr/share/yunohost/helpers
# Remove cron job
# TODO: Ensure that cron job is not running
sudo rm -f "/etc/cron.d/${app}"
# Drop MySQL database and user
ynh_mysql_drop_db "$dbname" 2>/dev/null || true
ynh_mysql_drop_user "$dbuser" 2>/dev/null || true

3
scripts/restore

@ -78,6 +78,9 @@ sudo chmod 755 /home/yunohost.app
sudo cp -a ./conf/nginx.conf "$nginx_conf"
sudo cp -a ./conf/php-fpm.conf "$phpfpm_conf"
# Restore cron job
sudo cp -a ./config/cron "/etc/cron.d/${app}"
# Reload services
sudo service php5-fpm restart || true
sudo service nginx reload || true

8
scripts/upgrade

@ -154,6 +154,14 @@ ynh_app_setting_set "$app" skipped_regex \
sudo service php5-fpm restart || true
sudo service nginx reload || true
# Add cron job
cron_path="/etc/cron.d/$app"
sed -i "s@#USER#@${app}@g" ../conf/owncloud.cron
sed -i "s@#DESTDIR#@${DESTDIR}@g" ../conf/owncloud.cron
sudo cp ../conf/owncloud.cron "$cron_path"
sudo chmod 644 "$cron_path"
_exec_occ background:cron
# Warn about possible disabled apps
echo "Note that if you've installed some third-parties ownCloud applications, \
they are probably disabled and you'll have to manually activate them again." >&2
Loading…
Cancel
Save