diff --git a/conf/config.php b/conf/config.php index ac20a0d..0c3ed7f 100644 --- a/conf/config.php +++ b/conf/config.php @@ -61,7 +61,7 @@ * State migration script is available, more informations: https://wiki.z-hub.io/x/xIAa */ define('STATE_MACHINE', 'FILE'); - define('STATE_DIR', 'ALIASTOCHANGE/'); + define('STATE_DIR', 'STATEDIRTOCHANGE/'); /********************************************************************************** * IPC - InterProcessCommunication diff --git a/scripts/backup b/scripts/backup index 8041e9e..97d1221 100755 --- a/scripts/backup +++ b/scripts/backup @@ -19,6 +19,7 @@ source /usr/share/yunohost/helpers path=$(ynh_app_setting_get $app path) domain=$(ynh_app_setting_get $app domain) final_path=$(ynh_app_setting_get $app final_path) +statedir=$(ynh_app_setting_get $app statedir) final_logpath=$(ynh_app_setting_get $app final_logpath) final_nginxconf=$(ynh_app_setting_get $app final_nginxconf) final_phpconf=$(ynh_app_setting_get $app final_phpconf) @@ -27,6 +28,9 @@ final_phpconf=$(ynh_app_setting_get $app final_phpconf) # Note: the last argument is where to save this path, see the restore script. ynh_backup "$final_path" "sources" +# Backup statedir +ynh_backup "$statedir" "statedir" + # Backup logs ynh_backup "$final_logpath" "logs" ynh_backup "/etc/logrotate.d/$app" "logrotate" diff --git a/scripts/install b/scripts/install index 9d4ee00..fbf9806 100755 --- a/scripts/install +++ b/scripts/install @@ -79,11 +79,23 @@ CHECK_FINALPATH () { # Vérifie que le dossier de destination n'est pas déj CHECK_FINALPATH +statedir="/home/yunohost.app/$app" + +CHECK_STATEDIRPATH () { # Vérifie que le dossier de destination n'est pas déjà utilisé. + if [ -e "$statedir" ] + then + echo "This path already contains a folder" >&2 + false + fi +} + +CHECK_STATEDIRPATH # Define variables and Save app settings ynh_app_setting_set "$app" domain "$domain" ynh_app_setting_set "$app" final_path "$final_path" +ynh_app_setting_set "$app" statedir "$statedir" final_logpath="/var/log/$app" ynh_app_setting_set "$app" final_logpath "$final_logpath" @@ -106,10 +118,15 @@ sudo cp -R ../sources/$SFILE/* $final_path # Configuration sed -i "s^define('TIMEZONE', .*^define('TIMEZONE', '$(cat /etc/timezone)');^" ../conf/config.php -sed -i "s@ALIASTOCHANGE@$final_path@g" ../conf/config.php sed -i "s@LOGTOCHANGE@$final_logpath@g" ../conf/config.php sed -i "s@LOGTOCHANGE@$final_logpath@g" ../conf/logrotate +# Storage of state_dir in /home/yunohost.app +# This contains the sync status in between device and z-push +sed -i "s@STATEDIRTOCHANGE@$statedir@g" ../conf/config.php +sudo mkdir -p $statedir +sudo chown -R www:data-www-data $statedir + # Enable caldav carddav support if sudo yunohost app list --installed -f baikal | grep -q id ; then echo "Detected Baikal" diff --git a/scripts/remove b/scripts/remove index 538e6f1..2aad6a3 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,6 +9,7 @@ domain=$(ynh_app_setting_get $app domain) # Cleaning sudo rm -rf /var/www/$app +sudo rm -rf /home/yunohost.app/$app sudo rm -rf /var/log/$app sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf sudo rm -f /etc/php5/fpm/pool.d/$app.conf diff --git a/scripts/restore b/scripts/restore index 6f21da3..4a59e58 100755 --- a/scripts/restore +++ b/scripts/restore @@ -9,6 +9,7 @@ source /usr/share/yunohost/helpers path=$(ynh_app_setting_get $app path) domain=$(ynh_app_setting_get $app domain) final_path=$(ynh_app_setting_get $app final_path) +statedir=$(ynh_app_setting_get $app statedir) final_logpath=$(ynh_app_setting_get $app final_logpath) final_nginxconf=$(ynh_app_setting_get $app final_nginxconf) final_phpconf=$(ynh_app_setting_get $app final_phpconf) @@ -18,6 +19,11 @@ sudo mkdir -p $final_path sudo cp -a ./sources/* $final_path/ sudo chown -R www-data: $final_path +# Restore statedir +sudo mkdir -p $statedir +sudo cp -a ./statedir/* $statedir/ +sudo chown -R www-data:www-data $statedir + # Restore logs, data & permissions sudo mkdir -p $final_logpath sudo cp -a ./logs/* $final_logpath/ diff --git a/scripts/upgrade b/scripts/upgrade index a895e84..93e20c1 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -8,6 +8,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) path=$(ynh_app_setting_get $app path) final_path=$(ynh_app_setting_get $app final_path) +statedir=$(ynh_app_setting_get $app statedir) final_logpath=$(ynh_app_setting_get $app final_logpath) final_nginxconf=$(ynh_app_setting_get $app final_nginxconf) final_phpconf=$(ynh_app_setting_get $app final_phpconf) @@ -21,6 +22,14 @@ else echo "${final_path} exists, we don't create it." fi +if [ -z "$statedir" ]; +then + statedir="/home/yunohost.app/$app" + ynh_app_setting_set "$app" statedir "$statedir" +else + echo "${statedir} exists, we don't create it." +fi + if [ -z "$final_logpath" ]; then final_logpath="/var/log/$app" @@ -68,10 +77,16 @@ sudo cp -R ../sources/$SFILE/* $final_path # Configuration sed -i "s^define('TIMEZONE', .*^define('TIMEZONE', '$(cat /etc/timezone)');^" ../conf/config.php -sed -i "s@ALIASTOCHANGE@$final_path@g" ../conf/config.php sed -i "s@LOGTOCHANGE@$final_logpath@g" ../conf/config.php sed -i "s@LOGTOCHANGE@$final_logpath@g" ../conf/logrotate +# Storage of state_dir in /home/yunohost.app +# This contains the sync status in between device and z-push +sed -i "s@STATEDIRTOCHANGE@$statedir@g" ../conf/config.php +sudo mkdir -p $statedir +sudo chown -R www:data-www-data $statedir +# Note : there is a "fixstates actions done after the sources have been installed and configured + # Enable caldav carddav support if sudo yunohost app list --installed -f baikal | grep -q id ; then echo "Detected Baikal" @@ -133,6 +148,9 @@ sudo cp ../conf/php-fpm.conf $final_phpconf sudo chown root: $final_phpconf sudo chmod 644 $final_phpconf +# Fixstates to avoid full resync of devices after evrsion upgrades +sudo $final_path/z-push-admin.php -a fixstates + # Enable api for client and make the app public ynh_app_setting_set $app skipped_uris "/"