2015-05-08 12:03:12 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-08-28 16:34:15 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2017-04-20 19:34:26 +02:00
|
|
|
|
2021-02-13 19:19:24 +01:00
|
|
|
source _common.sh
|
2017-08-28 16:34:15 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
2015-05-08 12:03:12 +02:00
|
|
|
|
2017-04-20 19:34:26 +02:00
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
2017-08-28 16:34:15 +02:00
|
|
|
path_url=$YNH_APP_ARG_PATH
|
2017-04-20 19:34:26 +02:00
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2015-05-08 12:03:12 +02:00
|
|
|
|
2017-08-28 16:34:15 +02:00
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
|
|
#=================================================
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_script_progression --message="Validating installation parameters..."
|
2017-08-28 16:34:15 +02:00
|
|
|
|
|
|
|
# Register (book) web path
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
2017-08-28 16:34:15 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_script_progression --message="Storing installation settings..."
|
2017-08-28 16:34:15 +02:00
|
|
|
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
|
|
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
2017-08-28 16:34:15 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD MODIFICATIONS
|
|
|
|
#=================================================
|
|
|
|
# FIND AND OPEN A PORT
|
|
|
|
#=================================================
|
2021-01-09 22:47:07 +01:00
|
|
|
ynh_script_progression --message="Finding an available port..." --weight=2
|
2017-08-28 16:34:15 +02:00
|
|
|
|
|
|
|
# Find a free port
|
2019-05-20 17:03:46 +02:00
|
|
|
port=$(ynh_find_port --port=4200)
|
|
|
|
ynh_app_setting_set --app=$app --key=port --value=$port
|
2017-08-28 16:34:15 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# INSTALL SHELLINABOX
|
|
|
|
#=================================================
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_script_progression --message="Installing shellinabox..." --weight=7
|
2017-08-28 16:34:15 +02:00
|
|
|
|
|
|
|
ynh_package_update
|
2021-02-13 19:19:24 +01:00
|
|
|
ynh_install_app_dependencies $pkg_dependencies
|
2017-08-28 16:34:15 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_script_progression --message="Configuring nginx web server..." --weight=2
|
2017-08-28 16:34:15 +02:00
|
|
|
|
|
|
|
# Create a dedicated nginx config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
|
|
|
#=================================================
|
|
|
|
# CONFIGURE SHELLINABOX
|
|
|
|
#=================================================
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_script_progression --message="Configuring shellinabox..." --weight=2
|
2017-08-28 16:34:15 +02:00
|
|
|
|
|
|
|
cp ../conf/shellinabox /etc/default/shellinabox
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="/etc/default/shellinabox"
|
2018-03-08 00:25:33 +01:00
|
|
|
|
|
|
|
# Allow the service to log in syslog
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_replace_string --match_string=" -- -q --background" --replace_string=" -- --background" --target_file="/etc/init.d/shellinabox"
|
2018-03-08 00:51:15 +01:00
|
|
|
systemctl daemon-reload
|
2018-03-08 00:25:33 +01:00
|
|
|
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_systemd_action --service_name=shellinabox --action=restart
|
2015-05-08 12:03:12 +02:00
|
|
|
|
2017-08-28 16:34:15 +02:00
|
|
|
#=================================================
|
|
|
|
# STORE THE CHECKSUM OF THE CONFIG FILE
|
|
|
|
#=================================================
|
2015-05-08 12:03:12 +02:00
|
|
|
|
2017-08-28 16:34:15 +02:00
|
|
|
# Calculate and store the config file checksum into the app settings
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_store_file_checksum --file="/etc/default/shellinabox"
|
2015-05-08 12:03:12 +02:00
|
|
|
|
2017-08-28 16:34:15 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
|
|
|
#=================================================
|
2015-05-08 12:03:12 +02:00
|
|
|
|
2017-08-28 16:34:15 +02:00
|
|
|
yunohost service add $app
|
2015-05-08 12:03:12 +02:00
|
|
|
|
2017-08-28 16:34:15 +02:00
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_script_progression --message="Reloading nginx web server..."
|
2015-05-08 12:03:12 +02:00
|
|
|
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
2019-03-04 16:24:27 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|