1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mosquitto_ynh.git synced 2024-09-03 19:45:54 +02:00
mosquitto_ynh/scripts/install

101 lines
3.6 KiB
Text
Raw Normal View History

2017-10-26 13:01:33 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
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
#=================================================
2021-02-13 18:14:54 +01:00
username=$YNH_APP_ARG_USERNAME
password=$YNH_APP_ARG_PASSWORD
2017-10-26 13:01:33 +02:00
2022-06-20 01:41:47 +02:00
app=$YNH_APP_INSTANCE_NAME
2017-10-26 13:01:33 +02:00
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
2021-02-13 18:14:54 +01:00
ynh_script_progression --message="Storing installation settings..." --weight=1
2017-10-26 13:01:33 +02:00
2021-02-13 18:14:54 +01:00
ynh_app_setting_set --app=$app --key=username --value=$username
ynh_app_setting_set --app=$app --key=password --value=$password
2017-10-26 13:01:33 +02:00
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
2021-02-13 18:14:54 +01:00
ynh_script_progression --message="Finding an available port..." --weight=1
2017-10-26 13:01:33 +02:00
2021-02-13 18:14:54 +01:00
# Find an available port
port=$(ynh_find_port --port=1883)
ynh_app_setting_set --app=$app --key=port --value=$port
# Open the port
ynh_script_progression --message="Configuring firewall..." --weight=1
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
2017-10-26 13:01:33 +02:00
#=================================================
# INSTALL DEPENDENCIES
#=================================================
2021-02-13 18:14:54 +01:00
ynh_script_progression --message="Installing dependencies..." --weight=20
2017-10-26 13:01:33 +02:00
2023-04-10 18:24:41 +02:00
ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian bullseye main" --package="$extra_pkg_dependencies" --key="http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" --name="$app"
2017-10-26 13:01:33 +02:00
#=================================================
2021-02-13 18:14:54 +01:00
# SPECIFIC SETUP
2017-10-26 13:01:33 +02:00
#=================================================
2022-06-20 01:41:47 +02:00
# ADD A CONFIGURATION
2021-02-13 18:14:54 +01:00
#=================================================
2022-06-20 01:41:47 +02:00
ynh_script_progression --message="Adding a configuration file..." --weight=1
2017-10-26 13:01:33 +02:00
2022-06-20 01:41:47 +02:00
ynh_add_config --template="../conf/passwd" --destination="/etc/mosquitto/passwd"
mosquitto_passwd -U "/etc/mosquitto/passwd"
2023-04-21 21:28:08 +02:00
ynh_store_file_checksum --file="/etc/mosquitto/passwd"
2017-10-26 13:01:33 +02:00
2022-06-20 01:41:47 +02:00
ynh_add_config --template="../conf/mosquitto.conf" --destination="/etc/mosquitto/conf.d/default.conf"
2017-10-26 13:01:33 +02:00
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
2021-02-13 18:14:54 +01:00
ynh_script_progression --message="Configuring log rotation..." --weight=1
2017-10-26 13:01:33 +02:00
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
2021-02-13 18:14:54 +01:00
# INTEGRATE SERVICE IN YUNOHOST
2017-10-26 13:01:33 +02:00
#=================================================
2021-02-13 18:14:54 +01:00
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
2017-10-26 13:01:33 +02:00
2021-02-13 18:14:54 +01:00
yunohost service add $app --description="Allows MQTT clients to send/receive data" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port"
2017-10-26 13:01:33 +02:00
#=================================================
2022-06-20 01:41:47 +02:00
# START SYSTEMD SERVICE
2017-10-26 13:01:33 +02:00
#=================================================
2022-06-20 01:41:47 +02:00
ynh_script_progression --message="Starting a systemd service..." --weight=1
2017-10-26 13:01:33 +02:00
2022-06-20 01:41:47 +02:00
# Start a systemd service
ynh_systemd_action --service_name=$app --action="restart"
2017-10-26 13:01:33 +02:00
#=================================================
2021-02-13 18:14:54 +01:00
# END OF SCRIPT
2017-10-26 13:01:33 +02:00
#=================================================
2021-02-13 18:14:54 +01:00
ynh_script_progression --message="Installation of $app completed" --last