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

69 lines
1.6 KiB
Text
Raw Normal View History

2015-04-06 17:46:57 +02:00
#!/bin/bash
2017-04-30 15:45:50 +02:00
# Exit on command errors and treat unset variables as an error
set -eu
2017-05-08 17:37:47 +02:00
if [ ! -e _common ]; then
2017-05-08 17:37:47 +02:00
# Get file fonction if not been to the current directory
sudo cp ../settings/scripts/_common ./_common
sudo chmod a+rx _common
fi
2017-04-30 15:45:50 +02:00
# Source app helpers
source ./_common
source /usr/share/yunohost/helpers
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path)
user=$(ynh_app_setting_get "$app" user)
is_public=$(ynh_app_setting_get $app is_public)
ynh_backup_before_upgrade # Backup the current version of the app
ynh_clean_setup () {
ynh_backup_fail_upgrade # restore it if the upgrade fails
}
ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est détectée.
2015-04-06 17:46:57 +02:00
# Remove trailing "/" for next commands
2017-04-30 15:45:50 +02:00
if [[ ! "$path" == "/" ]]; then
path=${path%/}
fi
2015-04-06 17:46:57 +02:00
2017-04-30 15:45:50 +02:00
# Create system user dedicace for this app
ynh_system_user_create $app
# Init final_path, if ever it got deleted somehow
2015-04-06 17:46:57 +02:00
final_path=/var/www/$app
2017-04-30 15:45:50 +02:00
# Clean all files and directory except the data directory
ynh_secure_remove $final_path
# Create directory
2015-04-06 17:46:57 +02:00
sudo mkdir -p $final_path
2017-04-30 15:45:50 +02:00
# Copy files to the right place
extract_source $final_path
# Fix owner
sudo chown -R $app: $final_path
2015-04-06 17:46:57 +02:00
# Modify Nginx configuration file and copy it to Nginx conf directory
2017-04-30 15:45:50 +02:00
ynh_nginx_config
2015-04-06 17:46:57 +02:00
2017-04-30 15:45:50 +02:00
# Create the php-fpm pool config
ynh_fpm_config
2015-04-06 17:46:57 +02:00
2017-04-30 15:45:50 +02:00
# Set ssowat config
2017-05-01 16:36:17 +02:00
if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set $app is_public 1 # Fixe is_public en booléen
is_public=1
elif [ "$is_public" = "No" ]; then
ynh_app_setting_set $app is_public 0
is_public=0
2017-04-30 15:45:50 +02:00
fi
# Reload Nginx
sudo systemctl reload nginx
sudo yunohost app ssowatconf