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

111 lines
3.5 KiB
Text
Raw Normal View History

2019-02-20 12:08:50 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
# Retrieve arguments
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-11-16 19:38:35 +01:00
# ynh_script_progression --message="Validating installation parameters..." --weight=1
2019-02-20 12:08:50 +01:00
2020-11-16 19:38:35 +01:00
# final_path=/var/www/$app
# test ! -e "$final_path" || ynh_die "This path already contains a folder"
2019-02-20 12:08:50 +01:00
2020-11-16 19:38:35 +01:00
# # Normalize the url path syntax
# path_url=$(ynh_normalize_url_path $path_url)
2019-02-20 12:08:50 +01:00
2020-11-16 19:38:35 +01:00
# # Check web path availability
# ynh_webpath_available $domain $path_url
# # Register (book) web path
# ynh_webpath_register $app $domain $path_url
2019-02-20 12:08:50 +01:00
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
2020-11-16 19:12:12 +01:00
ynh_script_progression --message="Storing installation settings..." --weight=2
2019-02-20 12:08:50 +01:00
2021-07-07 19:27:38 +02:00
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
2019-02-20 12:22:52 +01:00
2020-11-16 19:12:12 +01:00
#=================================================
# STANDARD MODIFICATIONS
2019-02-20 12:08:50 +01:00
#=================================================
# FIND AND OPEN A PORT
#=================================================
2020-11-16 19:12:12 +01:00
ynh_script_progression --message="Configuring firewall..." --weight=2
2019-02-20 12:08:50 +01:00
2020-11-16 19:12:12 +01:00
# Find an available port
port=$(ynh_find_port --port=9090)
ynh_app_setting_set --app=$app --key=port --value=$port
2019-02-20 12:08:50 +01:00
#=================================================
2020-11-16 19:12:12 +01:00
# INSTALL DEPENDENCIES
2019-02-20 12:08:50 +01:00
#=================================================
2020-11-16 19:12:12 +01:00
ynh_script_progression --message="Installing dependencies..." --weight=20
2019-02-20 12:08:50 +01:00
2020-11-16 19:12:12 +01:00
ynh_install_app_dependencies $pkg_dependencies
2019-02-20 12:08:50 +01:00
#=================================================
# NGINX CONFIGURATION
#=================================================
2020-11-16 19:12:12 +01:00
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
2019-02-20 12:08:50 +01:00
2020-11-16 19:12:12 +01:00
# Create a dedicated NGINX config
2019-02-20 12:08:50 +01:00
ynh_add_nginx_config
2020-11-16 19:38:35 +01:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2
# Reload services
2020-11-16 20:05:17 +01:00
systemctl start $app
2021-07-07 19:27:38 +02:00
systemctl enable $app --quiet
2020-11-16 19:38:35 +01:00
2019-02-20 12:08:50 +01:00
#=================================================
2020-11-16 19:12:12 +01:00
# SETUP SSOWAT
2019-02-20 12:08:50 +01:00
#=================================================
2020-11-16 19:38:35 +01:00
ynh_script_progression --message="Configuring SSOwat..." --weight=1
2019-02-20 12:08:50 +01:00
2020-11-16 19:38:35 +01:00
# Make app public if necessary or protect it
if [ $is_public -eq 1 ]
then
ynh_permission_update --permission "main" --add "visitors"
2020-11-16 19:12:12 +01:00
fi
2019-02-20 12:08:50 +01:00
#=================================================
2020-11-16 19:12:12 +01:00
# RELOAD NGINX
2019-02-20 12:08:50 +01:00
#=================================================
2020-11-16 19:12:12 +01:00
ynh_script_progression --message="Reloading NGINX web server..." --weight=2
2019-02-20 12:08:50 +01:00
2020-11-16 19:12:12 +01:00
ynh_systemd_action --service_name=nginx --action=reload
2019-02-20 12:08:50 +01:00
#=================================================
2020-11-16 19:12:12 +01:00
# END OF SCRIPT
2019-02-20 12:08:50 +01:00
#=================================================
2021-07-07 19:08:59 +02:00
ynh_script_progression --message="Installation of $app completed" --last