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
|
|
|
|
2021-12-06 22:57:44 +01:00
|
|
|
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
2019-02-20 12:08:50 +01:00
|
|
|
|
2021-12-06 22:54:30 +01:00
|
|
|
#=================================================
|
|
|
|
# ADD A CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
|
|
|
|
2021-12-06 22:57:44 +01:00
|
|
|
ynh_add_config --template="../conf/cockpit.conf" --destination="/etc/cockpit/cockpit.conf"
|
2021-12-06 22:54:30 +01:00
|
|
|
|
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
|
|
|
#=================================================
|
2021-12-06 23:12:58 +01:00
|
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
2020-11-16 19:38:35 +01:00
|
|
|
#=================================================
|
2021-12-06 23:12:58 +01:00
|
|
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
2020-11-16 19:38:35 +01:00
|
|
|
|
2021-12-06 23:12:58 +01:00
|
|
|
yunohost service add cockpit.socket --description="Monitor" --log="/var/log/$app/$app.log"
|
2021-12-06 23:01:56 +01:00
|
|
|
|
|
|
|
#=================================================
|
2021-12-06 23:12:58 +01:00
|
|
|
# START SYSTEMD SERVICE
|
2021-12-06 23:01:56 +01:00
|
|
|
#=================================================
|
2021-12-06 23:12:58 +01:00
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=2
|
2020-11-16 19:38:35 +01:00
|
|
|
|
2021-12-06 23:06:28 +01:00
|
|
|
ynh_systemd_action --service_name=cockpit.socket --action="start" --log_path="/var/log/$app/$app.log"
|
|
|
|
|
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
|