2017-01-28 23:40:29 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
2017-01-29 16:32:14 +01:00
|
|
|
set -eu
|
2017-01-28 23:40:29 +01:00
|
|
|
|
2017-01-29 16:32:14 +01:00
|
|
|
# Source app helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
2017-01-28 23:40:29 +01:00
|
|
|
|
|
|
|
# This is a multi-instance app, meaning it can be installed several times independently
|
|
|
|
# The id of the app as stated in the manifest is available as $YNH_APP_ID
|
|
|
|
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
|
|
|
# The app instance name is available as $YNH_APP_INSTANCE_NAME
|
|
|
|
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
|
|
|
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
|
|
|
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
|
|
|
# The app instance name is probably what you are interested the most, since this is
|
|
|
|
# guaranteed to be unique. This is a good unique identifier to define installation path,
|
|
|
|
# db names, ...
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
# Retrieve arguments
|
2017-02-11 21:06:26 +01:00
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
2017-01-28 23:40:29 +01:00
|
|
|
|
|
|
|
# Get old parameter of the app
|
2017-02-11 21:06:26 +01:00
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
|
|
|
path=$(ynh_app_setting_get $app path)
|
|
|
|
user=$(ynh_app_setting_get $app allowed_users)
|
|
|
|
is_public=$(ynh_app_setting_get $app is_public)
|
2017-01-29 16:36:22 +01:00
|
|
|
final_path=/var/www/$app
|
2017-01-28 23:40:29 +01:00
|
|
|
|
|
|
|
# Check domain/path availability
|
2017-01-29 16:36:22 +01:00
|
|
|
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
|
|
|
|| ynh_die "Path not available: ${domain}${path}"
|
2017-01-28 23:40:29 +01:00
|
|
|
|
|
|
|
if [ -d $final_path ]; then
|
|
|
|
echo "There is already a directory: $final_path " | sudo tee /dev/stderr
|
2017-01-29 16:36:22 +01:00
|
|
|
ynh_die
|
2017-01-28 23:40:29 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
conf=/etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
if [ -f $conf ]; then
|
|
|
|
echo "There is already a nginx conf file at this path: $conf " | sudo tee /dev/stderr
|
2017-01-29 16:36:22 +01:00
|
|
|
ynh_die
|
2017-01-28 23:40:29 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Restore sources & data
|
|
|
|
sudo cp -a "./sources" $final_path
|
|
|
|
|
2017-01-28 23:43:05 +01:00
|
|
|
sudo chown www-data:www-data $final_path -R
|
|
|
|
sudo chmod 755 $final_path -R
|
2017-01-28 23:40:29 +01:00
|
|
|
|
|
|
|
# Restore conf files
|
|
|
|
sudo cp -a "./conf/nginx.conf" $conf
|
|
|
|
|
|
|
|
# Reload Nginx
|
|
|
|
sudo service nginx reload
|
|
|
|
|
|
|
|
# Set ssowat config
|
|
|
|
if [ "$is_public" = "Yes" ];
|
|
|
|
then
|
2017-02-11 22:14:57 +01:00
|
|
|
ynh_app_setting_set $app unprotected_uris "/"
|
2017-01-28 23:40:29 +01:00
|
|
|
fi
|