From 3a4017f33b5152c40e1a7b60f9c98e38cc35f6d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 26 Jan 2024 21:51:05 +0100 Subject: [PATCH] Small cleanup, coding style, fix progress messages --- conf/env | 8 ++++---- conf/nginx.conf | 23 +++++++++++------------ manifest.toml | 25 ++++++++++++++++--------- scripts/backup | 12 ++++-------- scripts/change_url | 2 +- scripts/install | 29 ++++++++++++++--------------- scripts/remove | 6 ++---- scripts/restore | 23 +++++++++-------------- scripts/upgrade | 23 ++++++++--------------- tests.toml | 2 ++ 10 files changed, 71 insertions(+), 82 deletions(-) diff --git a/conf/env b/conf/env index b44ebaf..84bd023 100644 --- a/conf/env +++ b/conf/env @@ -6,10 +6,10 @@ NC_PUBLIC_URL=https://__DOMAIN__ NC_REQUEST_BODY_SIZE=104857600 NC_REDIS_URL=redis://localhost/ -NC_SMTP_FROM=__APP__@__DOMAIN__ +NC_SMTP_FROM=__APP__@__DOMAIN__ NC_SMTP_HOST=localhost NC_SMTP_PORT=25 -NC_SMTP_USERNAME=__APP__ -NC_SMTP_PASSWORD=__MAIL_PWD__ -NC_SMTP_SECURE=false +NC_SMTP_USERNAME=__APP__ +NC_SMTP_PASSWORD=__MAIL_PWD__ +NC_SMTP_SECURE=false NC_SMTP_IGNORE_TLS=true diff --git a/conf/nginx.conf b/conf/nginx.conf index 5a49c3e..637de7f 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,17 +1,16 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { + proxy_pass http://127.0.0.1:__PORT____PATH__; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_http_version 1.1; + proxy_no_cache $cookie_session; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $http_connection; - proxy_pass http://127.0.0.1:__PORT____PATH__; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_http_version 1.1; - proxy_no_cache $cookie_session; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $http_connection; + client_max_body_size 100M; - client_max_body_size 100M; - - # Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; } diff --git a/manifest.toml b/manifest.toml index da17be1..b32c648 100644 --- a/manifest.toml +++ b/manifest.toml @@ -1,3 +1,5 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + packaging_format = 2 id = "nocodb" @@ -39,18 +41,21 @@ ram.runtime = "50M" default = "visitors" [resources] - [resources.sources.main] + [resources.sources.main] + amd64.url = "https://github.com/nocodb/nocodb/releases/download/0.203.2/Noco-linux-x64" + amd64.sha256 = "dae67f74461dd55ff1f09a48a6f7cddeb2ce52fd56fa4fa377afb6f90943298a" + arm64.url = "https://github.com/nocodb/nocodb/releases/download/0.203.2/Noco-linux-arm64" + arm64.sha256 = "8545dc5d03c530dfc1a15ece70b2473b653e003722c255b30b5595affea4b092" + rename = "nocodb" + extract = false - amd64.url = "https://github.com/nocodb/nocodb/releases/download/0.203.2/Noco-linux-x64" - amd64.sha256 = "dae67f74461dd55ff1f09a48a6f7cddeb2ce52fd56fa4fa377afb6f90943298a" - arm64.url = "https://github.com/nocodb/nocodb/releases/download/0.203.2/Noco-linux-arm64" - arm64.sha256 = "8545dc5d03c530dfc1a15ece70b2473b653e003722c255b30b5595affea4b092" - rename = "nocodb" - extract = false + autoupdate.strategy = "latest_github_release" + autoupdate.asset.amd64 = "Noco-linux-x64" + autoupdate.asset.arm64 = "Noco-linux-arm64" [resources.system_user] allow_email = true - + [resources.install_dir] [resources.ports] @@ -59,7 +64,9 @@ ram.runtime = "50M" main.url = "/" [resources.apt] - packages = "mariadb-server" + packages = [ + "mariadb-server", + ] [resources.database] type = "mysql" diff --git a/scripts/backup b/scripts/backup index e007e63..c2c3a41 100755 --- a/scripts/backup +++ b/scripts/backup @@ -22,24 +22,20 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$install_dir" #================================================= -# BACKUP THE NGINX CONFIGURATION +# SYSTEM CONFIGURATION #================================================= ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE -#================================================= +ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/logrotate.d/$app" #================================================= -# BACKUP SYSTEMD +# BACKUP VARIOUS FILES #================================================= -ynh_backup --src_path="/etc/systemd/system/$app.service" +ynh_backup --src_path="/var/log/$app/" #================================================= # BACKUP THE MYSQL DATABASE diff --git a/scripts/change_url b/scripts/change_url index 49d5387..1faa49d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -33,7 +33,7 @@ ynh_change_url_nginx_config ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="application successfully started" +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="application successfully started" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index e7142d6..25dd6cb 100755 --- a/scripts/install +++ b/scripts/install @@ -21,8 +21,18 @@ ynh_script_progression --message="Setting up source files..." --weight=1 ynh_setup_source --dest_dir="$install_dir" chmod -R o-rwx "$install_dir" -chown -R $app:$app "$install_dir" -chmod +x $install_dir/nocodb +chown -R "$app:$app" "$install_dir" +chmod +x "$install_dir/nocodb" + +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." --weight=1 + +ynh_add_config --template="env" --destination="$install_dir/.env" + +chmod 400 "$install_dir/.env" +chown "$app:$app" "$install_dir/.env" #================================================= # NGINX CONFIGURATION @@ -34,29 +44,18 @@ ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config +yunohost service add "$app" --description="Turns any database into a smart-spreadsheet" --log="/var/log/$app/$app.log" # Use logrotate to manage application logfile(s) ynh_use_logrotate -yunohost service add $app --description="Turns any database into a smart-spreadsheet" --log="/var/log/$app/$app.log" - -#================================================= -# ADD A CONFIGURATION -#================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 - -ynh_add_config --template="env" --destination="$install_dir/.env" - -chmod 400 "$install_dir/.env" -chown $app:$app "$install_dir/.env" - #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="application successfully started" +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="application successfully started" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 83c5e64..09ecc87 100755 --- a/scripts/remove +++ b/scripts/remove @@ -17,10 +17,8 @@ source /usr/share/yunohost/helpers ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # 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 -then - ynh_script_progression --message="Removing $app service integration..." --weight=1 - yunohost service remove $app +if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then + yunohost service remove "$app" fi # Remove the dedicated systemd config diff --git a/scripts/restore b/scripts/restore index 90740b3..07e1039 100755 --- a/scripts/restore +++ b/scripts/restore @@ -18,42 +18,37 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" chmod -R o-rwx "$install_dir" -chown -R $app:$app "$install_dir" -chmod +x $install_dir/nocodb +chown -R "$app:$app" "$install_dir" +chmod +x "$install_dir/nocodb" #================================================= # RESTORE THE MYSQL DATABASE #================================================= ynh_script_progression --message="Restoring the MySQL database..." --weight=2 -ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql #================================================= -# RESTORE THE NGINX CONFIGURATION +# RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1 +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -log_path=/var/log/$app -mkdir -p "$log_path" -chmod 750 "$log_path" -chmod -R o-rwx "$log_path" -chown -R $app:www-data "$log_path" - ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service --quiet +systemctl enable "$app.service" --quiet +yunohost service add "$app" --description="Turns any database into a smart-spreadsheet" --log="/var/log/$app/$app.log" ynh_restore_file --origin_path="/etc/logrotate.d/$app" -yunohost service add $app --description="Turns any database into a smart-spreadsheet" --log="/var/log/$app/$app.log" +ynh_restore_file --origin_path="/var/log/$app/" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="application successfully started" +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="application successfully started" ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index dedf08b..d193daa 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,12 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# CHECK VERSION -#================================================= - -upgrade_type=$(ynh_check_app_version_changed) - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -22,7 +16,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -30,34 +24,33 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir" --keep=".env nc" --full_replace +ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep=".env nc" chmod -R o-rwx "$install_dir" -chown -R $app:$app "$install_dir" -chmod +x $install_dir/nocodb +chown -R "$app:$app" "$install_dir" +chmod +x "$install_dir/nocodb" #================================================= -# NGINX CONFIGURATION +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config +yunohost service add "$app" --description="Turns any database into a smart-spreadsheet" --log="/var/log/$app/$app.log" # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append -yunohost service add $app --description="Turns any database into a smart-spreadsheet" --log="/var/log/$app/$app.log" - #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="application successfully started" +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="application successfully started" #================================================= # END OF SCRIPT diff --git a/tests.toml b/tests.toml index ac9c57b..f25024a 100644 --- a/tests.toml +++ b/tests.toml @@ -1,3 +1,5 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + test_format = 1.0 [default]