1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/limesurvey_ynh.git synced 2024-09-03 19:36:32 +02:00
limesurvey_ynh/scripts/upgrade

69 lines
2.1 KiB
Text
Raw Normal View History

#!/bin/bash
2017-02-06 23:40:55 +01:00
source /usr/share/yunohost/helpers
source _common.sh
2017-02-06 23:40:55 +01:00
ynh_trap_on
2017-02-06 23:40:55 +01:00
export app=$YNH_APP_INSTANCE_NAME
user=$app
export domain=$(sudo yunohost app setting $app domain)
export path=$(sudo yunohost app setting $app path)
export admin=$(sudo yunohost app setting $app admin)
db_pwd=$(sudo yunohost app setting $app mysqlpwd)
2017-02-06 23:40:55 +01:00
export local_path=$(sudo yunohost app setting $app local_path)
export is_public=$(sudo yunohost app setting $app is_public || echo 0)
export prefix=$(sudo yunohost app setting $app prefix || echo 'prefix_')
version=$(ynh_read_json "/etc/yunohost/apps/$app/manifest.json" 'version' 2> /dev/null || echo '2.0.5')
last_version=$(ynh_read_manifest 'version')
2017-02-06 23:40:55 +01:00
ynh_exit_if_up_to_date
ynh_check_var "$app" "app name not set"
ynh_user_exists "$admin" || err "User does not exist: $admin"
ynh_normalize_url_path "$path"
2017-02-06 23:40:55 +01:00
if [ "${version}" = "2.0.5" ]; then
2017-02-06 23:40:55 +01:00
ynh_save_args path is_public prefix
2017-02-06 23:40:55 +01:00
ynh_app_dependencies php5-imap
ynh_system_user_create "$user" "$local_path"
# Move the upload dir to local_path if needed
# The upload dir can't be symlinked in home (not supported by LS)
upload_path=/home/yunohost.app/$app/upload
if [ -h $local_path/upload ]; then
sudo rm $local_path/upload
sudo mv $upload_path $local_path/
fi
2017-02-06 23:40:55 +01:00
sudo yunohost app setting $app skipped_uris -d
ynh_sso_access "/index.php?r=admin,/index.php?r=plugins,/scripts"
ynh_configure_php_fpm
ynh_configure_nginx
ynh_configure migrations/2.0.5.sql ./2.0.5.sql
mysql -u $app -p$db_pwd $app < ./2.0.5.sql
fi
# Backup config, plugins and themes and delete previous files
ynh_save_persistent modules themes plugins
ynh_save_persistent data application/config/config.php upload
# Copie new files and restore config, plugins, upload and themes
sudo rm -Rf $local_path
ynh_setup_source "$local_path" "$user"
# Set permissions
2017-02-06 23:40:55 +01:00
ynh_set_default_perm $local_path
sudo chmod -R u+w $local_path/tmp
sudo chmod -R u+w $local_path/upload
sudo chmod -R u+w $local_path/application/config/
2017-02-06 23:40:55 +01:00
# Migrate DB
cd $local_path/application/commands
ynh_exec_as "$app" php console.php update