2013-12-24 13:37:55 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-04-16 17:22:30 +02:00
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
set -eu
|
2017-04-17 18:20:58 +02:00
|
|
|
# Source app helpers
|
2016-08-24 19:33:06 +02:00
|
|
|
source ./_common
|
2017-04-17 18:20:58 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
2016-08-24 19:33:06 +02:00
|
|
|
|
2016-08-24 19:43:33 +02:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
2017-04-16 17:22:30 +02:00
|
|
|
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)
|
2013-12-24 13:37:55 +01:00
|
|
|
|
|
|
|
# Remove trailing "/" for next commands
|
2015-05-23 15:04:48 +02:00
|
|
|
if [[ ! "$path" == "/" ]]; then
|
|
|
|
path=${path%/}
|
|
|
|
fi
|
2013-12-24 13:37:55 +01:00
|
|
|
|
2017-04-17 18:20:58 +02:00
|
|
|
# Create system user dedicace for this app
|
|
|
|
ynh_system_user_create $app
|
|
|
|
|
2016-08-24 19:33:06 +02:00
|
|
|
# Init final_path, if ever it got deleted somehow
|
2016-08-24 19:43:33 +02:00
|
|
|
final_path=/var/www/$app
|
2013-12-24 13:37:55 +01:00
|
|
|
sudo mkdir -p $final_path
|
2016-08-24 19:33:06 +02:00
|
|
|
|
2017-04-16 17:22:30 +02:00
|
|
|
# Clean all files and directory except the data directory
|
2017-04-17 18:20:58 +02:00
|
|
|
ynh_secure_remove $final_path/cfg
|
|
|
|
ynh_secure_remove $final_path/CREDITS.md
|
|
|
|
ynh_secure_remove $final_path/i18n
|
|
|
|
ynh_secure_remove $final_path/index.php
|
|
|
|
ynh_secure_remove $final_path/js
|
|
|
|
ynh_secure_remove $final_path/README.md
|
|
|
|
ynh_secure_remove $final_path/tmp
|
|
|
|
ynh_secure_remove $final_path/CHANGELOG.md
|
|
|
|
ynh_secure_remove $final_path/css
|
|
|
|
ynh_secure_remove $final_path/favicon.ico
|
|
|
|
ynh_secure_remove $final_path/img
|
|
|
|
ynh_secure_remove $final_path/INSTALL.md
|
|
|
|
ynh_secure_remove $final_path/lib
|
|
|
|
ynh_secure_remove $final_path/robots.txt
|
|
|
|
ynh_secure_remove $final_path/tpl
|
|
|
|
ynh_secure_remove $final_path/data
|
2016-08-24 19:33:06 +02:00
|
|
|
|
|
|
|
# Copy files to the right place
|
|
|
|
extract_source $final_path
|
2013-12-24 13:37:55 +01:00
|
|
|
|
|
|
|
# Files owned by root, www-data can just read
|
|
|
|
sudo find $final_path -type f | xargs sudo chmod 644
|
|
|
|
sudo find $final_path -type d | xargs sudo chmod 755
|
2017-04-17 19:49:45 +02:00
|
|
|
sudo chown -R root: $final_path
|
2013-12-24 13:37:55 +01:00
|
|
|
|
|
|
|
# except for data and tmp subdir, where www-data must have write permissions
|
2016-09-23 15:48:34 +02:00
|
|
|
sudo mkdir -p $final_path/{data,tmp}
|
2017-04-17 18:20:58 +02:00
|
|
|
sudo chown -R $app:root $final_path/{data,tmp}
|
2013-12-24 13:37:55 +01:00
|
|
|
sudo chmod 700 $final_path/{data,tmp}
|
|
|
|
|
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
2017-05-20 19:40:39 +02:00
|
|
|
ynh_nginx_config
|
2013-12-24 13:37:55 +01:00
|
|
|
|
2017-04-16 23:57:23 +02:00
|
|
|
# Create the php-fpm pool config
|
2017-04-17 18:20:58 +02:00
|
|
|
ynh_fpm_config
|
2017-04-16 23:57:23 +02:00
|
|
|
|
2017-04-16 17:22:30 +02:00
|
|
|
# Set ssowat config
|
2017-05-20 19:40:39 +02:00
|
|
|
if [ "$is_public" = "Yes" ]; then
|
|
|
|
ynh_app_setting_set $app is_public 1 # Fixe is_public en booléen
|
|
|
|
is_public=1
|
|
|
|
else
|
|
|
|
ynh_app_setting_set $app is_public 0
|
|
|
|
is_public=0
|
2013-12-24 13:37:55 +01:00
|
|
|
fi
|
|
|
|
|
2017-04-16 17:22:30 +02:00
|
|
|
# Reload Nginx
|
|
|
|
sudo systemctl reload nginx
|
2013-12-24 13:37:55 +01:00
|
|
|
sudo yunohost app ssowatconf
|