1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/cesium_ynh.git synced 2024-09-03 18:06:25 +02:00
cesium_ynh/scripts/install

115 lines
3.8 KiB
Text
Raw Normal View History

2016-06-13 22:03:33 +02:00
#!/bin/bash
2020-06-03 23:41:51 +02:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2016-06-13 22:03:33 +02:00
2020-06-03 23:41:51 +02:00
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
#=================================================
2016-06-13 22:03:33 +02:00
# Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$YNH_APP_ARG_DOMAIN
2020-06-03 23:41:51 +02:00
path_url=$YNH_APP_ARG_PATH
2016-06-13 22:03:33 +02:00
is_public=$YNH_APP_ARG_IS_PUBLIC
2020-06-03 23:41:51 +02:00
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
2020-06-04 05:36:19 +02:00
ynh_script_progression --message="Validating installation parameters..."
2020-06-03 23:41:51 +02:00
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url)
# Check web path availability
ynh_webpath_available $domain $path_url
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
2020-06-04 06:27:02 +02:00
ynh_script_progression --message="Storing installation settings..."
2016-06-13 22:03:33 +02:00
# Save app settings
2020-06-03 23:41:51 +02:00
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
2016-06-13 22:03:33 +02:00
2020-06-03 23:41:51 +02:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2020-06-04 05:36:19 +02:00
ynh_script_progression --message="Setting up source files..."
2016-06-13 22:03:33 +02:00
# Retrieve sources and install them
2020-06-03 23:41:51 +02:00
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
2020-06-03 23:41:51 +02:00
ynh_setup_source --dest_dir="$final_path"
#=================================================
# Permissions files
#=================================================
2020-06-03 23:46:53 +02:00
chown -R www-data: $final_path
2016-06-13 22:03:33 +02:00
2020-06-03 23:41:51 +02:00
# Remove the public access
ynh_app_setting_delete --app=$app --key=skipped_uris
#=================================================
# NGINX CONFIGURATION
#=================================================
2020-06-04 05:36:19 +02:00
ynh_script_progression --message="Configuring nginx web server..."
2020-06-03 23:41:51 +02:00
### `ynh_add_nginx_config` will use the file conf/nginx.conf
# Create a dedicated nginx config
ynh_add_nginx_config
2020-06-03 23:57:07 +02:00
2020-06-03 23:41:51 +02:00
if [ "$path_url" != "/" ]
then
ynh_replace_string "^#sub_path_only" "" "/etc/nginx/conf.d/$domain.d/$app.conf"
fi
2016-06-13 22:03:33 +02:00
2020-06-03 23:41:51 +02:00
#=================================================
# SETUP SSOWAT
#=================================================
2020-06-04 05:36:19 +02:00
ynh_script_progression --message="Configuring permissions..."
2020-06-03 23:41:51 +02:00
# If app is public, add url to SSOWat conf as skipped_uris and read-only mode
2016-06-13 22:03:33 +02:00
if [[ $is_public -eq 1 ]]; then
# unprotected_uris allows SSO credentials to be passed anyway.
2020-06-04 05:36:19 +02:00
ynh_permission_update --permission "main" --add "visitors"
# activate read-only
2020-06-03 23:41:51 +02:00
ynh_replace_string --match_string='"readonly": false,' --replace_string='"readonly": true,' --target_file="$final_path/config.js"
2016-06-13 22:03:33 +02:00
fi
2020-06-03 23:41:51 +02:00
#=================================================
# RELOAD NGINX
#=================================================
2020-06-04 06:27:02 +02:00
ynh_script_progression --message="Reloading nginx web server..."
2020-06-03 23:41:51 +02:00
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --time --last