From d50ce2b5f21ef65632e311ddcc6cf2e5c5557b75 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 5 Sep 2021 22:50:30 +0200 Subject: [PATCH] Add recordig and groups to user folder --- conf/systemd.service | 2 +- scripts/backup | 7 +++++++ scripts/install | 24 +++++++++++++++++++----- scripts/remove | 12 ++++++++++++ scripts/restore | 15 ++++++++++++++- scripts/upgrade | 40 ++++++++++++++++++++-------------------- 6 files changed, 73 insertions(+), 27 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index c68481e..3cd1b26 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -8,7 +8,7 @@ Type=simple WorkingDirectory=__FINALPATH__/ User=__APP__ Group=__APP__ -ExecStart=__FINALPATH__/galene -turn __PUBLIC_IP4__:__TURN_PORT__ -udp-range 49152-65535 +ExecStart=__FINALPATH__/galene -turn __PUBLIC_IP4__:__TURN_PORT__ -udp-range 49152-65535 -groups /home/yunohost.app/__APP__/groups -recordings /home/yunohost.app/__APP__/recordings LimitNOFILE=65536 # Sandboxing options to harden security diff --git a/scripts/backup b/scripts/backup index 11f1bbb..e9c81e1 100755 --- a/scripts/backup +++ b/scripts/backup @@ -28,6 +28,7 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -40,6 +41,12 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$final_path" +#================================================= +# BACKUP THE DATA DIR +#================================================= + +ynh_backup --src_path="$datadir" --is_big + #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= diff --git a/scripts/install b/scripts/install index 2de7831..6f34f78 100755 --- a/scripts/install +++ b/scripts/install @@ -106,10 +106,10 @@ data="$final_path/data" # Create data folder mkdir -p "$data" -# Define app's groups directory -groups="$final_path/groups" -# Create groups folder -mkdir -p "$groups" +# # Define app's groups directory +# groups="$final_path/groups" +# # Create groups folder +# mkdir -p "$groups" #================================================= # NGINX CONFIGURATION @@ -119,6 +119,20 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2 # Create a dedicated NGINX config ynh_add_nginx_config +#================================================= +# CREATE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Creating a data directory..." --weight=1 + +datadir=/home/yunohost.app/$app +ynh_app_setting_set --app=$app --key=datadir --value=$datadir + +mkdir -p $datadir/{groups,recordings} + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" + #================================================= # SETUP SYSTEMD #================================================= @@ -151,7 +165,7 @@ yunohost service add $app --description="Videoconferencing server" --log="/var/l ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service -ynh_systemd_action --service_name=$app --action=start --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action=start --log_path="systemd" #================================================= # SETUP SSOWAT diff --git a/scripts/remove b/scripts/remove index 27f03fd..5f7e3d1 100755 --- a/scripts/remove +++ b/scripts/remove @@ -20,6 +20,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) turn_port=$(ynh_app_setting_get --app=$app --key=turn_port) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # STANDARD REMOVE @@ -50,6 +51,17 @@ ynh_script_progression --message="Removing app main directory..." --weight=2 # Remove the app directory securely ynh_secure_remove --file="$final_path" +#================================================= +# REMOVE DATA DIR +#================================================= + +# # Remove the app data directory with the command `yunohost app remove --purge` +# if [ "${YNH_APP_PURGE:-0}" -eq 1 ] +# then +# ynh_script_progression --message="Removing $app data directory..." --weight=2 +# ynh_secure_remove --file="$datadir" +# fi + #================================================= # REMOVE NGINX CONFIGURATION #================================================= diff --git a/scripts/restore b/scripts/restore index 9ae79c2..f920439 100755 --- a/scripts/restore +++ b/scripts/restore @@ -68,6 +68,19 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" +#================================================= +# RESTORE THE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Restoring the data directory..." --weight=1 + +ynh_restore_file --origin_path="$datadir" --not_mandatory + +mkdir -p $datadir/{groups,recordings} + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" + #================================================= # RESTORE SYSTEMD #================================================= @@ -88,7 +101,7 @@ yunohost service add $app --description="Videoconferencing server" --log="/var/l #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=3 -ynh_systemd_action --service_name=$app --action=start --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action=start --log_path="systemd" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index e6161fd..611e232 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -31,6 +31,20 @@ architecture=$(ynh_detect_arch) 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)..." --weight=1 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -50,18 +64,12 @@ if ynh_legacy_permissions_exists; then fi #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # STANDARD UPGRADE STEPS @@ -90,7 +98,7 @@ then # # Remove the app directory securely # ynh_secure_remove --file="$final_path" - ynh_setup_source --dest_dir="$final_path" --source_id="$architecture" --keep="$final_path/groups $final_path/data/passwd" + ynh_setup_source --dest_dir="$final_path" --source_id="$architecture" --keep="$final_path/data/passwd" # # Create data and groups folder # mkdir -p "$final_path/data" "$final_path/groups" @@ -115,14 +123,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # SETUP SYSTEMD #================================================= @@ -145,7 +145,7 @@ yunohost service add $app --description="Videoconferencing server" --log="/var/l #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action=start --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action=start --log_path="systemd" #================================================= # RELOAD NGINX