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:
parent
562488f04f
commit
25698019e7
6 changed files with 25 additions and 0 deletions
1
conf/owncloud.cron
Normal file
1
conf/owncloud.cron
Normal file
|
@ -0,0 +1 @@
|
||||||
|
*/15 * * * * #USER# /usr/bin/php -f #DESTDIR#/cron.php
|
|
@ -29,6 +29,7 @@ ynh_backup "$DATADIR" "data" 1
|
||||||
mkdir ./conf
|
mkdir ./conf
|
||||||
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "conf/nginx.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/php5/fpm/pool.d/${app}.conf" "conf/php-fpm.conf"
|
||||||
|
ynh_backup "/etc/cron.d/${app}" "conf/cron"
|
||||||
|
|
||||||
# Dump the database
|
# Dump the database
|
||||||
mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./db.sql
|
mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./db.sql
|
||||||
|
|
|
@ -163,3 +163,11 @@ ynh_app_setting_set "$app" skipped_regex \
|
||||||
# Reload services
|
# Reload services
|
||||||
sudo service php5-fpm restart || true
|
sudo service php5-fpm restart || true
|
||||||
sudo service nginx reload || 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
|
||||||
|
|
|
@ -13,6 +13,10 @@ dbuser=$app
|
||||||
# Source app helpers
|
# Source app helpers
|
||||||
. /usr/share/yunohost/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
|
# Drop MySQL database and user
|
||||||
ynh_mysql_drop_db "$dbname" 2>/dev/null || true
|
ynh_mysql_drop_db "$dbname" 2>/dev/null || true
|
||||||
ynh_mysql_drop_user "$dbuser" 2>/dev/null || true
|
ynh_mysql_drop_user "$dbuser" 2>/dev/null || true
|
||||||
|
|
|
@ -78,6 +78,9 @@ sudo chmod 755 /home/yunohost.app
|
||||||
sudo cp -a ./conf/nginx.conf "$nginx_conf"
|
sudo cp -a ./conf/nginx.conf "$nginx_conf"
|
||||||
sudo cp -a ./conf/php-fpm.conf "$phpfpm_conf"
|
sudo cp -a ./conf/php-fpm.conf "$phpfpm_conf"
|
||||||
|
|
||||||
|
# Restore cron job
|
||||||
|
sudo cp -a ./config/cron "/etc/cron.d/${app}"
|
||||||
|
|
||||||
# Reload services
|
# Reload services
|
||||||
sudo service php5-fpm restart || true
|
sudo service php5-fpm restart || true
|
||||||
sudo service nginx reload || true
|
sudo service nginx reload || true
|
||||||
|
|
|
@ -154,6 +154,14 @@ ynh_app_setting_set "$app" skipped_regex \
|
||||||
sudo service php5-fpm restart || true
|
sudo service php5-fpm restart || true
|
||||||
sudo service nginx reload || 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
|
# Warn about possible disabled apps
|
||||||
echo "Note that if you've installed some third-parties ownCloud applications, \
|
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
|
they are probably disabled and you'll have to manually activate them again." >&2
|
||||||
|
|
Loading…
Add table
Reference in a new issue