1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/nextcloud_ynh.git synced 2024-09-03 19:55:57 +02:00

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

This commit is contained in:
Jérôme Lebleu 2016-06-10 21:32:55 +02:00
parent 562488f04f
commit 25698019e7
6 changed files with 25 additions and 0 deletions

1
conf/owncloud.cron Normal file
View file

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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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