mirror of
https://github.com/YunoHost-Apps/rainloop_ynh.git
synced 2024-09-03 20:16:18 +02:00
apply example_ynh on backup, restore and upgrade
This commit is contained in:
parent
814da2ff4f
commit
30645d06e0
3 changed files with 352 additions and 150 deletions
|
@ -1,31 +1,78 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Exit on command errors and treat unset variables as an error
|
#=================================================
|
||||||
set -eu
|
# GENERIC START
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Source app helpers
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Retrieve app settings
|
#=================================================
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
# MANAGE SCRIPT FAILURE
|
||||||
path=$(ynh_app_setting_get "$app" path)
|
#=================================================
|
||||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
|
||||||
|
|
||||||
# Copy the app files
|
ynh_clean_setup () {
|
||||||
DESTDIR="/var/www/$app"
|
### Remove this function if there's nothing to clean before calling the remove script.
|
||||||
ynh_backup "$DESTDIR" "sources"
|
true
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# Copy the conf files
|
#=================================================
|
||||||
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Copy dedicated php-fpm process to backup folder
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf"
|
|
||||||
|
|
||||||
# Set app specific variables
|
final_path=$(ynh_app_setting_get $app final_path)
|
||||||
dbname=$app
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
dbuser=$app
|
db_name=$(ynh_app_setting_get $app db_name)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD BACKUP STEPS
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE APP MAIN DIR
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup "$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE PHP-FPM CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup "/etc/php5/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE MYSQL DATABASE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_mysql_dump_db "$db_name" > db.sql
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC BACKUP
|
||||||
|
#=================================================
|
||||||
|
# BACKUP LOGROTATE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#ynh_backup "/etc/logrotate.d/$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP SYSTEMD
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#ynh_backup "/etc/systemd/system/$app.service"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP A CRON FILE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#ynh_backup "/etc/cron.d/$app"
|
||||||
|
|
||||||
# Dump the database
|
|
||||||
mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./db.sql
|
|
||||||
ynh_backup "db.sql" "dump.sql"
|
|
||||||
|
|
157
scripts/restore
157
scripts/restore
|
@ -1,56 +1,127 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Exit on command errors and treat unset variables as an error
|
#=================================================
|
||||||
set -eu
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Get multi-instances specific variables
|
source ../settings/scripts/_common.sh
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
# Source app helpers
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Retrieve old app settings
|
#=================================================
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
# MANAGE SCRIPT FAILURE
|
||||||
path=$(ynh_app_setting_get "$app" path)
|
#=================================================
|
||||||
dbname=$app
|
|
||||||
dbuser=$app
|
|
||||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
|
||||||
|
|
||||||
# Check domain/path availability
|
ynh_clean_setup () {
|
||||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
#### Remove this function if there's nothing to clean before calling the remove script.
|
||||||
|| ynh_die
|
true
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# Check destination directory
|
#=================================================
|
||||||
DESTDIR="/var/www/$app"
|
# LOAD SETTINGS
|
||||||
[[ -d $DESTDIR ]] && ynh_die \
|
#=================================================
|
||||||
"The destination directory '$DESTDIR' already exists.\
|
|
||||||
You should safely delete it before restoring this app."
|
|
||||||
|
|
||||||
# Check configuration files
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
|
||||||
[[ -f $nginx_conf ]] && ynh_die \
|
|
||||||
"The NGINX configuration already exists at '${nginx_conf}'.
|
|
||||||
You should safely delete it before restoring this app."
|
|
||||||
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
|
||||||
[[ -f $phpfpm_conf ]] && ynh_die \
|
|
||||||
"The PHP FPM configuration already exists at '${phpfpm_conf}'.
|
|
||||||
You should safely delete it before restoring this app."
|
|
||||||
|
|
||||||
# Restore the app files
|
|
||||||
sudo cp -a ./sources "$DESTDIR"
|
|
||||||
|
|
||||||
# Create and restore the database
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
ynh_mysql_create_db $dbname $dbuser $dbpass
|
path_url=$(ynh_app_setting_get $app path)
|
||||||
ynh_mysql_connect_as $dbuser $dbpass $dbname < ./dump.sql
|
final_path=$(ynh_app_setting_get $app final_path)
|
||||||
|
db_name=$(ynh_app_setting_get $app db_name)
|
||||||
|
|
||||||
# Fix installation directories and permissions
|
#=================================================
|
||||||
sudo mkdir -p "${DESTDIR}/logs" "${DESTDIR}/temp"
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
sudo chown -R www-data: "$DESTDIR"
|
#=================================================
|
||||||
|
|
||||||
# Restore configuration files
|
ynh_webpath_available $domain $path_url \
|
||||||
sudo cp -a ./nginx.conf "$nginx_conf"
|
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||||
sudo cp -a ./php-fpm.conf "$phpfpm_conf"
|
test ! -d $final_path \
|
||||||
|
|| ynh_die "There is already a directory: $final_path "
|
||||||
|
|
||||||
# Reload services
|
#=================================================
|
||||||
sudo service php5-fpm reload
|
# STANDARD RESTORATION STEPS
|
||||||
sudo service nginx reload
|
#=================================================
|
||||||
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE APP MAIN DIR
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_restore_file "$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE MYSQL DATABASE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||||
|
ynh_mysql_setup_db $db_name $db_name $db_pwd
|
||||||
|
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RECREATE THE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Create the dedicated user (if not existing)
|
||||||
|
#ynh_system_user_create $app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE USER RIGHTS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Restore permissions on app files
|
||||||
|
chown -R www-data: $final_path
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE PHP-FPM CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC RESTORATION
|
||||||
|
#=================================================
|
||||||
|
# REINSTALL DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Define and install dependencies
|
||||||
|
#ynh_install_app_dependencies deb1 deb2
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE SYSTEMD
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#ynh_restore_file "/etc/systemd/system/$app.service"
|
||||||
|
#systemctl enable $app.service
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#yunohost service add $app --log "/var/log/$app/APP.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE CRON FILE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#ynh_restore_file "/etc/cron.d/$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE LOGROTATE CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#ynh_restore_file "/etc/logrotate.d/$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX AND PHP-FPM
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
systemctl reload php5-fpm
|
||||||
|
systemctl reload nginx
|
||||||
|
|
238
scripts/upgrade
238
scripts/upgrade
|
@ -1,105 +1,189 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
rainloop_version=$(cat ../sources/rainloop_version)
|
|
||||||
|
|
||||||
# Source app helpers
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
source .fonctions
|
|
||||||
|
|
||||||
# Backup the current version of the app, restore it if the upgrade fails
|
#=================================================
|
||||||
# Check if old backup exists
|
# LOAD SETTINGS
|
||||||
if sudo yunohost backup list | grep -q $app-before-upgrade > /dev/null 2>&1;
|
#=================================================
|
||||||
then
|
|
||||||
sudo yunohost backup delete $app-before-upgrade
|
|
||||||
else
|
|
||||||
echo "no old backup to delete"
|
|
||||||
fi
|
|
||||||
sudo yunohost backup create --ignore-hooks --apps $app --name $app-before-upgrade --quiet
|
|
||||||
EXIT_PROPERLY () {
|
|
||||||
trap '' ERR
|
|
||||||
set +eu
|
|
||||||
sudo yunohost backup restore --ignore-hooks $app-before-upgrade --apps $app --force --quiet # Restore the backup if upgrade failed
|
|
||||||
ynh_die "Upgrade failed. The app was restored to the way it was before the failed upgrade."
|
|
||||||
}
|
|
||||||
set -eu
|
|
||||||
trap EXIT_PROPERLY ERR
|
|
||||||
|
|
||||||
# Retrieve arguments
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
|
||||||
path=$(ynh_app_setting_get "$app" path)
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
is_public=$(ynh_app_setting_get "$app" is_public)
|
path_url=$(ynh_app_setting_get $app path)
|
||||||
|
#admin=$(ynh_app_setting_get $app admin)
|
||||||
|
is_public=$(ynh_app_setting_get $app is_public)
|
||||||
|
final_path=$(ynh_app_setting_get $app final_path)
|
||||||
|
language=$(ynh_app_setting_get $app language)
|
||||||
|
db_name=$(ynh_app_setting_get $app db_name)
|
||||||
password=$(ynh_app_setting_get "$app" password)
|
password=$(ynh_app_setting_get "$app" password)
|
||||||
ldap=$(ynh_app_setting_get "$app" ldap)
|
ldap=$(ynh_app_setting_get "$app" ldap)
|
||||||
language=$(ynh_app_setting_get "$app" language)
|
|
||||||
dp_pwd=$(ynh_app_setting_get "$app" mysqlpwd)
|
|
||||||
db_user=$app
|
|
||||||
plugins=$(ynh_app_setting_get "$app" plugins)
|
plugins=$(ynh_app_setting_get "$app" plugins)
|
||||||
|
|
||||||
# Correct path using .fonctions
|
lang=$(ynh_app_setting_get $app lang)
|
||||||
CHECK_PATH
|
language=$lang
|
||||||
|
ynh_app_setting_set $app language $language
|
||||||
|
|
||||||
# no update for db now...
|
rainloop_path=${final_path}/app
|
||||||
|
|
||||||
# Copy the new sources
|
#=================================================
|
||||||
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Fix is_public as a boolean value
|
||||||
|
if [ "$is_public" = "Yes" ]; then
|
||||||
|
ynh_app_setting_set $app is_public 1
|
||||||
|
is_public=1
|
||||||
|
elif [ "$is_public" = "No" ]; then
|
||||||
|
ynh_app_setting_set $app is_public 0
|
||||||
|
is_public=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If db_name doesn't exist, create it
|
||||||
|
if [ -z $db_name ]; then
|
||||||
|
db_name=$(ynh_sanitize_dbid $app)
|
||||||
|
ynh_app_setting_set $app db_name $db_name
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If final_path doesn't exist, create it
|
||||||
|
if [ -z $final_path ]; then
|
||||||
final_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
final_path=${final_path}/app
|
ynh_app_setting_set $app final_path $final_path
|
||||||
sudo rm -rf $final_path/rainloop # Remove the previous Rainloop files except data
|
fi
|
||||||
|
|
||||||
# Download sources and keys
|
#=================================================
|
||||||
sudo wget -q https://github.com/RainLoop/rainloop-webmail/releases/download/v${rainloop_version}/rainloop-community-${rainloop_version}.zip
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
sudo wget -q https://github.com/RainLoop/rainloop-webmail/releases/download/v${rainloop_version}/rainloop-community-${rainloop_version}.zip.asc
|
#=================================================
|
||||||
sudo wget -q https://repository.rainloop.net/RainLoop.asc
|
|
||||||
# Verify the integrity of sources
|
# Backup the current version of the app
|
||||||
sudo gpg --import --quiet RainLoop.asc
|
ynh_backup_before_upgrade
|
||||||
sudo gpg --verify --quiet rainloop-community-${rainloop_version}.zip.asc rainloop-community-${rainloop_version}.zip
|
ynh_clean_setup () {
|
||||||
sudo gpg --batch --delete-key --yes Rainloop
|
# restore it if the upgrade fails
|
||||||
# Unzip and overwrite
|
ynh_restore_upgradebackup
|
||||||
sudo unzip -qq -o rainloop-community-${rainloop_version}.zip -d $final_path/
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK THE PATH
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Normalize the URL path syntax
|
||||||
|
path_url=$(ynh_normalize_url_path $path_url)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD UPGRADE STEPS
|
||||||
|
#=================================================
|
||||||
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
|
ynh_setup_source "$rainloop_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Create a dedicated nginx config
|
||||||
|
ynh_add_nginx_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# UPGRADE DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#ynh_install_app_dependencies deb1 deb2
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Create a dedicated user (if not existing)
|
||||||
|
#ynh_system_user_create $app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# PHP-FPM CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Create a dedicated php-fpm config
|
||||||
|
ynh_add_fpm_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC UPGRADE
|
||||||
|
#=================================================
|
||||||
|
# ...
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
application_file=$rainloop_path/data/_data_/_default_/configs/application.ini
|
||||||
|
|
||||||
# Update ynh plugins:
|
# Update ynh plugins:
|
||||||
sudo mkdir -p $final_path/data/_data_/_default_/plugins
|
sudo mkdir -p $rainloop_path/data/_data_/_default_/plugins
|
||||||
sudo cp -rf ../sources/plugins/auto-domain-grab $final_path/data/_data_/_default_/plugins/.
|
sudo cp -rf ../sources/plugins/auto-domain-grab $rainloop_path/data/_data_/_default_/plugins/.
|
||||||
sudo cp -rf ../sources/plugins/ynh-login-mapping $final_path/data/_data_/_default_/plugins/.
|
sudo cp -rf ../sources/plugins/ynh-login-mapping $rainloop_path/data/_data_/_default_/plugins/.
|
||||||
sudo cp -rf ../sources/plugins/ynh-ldap-suggestions $final_path/data/_data_/_default_/plugins/.
|
sudo cp -rf ../sources/plugins/ynh-ldap-suggestions $rainloop_path/data/_data_/_default_/plugins/.
|
||||||
|
|
||||||
# update SSO
|
# update SSO
|
||||||
sudo cp ../sources/sso/sso.php $final_path/index.php
|
sudo cp ../sources/sso/sso.php $final_path/index.php
|
||||||
sudo sed -i "s@domain.tld@$domain@g" $final_path/index.php
|
|
||||||
sudo sed -i "s@ALIASTOCHANGE@$final_path@g" $final_path/index.php
|
ynh_replace_string "__URL__" $domain$path_url $final_path/index.php
|
||||||
if [ $path = "/" ]; then
|
ynh_replace_string "__FINAL_PATH__" $final_path $final_path/index.php
|
||||||
sudo sed -i "s@ROOTTOCHANGE@@g" $final_path/index.php
|
|
||||||
else
|
|
||||||
sudo sed -i "s@ROOTTOCHANGE@$path@g" $final_path/index.php
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Install PGPback by chtixof to allow users to backup/restore their PGP private keys on the server
|
# Install PGPback by chtixof to allow users to backup/restore their PGP private keys on the server
|
||||||
sudo cp -rf ../sources/pgpback $final_path/.
|
sudo cp -rf ../sources/pgpback $final_path/.
|
||||||
|
|
||||||
# Set permissions to rainloop directory
|
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
||||||
|
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
|
||||||
|
ynh_backup_if_checksum_is_different "$final_path/index.php"
|
||||||
|
ynh_backup_if_checksum_is_different "$application_file"
|
||||||
|
# Recalculate and store the checksum of the file for the next upgrade.
|
||||||
|
ynh_store_file_checksum "$final_path/index.php"
|
||||||
|
ynh_store_file_checksum "$application_file"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP LOGROTATE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Use logrotate to manage app-specific logfile(s)
|
||||||
|
#ynh_use_logrotate --non-append
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SYSTEMD
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Create a dedicated systemd config
|
||||||
|
#ynh_add_systemd_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# SECURE FILES AND DIRECTORIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Set permissions on app files
|
||||||
|
chown -R www-data:www-data $final_path
|
||||||
sudo find $final_path/. -type d -exec chmod 755 {} \;
|
sudo find $final_path/. -type d -exec chmod 755 {} \;
|
||||||
sudo find $final_path/. -type f -exec chmod 644 {} \;
|
sudo find $final_path/. -type f -exec chmod 644 {} \;
|
||||||
sudo chown -R www-data:www-data $final_path
|
|
||||||
|
|
||||||
# Update Nginx configuration file
|
#=================================================
|
||||||
nginx_conf_file=/etc/nginx/conf.d/$domain.d/$app.conf
|
# SETUP SSOWAT
|
||||||
sudo cp ../conf/nginx.conf $nginx_conf_file
|
#=================================================
|
||||||
if [ $path = "/" ]; then
|
|
||||||
sudo sed -i "s@ROOTTOCHANGE@@g" $nginx_conf_file
|
# Make app public if necessary
|
||||||
else
|
if [ $is_public -eq 1 ]
|
||||||
sudo sed -i "s@ROOTTOCHANGE@$path@g" $nginx_conf_file
|
then
|
||||||
|
# unprotected_uris allows SSO credentials to be passed anyway
|
||||||
|
ynh_app_setting_set $app unprotected_uris "/"
|
||||||
fi
|
fi
|
||||||
sudo sed -i "s@PATHTOCHANGE@$path@g" $nginx_conf_file
|
|
||||||
sudo sed -i "s@ALIASTOCHANGE@$final_path/@g" $nginx_conf_file
|
|
||||||
sudo sed -i "s@NAMETOCHANGE@$app@g" $nginx_conf_file
|
|
||||||
sudo chown root: $nginx_conf_file
|
|
||||||
sudo chmod 644 $nginx_conf_file
|
|
||||||
|
|
||||||
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
|
#=================================================
|
||||||
sudo cp ../conf/php-fpm.conf $finalphpconf
|
# RELOAD NGINX
|
||||||
sudo sed -i "s@NAMETOCHANGE@$app@g" $finalphpconf
|
#=================================================
|
||||||
sudo chown root: $finalphpconf
|
|
||||||
sudo chmod 644 $finalphpconf
|
|
||||||
|
|
||||||
# Reload services
|
systemctl reload nginx
|
||||||
sudo service php5-fpm reload
|
systemctl reload php5-fpm
|
||||||
sudo service nginx reload
|
|
Loading…
Add table
Reference in a new issue