#!/bin/bash [[ ! $GITEA_DIR ]] && export GITEA_DIR="$(dirname "$(cd "$(dirname "$BASH_SOURCE")"; pwd -P)")" function version () { # https://askubuntu.com/a/952479/478337 [[ ! -f $GITEA_DIR/gitea.bin ]] && echo "" && return 2 CUR_VER=$($GITEA_DIR/gitea.bin -version | sed -nr 's:.*version ([^ ]+).*:\1:p') [ ! $CUR_VER ] && return 1 echo $CUR_VER } # sets global $OS function get_OS () { case "$OSTYPE" in # uncomment valid OS darwin*) OS=darwin ;; linux*) OS=linux ;; # msys*) OS=windows ;; *) ;; esac [ ! $OS ] && return 1 echo $OS } # sets global $ARCH function get_arch () { declare -A ARCHES #ARCHES=( ["arm64"]="arm64" ["aarch64"]="arm64" ["x86_64"]="amd64" ["armv61"]="armv6" ["armv71"]="armv7" ["arm32"]="armv7" ["armhf"]="armv7" ) # set valid architectures ARCHES=( ["arm64"]="arm64" ["aarch64"]="arm64" ["x86_64"]="amd64" ) ARCH=${ARCHES[$(uname -m)]} [ ! $ARCH ] && return 1 echo $ARCH } function set-env () { for f in $1/*.env; do source $f; done }