mirror of
https://github.com/YunoHost-Apps/duniter_ynh.git
synced 2024-09-03 18:26:35 +02:00
d0ec6502f2
Check ports are available locally
153 lines
5 KiB
Bash
153 lines
5 KiB
Bash
#!/bin/bash
|
||
|
||
#=================================================
|
||
# GENERIC START
|
||
#=================================================
|
||
# IMPORT GENERIC HELPERS
|
||
#=================================================
|
||
|
||
source _common.sh
|
||
source /usr/share/yunohost/helpers
|
||
|
||
#=================================================
|
||
# LOAD SETTINGS
|
||
#=================================================
|
||
ynh_script_progression --message="Loading installation settings…"
|
||
|
||
app=$YNH_APP_INSTANCE_NAME
|
||
|
||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||
local_bma_port=$(ynh_app_setting_get --app=$app --key=local_bma_port)
|
||
local_ws2p_port=$(ynh_app_setting_get --app=$app --key=local_ws2p_port)
|
||
webadmin_port=$(ynh_app_setting_get --app=$app --key=webadmin_port)
|
||
architecture=$YNH_ARCH
|
||
|
||
#=================================================
|
||
# CHECK VERSION
|
||
#=================================================
|
||
ynh_script_progression --message="Checking version…"
|
||
|
||
upgrade_type=$(ynh_check_app_version_changed)
|
||
|
||
#=================================================
|
||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||
#=================================================
|
||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)…"
|
||
|
||
# Backup the current version of the app
|
||
ynh_backup_before_upgrade
|
||
ynh_clean_setup () {
|
||
ynh_clean_check_starting
|
||
# Restore it if the upgrade fails
|
||
ynh_restore_upgradebackup
|
||
}
|
||
# Exit if an error occurs during the execution of the script
|
||
ynh_abort_if_errors
|
||
|
||
#=================================================
|
||
# STANDARD UPGRADE STEPS
|
||
#=================================================
|
||
# STOP SYSTEMD SERVICE
|
||
#=================================================
|
||
ynh_script_progression --message="Stopping a systemd service…"
|
||
|
||
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
|
||
|
||
#=================================================
|
||
# ENSURE DOWNWARD COMPATIBILITY
|
||
#=================================================
|
||
ynh_script_progression --message="Ensuring downward compatibility…"
|
||
|
||
# Cleaning legacy permissions
|
||
if ynh_legacy_permissions_exists; then
|
||
ynh_legacy_permissions_delete_all
|
||
|
||
ynh_app_setting_delete --app=$app --key=is_public
|
||
fi
|
||
|
||
#=================================================
|
||
# CREATE DEDICATED USER
|
||
#=================================================
|
||
ynh_script_progression --message="Making sure dedicated system user exists…"
|
||
|
||
# Create a dedicated user (if not existing)
|
||
datadir=/home/yunohost.app/$app
|
||
ynh_system_user_create --username=$app --home_dir=$datadir --use_shell
|
||
|
||
#=================================================
|
||
# NGINX CONFIGURATION
|
||
#=================================================
|
||
ynh_script_progression --message="Upgrading NGINX web server configuration…"
|
||
|
||
# Create a dedicated NGINX config
|
||
ynh_add_nginx_config
|
||
|
||
#=================================================
|
||
# SPECIFIC UPGRADE
|
||
#=================================================
|
||
# INSTALL DUNITER
|
||
#=================================================
|
||
ynh_script_progression --message="Installation of Debian package of Duniter…"
|
||
|
||
dpkg -r duniter
|
||
|
||
tempdir="$(mktemp -d)"
|
||
|
||
ynh_setup_source --dest_dir=$tempdir --source_id=$architecture
|
||
ynh_exec_warn_less dpkg -i $tempdir/duniter-server-v1.8.*-linux-*.deb
|
||
|
||
#=================================================
|
||
# MOVE DUNITER DIRECTORY
|
||
#=================================================
|
||
if [[ ! -d "${datadir}" ]]; then
|
||
ynh_script_progression --message="Moving data directory…"
|
||
mv /root/.config/duniter $datadir
|
||
chmod 750 "$datadir"
|
||
chmod -R o-rwx "$datadir"
|
||
chown -R $app:www-data "$datadir"
|
||
fi
|
||
|
||
#=================================================
|
||
# UPDATE DUNITER CONFIG FILE
|
||
#=================================================
|
||
ynh_script_progression --message="Configure Duniter…"
|
||
|
||
CONFIGURE_DUNITER
|
||
|
||
#=================================================
|
||
# SETUP SYSTEMD
|
||
#=================================================
|
||
ynh_script_progression --message="Upgrading systemd configuration…"
|
||
|
||
# Create a dedicated systemd config
|
||
ynh_add_systemd_config
|
||
|
||
#=================================================
|
||
# INTEGRATE SERVICE IN YUNOHOST
|
||
#=================================================
|
||
ynh_script_progression --message="Integrating service in YunoHost…"
|
||
|
||
yunohost service add $app
|
||
|
||
#=================================================
|
||
# START SYSTEMD SERVICE
|
||
#=================================================
|
||
ynh_script_progression --message="Starting a systemd service…"
|
||
|
||
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd
|
||
|
||
#=================================================
|
||
# RELOAD NGINX
|
||
#=================================================
|
||
ynh_script_progression --message="Reloading NGINX web server…"
|
||
|
||
ynh_systemd_action --service_name=nginx --action=reload
|
||
|
||
#=================================================
|
||
# END OF SCRIPT
|
||
#=================================================
|
||
|
||
ynh_script_progression --message="Upgrade of $app completed"
|