From 727bbc00cb3f02b733f5a0ef25a6854df808d894 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sat, 31 Aug 2024 01:00:27 +0200 Subject: [PATCH 1/2] [autopatch] Automatic patch attempt for helpers 2.1 --- conf/lemmy-ui.service | 2 +- manifest.toml | 3 +- scripts/_common.sh | 26 +++----- scripts/backup | 31 ++++------ scripts/change_url | 40 +++++------- scripts/install | 98 ++++++++++++++---------------- scripts/remove | 36 +++++------ scripts/restore | 71 ++++++++++------------ scripts/upgrade | 137 ++++++++++++++++++------------------------ 9 files changed, 186 insertions(+), 258 deletions(-) diff --git a/conf/lemmy-ui.service b/conf/lemmy-ui.service index 5034c2d..3107412 100644 --- a/conf/lemmy-ui.service +++ b/conf/lemmy-ui.service @@ -11,7 +11,7 @@ Environment="LEMMY_EXTERNAL_HOST=__DOMAIN__" Environment="LEMMY_HTTPS=true" Environment="LEMMY_UI_HOST=0.0.0.0:__PORT_UI__" WorkingDirectory=__INSTALL_DIR__/lemmy-ui/ -ExecStart=__YNH_NODE__ dist/js/server.js +ExecStart=__NODEJS_DIR__/node dist/js/server.js StandardOutput=append:/var/log/__APP__/__APP__-ui.log StandardError=inherit Restart=always diff --git a/manifest.toml b/manifest.toml index 53b9ff6..f19f4b0 100644 --- a/manifest.toml +++ b/manifest.toml @@ -17,7 +17,8 @@ admindoc = "https://join-lemmy.org/docs/en/" code = "https://github.com/LemmyNet/lemmy" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = ["amd64"] multi_instance = false diff --git a/scripts/_common.sh b/scripts/_common.sh index 785d52f..f801aaa 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,28 +1,20 @@ #!/bin/bash #================================================= -# COMMON VARIABLES +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= PICTRS_VERSION=0.4.1-rc.0 -NODEJS_VERSION=20 +nodejs_version=20 main_domain=$(cat /etc/yunohost/current_host) -#================================================= -# PERSONAL HELPERS -#================================================= - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - # Downloads an AppImage from an url, unpacks and extracts it in a destination directory, and creates a symlink to its executable download_and_install_appimage() { # Declare an array to define the options of this helper. - local legacy_args=nud + #REMOVEME? local legacy_args=nud local -A args_array=([n]=name= [u]=url= [d]=directory= [s]=symlink=) local url local directory @@ -31,13 +23,13 @@ download_and_install_appimage() { ynh_handle_getopts_args "$@" # Cleanup - ynh_secure_remove --file="$install_dir/pict-rs/$name" - ynh_secure_remove --file="$install_dir/pict-rs/$name.appimage" - ynh_secure_remove --file="$install_dir/pict-rs/$name.appimageextract" + ynh_safe_rm "$install_dir/pict-rs/$name" + ynh_safe_rm "$install_dir/pict-rs/$name.appimage" + ynh_safe_rm "$install_dir/pict-rs/$name.appimageextract" # Download and make executable curl -f "$url" -o "$directory/$name.appimage" -s - [ ! -f "$directory/$name.appimage" ] && ynh_print_err --message="AppImage could not be downloaded" + [ ! -f "$directory/$name.appimage" ] && ynh_print_warn "AppImage could not be downloaded" chmod +x "$directory/$name.appimage" # Extract and create link @@ -47,7 +39,3 @@ download_and_install_appimage() { ln -s "$directory/$name.appimageextract/AppRun" "$directory/$name" popd } - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= diff --git a/scripts/backup b/scripts/backup index feb96a4..8840e15 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,37 +1,28 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - # 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 -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -ynh_print_info --message="Declaring files to be backed up..." +ynh_print_info "Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$install_dir" +ynh_backup "$install_dir" #================================================= # BACKUP THE DATA DIR #================================================= -ynh_backup --src_path="$data_dir" --is_big +ynh_backup "$data_dir" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # SPECIFIC BACKUP @@ -39,25 +30,25 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" # BACKUP LOGROTATE #================================================= -ynh_backup --src_path="/etc/logrotate.d/$app" +ynh_backup "/etc/logrotate.d/$app" #================================================= # BACKUP SYSTEMD #================================================= -ynh_backup --src_path="/etc/systemd/system/$app.service" -ynh_backup --src_path="/etc/systemd/system/$app-ui.service" -ynh_backup --src_path="/etc/systemd/system/$app-pict-rs.service" +ynh_backup "/etc/systemd/system/$app.service" +ynh_backup "/etc/systemd/system/$app-ui.service" +ynh_backup "/etc/systemd/system/$app-pict-rs.service" #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= -ynh_print_info --message="Backing up the PostgreSQL database..." +ynh_print_info "Backing up the PostgreSQL database..." -ynh_psql_dump_db --database="$db_name" > db.sql +ynh_psql_dump_db > db.sql #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index 44543c4..eac4140 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,56 +1,46 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD MODIFICATIONS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped" "/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-ui --action="stop" --line_match="Stopped" --log_path="/var/log/$app/$app-ui.log" -ynh_systemd_action --service_name=$app-pict-rs --action="stop" --line_match="Stopped" --log_path="/var/log/$app/$app-pict-rs.log" +ynh_systemctl --service=$app --action="stop" --wait_until="Stopped" "/var/log/$app/$app.log" +ynh_systemctl --service=$app-ui --action="stop" --wait_until="Stopped" --log_path="/var/log/$app/$app-ui.log" +ynh_systemctl --service=$app-pict-rs --action="stop" --wait_until="Stopped" --log_path="/var/log/$app/$app-pict-rs.log" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression "Adding $app's configuration..." mkdir -p "$install_dir/config/" -ynh_add_config --template="../conf/lemmy.hjson" --destination="$install_dir/config/config.hjson" +ynh_config_add --template="lemmy.hjson" --destination="$install_dir/config/config.hjson" -chmod 400 "$install_dir/config/config.hjson" -chown $app:$app "$install_dir/config/config.hjson" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/config/config.hjson" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/config/config.hjson" -#================================================= -# GENERIC FINALISATION #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="Starting http server at" -ynh_systemd_action --service_name=$app-ui --action="start" --log_path="/var/log/$app/$app-ui.log" --line_match="http://0.0.0.0" -ynh_systemd_action --service_name=$app-pict-rs --action="start" --log_path="/var/log/$app/$app-pict-rs.log" --line_match="starting in Actix runtime" +ynh_systemctl --service=$app --action="start" --wait_until="Starting http server at" +ynh_systemctl --service=$app-ui --action="start" --log_path="/var/log/$app/$app-ui.log" --wait_until="http://0.0.0.0" +ynh_systemctl --service=$app-pict-rs --action="start" --log_path="/var/log/$app/$app-pict-rs.log" --wait_until="starting in Actix runtime" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 8f05ce0..17c0cd1 100755 --- a/scripts/install +++ b/scripts/install @@ -1,34 +1,28 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=1 +ynh_script_progression "Installing dependencies..." + +ynh_nodejs_install -ynh_install_nodejs --nodejs_version=$NODEJS_VERSION -ynh_use_nodejs ln -fs /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1 #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1 +ynh_script_progression "Creating a PostgreSQL database..." -ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pgcrypto;" --database="$db_name" +ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS pgcrypto;" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=1 +ynh_script_progression "Setting up source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir/build-lemmy/" @@ -36,30 +30,29 @@ ynh_setup_source --dest_dir="$install_dir/build-lemmy-ui/" ynh_setup_source --dest_dir="$install_dir/lemmy-ui/lemmy-translations/" --source_id="lemmy-translations" ynh_setup_source --dest_dir="$install_dir/build-pict-rs/" -chmod -R o-rwx "$install_dir" -chown -R $app:$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 | 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:$app "$install_dir" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=1 +ynh_script_progression "Configuring NGINX web server..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx #================================================= # INSTALL SHARP #================================================= pushd $install_dir/lemmy-ui - ynh_use_nodejs - ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn add sharp + + ynh_hide_warnings ynh_exec_as_app node_load_PATH yarn add sharp popd #================================================= # MAKE INSTALL #================================================= -ynh_script_progression --message="Making install..." --weight=1 +ynh_script_progression "Making install..." # Install lemmy-ui pushd $install_dir/build-lemmy-ui @@ -67,7 +60,7 @@ pushd $install_dir/build-lemmy-ui popd mkdir -p "$install_dir/lemmy-ui/" rsync -a "$install_dir/build-lemmy-ui/output/app/" "$install_dir/lemmy-ui/" -ynh_secure_remove --file="$install_dir/build-lemmy-ui" +ynh_safe_rm "$install_dir/build-lemmy-ui" # Install lemmy pushd $install_dir/build-lemmy @@ -75,7 +68,7 @@ pushd $install_dir/build-lemmy popd mkdir -p "$install_dir/lemmy/" mv -f "$install_dir/build-lemmy/output/app/lemmy" "$install_dir/lemmy/lemmy" -ynh_secure_remove --file="$install_dir/build-lemmy" +ynh_safe_rm "$install_dir/build-lemmy" # Install pict-rs pushd $install_dir/build-pict-rs @@ -83,71 +76,68 @@ pushd $install_dir/build-pict-rs popd mkdir -p "$install_dir/pict-rs/" mv -f "$install_dir/build-pict-rs/output/usr/local/bin/pict-rs" "$install_dir/pict-rs/pict-rs" -ynh_secure_remove --file="$install_dir/build-pict-rs" - -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R $app:$app "$install_dir" +ynh_safe_rm "$install_dir/build-pict-rs" +#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:$app "$install_dir" # (Dirty) Install ImageMagick # Requires 'libfuse2' and 'libimage-exiftool-perl' apt dependencies -ynh_script_progression --message="Downloading and installing ImageMagick..." --weight=1 +ynh_script_progression "Downloading and installing ImageMagick..." download_and_install_appimage --name="magick" --url="https://imagemagick.org/archive/binaries/magick" --directory="$install_dir/pict-rs" --symlink="$install_dir/pict-rs/magick" #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression "Adding $app's configuration..." # Lemmy configuration mkdir -p "$install_dir/config/" -ynh_add_config --template="lemmy.hjson" --destination="$install_dir/config/config.hjson" -chmod 400 "$install_dir/config/config.hjson" -chown $app:$app "$install_dir/config/config.hjson" +ynh_config_add --template="lemmy.hjson" --destination="$install_dir/config/config.hjson" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/config/config.hjson" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/config/config.hjson" # Pict-RS configuration -ynh_add_config --template="pict-rs.toml" --destination="$install_dir/pict-rs/pict-rs.toml" +ynh_config_add --template="pict-rs.toml" --destination="$install_dir/pict-rs/pict-rs.toml" chmod 400 "$install_dir/pict-rs/pict-rs.toml" chown $app:$app "$install_dir/pict-rs/pict-rs.toml" # ImageMagick configuration mkdir -p "$install_dir/.config/ImageMagick" -ynh_add_config --template="policy.xml" --destination="$install_dir/.config/ImageMagick/policy.xml" -chmod 400 "$install_dir/.config/ImageMagick/policy.xml" +ynh_config_add --template="policy.xml" --destination="$install_dir/.config/ImageMagick/policy.xml" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/.config/ImageMagick/policy.xml" chown -R $app:$app "$install_dir/.config" #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=1 +ynh_script_progression "Configuring $app's systemd service..." # Prep local path for Pict-RS pictrs_path="$install_dir/pict-rs:$PATH" # Create a dedicated systemd config -ynh_add_systemd_config --service="$app" --template="lemmy.service" -ynh_add_systemd_config --service="$app-ui" --template="lemmy-ui.service" -ynh_add_systemd_config --service="$app-pict-rs" --template="pict-rs.service" +ynh_config_add_systemd --template="lemmy.service" +ynh_config_add_systemd --service="$app-ui" --template="lemmy-ui.service" +ynh_config_add_systemd --service="$app-pict-rs" --template="pict-rs.service" -#================================================= -# GENERIC FINALIZATION #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 +ynh_script_progression "Configuring log rotation..." mkdir -p "/var/log/$app" -chmod 750 "/var/log/$app" -chmod -R o-rwx "/var/log/$app" -chown -R $app:$app "/var/log/$app" +#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "/var/log/$app" +#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "/var/log/$app" +#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "/var/log/$app" # Use logrotate to manage application logfile(s) -ynh_use_logrotate +ynh_config_add_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression "Integrating service in YunoHost..." yunohost service add $app --description="Link aggregator/Reddit clone" --log="/var/log/$app/$app.log" yunohost service add $app-ui --description="Link aggregator/Reddit clone" --log="/var/log/$app/$app-ui.log" @@ -159,19 +149,19 @@ yunohost service add $app-pict-rs --description="Simple image hosting service fo # TMP rebuild sharp pushd $install_dir/lemmy-ui - ynh_use_nodejs - ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH npm rebuild sharp + + ynh_hide_warnings ynh_exec_as_app node_load_PATH npm rebuild sharp popd -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="Starting http server at" -ynh_systemd_action --service_name=$app-ui --action="start" --log_path="/var/log/$app/$app-ui.log" --line_match="http://0.0.0.0" -ynh_systemd_action --service_name=$app-pict-rs --action="start" --log_path="/var/log/$app/$app-pict-rs.log" --line_match="starting in Actix runtime" +ynh_systemctl --service=$app --action="start" --wait_until="Starting http server at" +ynh_systemctl --service=$app-ui --action="start" --log_path="/var/log/$app/$app-ui.log" --wait_until="http://0.0.0.0" +ynh_systemctl --service=$app-pict-rs --action="start" --log_path="/var/log/$app/$app-pict-rs.log" --wait_until="starting in Actix runtime" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index c20b60a..d2a3877 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers @@ -14,39 +8,39 @@ source /usr/share/yunohost/helpers #================================================= # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -ynh_script_progression --message="Removing system configurations related to $app..." --weight=10 +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_exec_warn_less yunohost service status $app >/dev/null +if ynh_hide_warnings yunohost service status $app >/dev/null then - ynh_script_progression --message="Removing $app service integration..." --weight=1 + ynh_script_progression "Removing $app service integration..." yunohost service remove $app fi -if ynh_exec_warn_less yunohost service status $app-ui >/dev/null +if ynh_hide_warnings yunohost service status $app-ui >/dev/null then - ynh_script_progression --message="Removing $app-ui service integration..." --weight=1 + ynh_script_progression "Removing $app-ui service integration..." yunohost service remove $app-ui fi -if ynh_exec_warn_less yunohost service status $app-pict-rs >/dev/null +if ynh_hide_warnings yunohost service status $app-pict-rs >/dev/null then - ynh_script_progression --message="Removing $app-pict-rs service integration..." --weight=1 + ynh_script_progression "Removing $app-pict-rs service integration..." yunohost service remove $app-pict-rs fi # Remove the dedicated systemd config -ynh_remove_systemd_config -ynh_remove_systemd_config --service=$app-ui -ynh_remove_systemd_config --service=$app-pict-rs +ynh_config_remove_systemd +ynh_config_remove_systemd$app-ui +ynh_config_remove_systemd$app-pict-rs # Remove the app-specific logrotate config -ynh_remove_logrotate +ynh_config_remove_logrotate # Remove the dedicated NGINX config -ynh_remove_nginx_config +ynh_config_remove_nginx # Remove metapackage and its dependencies -ynh_remove_nodejs -#ynh_secure_remove --file="/lib/libc.musl-x86_64.so.1" +ynh_nodejs_remove +#ynh_safe_rm "/lib/libc.musl-x86_64.so.1" # Remove the log files @@ -54,4 +48,4 @@ ynh_remove_nodejs # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 34e3851..359e1a7 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - # 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,19 +7,18 @@ source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 +ynh_script_progression "Restoring the app main directory..." -ynh_restore_file --origin_path="$install_dir" - -chmod -R o-rwx "$install_dir" -chown -R $app:$app "$install_dir" +ynh_restore "$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:$app "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= -ynh_script_progression --message="Restoring the data directory..." --weight=1 +ynh_script_progression "Restoring the data directory..." -ynh_restore_file --origin_path="$data_dir" --not_mandatory +ynh_restore "$data_dir" chown -R $app:$app "$data_dir" @@ -34,56 +27,56 @@ chown -R $app:$app "$data_dir" #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=1 +ynh_script_progression "Reinstalling dependencies..." # Define and install dependencies -ynh_install_nodejs --nodejs_version=$NODEJS_VERSION -ynh_use_nodejs +ynh_nodejs_install + ln -fs /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1 #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 +ynh_script_progression "Restoring the NGINX web server configuration..." -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 +ynh_script_progression "Restoring the PostgreSQL database..." -ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" -ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pgcrypto;" --database="$db_name" +ynh_psql_db_shell " < "./db.sql"" +ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS pgcrypto;" #================================================= # RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 +ynh_script_progression "Restoring $app's systemd service..." -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +ynh_restore "/etc/systemd/system/$app.service" systemctl enable $app.service --quiet -ynh_restore_file --origin_path="/etc/systemd/system/$app-ui.service" +ynh_restore "/etc/systemd/system/$app-ui.service" systemctl enable $app-ui.service --quiet -ynh_restore_file --origin_path="/etc/systemd/system/$app-pict-rs.service" +ynh_restore "/etc/systemd/system/$app-pict-rs.service" systemctl enable $app-pict-rs.service --quiet #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 +ynh_script_progression "Restoring the logrotate configuration..." mkdir -p "/var/log/$app" -chmod 750 "/var/log/$app" -chmod -R o-rwx "/var/log/$app" -chown -R $app:$app "/var/log/$app" +#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "/var/log/$app" +#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "/var/log/$app" +#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "/var/log/$app" -ynh_restore_file --origin_path="/etc/logrotate.d/$app" +ynh_restore "/etc/logrotate.d/$app" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression "Integrating service in YunoHost..." yunohost service add $app --description="Link aggregator/Reddit clone" --log="/var/log/$app/$app.log" yunohost service add $app-ui --description="Link aggregator/Reddit clone" --log="/var/log/$app/$app-ui.log" @@ -92,23 +85,21 @@ yunohost service add $app-pict-rs --description="Simple image hosting service fo #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="Starting http server at" -ynh_systemd_action --service_name=$app-ui --action="start" --log_path="/var/log/$app/$app-ui.log" --line_match="http://0.0.0.0" -ynh_systemd_action --service_name=$app-pict-rs --action="start" --log_path="/var/log/$app/$app-pict-rs.log" --line_match="starting in Actix runtime" +ynh_systemctl --service=$app --action="start" --wait_until="Starting http server at" +ynh_systemctl --service=$app-ui --action="start" --log_path="/var/log/$app/$app-ui.log" --wait_until="http://0.0.0.0" +ynh_systemctl --service=$app-pict-rs --action="start" --log_path="/var/log/$app/$app-pict-rs.log" --wait_until="starting in Actix runtime" -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_script_progression "Reloading NGINX web server..." -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 5db22fe..04288d4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,53 +1,41 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# CHECK VERSION -#================================================= - -upgrade_type=$(ynh_check_app_version_changed) - -#================================================= -# STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-ui --action="stop" --line_match="Stopped" --log_path="/var/log/$app/$app-ui.log" -ynh_systemd_action --service_name=$app-pict-rs --action="stop" --line_match="Stopped" --log_path="/var/log/$app/$app-pict-rs.log" +ynh_systemctl --service=$app --action="stop" --wait_until="Stopped" + +ynh_systemctl --service=$app-ui --action="stop" --wait_until="Stopped" --log_path="/var/log/$app/$app-ui.log" +ynh_systemctl --service=$app-pict-rs --action="stop" --wait_until="Stopped" --log_path="/var/log/$app/$app-pict-rs.log" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +ynh_script_progression "Ensuring downward compatibility..." # Removing previously installed iframely -if ynh_exec_warn_less yunohost service status $app-iframely >/dev/null +if ynh_hide_warnings yunohost service status $app-iframely >/dev/null then - ynh_script_progression --message="Removing $app-iframely service integration..." + ynh_script_progression "Removing $app-iframely service integration..." yunohost service remove $app-iframely - ynh_app_setting_delete --app=$app --key=random - ynh_app_setting_delete --app=$app --key=port_iframely - ynh_remove_systemd_config --service=$app-iframely + ynh_app_setting_delete --key=random + ynh_app_setting_delete --key=port_iframely + ynh_config_remove_systemd$app-iframely fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -if [ "$upgrade_type" == "UPGRADE_APP" ] +# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed +if ynh_app_upstream_version_changed then - ynh_script_progression --message="Upgrading source files..." --weight=1 + ynh_script_progression "Upgrading source files..." # Download, check integrity, uncompress the source of lemmy from app.src to his build directory ynh_setup_source --dest_dir="$install_dir/build-lemmy/" @@ -56,43 +44,41 @@ then ynh_setup_source --dest_dir="$install_dir/build-pict-rs/" fi -chmod -R o-rwx "$install_dir" -chown -R $app:$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 | 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:$app "$install_dir" #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=1 +ynh_script_progression "Upgrading dependencies..." + +ynh_nodejs_install -ynh_install_nodejs --nodejs_version=$NODEJS_VERSION -ynh_use_nodejs ln -fs /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1 #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 +ynh_script_progression "Upgrading NGINX web server configuration..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx #================================================= # INSTALL SHARP #================================================= pushd $install_dir/lemmy-ui - ynh_use_nodejs - ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn add sharp + + ynh_hide_warnings ynh_exec_as_app node_load_PATH yarn add sharp popd -#================================================= -# SPECIFIC UPGRADE #================================================= # MAKE UPGRADE #================================================= -ynh_script_progression --message="Making upgrade..." --weight=1 +ynh_script_progression "Making upgrade..." -if [ "$upgrade_type" == "UPGRADE_APP" ] +# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed +if ynh_app_upstream_version_changed then # Install lemmy-ui pushd $install_dir/build-lemmy-ui @@ -100,7 +86,7 @@ then popd mkdir -p "$install_dir/lemmy-ui/" rsync -a "$install_dir/build-lemmy-ui/output/app/" "$install_dir/lemmy-ui/" - ynh_secure_remove --file="$install_dir/build-lemmy-ui" + ynh_safe_rm "$install_dir/build-lemmy-ui" # Install lemmy pushd $install_dir/build-lemmy @@ -108,7 +94,7 @@ then popd mkdir -p "$install_dir/lemmy/" mv -f "$install_dir/build-lemmy/output/app/lemmy" "$install_dir/lemmy/lemmy" - ynh_secure_remove --file="$install_dir/build-lemmy" + ynh_safe_rm "$install_dir/build-lemmy" # Install pict-rs pushd $install_dir/build-pict-rs @@ -116,83 +102,80 @@ then popd mkdir -p "$install_dir/pict-rs/" mv -f "$install_dir/build-pict-rs/output/usr/local/bin/pict-rs" "$install_dir/pict-rs/pict-rs" - ynh_secure_remove --file="$install_dir/build-pict-rs" + ynh_safe_rm "$install_dir/build-pict-rs" # (Dirty) Install ImageMagick # Requires 'libfuse2' and 'libimage-exiftool-perl' apt dependencies - ynh_script_progression --message="Downloading and installing ImageMagick..." --weight=1 + ynh_script_progression "Downloading and installing ImageMagick..." download_and_install_appimage --name="magick" --url="https://imagemagick.org/archive/binaries/magick" --directory="$install_dir/pict-rs" --symlink="$install_dir/pict-rs/magick" fi -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R $app:$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 | 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:$app "$install_dir" #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." --weight=1 +ynh_script_progression "Updating configuration..." # Lemmy configuration mkdir -p "$install_dir/lemmy/" chown $app:$app "$install_dir/lemmy" -ynh_add_config --template="lemmy.hjson" --destination="$install_dir/config/config.hjson" -chmod 400 "$install_dir/config/config.hjson" -chown $app:$app "$install_dir/config/config.hjson" +ynh_config_add --template="lemmy.hjson" --destination="$install_dir/config/config.hjson" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/config/config.hjson" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/config/config.hjson" # Pict-RS configuration mkdir -p "$install_dir/pict-rs" chown $app:$app "$install_dir/pict-rs" -ynh_add_config --template="pict-rs.toml" --destination="$install_dir/pict-rs/pict-rs.toml" +ynh_config_add --template="pict-rs.toml" --destination="$install_dir/pict-rs/pict-rs.toml" chmod 400 "$install_dir/pict-rs/pict-rs.toml" chown $app:$app "$install_dir/pict-rs/pict-rs.toml" # ImageMagick configuration mkdir -p "$install_dir/.config/ImageMagick" -chown $app:$app -R "$install_dir/.config" -ynh_add_config --template="policy.xml" --destination="$install_dir/.config/ImageMagick/policy.xml" -chmod 400 "$install_dir/.config/ImageMagick/policy.xml" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app -R "$install_dir/.config" +ynh_config_add --template="policy.xml" --destination="$install_dir/.config/ImageMagick/policy.xml" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/.config/ImageMagick/policy.xml" chown -R $app:$app "$install_dir/.config" #================================================= # CREATE EXTENSION IF NOT EXISTS pgcrypto #================================================= -ynh_script_progression --message="Creating pgcrypto extension if needed..." --weight=1 +ynh_script_progression "Creating pgcrypto extension if needed..." -ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pgcrypto;" --database="$db_name" +ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS pgcrypto;" #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 +ynh_script_progression "Upgrading systemd configuration..." # Prep local path for Pict-RS pictrs_path="$install_dir/pict-rs:$PATH" # Create a dedicated systemd config -ynh_add_systemd_config --service="$app" --template="lemmy.service" -ynh_add_systemd_config --service="$app-ui" --template="lemmy-ui.service" -ynh_add_systemd_config --service="$app-pict-rs" --template="pict-rs.service" +ynh_config_add_systemd --template="lemmy.service" +ynh_config_add_systemd --service="$app-ui" --template="lemmy-ui.service" +ynh_config_add_systemd --service="$app-pict-rs" --template="pict-rs.service" -#================================================= -# GENERIC FINALIZATION #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 +ynh_script_progression "Upgrading logrotate configuration..." mkdir -p "/var/log/$app" -chmod 750 "/var/log/$app" -chmod -R o-rwx "/var/log/$app" -chown -R $app:$app "/var/log/$app" +#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "/var/log/$app" +#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "/var/log/$app" +#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "/var/log/$app" # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append +ynh_config_add_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression "Integrating service in YunoHost..." yunohost service add $app --description="Link aggregator/Reddit clone" --log="/var/log/$app/$app.log" yunohost service add $app-ui --description="Link aggregator/Reddit clone" --log="/var/log/$app/$app-ui.log" @@ -204,18 +187,18 @@ yunohost service add $app-pict-rs --description="Simple image hosting service fo # TMP rebuild sharp pushd $install_dir/lemmy-ui - ynh_use_nodejs - ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH npm rebuild sharp + + ynh_hide_warnings ynh_exec_as_app node_load_PATH npm rebuild sharp popd -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="Starting http server at" -ynh_systemd_action --service_name=$app-ui --action="start" --log_path="/var/log/$app/$app-ui.log" --line_match="http://0.0.0.0" -ynh_systemd_action --service_name=$app-pict-rs --action="start" --log_path="/var/log/$app/$app-pict-rs.log" --line_match="starting in Actix runtime" +ynh_systemctl --service=$app --action="start" --wait_until="Starting http server at" +ynh_systemctl --service=$app-ui --action="start" --log_path="/var/log/$app/$app-ui.log" --wait_until="http://0.0.0.0" +ynh_systemctl --service=$app-pict-rs --action="start" --log_path="/var/log/$app/$app-pict-rs.log" --wait_until="starting in Actix runtime" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed" From de2f8bb5458ffe4522d34b9bdfdaa109d3f1a132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 31 Aug 2024 22:25:52 +0200 Subject: [PATCH 2/2] cleaning --- manifest.toml | 2 +- scripts/backup | 11 ----------- scripts/change_url | 3 --- scripts/install | 18 ++---------------- scripts/remove | 10 ---------- scripts/restore | 9 ++------- scripts/upgrade | 32 ++++++-------------------------- 7 files changed, 11 insertions(+), 74 deletions(-) diff --git a/manifest.toml b/manifest.toml index f19f4b0..e2c2e91 100644 --- a/manifest.toml +++ b/manifest.toml @@ -17,7 +17,7 @@ admindoc = "https://join-lemmy.org/docs/en/" code = "https://github.com/LemmyNet/lemmy" [integration] -yunohost = ">= 11.2.18" +yunohost = ">= 11.2.29" helpers_version = "2.1" architectures = ["amd64"] multi_instance = false diff --git a/scripts/backup b/scripts/backup index 8840e15..3fb3575 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 @@ -24,18 +23,8 @@ ynh_backup "$data_dir" 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-ui.service" ynh_backup "/etc/systemd/system/$app-pict-rs.service" diff --git a/scripts/change_url b/scripts/change_url index eac4140..0bbe7a3 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -27,9 +27,6 @@ ynh_script_progression "Adding $app's configuration..." mkdir -p "$install_dir/config/" ynh_config_add --template="lemmy.hjson" --destination="$install_dir/config/config.hjson" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/config/config.hjson" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/config/config.hjson" - #================================================= # START SYSTEMD SERVICE #================================================= diff --git a/scripts/install b/scripts/install index 17c0cd1..c6f9eb0 100755 --- a/scripts/install +++ b/scripts/install @@ -24,14 +24,11 @@ ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS pgcrypto;" #================================================= ynh_script_progression "Setting up source files..." -# Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir/build-lemmy/" ynh_setup_source --dest_dir="$install_dir/build-lemmy-ui/" ynh_setup_source --dest_dir="$install_dir/lemmy-ui/lemmy-translations/" --source_id="lemmy-translations" ynh_setup_source --dest_dir="$install_dir/build-pict-rs/" -#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:$app "$install_dir" #================================================= # NGINX CONFIGURATION #================================================= @@ -45,8 +42,7 @@ ynh_config_add_nginx #================================================= pushd $install_dir/lemmy-ui - - ynh_hide_warnings ynh_exec_as_app node_load_PATH yarn add sharp + ynh_hide_warnings ynh_exec_as_app yarn add sharp popd #================================================= @@ -78,9 +74,6 @@ mkdir -p "$install_dir/pict-rs/" mv -f "$install_dir/build-pict-rs/output/usr/local/bin/pict-rs" "$install_dir/pict-rs/pict-rs" ynh_safe_rm "$install_dir/build-pict-rs" -#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:$app "$install_dir" # (Dirty) Install ImageMagick # Requires 'libfuse2' and 'libimage-exiftool-perl' apt dependencies ynh_script_progression "Downloading and installing ImageMagick..." @@ -94,8 +87,6 @@ ynh_script_progression "Adding $app's configuration..." # Lemmy configuration mkdir -p "$install_dir/config/" ynh_config_add --template="lemmy.hjson" --destination="$install_dir/config/config.hjson" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/config/config.hjson" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/config/config.hjson" # Pict-RS configuration ynh_config_add --template="pict-rs.toml" --destination="$install_dir/pict-rs/pict-rs.toml" @@ -127,11 +118,7 @@ ynh_config_add_systemd --service="$app-pict-rs" --template="pict-rs.service" ynh_script_progression "Configuring log rotation..." mkdir -p "/var/log/$app" -#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "/var/log/$app" -#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "/var/log/$app" -#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "/var/log/$app" -# Use logrotate to manage application logfile(s) ynh_config_add_logrotate #================================================= @@ -149,8 +136,7 @@ yunohost service add $app-pict-rs --description="Simple image hosting service fo # TMP rebuild sharp pushd $install_dir/lemmy-ui - - ynh_hide_warnings ynh_exec_as_app node_load_PATH npm rebuild sharp + ynh_hide_warnings ynh_exec_as_app npm rebuild sharp popd ynh_script_progression "Starting $app's systemd service..." diff --git a/scripts/remove b/scripts/remove index d2a3877..318f04c 100755 --- a/scripts/remove +++ b/scripts/remove @@ -3,14 +3,11 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD REMOVE #================================================= # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= 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..." @@ -27,22 +24,15 @@ then yunohost service remove $app-pict-rs fi -# Remove the dedicated systemd config ynh_config_remove_systemd ynh_config_remove_systemd$app-ui ynh_config_remove_systemd$app-pict-rs -# Remove the app-specific logrotate config ynh_config_remove_logrotate -# Remove the dedicated NGINX config ynh_config_remove_nginx -# Remove metapackage and its dependencies ynh_nodejs_remove -#ynh_safe_rm "/lib/libc.musl-x86_64.so.1" - -# Remove the log files #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 359e1a7..48e310a 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 @@ -11,8 +10,6 @@ ynh_script_progression "Restoring the app main directory..." ynh_restore "$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:$app "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= @@ -29,7 +26,6 @@ chown -R $app:$app "$data_dir" #================================================= ynh_script_progression "Reinstalling dependencies..." -# Define and install dependencies ynh_nodejs_install ln -fs /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1 @@ -56,8 +52,10 @@ ynh_script_progression "Restoring $app's systemd service..." ynh_restore "/etc/systemd/system/$app.service" systemctl enable $app.service --quiet + ynh_restore "/etc/systemd/system/$app-ui.service" systemctl enable $app-ui.service --quiet + ynh_restore "/etc/systemd/system/$app-pict-rs.service" systemctl enable $app-pict-rs.service --quiet @@ -67,9 +65,6 @@ systemctl enable $app-pict-rs.service --quiet ynh_script_progression "Restoring the logrotate configuration..." mkdir -p "/var/log/$app" -#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "/var/log/$app" -#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "/var/log/$app" -#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "/var/log/$app" ynh_restore "/etc/logrotate.d/$app" diff --git a/scripts/upgrade b/scripts/upgrade index 04288d4..87919b4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,7 +9,6 @@ source /usr/share/yunohost/helpers ynh_script_progression "Stopping $app's systemd service..." ynh_systemctl --service=$app --action="stop" --wait_until="Stopped" - ynh_systemctl --service=$app-ui --action="stop" --wait_until="Stopped" --log_path="/var/log/$app/$app-ui.log" ynh_systemctl --service=$app-pict-rs --action="stop" --wait_until="Stopped" --log_path="/var/log/$app/$app-pict-rs.log" @@ -31,21 +30,13 @@ fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression "Upgrading source files..." -# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed -if ynh_app_upstream_version_changed -then - ynh_script_progression "Upgrading source files..." +ynh_setup_source --dest_dir="$install_dir/build-lemmy/" +ynh_setup_source --dest_dir="$install_dir/build-lemmy-ui/" +ynh_setup_source --dest_dir="$install_dir/lemmy-ui/lemmy-translations/" --source_id="lemmy-translations" +ynh_setup_source --dest_dir="$install_dir/build-pict-rs/" - # Download, check integrity, uncompress the source of lemmy from app.src to his build directory - ynh_setup_source --dest_dir="$install_dir/build-lemmy/" - ynh_setup_source --dest_dir="$install_dir/build-lemmy-ui/" - ynh_setup_source --dest_dir="$install_dir/lemmy-ui/lemmy-translations/" --source_id="lemmy-translations" - ynh_setup_source --dest_dir="$install_dir/build-pict-rs/" -fi - -#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:$app "$install_dir" #================================================= # UPGRADE DEPENDENCIES #================================================= @@ -60,7 +51,6 @@ ln -fs /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1 #================================================= ynh_script_progression "Upgrading NGINX web server configuration..." -# Create a dedicated NGINX config ynh_config_add_nginx #================================================= @@ -68,8 +58,7 @@ ynh_config_add_nginx #================================================= pushd $install_dir/lemmy-ui - - ynh_hide_warnings ynh_exec_as_app node_load_PATH yarn add sharp + ynh_hide_warnings ynh_exec_as_app yarn add sharp popd #================================================= @@ -110,9 +99,6 @@ then download_and_install_appimage --name="magick" --url="https://imagemagick.org/archive/binaries/magick" --directory="$install_dir/pict-rs" --symlink="$install_dir/pict-rs/magick" fi -#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:$app "$install_dir" #================================================= # UPDATE A CONFIG FILE #================================================= @@ -122,8 +108,6 @@ ynh_script_progression "Updating configuration..." mkdir -p "$install_dir/lemmy/" chown $app:$app "$install_dir/lemmy" ynh_config_add --template="lemmy.hjson" --destination="$install_dir/config/config.hjson" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/config/config.hjson" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/config/config.hjson" # Pict-RS configuration mkdir -p "$install_dir/pict-rs" @@ -165,11 +149,7 @@ ynh_config_add_systemd --service="$app-pict-rs" --template="pict-rs.service" ynh_script_progression "Upgrading logrotate configuration..." mkdir -p "/var/log/$app" -#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "/var/log/$app" -#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "/var/log/$app" -#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "/var/log/$app" -# Use logrotate to manage app-specific logfile(s) ynh_config_add_logrotate #=================================================