diff --git a/manifest.toml b/manifest.toml index e0f245a..b33b65d 100644 --- a/manifest.toml +++ b/manifest.toml @@ -21,6 +21,7 @@ code = "https://github.com/TeamPiped/Piped" [integration] yunohost = '>= 11.2' +helpers_version = "2.1" architectures = [ "amd64", "arm64" ] multi_instance = true ldap = false @@ -71,6 +72,7 @@ ram.runtime = "50M" [resources.system_user] [resources.install_dir] +group = "www-data:r-x" [resources.permissions] main.url = "/" diff --git a/scripts/_common.sh b/scripts/_common.sh index 3ee315f..cd2354e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,11 +1,7 @@ #!/bin/bash #================================================= -# COMMON VARIABLES +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= -NODEJS_VERSION=20 - -#================================================= -# PERSONAL HELPERS -#================================================= +nodejs_version=20 diff --git a/scripts/backup b/scripts/backup index cb47973..1d36484 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,61 +1,52 @@ #!/bin/bash #### App file generated with YoloGen, the YunoHost app generator, version . -#================================================= -# 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 NGINX CONFIGURATION #================================================= -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP LOGROTATE CONFIGURATION #================================================= -ynh_backup --src_path="/etc/logrotate.d/$app" +ynh_backup "/etc/logrotate.d/$app" #================================================= # BACKUP SYSTEMD CONFIGURATION #================================================= -ynh_backup --src_path="/etc/systemd/system/$app-api.service" -ynh_backup --src_path="/etc/systemd/system/$app-proxy.service" +ynh_backup "/etc/systemd/system/$app-api.service" +ynh_backup "/etc/systemd/system/$app-proxy.service" #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= -ynh_print_info --message="Backing up the PostgreSQL database..." +ynh_print_info "Backing up the PostgreSQL database..." ## linter complains about this line so let's make it happy ## uncomment once hell breaks loose -# ynh_systemd_action --service_name=$app-api --action="stop" --log_path="/var/log/$app/$app-api.log" --line_match="Shutdown completed" +# ynh_systemctl --service=$app-api --action="stop" --log_path="/var/log/$app/$app-api.log" --wait_until="Shutdown completed" -ynh_psql_dump_db --database="$db_name" > db.sql +ynh_psql_dump_db > db.sql -# ynh_systemd_action --service_name=$app-api --action="start" --log_path="/var/log/$app/$app-api.log" --line_match="HTTP Server is listening on" +# ynh_systemctl --service=$app-api --action="start" --log_path="/var/log/$app/$app-api.log" --wait_until="HTTP Server is listening on" #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." \ No newline at end of file +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." \ No newline at end of file diff --git a/scripts/change_url b/scripts/change_url index 9faa09e..cae78cd 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,48 +1,42 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name=$app-api --action="stop" --log_path="/var/log/$app/$app-api.log" +ynh_systemctl --service=$app-api --action="stop" --log_path="/var/log/$app/$app-api.log" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx #================================================= # SPECIFIC MODIFICATIONS #================================================= -ynh_script_progression --message="Updating $app configuration..." +ynh_script_progression "Updating $app configuration..." sed -i s/"$old_domain"/"$new_domain"/g $install_dir/dist/assets/* -ynh_add_config --template="config.properties" --destination="$install_dir/config.properties" -chown $app:$app "$install_dir/config.properties" -chmod 600 "$install_dir/config.properties" +ynh_config_add --template="config.properties" --destination="$install_dir/config.properties" +#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.properties" +#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 600 "$install_dir/config.properties" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name=$app-api --action="start" --log_path="/var/log/$app/$app-api.log" --line_match="Database connection is ready!" +ynh_systemctl --service=$app-api --action="start" --log_path="/var/log/$app/$app-api.log" --wait_until="Database connection is ready!" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last \ No newline at end of file +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 973c749..5a2ea69 100644 --- a/scripts/install +++ b/scripts/install @@ -1,24 +1,18 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=3 +ynh_script_progression "Installing dependencies..." -ynh_install_nodejs --nodejs_version=$NODEJS_VERSION -ynh_use_nodejs +ynh_nodejs_install ynh_setup_source --dest_dir="$install_dir/jdk" --source_id="jdk" -ynh_exec_warn_less ynh_exec_as $app RUSTUP_HOME="$install_dir"/.rustup CARGO_HOME="$install_dir"/.cargo bash -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y' +ynh_hide_warnings ynh_exec_as_app RUSTUP_HOME="$install_dir"/.rustup CARGO_HOME="$install_dir"/.cargo bash -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y' export PATH="$install_dir/jdk/bin:$install_dir/.cargo/bin:$PATH" #================================================= @@ -26,7 +20,7 @@ export PATH="$install_dir/jdk/bin:$install_dir/.cargo/bin:$PATH" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." +ynh_script_progression "Setting up source files..." ynh_setup_source --dest_dir="$install_dir/build" @@ -34,21 +28,20 @@ ynh_setup_source --dest_dir="$install_dir/build_api" --source_id="api" ynh_setup_source --dest_dir="$install_dir/build_proxy" --source_id="proxy" -chown -R $app:www-data "$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" #================================================= # INSTALL APP #================================================= -ynh_script_progression --message="Building UI..." --weight=5 +ynh_script_progression "Building UI..." pushd $install_dir/build - env $ynh_node_load_PATH corepack enable - env $ynh_node_load_PATH corepack prepare pnpm@latest --activate - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH corepack enable - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH corepack prepare pnpm@latest --activate - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH pnpm install - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_ENV=production pnpm build - ynh_exec_warn_less ynh_exec_as $app ./localizefonts.sh + env node_load_PATH corepack enable + env node_load_PATH corepack prepare pnpm@latest --activate + ynh_hide_warnings ynh_exec_as_app node_load_PATH corepack enable + ynh_hide_warnings ynh_exec_as_app node_load_PATH corepack prepare pnpm@latest --activate + ynh_hide_warnings ynh_exec_as_app node_load_PATH pnpm install + ynh_hide_warnings ynh_exec_as_app node_load_PATH NODE_ENV=production pnpm build + ynh_hide_warnings ynh_exec_as_app ./localizefonts.sh popd mv $install_dir/build/dist $install_dir @@ -58,72 +51,70 @@ popd chown -R $app:www-data "$install_dir/dist" chmod -R 755 "$install_dir/dist" -ynh_secure_remove --file="$install_dir/build" -ynh_secure_remove --file="$install_dir/.local" -ynh_secure_remove --file="$install_dir/.cache" +ynh_safe_rm "$install_dir/build" +ynh_safe_rm "$install_dir/.local" +ynh_safe_rm "$install_dir/.cache" -ynh_script_progression --message="Building API..." --weight=5 +ynh_script_progression "Building API..." pushd $install_dir/build_api - ynh_exec_warn_less ynh_exec_as $app JAVA_HOME=$install_dir/jdk ./gradlew shadowJar - ynh_exec_warn_less ynh_exec_as $app JAVA_HOME=$install_dir/jdk ./gradlew --stop + ynh_hide_warnings ynh_exec_as_app JAVA_HOME=$install_dir/jdk ./gradlew shadowJar + ynh_hide_warnings ynh_exec_as_app JAVA_HOME=$install_dir/jdk ./gradlew --stop popd mv $install_dir/build_api/build/libs/piped-1.0-all.jar $install_dir/piped.jar -ynh_add_config --template="config.properties" --destination="$install_dir/config.properties" -chown $app:$app "$install_dir/config.properties" -chmod 600 "$install_dir/config.properties" -ynh_secure_remove --file="$install_dir/.gradle" -ynh_secure_remove --file="$install_dir/build_api" +ynh_config_add --template="config.properties" --destination="$install_dir/config.properties" +#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.properties" +#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 600 "$install_dir/config.properties" +ynh_safe_rm "$install_dir/.gradle" +ynh_safe_rm "$install_dir/build_api" -ynh_script_progression --message="Building Proxy..." --weight=5 +ynh_script_progression "Building Proxy..." pushd $install_dir/build_proxy - ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH cargo build --release + ynh_hide_warnings ynh_exec_as_app PATH=$PATH cargo build --release popd mv $install_dir/build_proxy/target/release/piped-proxy $install_dir -ynh_secure_remove --file="$install_dir/.rustup" -ynh_secure_remove --file="$install_dir/.cargo" -ynh_secure_remove --file="$install_dir/build_proxy" +ynh_safe_rm "$install_dir/.rustup" +ynh_safe_rm "$install_dir/.cargo" +ynh_safe_rm "$install_dir/build_proxy" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 +ynh_script_progression "Adding system configurations related to $app..." -ynh_add_nginx_config +ynh_config_add_nginx ### systemd mkdir -p "/var/log/$app" touch "/var/log/$app/$app-api.log" touch "/var/log/$app/$app-proxy.log" -chown -R "$app:" "/var/log/$app" -chmod 640 "/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:" "/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 640 "/var/log/$app" -ynh_use_logrotate --logfile="/var/log/$app/$app-api.log" -ynh_use_logrotate --logfile="/var/log/$app/$app-proxy.log" +ynh_config_add_logrotate "/var/log/$app/$app-api.log" +ynh_config_add_logrotate "/var/log/$app/$app-proxy.log" -ynh_add_systemd_config --template="api.service" --service="$app-api" +ynh_config_add_systemd --template="api.service" --service="$app-api" yunohost service add "$app-api" --description="Piped backend API service" --log="/var/log/$app/$app-api.log" -ynh_add_systemd_config --template="proxy.service" --service="$app-proxy" +ynh_config_add_systemd --template="proxy.service" --service="$app-proxy" yunohost service add "$app-proxy" --description="Piped HTTP proxy service" --log="/var/log/$app/$app-proxy.log" -#================================================= -# GENERIC FINALIZATION #================================================= # START SYSTEMD SERVICE #================================================= -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-api --action="start" --log_path="/var/log/$app/$app-api.log" --line_match="Database connection is ready!" +ynh_systemctl --service=$app-api --action="start" --log_path="/var/log/$app/$app-api.log" --wait_until="Database connection is ready!" -ynh_systemd_action --service_name=$app-proxy --action="start" --log_path="/var/log/$app/$app-proxy.log" --line_match="Running server!" +ynh_systemctl --service=$app-proxy --action="start" --log_path="/var/log/$app/$app-proxy.log" --wait_until="Running server!" #================================================= # 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 2fa0de9..0aa9c0f 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,10 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= source _common.sh source /usr/share/yunohost/helpers @@ -13,31 +8,31 @@ source /usr/share/yunohost/helpers #================================================= # REMOVE SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Removing system configurations related to $app..." +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-api >/dev/null +if ynh_hide_warnings yunohost service status $app-api >/dev/null then - ynh_script_progression --message="Removing $app-api service integration..." - ynh_remove_systemd_config --service="$app-api" + ynh_script_progression "Removing $app-api service integration..." + ynh_config_remove_systemd"$app-api" yunohost service remove $app-api fi -if ynh_exec_warn_less yunohost service status $app-proxy >/dev/null +if ynh_hide_warnings yunohost service status $app-proxy >/dev/null then - ynh_script_progression --message="Removing $app-proxy service integration..." - ynh_remove_systemd_config --service="$app-proxy" + ynh_script_progression "Removing $app-proxy service integration..." + ynh_config_remove_systemd"$app-proxy" yunohost service remove $app-proxy fi -ynh_remove_nginx_config +ynh_config_remove_nginx # Remove other various files specific to the app... such as : -ynh_remove_logrotate +ynh_config_remove_logrotate #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last \ No newline at end of file +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 14e6701..d3551bd 100644 --- 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,48 +7,48 @@ 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" +ynh_restore "$install_dir" -chown -R $app:www-data "$install_dir" -chown $app:$app "$install_dir/config.properties" -chmod 600 "$install_dir/config.properties" +#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" +#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.properties" +#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 600 "$install_dir/config.properties" #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=3 +ynh_script_progression "Restoring the PostgreSQL database..." -ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name +ynh_psql_db_shell < "./db.sql"" #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 +ynh_script_progression "Restoring system configurations related to $app..." -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_restore_file --origin_path="/etc/systemd/system/$app-api.service" +ynh_restore "/etc/systemd/system/$app-api.service" systemctl enable $app-api.service --quiet -ynh_restore_file --origin_path="/etc/systemd/system/$app-proxy.service" +ynh_restore "/etc/systemd/system/$app-proxy.service" systemctl enable $app-proxy.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" -chown -R "$app:root" "/var/log/$app" -chmod 640 "/var/log/$app" -ynh_restore_file --origin_path="/etc/logrotate.d/$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:root" "/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 640 "/var/log/$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-api" --description="Piped backend API service" --log="/var/log/$app/$app-api.log" yunohost service add "$app-proxy" --description="Piped HTTP proxy service" --log="/var/log/$app/$app-proxy.log" @@ -62,19 +56,19 @@ yunohost service add "$app-proxy" --description="Piped HTTP proxy service" --log #================================================= # RELOAD NGINX THE APP SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 +ynh_script_progression "Reloading NGINX web server and $app's service..." -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service=nginx --action=reload #================================================= # START SYSTEMD SERVICE #================================================= -ynh_systemd_action --service_name=$app-api --action="start" --log_path="/var/log/$app/$app-api.log" --line_match="Database connection is ready!" +ynh_systemctl --service=$app-api --action="start" --log_path="/var/log/$app/$app-api.log" --wait_until="Database connection is ready!" -ynh_systemd_action --service_name=$app-proxy --action="start" --log_path="/var/log/$app/$app-proxy.log" --line_match="Running server!" +ynh_systemctl --service=$app-proxy --action="start" --log_path="/var/log/$app/$app-proxy.log" --wait_until="Running server!" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last \ No newline at end of file +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 3860c6d..b67beef 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,31 +1,21 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -upgrade_type=$(ynh_check_app_version_changed) - -#================================================= -# STANDARD UPGRADE STEPS #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -chmod 640 "/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 640 "/var/log/$app" #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name=$app-api --action="stop" --log_path="/var/log/$app/$app-api.log" -ynh_systemd_action --service_name=$app-proxy --action="stop" +ynh_systemctl --service=$app-api --action="stop" --log_path="/var/log/$app/$app-api.log" +ynh_systemctl --service=$app-proxy --action="stop" #================================================= # "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...) @@ -33,19 +23,19 @@ ynh_systemd_action --service_name=$app-proxy --action="stop" # 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="Installing dependencies..." --weight=3 + ynh_script_progression "Installing dependencies..." - ynh_install_nodejs --nodejs_version=$NODEJS_VERSION - ynh_use_nodejs + ynh_nodejs_install - ynh_setup_source --dest_dir="$install_dir/jdk" --source_id="jdk" --full_replace=1 + ynh_setup_source --dest_dir="$install_dir/jdk" --source_id="jdk" --full_replace - ynh_exec_warn_less ynh_exec_as $app RUSTUP_HOME="$install_dir"/.rustup CARGO_HOME="$install_dir"/.cargo bash -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y' + ynh_hide_warnings ynh_exec_as_app RUSTUP_HOME="$install_dir"/.rustup CARGO_HOME="$install_dir"/.cargo bash -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y' export PATH="$install_dir/jdk/bin:$install_dir/.cargo/bin:$PATH" - ynh_script_progression --message="Setting up source files..." + ynh_script_progression "Setting up source files..." ynh_setup_source --dest_dir="$install_dir/build" @@ -53,22 +43,21 @@ then ynh_setup_source --dest_dir="$install_dir/build_proxy" --source_id="proxy" - chown -R $app:www-data "$install_dir" - chmod -R 755 "$install_dir" - - ynh_script_progression --message="Building UI..." --weight=5 + #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" + #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 755 "$install_dir" + ynh_script_progression "Building UI..." pushd $install_dir/build - env $ynh_node_load_PATH corepack enable - env $ynh_node_load_PATH corepack prepare pnpm@latest --activate - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH corepack enable - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH corepack prepare pnpm@latest --activate - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH pnpm install - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_ENV=production pnpm build - ynh_exec_warn_less ynh_exec_as $app ./localizefonts.sh + env node_load_PATH corepack enable + env node_load_PATH corepack prepare pnpm@latest --activate + ynh_hide_warnings ynh_exec_as_app node_load_PATH corepack enable + ynh_hide_warnings ynh_exec_as_app node_load_PATH corepack prepare pnpm@latest --activate + ynh_hide_warnings ynh_exec_as_app node_load_PATH pnpm install + ynh_hide_warnings ynh_exec_as_app node_load_PATH NODE_ENV=production pnpm build + ynh_hide_warnings ynh_exec_as_app ./localizefonts.sh popd - ynh_secure_remove --file="$install_dir/dist" + ynh_safe_rm "$install_dir/dist" mv $install_dir/build/dist $install_dir pushd $install_dir/dist sed -i s/pipedapi.kavin.rocks/"$domain\\/api"/g assets/* @@ -76,46 +65,46 @@ then chown -R $app:www-data "$install_dir/dist" chmod -R 755 "$install_dir/dist" - ynh_secure_remove --file="$install_dir/build" - ynh_secure_remove --file="$install_dir/.local" - ynh_secure_remove --file="$install_dir/.cache" + ynh_safe_rm "$install_dir/build" + ynh_safe_rm "$install_dir/.local" + ynh_safe_rm "$install_dir/.cache" - ynh_script_progression --message="Building API..." --weight=5 + ynh_script_progression "Building API..." pushd $install_dir/build_api - ynh_exec_warn_less ynh_exec_as $app JAVA_HOME=$install_dir/jdk ./gradlew shadowJar - ynh_exec_warn_less ynh_exec_as $app JAVA_HOME=$install_dir/jdk ./gradlew --stop + ynh_hide_warnings ynh_exec_as_app JAVA_HOME=$install_dir/jdk ./gradlew shadowJar + ynh_hide_warnings ynh_exec_as_app JAVA_HOME=$install_dir/jdk ./gradlew --stop popd - ynh_secure_remove --file="$install_dir/piped.jar" + ynh_safe_rm "$install_dir/piped.jar" mv $install_dir/build_api/build/libs/piped-1.0-all.jar $install_dir/piped.jar - ynh_secure_remove --file="$install_dir/build_api" - ynh_secure_remove --file="$install_dir/.gradle" + ynh_safe_rm "$install_dir/build_api" + ynh_safe_rm "$install_dir/.gradle" - ynh_script_progression --message="Building Proxy..." --weight=5 + ynh_script_progression "Building Proxy..." pushd $install_dir/build_proxy - ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH cargo build --release + ynh_hide_warnings ynh_exec_as_app PATH=$PATH cargo build --release popd - ynh_secure_remove --file="$install_dir/piped-proxy" + ynh_safe_rm "$install_dir/piped-proxy" mv $install_dir/build_proxy/target/release/piped-proxy $install_dir - ynh_secure_remove --file="$install_dir/.rustup" - ynh_secure_remove --file="$install_dir/.cargo" - ynh_secure_remove --file="$install_dir/build_proxy" + ynh_safe_rm "$install_dir/.rustup" + ynh_safe_rm "$install_dir/.cargo" + ynh_safe_rm "$install_dir/build_proxy" fi #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." +ynh_script_progression "Upgrading system configurations related to $app..." -ynh_add_nginx_config +ynh_config_add_nginx -ynh_add_systemd_config --template="api.service" --service="$app-api" +ynh_config_add_systemd --template="api.service" --service="$app-api" yunohost service add "$app-api" --description="Piped backend API service" --log="/var/log/$app/$app-api.log" -ynh_add_systemd_config --template="proxy.service" --service="$app-proxy" +ynh_config_add_systemd --template="proxy.service" --service="$app-proxy" yunohost service add "$app-proxy" --description="Piped HTTP proxy service" --log="/var/log/$app/$app-proxy.log" #================================================= @@ -123,24 +112,24 @@ yunohost service add "$app-proxy" --description="Piped HTTP proxy service" --log #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." +ynh_script_progression "Updating configuration..." -ynh_add_config --template="config.properties" --destination="$install_dir/config.properties" -chown $app:$app "$install_dir/config.properties" -chmod 600 "$install_dir/config.properties" +ynh_config_add --template="config.properties" --destination="$install_dir/config.properties" +#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.properties" +#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 600 "$install_dir/config.properties" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression "Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app-api --action="start" --log_path="/var/log/$app/$app-api.log" --line_match="Database connection is ready!" +ynh_systemctl --service=$app-api --action="start" --log_path="/var/log/$app/$app-api.log" --wait_until="Database connection is ready!" -ynh_systemd_action --service_name=$app-proxy --action="start" --log_path="/var/log/$app/$app-proxy.log" --line_match="Running server!" +ynh_systemctl --service=$app-proxy --action="start" --log_path="/var/log/$app/$app-proxy.log" --wait_until="Running server!" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed"