2017-10-26 13:01:33 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2024-01-19 17:14:28 +01:00
|
|
|
#=================================================
|
|
|
|
# INITIALIZE AND STORE SETTINGS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Passwords aren't saved by default
|
|
|
|
ynh_app_setting_set --app="$app" --key=userpass --value="$userpass"
|
|
|
|
|
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
|
|
|
|
2023-12-13 00:28:26 +01:00
|
|
|
ynh_add_config --template="mosquitto.conf" --destination="/etc/mosquitto/conf.d/default.conf"
|
|
|
|
ynh_add_config --template="passwd" --destination="/etc/mosquitto/passwd"
|
|
|
|
|
2022-06-20 01:41:47 +02:00
|
|
|
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
|
|
|
|
|
|
|
#=================================================
|
2024-01-19 17:14:28 +01:00
|
|
|
# SYSTEM CONFIGURATION
|
2017-10-26 13:01:33 +02:00
|
|
|
#=================================================
|
2024-01-19 17:14:28 +01:00
|
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
2017-10-26 13:01:33 +02:00
|
|
|
|
|
|
|
# Use logrotate to manage application logfile(s)
|
|
|
|
ynh_use_logrotate
|
|
|
|
|
2024-01-19 17:14:28 +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
|
2024-01-19 17:14:28 +01:00
|
|
|
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
|