2016-06-13 22:03:33 +02:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
|
|
# Retrieve arguments
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
|
|
|
path=$YNH_APP_ARG_PATH
|
|
|
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
|
|
|
|
|
|
|
|
|
# Source YunoHost helpers
|
2016-06-15 23:35:36 +02:00
|
|
|
|
source /usr/share/yunohost/helpers
|
2016-06-13 22:03:33 +02:00
|
|
|
|
|
|
|
|
|
# Save app settings
|
|
|
|
|
ynh_app_setting_set "$app" is_public "$is_public"
|
|
|
|
|
|
|
|
|
|
# Check domain/path availability
|
2020-03-05 20:27:10 +01:00
|
|
|
|
yunohost app checkurl "${domain}${path}" -a "$app" \
|
2016-06-13 22:03:33 +02:00
|
|
|
|
|| ynh_die "Path not available: ${domain}${path}"
|
|
|
|
|
|
|
|
|
|
# Retrieve sources and install them
|
|
|
|
|
src_path=/var/www/$app
|
2020-03-05 20:27:10 +01:00
|
|
|
|
mkdir -p $src_path
|
2019-07-30 23:07:10 +02:00
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
|
|
|
ynh_script_progression --message="Setting up source files..." --time --weight=1
|
|
|
|
|
ynh_setup_source --dest_dir=$src_path
|
2020-03-05 20:27:10 +01:00
|
|
|
|
chown -R www-data: $src_path
|
2016-06-13 22:03:33 +02:00
|
|
|
|
|
|
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
|
|
|
|
nginx_conf=../conf/nginx.conf
|
|
|
|
|
sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf
|
|
|
|
|
sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf
|
2020-03-05 20:27:10 +01:00
|
|
|
|
cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
|
2016-06-13 22:03:33 +02:00
|
|
|
|
|
|
|
|
|
# If app is public, add url to SSOWat conf as skipped_uris
|
|
|
|
|
if [[ $is_public -eq 1 ]]; then
|
|
|
|
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
|
|
|
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Reload nginx service
|
2020-03-05 20:27:10 +01:00
|
|
|
|
service nginx reload
|