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
2017-05-01 16:36:17 +02:00

62 lines
1.5 KiB
Bash

#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
# 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.
# Remove trailing "/" for next commands
if [[ ! "$path" == "/" ]]; then
path=${path%/}
fi
# Create system user dedicace for this app
ynh_system_user_create $app
# Init final_path, if ever it got deleted somehow
final_path=/var/www/$app
# Clean all files and directory except the data directory
ynh_secure_remove $final_path
# Create directory
sudo mkdir -p $final_path
# Copy files to the right place
extract_source $final_path
# Fix owner
sudo chown -R $app: $final_path
# Modify Nginx configuration file and copy it to Nginx conf directory
ynh_nginx_config
# Create the php-fpm pool config
ynh_fpm_config
# Set ssowat config
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
fi
# Reload Nginx
sudo systemctl reload nginx
sudo yunohost app ssowatconf