2020-03-11 00:07:10 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_clean_setup () {
|
|
|
|
### Remove this function if there's nothing to clean before calling the remove script.
|
|
|
|
true
|
|
|
|
}
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
|
|
path_url=$YNH_APP_ARG_PATH
|
|
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
|
|
#=================================================
|
2020-03-24 00:09:56 +01:00
|
|
|
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
2020-03-11 00:07:10 +01:00
|
|
|
|
|
|
|
final_path=/var/www/$app
|
|
|
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
|
|
|
|
|
|
|
# Register (book) web path
|
|
|
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
2020-03-24 00:09:56 +01:00
|
|
|
ynh_script_progression --message="Storing installation settings..." --weight=2
|
2020-03-11 00:07:10 +01:00
|
|
|
|
|
|
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
|
|
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2020-03-24 00:09:56 +01:00
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=2
|
2020-03-11 00:07:10 +01:00
|
|
|
|
|
|
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
|
|
|
ynh_setup_source --dest_dir="$final_path"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2021-04-18 16:14:40 +02:00
|
|
|
ynh_script_progression --message="Configuring NGINX web server..." --weight=15
|
2020-03-11 00:07:10 +01:00
|
|
|
|
|
|
|
# Create a dedicated nginx config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
2020-04-05 11:56:23 +02:00
|
|
|
#=================================================
|
|
|
|
# REMOVE CALLS TO THIRD PARTY WEBSITES
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Add "offline" parameter in index.html
|
|
|
|
# See https://desk.draw.io/support/solutions/articles/16000042546-what-url-parameters-are-supported-
|
|
|
|
# and https://shelter.moe/@Neil/103928506546498078 [French]
|
2020-04-05 12:32:37 +02:00
|
|
|
sed_pattern="s/var params = window.location.search.slice(1).split('&');/&\n\t\t\tparams.push(\"offline=1\");/g"
|
2020-04-05 11:56:23 +02:00
|
|
|
sed -i "$sed_pattern" "$final_path/src/main/webapp/index.html"
|
|
|
|
|
2020-03-11 00:07:10 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# SECURE FILES AND DIRECTORIES
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Set permissions to app files
|
|
|
|
chown -R root: $final_path
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP SSOWAT
|
|
|
|
#=================================================
|
2021-04-18 16:14:40 +02:00
|
|
|
ynh_script_progression --message="Configuring permissions..." --weight=3
|
2020-03-11 00:07:10 +01:00
|
|
|
|
|
|
|
# Make app public if necessary
|
|
|
|
if [ $is_public -eq 1 ]
|
|
|
|
then
|
2021-04-18 16:14:40 +02:00
|
|
|
# Everyone can access the app.
|
|
|
|
# The "main" permission is automatically created before the install script.
|
|
|
|
ynh_permission_update --permission="main" --add="visitors"
|
2020-03-11 00:07:10 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2021-04-18 16:14:40 +02:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
2020-03-11 00:07:10 +01:00
|
|
|
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2020-03-24 00:09:56 +01:00
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|