mirror of
https://github.com/casjaysdevdocker/forgejo
synced 2025-10-07 10:17:28 -04:00
🦈🏠🐜❗ Initial Commit ❗🐜🦈🏠
This commit is contained in:
74
rootfs/root/docker/setup/05-custom.sh
Executable file
74
rootfs/root/docker/setup/05-custom.sh
Executable file
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck shell=bash
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
##@Version : 202509172108-git
|
||||
# @@Author : CasjaysDev
|
||||
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
|
||||
# @@License : MIT
|
||||
# @@Copyright : Copyright 2025 CasjaysDev
|
||||
# @@Created : Wed Sep 17 09:08:33 PM EDT 2025
|
||||
# @@File : 05-custom.sh
|
||||
# @@Description : script to run custom
|
||||
# @@Changelog : newScript
|
||||
# @@TODO : Refactor code
|
||||
# @@Other : N/A
|
||||
# @@Resource : N/A
|
||||
# @@Terminal App : yes
|
||||
# @@sudo/root : yes
|
||||
# @@Template : templates/dockerfiles/init_scripts/05-custom.sh
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2120,SC2155,SC2199,SC2317,SC2329
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Set bash options
|
||||
set -o pipefail
|
||||
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Set env variables
|
||||
exitCode=0
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Predefined actions
|
||||
FORGEJO_VERSION="${FORGEJO_VERSION:-latest}"
|
||||
FORGEJO_BIN_FILE="/usr/local/bin/forgejo"
|
||||
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_URL="$(curl -q -LSsf -H 'accept: application/json' "https://code.forgejo.org/api/v1/repos/forgejo/runner/releases" | jq -r '.[].assets[] | select(.name|match("linux.*'${ARCH}'$")) | .browser_download_url' | head -n1)"
|
||||
if [ "$FORGEJO_VERSION" = "latest" ] || [ "$FORGEJO_VERSION" = "current" ]; then
|
||||
FORGEJO_URL="$(curl -q -LSsf -H 'accept: application/json' 'https://code.forgejo.org/api/v1/repos/forgejo/forgejo/releases' | jq -r '.[].assets[] | select(.name|match("linux.*'${ARCH}'$")) | .browser_download_url' | head -n1)"
|
||||
else
|
||||
FORGEJO_URL="https://code.forgejo.org/forgejo/forgejo/releases/download/v$FORGEJO_VERSION/forgejo-$FORGEJO_VERSION-linux-$ARCH"
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Main script
|
||||
echo "Dowloading forgejo from $FORGEJO_URL"
|
||||
if curl -q -LSsf "$FORGEJO_URL" -o "/tmp/forgejo.$$"; then
|
||||
mv -f "/tmp/forgejo.$$" "$FORGEJO_BIN_FILE"
|
||||
echo "forgejo has been installed to: $FORGEJO_BIN_FILE"
|
||||
chmod +x "$FORGEJO_BIN_FILE"
|
||||
if [ -d "/etc/sudoers.d" ]; then
|
||||
echo "git ALL=(ALL) NOPASSWD: ALL" >"/etc/sudoers.d/git"
|
||||
echo "docker ALL=(ALL) NOPASSWD: ALL" >"/etc/sudoers.d/docker"
|
||||
fi
|
||||
else
|
||||
echo "Failed to download forgejo" >&2
|
||||
exitCode=$((exitCode++))
|
||||
fi
|
||||
echo "Downloading act_runner from $ACT_URL"
|
||||
if curl -q -LSsf "$ACT_URL" -o "/tmp/act_runner.$$"; then
|
||||
mv -f "/tmp/act_runner.$$" "$ACT_BIN_FILE"
|
||||
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 "$FORGEJO_BIN_FILE" ] && exitCode=0
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Set the exit code
|
||||
#exitCode=$?
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
exit $exitCode
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# ex: ts=2 sw=2 et filetype=sh
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
Reference in New Issue
Block a user