mirror of
https://github.com/YunoHost-Apps/z-push_ynh.git
synced 2024-09-03 18:05:58 +02:00
Places STATE_DIR in /home/yunohost.app instead of /vaer/www/z-push
The point is to keep the states in between upgrades to avoid full resync of devices in between upgrades of z-push sources
This commit is contained in:
parent
90889ba3ac
commit
4c6c5dbe68
6 changed files with 49 additions and 3 deletions
|
@ -61,7 +61,7 @@
|
||||||
* State migration script is available, more informations: https://wiki.z-hub.io/x/xIAa
|
* State migration script is available, more informations: https://wiki.z-hub.io/x/xIAa
|
||||||
*/
|
*/
|
||||||
define('STATE_MACHINE', 'FILE');
|
define('STATE_MACHINE', 'FILE');
|
||||||
define('STATE_DIR', 'ALIASTOCHANGE/');
|
define('STATE_DIR', 'STATEDIRTOCHANGE/');
|
||||||
|
|
||||||
/**********************************************************************************
|
/**********************************************************************************
|
||||||
* IPC - InterProcessCommunication
|
* IPC - InterProcessCommunication
|
||||||
|
|
|
@ -19,6 +19,7 @@ source /usr/share/yunohost/helpers
|
||||||
path=$(ynh_app_setting_get $app path)
|
path=$(ynh_app_setting_get $app path)
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
final_path=$(ynh_app_setting_get $app final_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_logpath=$(ynh_app_setting_get $app final_logpath)
|
||||||
final_nginxconf=$(ynh_app_setting_get $app final_nginxconf)
|
final_nginxconf=$(ynh_app_setting_get $app final_nginxconf)
|
||||||
final_phpconf=$(ynh_app_setting_get $app final_phpconf)
|
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.
|
# Note: the last argument is where to save this path, see the restore script.
|
||||||
ynh_backup "$final_path" "sources"
|
ynh_backup "$final_path" "sources"
|
||||||
|
|
||||||
|
# Backup statedir
|
||||||
|
ynh_backup "$statedir" "statedir"
|
||||||
|
|
||||||
# Backup logs
|
# Backup logs
|
||||||
ynh_backup "$final_logpath" "logs"
|
ynh_backup "$final_logpath" "logs"
|
||||||
ynh_backup "/etc/logrotate.d/$app" "logrotate"
|
ynh_backup "/etc/logrotate.d/$app" "logrotate"
|
||||||
|
|
|
@ -79,11 +79,23 @@ CHECK_FINALPATH () { # Vérifie que le dossier de destination n'est pas déj
|
||||||
|
|
||||||
CHECK_FINALPATH
|
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
|
# Define variables and Save app settings
|
||||||
ynh_app_setting_set "$app" domain "$domain"
|
ynh_app_setting_set "$app" domain "$domain"
|
||||||
ynh_app_setting_set "$app" final_path "$final_path"
|
ynh_app_setting_set "$app" final_path "$final_path"
|
||||||
|
ynh_app_setting_set "$app" statedir "$statedir"
|
||||||
|
|
||||||
final_logpath="/var/log/$app"
|
final_logpath="/var/log/$app"
|
||||||
ynh_app_setting_set "$app" final_logpath "$final_logpath"
|
ynh_app_setting_set "$app" final_logpath "$final_logpath"
|
||||||
|
@ -106,10 +118,15 @@ sudo cp -R ../sources/$SFILE/* $final_path
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
sed -i "s^define('TIMEZONE', .*^define('TIMEZONE', '$(cat /etc/timezone)');^" ../conf/config.php
|
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/config.php
|
||||||
sed -i "s@LOGTOCHANGE@$final_logpath@g" ../conf/logrotate
|
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
|
# Enable caldav carddav support
|
||||||
if sudo yunohost app list --installed -f baikal | grep -q id ; then
|
if sudo yunohost app list --installed -f baikal | grep -q id ; then
|
||||||
echo "Detected Baikal"
|
echo "Detected Baikal"
|
||||||
|
|
|
@ -9,6 +9,7 @@ domain=$(ynh_app_setting_get $app domain)
|
||||||
|
|
||||||
# Cleaning
|
# Cleaning
|
||||||
sudo rm -rf /var/www/$app
|
sudo rm -rf /var/www/$app
|
||||||
|
sudo rm -rf /home/yunohost.app/$app
|
||||||
sudo rm -rf /var/log/$app
|
sudo rm -rf /var/log/$app
|
||||||
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
sudo rm -f /etc/php5/fpm/pool.d/$app.conf
|
sudo rm -f /etc/php5/fpm/pool.d/$app.conf
|
||||||
|
|
|
@ -9,6 +9,7 @@ source /usr/share/yunohost/helpers
|
||||||
path=$(ynh_app_setting_get $app path)
|
path=$(ynh_app_setting_get $app path)
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
final_path=$(ynh_app_setting_get $app final_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_logpath=$(ynh_app_setting_get $app final_logpath)
|
||||||
final_nginxconf=$(ynh_app_setting_get $app final_nginxconf)
|
final_nginxconf=$(ynh_app_setting_get $app final_nginxconf)
|
||||||
final_phpconf=$(ynh_app_setting_get $app final_phpconf)
|
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 cp -a ./sources/* $final_path/
|
||||||
sudo chown -R www-data: $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
|
# Restore logs, data & permissions
|
||||||
sudo mkdir -p $final_logpath
|
sudo mkdir -p $final_logpath
|
||||||
sudo cp -a ./logs/* $final_logpath/
|
sudo cp -a ./logs/* $final_logpath/
|
||||||
|
|
|
@ -8,6 +8,7 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
path=$(ynh_app_setting_get $app path)
|
path=$(ynh_app_setting_get $app path)
|
||||||
final_path=$(ynh_app_setting_get $app final_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_logpath=$(ynh_app_setting_get $app final_logpath)
|
||||||
final_nginxconf=$(ynh_app_setting_get $app final_nginxconf)
|
final_nginxconf=$(ynh_app_setting_get $app final_nginxconf)
|
||||||
final_phpconf=$(ynh_app_setting_get $app final_phpconf)
|
final_phpconf=$(ynh_app_setting_get $app final_phpconf)
|
||||||
|
@ -21,6 +22,14 @@ else
|
||||||
echo "${final_path} exists, we don't create it."
|
echo "${final_path} exists, we don't create it."
|
||||||
fi
|
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" ];
|
if [ -z "$final_logpath" ];
|
||||||
then
|
then
|
||||||
final_logpath="/var/log/$app"
|
final_logpath="/var/log/$app"
|
||||||
|
@ -68,10 +77,16 @@ sudo cp -R ../sources/$SFILE/* $final_path
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
sed -i "s^define('TIMEZONE', .*^define('TIMEZONE', '$(cat /etc/timezone)');^" ../conf/config.php
|
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/config.php
|
||||||
sed -i "s@LOGTOCHANGE@$final_logpath@g" ../conf/logrotate
|
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
|
# Enable caldav carddav support
|
||||||
if sudo yunohost app list --installed -f baikal | grep -q id ; then
|
if sudo yunohost app list --installed -f baikal | grep -q id ; then
|
||||||
echo "Detected Baikal"
|
echo "Detected Baikal"
|
||||||
|
@ -133,6 +148,9 @@ sudo cp ../conf/php-fpm.conf $final_phpconf
|
||||||
sudo chown root: $final_phpconf
|
sudo chown root: $final_phpconf
|
||||||
sudo chmod 644 $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
|
# Enable api for client and make the app public
|
||||||
ynh_app_setting_set $app skipped_uris "/"
|
ynh_app_setting_set $app skipped_uris "/"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue