1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/navidrome_ynh.git synced 2024-09-03 19:46:30 +02:00

Manage rights

This commit is contained in:
yalh76 2021-05-18 03:30:40 +02:00
parent 2858154267
commit b9eed9c855
4 changed files with 67 additions and 71 deletions

View file

@ -31,9 +31,9 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up Navidrome before changing its URL..." --weight=1
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
@ -41,7 +41,7 @@ ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# restore it if the upgrade fails
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
@ -70,7 +70,7 @@ fi
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# MODIFY URL IN NGINX CONF
@ -111,6 +111,9 @@ path_url="$new_path"
ynh_add_config --template="../conf/navidrome.toml" --destination="$config_path/navidrome.toml"
chmod 600 "$config_path/navidrome.toml"
chown -R $app:$app "$config_path"
#=================================================
# GENERIC FINALISATION
#=================================================
@ -119,7 +122,7 @@ ynh_add_config --template="../conf/navidrome.toml" --destination="$config_path/n
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Version:"
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Version:"
#=================================================
# RELOAD NGINX

View file

@ -81,10 +81,13 @@ ynh_system_user_create --username=$app --home_dir=$final_path
ynh_script_progression --message="Setting up source files..." --weight=4
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir=$final_path --source_id="$architecture"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
@ -111,27 +114,19 @@ mkdir -p "$config_path"
# Main config File
ynh_add_config --template="../conf/navidrome.toml" --destination="$config_path/navidrome.toml"
chmod 600 "$config_path/navidrome.toml"
chown -R $app:$app "$config_path"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
ynh_replace_string --match_string="__CONFIG_PATH__" --replace_string="$config_path" --target_file="../conf/systemd.service"
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..." --weight=1
# Set permissions to app files
chown -R $app:$app "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$config_path"
chmod 600 "/var/lib/$app/navidrome.toml"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
@ -145,16 +140,18 @@ yunohost service add $app --description "Web-based music collection server and s
ynh_script_progression --message="Starting a systemd service..." --weight=2
# Start a systemd service
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Version:"
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Version:"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary or protect it
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi
@ -169,4 +166,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of Navidrome completed" --last
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -64,23 +64,9 @@ ynh_script_progression --message="Restoring Navidrome main directory..." --weigh
ynh_restore_file --origin_path="$final_path"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring Navidrome config directory..." --weight=2
ynh_restore_file --origin_path="/var/lib/$app"
#=================================================
# RESTORE USER RIGHTS
#=================================================
ynh_script_progression --message="Restoring user rights..."
# Restore permissions on app files
chown -R $app:$app "$final_path"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "/var/lib/$app"
chmod 600 "/var/lib/$app/navidrome.toml"
chown -R $app:$app "$final_path"
#=================================================
# SPECIFIC RESTORATION
@ -92,6 +78,16 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=7
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..." --weight=2
ynh_restore_file --origin_path="/var/lib/$app"
chmod 600 "/var/lib/$app/navidrome.toml"
chown -R $app:$app "/var/lib/$app"
#=================================================
# RESTORE SYSTEMD
#=================================================
@ -105,14 +101,14 @@ systemctl enable $app.service --quiet
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description "Web-based music collection server and streamer"
yunohost service add $app --description="Web-based music collection server and streamer"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Version:"
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Version:"
#=================================================
# GENERIC FINALIZATION

View file

@ -29,27 +29,15 @@ ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up Navidrome before upgrading..." --weight=4
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=4
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
@ -62,7 +50,19 @@ ynh_abort_if_errors
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action=stop --log_path=systemd
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# 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
@ -87,12 +87,16 @@ then
ynh_setup_source --dest_dir=$final_path --source_id="$architecture"
fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
# Create a dedicated nginx config
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
@ -103,32 +107,28 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=8
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# SETUP SYSTEMD
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=2
ynh_script_progression --message="Updating a configuration file..."
config_path="/var/lib/$app"
# Uncomment when there is new options added upstream
#ynh_add_config --template="../conf/navidrome.toml" --destination="$config_path/navidrome.toml"
chmod 600 "$config_path/navidrome.toml"
chown -R $app:$app "$config_path"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
# Create a dedicated systemd config
ynh_replace_string --match_string="__CONFIG_PATH__" --replace_string="$config_path" --target_file="../conf/systemd.service"
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..."
# Set permissions on app files
chown -R $app:$app "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$config_path"
chmod 600 "/var/lib/$app/navidrome.toml"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
@ -141,7 +141,7 @@ yunohost service add $app --description "Web-based music collection server and s
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Version:"
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Version:"
#=================================================
# RELOAD NGINX
@ -154,4 +154,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of Navidrome completed" --last
ynh_script_progression --message="Upgrade of $app completed" --last