mirror of
https://github.com/YunoHost-Apps/biboumi_ynh.git
synced 2024-09-03 18:15:58 +02:00
80 lines
2.9 KiB
Bash
Executable file
80 lines
2.9 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
#=================================================
|
|
|
|
if dpkg --compare-versions "$(uname -r)" "<=" "4.0"; then
|
|
ynh_die "Upgrade your kernel first. Unsupported version: $(uname -r)"
|
|
fi
|
|
|
|
#=================================================
|
|
# INITIALIZE AND STORE SETTINGS
|
|
#=================================================
|
|
|
|
shared_secret="$(ynh_string_random 25)"
|
|
ynh_app_setting_set --app="$app" --key="shared_secret" --value="$shared_secret"
|
|
|
|
admin_jid="${admin}@${app}.${domain}"
|
|
ynh_app_setting_set --app="$app" --key="admin_jid" --value="$admin_jid"
|
|
|
|
#=================================================
|
|
# CREATE DATA DIRECTORY
|
|
#=================================================
|
|
ynh_script_progression --message="Setting up the data directory..."
|
|
|
|
# Set permissions to app files
|
|
chown -R _biboumi:_biboumi "/var/lib/$app"
|
|
|
|
#=================================================
|
|
# APP INITIAL CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding $app's configuration files..." --weight=1
|
|
|
|
# Stop the service started by apt install
|
|
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd"
|
|
|
|
# Add metronome component
|
|
metronome_config_dir=$(_get_metronome_config_dir)
|
|
ynh_add_config --template="metronome.cfg.lua" --destination="$metronome_config_dir/$app.cfg.lua"
|
|
chown metronome:metronome "$metronome_config_dir/$app.cfg.lua"
|
|
ynh_systemd_action --service_name="metronome" --action="restart"
|
|
|
|
# Add biboumi configuration
|
|
mkdir -p "/etc/$app/"
|
|
ynh_add_config --template="biboumi.cfg" --destination="/etc/$app/$app.cfg"
|
|
chown -R _biboumi:_biboumi "/etc/$app/$app.cfg"
|
|
|
|
#=================================================
|
|
# SYSTEM CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
|
|
|
# Create a dedicated systemd config
|
|
systemctl enable "$app.service" --quiet
|
|
yunohost service add "$app" --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log"
|
|
|
|
# Use logrotate to manage application logfile(s)
|
|
ynh_use_logrotate
|
|
chown -R _biboumi:_biboumi "/var/log/$app"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
|
|
|
|
# Start a systemd service
|
|
ynh_systemd_action --service_name="$app" --action="start" --line_match="Authenticated with the XMPP server" --log_path="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed"
|