From cd60686646843e0044a40916b9e93735bae95780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Wed, 18 Sep 2024 20:34:28 +0200 Subject: [PATCH] cleaning --- scripts/backup | 17 +---------------- scripts/change_url | 2 -- scripts/install | 20 +++++++++----------- scripts/remove | 35 ++++------------------------------- scripts/restore | 9 ++++----- scripts/upgrade | 12 +++++++----- 6 files changed, 25 insertions(+), 70 deletions(-) diff --git a/scripts/backup b/scripts/backup index fd85c98..7899510 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,6 +1,5 @@ #!/bin/bash -# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -13,30 +12,16 @@ ynh_print_info "Declaring files to be backed up..." ynh_backup "$install_dir" #================================================= -# BACKUP THE NGINX CONFIGURATION +# SYSTEM CONFIGURATION #================================================= ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE -#================================================= - ynh_backup "/etc/logrotate.d/$app" -#================================================= -# BACKUP SYSTEMD -#================================================= - ynh_backup "/etc/systemd/system/$app.service" ynh_backup "/etc/systemd/system/$app-celery.service" -#================================================= -# BACKUP VARIOUS FILES -#================================================= - ynh_backup "/etc/uwsgi/apps-available/$app.ini" #================================================= diff --git a/scripts/change_url b/scripts/change_url index 041c63f..edda15b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -18,8 +18,6 @@ ynh_script_progression "Updating NGINX web server configuration..." ynh_config_change_url_nginx -#================================================= -# SPECIFIC MODIFICATIONS #================================================= # MODIFY SETTINGS #================================================= diff --git a/scripts/install b/scripts/install index cdd1f08..3c5014b 100755 --- a/scripts/install +++ b/scripts/install @@ -37,19 +37,17 @@ ynh_script_progression "Setting up source files..." mkdir -p "$install_dir/avatar-cache" mkdir -p "$install_dir/data" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" + #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression "Configuring NGINX web server..." -# Create a dedicated NGINX config ynh_config_add_nginx -#================================================= -# SPECIFIC SETUP #================================================= # INSTALL XXHASH #================================================= @@ -84,7 +82,7 @@ fi ynh_script_progression "Install weblate using PIP..." virtualenv --python=python3 "${install_dir}/venv" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app: "$install_dir" +chown -R $app: "$install_dir" #run source in a 'sub shell' ( set +o nounset @@ -124,10 +122,10 @@ touch "$install_dir/local_settings.py" ln -sf "$install_dir/local_settings.py" "$install_dir/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py" # Set permissions to app files -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app: "$install_dir" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:www-data" "$install_dir" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app: "$install_dir" +chown "$app:www-data" "$install_dir" chown -R "$app:www-data" "$install_dir/data" #================================================= diff --git a/scripts/remove b/scripts/remove index b4e2e43..fed424e 100755 --- a/scripts/remove +++ b/scripts/remove @@ -4,49 +4,24 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# STANDARD REMOVE -#================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST +# REMOVE SYSTEM CONFIGURATIONS #================================================= +ynh_script_progression "Removing system configurations related to $app..." -# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_hide_warnings yunohost service status $app >/dev/null -then - ynh_script_progression "Removing $app service integration..." +if ynh_hide_warnings yunohost service status $app >/dev/null; then yunohost service remove $app fi -# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_hide_warnings yunohost service status "$app-celery" >/dev/null -then - ynh_script_progression "Removing $app-celery service integration..." +if ynh_hide_warnings yunohost service status "$app-celery" >/dev/null; then yunohost service remove "$app-celery" fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression "Stopping and removing the systemd service..." - -# Remove the dedicated systemd config ynh_config_remove_systemd ynh_config_remove_systemd"$app-celery" -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression "Removing logrotate configuration..." - -# Remove the app-specific logrotate config ynh_config_remove_logrotate -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression "Removing NGINX web server configuration..." - -# Remove the dedicated NGINX config ynh_config_remove_nginx #================================================= @@ -62,8 +37,6 @@ pushd $tempdir popd ynh_safe_rm "$tempdir" -#================================================= -# SPECIFIC REMOVE #================================================= # REMOVE VARIOUS FILES #================================================= diff --git a/scripts/restore b/scripts/restore index 541db01..2817485 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,6 +1,5 @@ #!/bin/bash -# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -14,10 +13,10 @@ ynh_restore "$install_dir" touch "$install_dir/local_settings.py" ln -sf "$install_dir/local_settings.py" "$install_dir/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app: "$install_dir" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:www-data "$install_dir" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app: "$install_dir" +chown $app:www-data "$install_dir" chown -R $app:www-data "$install_dir/data" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b5659ce..18afb8a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -104,7 +104,7 @@ upgrade() { ynh_safe_rm "${install_dir}/venv" virtualenv --python=python3 "${install_dir}/venv" - #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app: "$install_dir" + chown -R $app: "$install_dir" #run source in a 'sub shell' ( set +o nounset @@ -128,6 +128,7 @@ upgrade() { # MODIFY A CONFIG FILE #================================================= ynh_script_progression "Create weblate configuration file..." + # save old settings file settings="$install_dir/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" path="${path%/}" @@ -199,12 +200,13 @@ upgrade $(ynh_app_upstream_version) "../conf/settings.py" # Set right permissions for curl installation mkdir -p "$install_dir/avatar-cache" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app: "$install_dir" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:www-data" "$install_dir" +chown -R $app: "$install_dir" +chown "$app:www-data" "$install_dir" chown -R "$app:www-data" "$install_dir/data" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" + #================================================= # SETUP LOGROTATE #=================================================