From 25d4bfa0ee76c80cd9c546200caeebda17cca0e5 Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Thu, 18 Dec 2025 13:34:07 +0100 Subject: [PATCH 1/5] f-1: clean: delete keep files #1 Signed-off-by: GnomeZworc --- cmd/agent/.keep | 0 internal/.keep | 0 pkg/.keep | 0 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 cmd/agent/.keep delete mode 100644 internal/.keep delete mode 100644 pkg/.keep diff --git a/cmd/agent/.keep b/cmd/agent/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/internal/.keep b/internal/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/pkg/.keep b/pkg/.keep deleted file mode 100644 index e69de29..0000000 -- 2.49.1 From f67376964a6eae797a8c92c392ddb3eaa6addb69 Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Thu, 18 Dec 2025 14:06:02 +0100 Subject: [PATCH 2/5] f-1: scripts: start deploy script #1 Signed-off-by: GnomeZworc --- scripts/deploy.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 scripts/deploy.sh diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100644 index 0000000..9fcd1dd --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,38 @@ +#!/bin/bash +set -e + +SED_PARAM="" +unameOut="$(uname -s)" +case "${unameOut}" in + Linux*) SED_PARAM=" -i ";; + Darwin*) SED_PARAM=" -i '' ";; + *) exit 1 +esac + +SCRIPT_PATH="scripts/deploy.sh" + +check_latest_script () { + REMOTE_URL="${1}" + LOCAL_PATH="${2}" + + REMOTE=$(curl --silent "${REMOTE_URL}" | sha256sum) + LOCAL=$(cat ${LOCAL_PATH} | sha256sum) + + [[ "${REMOTE}" == "${LOCAL}" ]] \ + && echo "both are the same" \ + || echo "not the same" +} + +main () { + [[ -f ./libs/shflags ]] && . ./libs/shflags || eval "$(curl --silent https://git.g3e.fr/H6N/tools/raw/branch/main/libs/shflags)" + + DEFINE_boolean 'dryrun' false 'Enable dry-run mode' 'd' + DEFINE_string 'git_server' 'https://git.g3e.fr/' 'Git Server' 'g' + DEFINE_string 'repo_path' 'syonad/two/' 'Path of repository' 'r' + DEFINE_string 'branch' 'main/' 'Branch name' 'b' + + check_latest_script "${FLAGS_git_server}${FLAGS_repo_path}raw/branch/${FLAGS_branch}${SCRIPT_PATH}" "${0}" +} + +[[ "${BASH_SOURCE[0]}" == "${0}" ]] && (main "$@" || exit 1) +[[ "${BASH_SOURCE[0]}" == "" ]] && (main "$@" || exit 1) \ No newline at end of file -- 2.49.1 From 05b3827e3cdd6c48c3a6ac02699904f833167fe6 Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Thu, 18 Dec 2025 14:09:37 +0100 Subject: [PATCH 3/5] f-1: fix: fix forgeten args #1 Signed-off-by: GnomeZworc --- scripts/deploy.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 9fcd1dd..3345488 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -24,6 +24,7 @@ check_latest_script () { } main () { + echo "$@" [[ -f ./libs/shflags ]] && . ./libs/shflags || eval "$(curl --silent https://git.g3e.fr/H6N/tools/raw/branch/main/libs/shflags)" DEFINE_boolean 'dryrun' false 'Enable dry-run mode' 'd' @@ -31,6 +32,9 @@ main () { DEFINE_string 'repo_path' 'syonad/two/' 'Path of repository' 'r' DEFINE_string 'branch' 'main/' 'Branch name' 'b' + FLAGS "$@" || exit $? + eval set -- "${FLAGS_ARGV}" + check_latest_script "${FLAGS_git_server}${FLAGS_repo_path}raw/branch/${FLAGS_branch}${SCRIPT_PATH}" "${0}" } -- 2.49.1 From b25ce92c66abbe878ff669f1b05de870a93fba12 Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Thu, 18 Dec 2025 14:30:04 +0100 Subject: [PATCH 4/5] f-1: scripts: edit script add dry-run Signed-off-by: GnomeZworc --- scripts/deploy.sh | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 3345488..635803f 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -11,6 +11,21 @@ esac SCRIPT_PATH="scripts/deploy.sh" +exec_with_dry_run () { + if [[ ${1} -eq ${FLAGS_TRUE} ]]; then + echo "# ${2}" + else + eval "${2}" 2> /tmp/error || \ + { + echo -e "failed with following error"; + output=$(cat /tmp/error | sed -e "s/^/ error -> /g"); + echo -e "${output}"; + return 1; + } + fi + return 0 +} + check_latest_script () { REMOTE_URL="${1}" LOCAL_PATH="${2}" @@ -18,16 +33,15 @@ check_latest_script () { REMOTE=$(curl --silent "${REMOTE_URL}" | sha256sum) LOCAL=$(cat ${LOCAL_PATH} | sha256sum) - [[ "${REMOTE}" == "${LOCAL}" ]] \ - && echo "both are the same" \ - || echo "not the same" + [[ "${REMOTE}" == "${LOCAL}" ]] || return 1 + return 0 } main () { - echo "$@" [[ -f ./libs/shflags ]] && . ./libs/shflags || eval "$(curl --silent https://git.g3e.fr/H6N/tools/raw/branch/main/libs/shflags)" DEFINE_boolean 'dryrun' false 'Enable dry-run mode' 'd' + DEFINE_boolean 'up_script' true 'Upgrade script' 's' DEFINE_string 'git_server' 'https://git.g3e.fr/' 'Git Server' 'g' DEFINE_string 'repo_path' 'syonad/two/' 'Path of repository' 'r' DEFINE_string 'branch' 'main/' 'Branch name' 'b' @@ -35,7 +49,12 @@ main () { FLAGS "$@" || exit $? eval set -- "${FLAGS_ARGV}" - check_latest_script "${FLAGS_git_server}${FLAGS_repo_path}raw/branch/${FLAGS_branch}${SCRIPT_PATH}" "${0}" + SCRIPT_URL="${FLAGS_git_server}${FLAGS_repo_path}raw/branch/${FLAGS_branch}${SCRIPT_PATH}" + check_latest_script "${SCRIPT_URL}" "${0}" || ( + [[ ${FLAGS_up_script} -eq ${FLAGS_TRUE} ]] && \ + exec_with_dry_run "${FLAGS_dryrun}" "curl --silent \"${SCRIPT_URL}\" -o \"${0}\"" + exit 1 + ) } [[ "${BASH_SOURCE[0]}" == "${0}" ]] && (main "$@" || exit 1) -- 2.49.1 From 6ed9d8abd924cabf6796852f01b995c6edb5ef77 Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Thu, 18 Dec 2025 15:29:09 +0100 Subject: [PATCH 5/5] f-1: scripts: add download scipts #1 Signed-off-by: GnomeZworc --- scripts/deploy.sh | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 635803f..8feee6f 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -37,6 +37,33 @@ check_latest_script () { return 0 } +download_binaries () { + DRY_RUN="${1}" + TAG="${2}" + GIT_SERVER="${3}" + REPO_PATH="${4}" + + #'.[0].assets.[].browser_download_url' + [[ "${TAG}" == "" ]] && TAG=$(curl --silent "${GIT_SERVER}api/v1/repos/${REPO_PATH}releases/?limit=1" | jq -r '.[0].tag_name') + echo "${TAG}" + + BIN_PATH="/opt/two/${TAG}/bin/" + LN_PATH="/opt/two/bin/" + + exec_with_dry_run "${DRY_RUN}" "mkdir -p \"${BIN_PATH}\"" + exec_with_dry_run "${DRY_RUN}" "mkdir -p \"${LN_PATH}\"" + + curl --silent "${GIT_SERVER}api/v1/repos/${REPO_PATH}releases/tags/${TAG}" | jq -c '.assets.[]' | while read tmp + do + BINARY_NAME=$(echo "${tmp}" | jq -r '.name') + BINARY_SHORT_NAME=$(echo "${BINARY_NAME}" | cut -d_ -f 1) + BINARY_URL=$(echo "${tmp}" | jq -r '.browser_download_url') + exec_with_dry_run "${DRY_RUN}" "curl --silent '${BINARY_URL}' -o '${BIN_PATH}${BINARY_NAME}'" + exec_with_dry_run "${DRY_RUN}" "rm -f '${LN_PATH}${BINARY_SHORT_NAME}'" + exec_with_dry_run "${DRY_RUN}" "ln -s '${BIN_PATH}${BINARY_NAME}' '${LN_PATH}${BINARY_SHORT_NAME}'" + done +} + main () { [[ -f ./libs/shflags ]] && . ./libs/shflags || eval "$(curl --silent https://git.g3e.fr/H6N/tools/raw/branch/main/libs/shflags)" @@ -45,6 +72,7 @@ main () { DEFINE_string 'git_server' 'https://git.g3e.fr/' 'Git Server' 'g' DEFINE_string 'repo_path' 'syonad/two/' 'Path of repository' 'r' DEFINE_string 'branch' 'main/' 'Branch name' 'b' + DEFINE_string 'tag' '' 'Tag name' 't' FLAGS "$@" || exit $? eval set -- "${FLAGS_ARGV}" @@ -52,9 +80,11 @@ main () { SCRIPT_URL="${FLAGS_git_server}${FLAGS_repo_path}raw/branch/${FLAGS_branch}${SCRIPT_PATH}" check_latest_script "${SCRIPT_URL}" "${0}" || ( [[ ${FLAGS_up_script} -eq ${FLAGS_TRUE} ]] && \ - exec_with_dry_run "${FLAGS_dryrun}" "curl --silent \"${SCRIPT_URL}\" -o \"${0}\"" + exec_with_dry_run "${FLAGS_dryrun}" "curl --silent '${SCRIPT_URL}' -o '${0}'" exit 1 ) + + download_binaries "${FLAGS_dryrun}" "${FLAGS_tag}" "${FLAGS_git_server}" "${FLAGS_repo_path}" } [[ "${BASH_SOURCE[0]}" == "${0}" ]] && (main "$@" || exit 1) -- 2.49.1