From bfeef66b0b220792cea49c397779af993429032f Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Fri, 29 Mar 2024 16:50:35 +0900 Subject: [PATCH] Add all files --- ReadMe.md | 9 +++++++++ download.sh | 14 ++++++++++++++ init.sh | 23 +++++++++++++++++++++++ install.sh | 13 +++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 ReadMe.md create mode 100755 download.sh create mode 100644 init.sh create mode 100755 install.sh diff --git a/ReadMe.md b/ReadMe.md new file mode 100644 index 0000000..35528a0 --- /dev/null +++ b/ReadMe.md @@ -0,0 +1,9 @@ +# Download and install gitea + +In `init.sh` set the `download_folder` and `target_file` + +Only arm and x86 are auto detected + +Run `download.sh` to download the latest file. Fill re-download as a different name if the same file is requested + +Run `install.sh ` to install the newest version diff --git a/download.sh b/download.sh new file mode 100755 index 0000000..b434299 --- /dev/null +++ b/download.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +BASE_FOLDER=$(dirname "$(readlink -f "$0")")"/"; +. "${BASE_FOLDER}init.sh"; + +cd "${download_folder}"; +curl -s https://api.github.com/repos/go-gitea/gitea/releases/latest |\ + grep browser_download_url |\ + cut -d '"' -f 4 |\ + grep "${arch}$" |\ + wget -P "${download_folder}" -i - +cd -; + +# __END__ diff --git a/init.sh b/init.sh new file mode 100644 index 0000000..86d5e75 --- /dev/null +++ b/init.sh @@ -0,0 +1,23 @@ +CPU_ARCH="" +# get the architecture +_cpu_arch=$(uname -m); +# weg get like x86_64 or x86_32 (NO), aarch64, etc +# we ONLY allow x86_64 or aarch64 +# possible add: arm64 +if [ "${_cpu_arch}" = "x86_64" ]; then + CPU_ARCH="amd64"; +elif [ "${_cpu_arch}" = "aarch64" ]; then + CPU_ARCH="arm64"; +else + echo "Not supported architecture: ${_cpu_arch}"; + exit; +fi; +arch="linux-${CPU_ARCH}"; +download_folder="/opt/downloads/gitea/"; +if [ ! -d "${download_folder}" ]; then + echo "Download folder ${download_folder} missing"; + exit; +fi; +target_file="/usr/local/bin/gitea"; + +# __END__ diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..13fca46 --- /dev/null +++ b/install.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +BASE_FOLDER=$(dirname "$(readlink -f "$0")")"/"; +. "${BASE_FOLDER}init.sh"; + +echo -e "Update gitea to ${1} ... "; +systemctl stop gitea; +cp "${download_folder}gitea-${1}-${arch}" "${target_file}"; +chmod +x "${target_file}"; +systemctl start gitea; +echo "[DONE]"; + +# __END__