From 0287b80c3ade4243152a4d88edbde4a259e16224 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 28 Jan 2023 19:24:20 +0100 Subject: [PATCH] Rely on upstream built binaries --- conf/amd64.src | 4 ++++ conf/arm64.src | 4 ++++ conf/systemd.service | 2 +- scripts/install | 15 ++++++++++++--- scripts/upgrade | 17 ++++++++++++++++- 5 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 conf/amd64.src create mode 100644 conf/arm64.src diff --git a/conf/amd64.src b/conf/amd64.src new file mode 100644 index 0000000..110b5f1 --- /dev/null +++ b/conf/amd64.src @@ -0,0 +1,4 @@ +SOURCE_URL=https://github.com/nocodb/nocodb/releases/download/0.104.2/Noco-linux-x64 +SOURCE_SUM=7506A5936B53CCFBB60FDEF80C5D90A87013B24C57CD4C477C57AF37E74654DD +SOURCE_SUM_PRG=sha256sum +SOURCE_FILENAME=nocodb diff --git a/conf/arm64.src b/conf/arm64.src new file mode 100644 index 0000000..d1074e6 --- /dev/null +++ b/conf/arm64.src @@ -0,0 +1,4 @@ +SOURCE_URL=https://github.com/nocodb/nocodb/releases/download/0.104.2/Noco-linux-arm64 +SOURCE_SUM=3B7EEF61DA6E69E2F8B99ED13DDC11DAA2B6E30552D6C877C2D0824E028D7361 +SOURCE_SUM_PRG=sha256sum +SOURCE_FILENAME=nocodb diff --git a/conf/systemd.service b/conf/systemd.service index d0a49ce..627af43 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -9,7 +9,7 @@ Group=__APP__ WorkingDirectory=__FINALPATH__/ Environment="__YNH_NODE_LOAD_PATH__" EnvironmentFile=__FINALPATH__/.env -ExecStart=__YNH_NODE__ index.js +ExecStart=__NOCODB_STARTCOMMAND__ StandardOutput=append:/var/log/__APP__/__APP__.log StandardError=inherit diff --git a/scripts/install b/scripts/install index 7f84c04..5d9cd52 100755 --- a/scripts/install +++ b/scripts/install @@ -36,10 +36,12 @@ jwt_secret=$(ynh_string_random --length=20) #================================================= ynh_script_progression --message="Validating installation parameters..." --weight=1 -# Stop if architecture is 32-bit ARM +# Stop if architecture is 32-bit ARM, else point to the ARM64 or AMD64 binaries, else to the source code to be downloaded case $YNH_ARCH in arm|armhf) ynh_die --message="Sorry, your architecture $YNH_ARCH is not supported by NocoDB. Aborting.";; - *) ;; + arm64) src="arm64";; + amd64) src="amd64";; + *) src="app";; esac final_path=/opt/yunohost/$app @@ -100,7 +102,7 @@ ynh_script_progression --message="Setting up source files..." --weight=1 ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$final_path" +ynh_setup_source --source_id="$src" --dest_dir="$final_path" chmod 750 "$final_path" chmod -R o-rwx "$final_path" @@ -148,6 +150,13 @@ chown $app:$app "$final_path/.env" #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=1 +if [ $YNH_ARCH = "arm64" || $YNH_ARCH = "amd64" ]; + nocodb_startcommand="nocodb" +else + nocodb_startcommand="$ynh_node index.js" +fi +ynh_app_setting_set --app=$app --key=nocodb_startcommand --value=$nocodb_startcommand + # Create a dedicated systemd config ynh_add_systemd_config diff --git a/scripts/upgrade b/scripts/upgrade index 04ee26d..337902e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,6 +22,14 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) port=$(ynh_app_setting_get --app=$app --key=port) +# Stop if architecture is 32-bit ARM, else point to the ARM64 or AMD64 binaries, else to the source code to be downloaded +case $YNH_ARCH in + arm|armhf) ynh_die --message="Sorry, your architecture $YNH_ARCH is not supported by NocoDB. Aborting.";; + arm64) src="arm64";; + amd64) src="amd64";; + *) src="app";; +esac + #================================================= # CHECK VERSION #================================================= @@ -75,7 +83,7 @@ then 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="$final_path" --keep=".env" + ynh_setup_source --source="$src" --dest_dir="$final_path" --keep=".env" fi chmod 750 "$final_path" @@ -126,6 +134,13 @@ popd #================================================= ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 +if [ $YNH_ARCH = "arm64" || $YNH_ARCH = "amd64" ]; + nocodb_startcommand="nocodb" +else + nocodb_startcommand="$ynh_node index.js" +fi +ynh_app_setting_set --app=$app --key=nocodb_startcommand --value=$nocodb_startcommand + # Create a dedicated systemd config ynh_add_systemd_config