🗃️ Committing everything that changed 🗃️

rootfs/root/docker/setup/05-custom.sh
This commit is contained in:
casjay 2024-08-11 16:00:51 -04:00
parent a93054ad31
commit 878f6b4319
Signed by untrusted user who does not match committer: jason
GPG Key ID: 1AB309F42A764145

View File

@ -23,16 +23,12 @@ set -e -o pipefail
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS [ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set env variables # Set env variables
GET_ARCH="$(uname -m | tr '[:upper]' '[:lower]')"
case "$GET_ARCH" in
x86_64) ARCH="amd64" && unset GET_ARCH ;;
aarch64) ARCH="arm64" && unset GET_ARCH ;;
*) echo "$GET_ARCH is not supported by this script" >&2 && exit 1 ;;
esac
exitCode=0 exitCode=0
GITEA_VERSION="${GITEA_VERSION:-latest}" GITEA_VERSION="${GITEA_VERSION:-latest}"
GITEA_BIN_FILE="/usr/local/bin/gitea" GITEA_BIN_FILE="/usr/local/bin/gitea"
ACT_BIN_FILE="/usr/local/bin/act_runner" ACT_BIN_FILE="/usr/local/bin/act_runner"
ARCH="$(uname -m | tr '[:upper]' '[:lower]')"
case "$ARCH" in x86_64) ARCH="amd64" ;; aarch64) ARCH="arm64" ;; *) echo "$ARCH is not supported by this script" >&2 && exit 1 ;; esac
ACT_VERSIONS="$(curl -q -LSsf 'https://gitea.com/api/v1/repos/gitea/act_runner/releases' -H 'accept: application/json' | jq -r '.[].tag_name' | sort -Vr | head -n1)" ACT_VERSIONS="$(curl -q -LSsf 'https://gitea.com/api/v1/repos/gitea/act_runner/releases' -H 'accept: application/json' | jq -r '.[].tag_name' | sort -Vr | head -n1)"
ACT_URL="$(curl -q -LSsf "https://gitea.com/api/v1/repos/gitea/act_runner/releases/tags/$ACT_VERSIONS" -H 'accept: application/json' | jq -rc '.assets|.[]|.browser_download_url' | grep "linux.*$ARCH$")" ACT_URL="$(curl -q -LSsf "https://gitea.com/api/v1/repos/gitea/act_runner/releases/tags/$ACT_VERSIONS" -H 'accept: application/json' | jq -rc '.assets|.[]|.browser_download_url' | grep "linux.*$ARCH$")"
if [ "$GITEA_VERSION" = "latest" ] || [ "$GITEA_VERSION" = "current" ]; then if [ "$GITEA_VERSION" = "latest" ] || [ "$GITEA_VERSION" = "current" ]; then
@ -43,20 +39,28 @@ fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Main script # Main script
echo "Dowloading gitea from $GITEA_URL" echo "Dowloading gitea from $GITEA_URL"
curl -q -LSsf "$GITEA_URL" -o "$GITEA_BIN_FILE" && GITEA=true || echo "Failed to download gitea" >&2 if curl -q -LSsf "$GITEA_URL" -o "$GITEA_BIN_FILE"; then
echo "Downloading act_runner from $ACT_URL" echo "gitea has been installed to: $GITEA_BIN_FILE"
curl -q -LSsf "$ACT_URL" -o "$ACT_BIN_FILE" && ACT=true || echo "Failed to download act_runner" >&2 chmod +x "$GITEA_BIN_FILE"
if [ "$GITEA" = true ] && [ "$ACT" = true ]; then
chmod +x "$GITEA_BIN_FILE" "$ACT_BIN_FILE"
if [ -d "/etc/sudoers.d" ]; then if [ -d "/etc/sudoers.d" ]; then
echo "gitea ALL=(ALL) NOPASSWD: ALL" >"/etc/sudoers.d/gitea" echo "gitea ALL=(ALL) NOPASSWD: ALL" >"/etc/sudoers.d/gitea"
echo "docker ALL=(ALL) NOPASSWD: ALL" >"/etc/sudoers.d/docker" echo "docker ALL=(ALL) NOPASSWD: ALL" >"/etc/sudoers.d/docker"
fi fi
else else
exitCode=5 echo "Failed to download gitea" >&2
exitCode=$((exitCode++))
fi fi
echo "Downloading act_runner from $ACT_URL"
if curl -q -LSsf "$ACT_URL" -o "$ACT_BIN_FILE"; then
echo "act_runner has been installed to: $ACT_BIN_FILE"
chmod +x "$ACT_BIN_FILE"
else
echo "Failed to download act_runner" >&2
exitCode=$((exitCode++))
fi
[ -x "$ACT_BIN_FILE" ] && [ -x "$GITEA_BIN_FILE" ] && exitCode=0
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set the exit code # Set the exit code
[ $exitCode -eq 0 ] && [ -x "$ACT_BIN_FILE" ] && [ -x "$ACT_BIN_FILE" ] && echo "gitea has been installed to: $GITEA_BIN_FILE" || echo "Failed to install gitea or act_runner" >&2 [ $exitCode -eq 0 ] || exitCode=1
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
exit $exitCode exit $exitCode