From 4875926f238def2c337bd98032f426522d306aeb Mon Sep 17 00:00:00 2001 From: Kayou Date: Wed, 3 Jul 2024 14:25:00 +0200 Subject: [PATCH] rework install/restore/upgrade scripts, add deps, add go as resources --- manifest.toml | 11 ++++++++++- scripts/install | 22 +++++++++++++--------- scripts/restore | 20 ++++++++++++-------- scripts/upgrade | 24 ++++++++++++++---------- 4 files changed, 49 insertions(+), 28 deletions(-) diff --git a/manifest.toml b/manifest.toml index 1adea77..88be750 100644 --- a/manifest.toml +++ b/manifest.toml @@ -53,6 +53,15 @@ ram.runtime = "50M" sha256 = "e909a109e1d60bf9416a70f2bb0bbf668d75c75d7ca9ce0b59d88fc634266114" autoupdate.strategy = "latest_github_release" autoupdate.asset = "^netdata-v([0-9.]*)tar.gz$" + [resources.sources.go] + amd64.url = "https://go.dev/dl/go1.22.4.linux-amd64.tar.gz" + amd64.sha256 = "ba79d4526102575196273416239cca418a651e049c2b099f3159db85e7bade7d" + i386.url = "https://go.dev/dl/go1.22.4.linux-386.tar.gz" + i386.sha256 = "47a2a8d249a91eb8605c33bceec63aedda0441a43eac47b4721e3975ff916cec" + arm64.url = "https://go.dev/dl/go1.22.4.linux-arm64.tar.gz" + arm64.sha256 = "a8e177c354d2e4a1b61020aca3562e27ea3e8f8247eca3170e3fa1e0c2f9e771" + armhf.url = "https://go.dev/dl/go1.21.5.linux-armv6l.tar.gz" + armhf.sha256 = "837f4bf4e22fcdf920ffeaa4abf3d02d1314e03725431065f4d44c46a01b42fe" [resources.system_user] @@ -62,4 +71,4 @@ ram.runtime = "50M" main.url = "/" [resources.apt] - packages = "zlib1g-dev, uuid-dev, libmnl-dev, gcc, g++, bison, flex, make, git, autoconf, autoconf-archive, autogen, automake, pkg-config, curl, jq, nodejs, python3-mysqldb, libipmimonitoring-dev, acl, python3-pymongo, libuv1-dev, liblz4-dev, libjudy-dev, libssl-dev, libelf-dev, cmake, golang-go" + packages = "cmake, ninja-build, pkg-config, bison, flex, gcc, g++, git, libelf-dev, libssl-dev, liblz4-dev, zlib1g-dev, uuid-dev, libyaml-dev, libjson-c-dev, libuv1-dev" \ No newline at end of file diff --git a/scripts/install b/scripts/install index 4f9d4da..bf92c3f 100644 --- a/scripts/install +++ b/scripts/install @@ -15,25 +15,29 @@ source /usr/share/yunohost/helpers ynh_script_progression --message="Setting up source files..." --weight=11 # Download, check integrity, uncompress and patch the source from app.src -NETDATA_TMPDIR=$(mktemp -d) +NETDATA_TMPDIR="$install_dir/netdata_install" +mkdir -p $NETDATA_TMPDIR ynh_setup_source --dest_dir="$NETDATA_TMPDIR" +GO_TMPDIR="$install_dir/go_install" +mkdir -p $GO_TMPDIR +ynh_setup_source --source_id="go" --dest_dir="$GO_TMPDIR" #================================================= # BUILD #================================================= ynh_script_progression --message="Executing Netdata installer..." --weight=10 -# create a temporary file for the log -tmplog=$(mktemp /tmp/netdata-updater-log-XXXXXX.log) - +export PATH="$GO_TMPDIR/bin:$PATH" +export GOPATH="$GO_TMPDIR/go/" +export HOME=${HOME:-"/root/"} pushd "$NETDATA_TMPDIR" # the installer.sh script will append "netdata" after the --install-prefix arg - if ! ./netdata-installer.sh --install-prefix /var/www/ --dont-wait --disable-cloud --disable-telemetry --stable-channel > "$tmplog" 2>&1; then - cat $tmplog - ynh_die "FAILED TO COMPILE/INSTALL NETDATA" - fi + ynh_exec_warn_less ./netdata-installer.sh --install-prefix /var/www/ --dont-wait --disable-cloud --disable-telemetry --stable-channel popd +ynh_secure_remove --file=$NETDATA_TMPDIR +ynh_secure_remove --file=$GO_TMPDIR + # Specific configuration configure_netdata @@ -59,4 +63,4 @@ ynh_systemd_action --service_name="$app" --action="restart" --log_path="$install # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression --message="Installation of $app completed" --last \ No newline at end of file diff --git a/scripts/restore b/scripts/restore index d27d19d..d26f6d3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -25,20 +25,24 @@ ynh_restore_file --origin_path="$install_dir/etc/netdata" ynh_script_progression --message="Reinstalling Netdata..." --weight=18 # Download, check integrity, uncompress and patch the source from app.src -NETDATA_TMPDIR=$(mktemp -d) +NETDATA_TMPDIR="$install_dir/netdata_install" +mkdir -p $NETDATA_TMPDIR ynh_setup_source --dest_dir="$NETDATA_TMPDIR" +GO_TMPDIR="$install_dir/go_install" +mkdir -p $GO_TMPDIR +ynh_setup_source --source_id="go" --dest_dir="$GO_TMPDIR" -# create a temporary file for the log -tmplog=$(mktemp /tmp/netdata-updater-log-XXXXXX.log) - +export PATH="$GO_TMPDIR/bin:$PATH" +export GOPATH="$GO_TMPDIR/go/" +export HOME=${HOME:-"/root/"} pushd "$NETDATA_TMPDIR" # the installer.sh script will append "netdata" after the --install-prefix arg - if ! ./netdata-installer.sh --install-prefix /var/www/ --dont-wait --disable-cloud --disable-telemetry --stable-channel > "$tmplog" 2>&1; then - cat $tmplog - ynh_die "FAILED TO COMPILE/INSTALL NETDATA" - fi + ynh_exec_warn_less ./netdata-installer.sh --install-prefix /var/www/ --dont-wait --disable-cloud --disable-telemetry --stable-channel popd +ynh_secure_remove --file=$NETDATA_TMPDIR +ynh_secure_remove --file=$GO_TMPDIR + # Specific configuration configure_netdata diff --git a/scripts/upgrade b/scripts/upgrade index 10d1a20..1109e6a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -19,8 +19,12 @@ ynh_script_progression --message="Upgrading source files..." --weight=18 #================================================= # Download, check integrity, uncompress and patch the source from app.src -NETDATA_TMPDIR=$(mktemp -d) -ynh_setup_source "$NETDATA_TMPDIR" +NETDATA_TMPDIR="$install_dir/netdata_install" +mkdir -p $NETDATA_TMPDIR +ynh_setup_source --dest_dir="$NETDATA_TMPDIR" +GO_TMPDIR="$install_dir/go_install" +mkdir -p $GO_TMPDIR +ynh_setup_source --source_id="go" --dest_dir="$GO_TMPDIR" #================================================= # SPECIFIC UPGRADE @@ -33,17 +37,17 @@ if [ -n "${pids}" ]; then kill -USR1 ${pids} fi -# create a temporary file for the log -tmplog=$(mktemp /tmp/netdata-updater-log-XXXXXX.log) - +export PATH="$GO_TMPDIR/bin:$PATH" +export GOPATH="$GO_TMPDIR/go/" +export HOME=${HOME:-"/root/"} pushd "$NETDATA_TMPDIR" - # the installer.sh script will append "netdata" after the --install-prefix arg - if ! ./netdata-installer.sh --install-prefix /var/www/ --dont-wait --disable-cloud --disable-telemetry --stable-channel > "$tmplog" 2>&1; then - cat $tmplog - ynh_die "FAILED TO COMPILE/INSTALL NETDATA" - fi + # the installer.sh script will append "netdata" after the --install-prefix arg + ynh_exec_warn_less ./netdata-installer.sh --install-prefix /var/www/ --dont-wait --disable-cloud --disable-telemetry --stable-channel popd +ynh_secure_remove --file=$NETDATA_TMPDIR +ynh_secure_remove --file=$GO_TMPDIR + # Specific configuration configure_netdata