2023-10-11 15:39:52 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
VERBOSE=false
|
|
|
|
DEBUG=false
|
|
|
|
: ${EXIT_ON_ERROR:=true}
|
|
|
|
|
|
|
|
function debug() {
|
|
|
|
DEBUG=true
|
|
|
|
set -x
|
|
|
|
PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}: '
|
|
|
|
}
|
|
|
|
|
|
|
|
function verbose() {
|
|
|
|
VERBOSE=true
|
|
|
|
}
|
|
|
|
|
|
|
|
function log() {
|
|
|
|
echo "$@" >&2
|
|
|
|
}
|
|
|
|
|
|
|
|
function log_error() {
|
|
|
|
log "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
function log_verbose() {
|
|
|
|
if $VERBOSE ; then
|
|
|
|
log "$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function log_info() {
|
|
|
|
log "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
function fatal_error() {
|
|
|
|
log_error "$@"
|
|
|
|
if $EXIT_ON_ERROR ; then
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function push_self() {
|
|
|
|
local host_port=$1
|
|
|
|
|
|
|
|
forgejo-test-helper.sh push_self_action http://root:admin1234@$host_port root cascading-pr vTest
|
|
|
|
}
|
|
|
|
|
|
|
|
function run() {
|
|
|
|
local host_port=$1 url=$2 token=$3
|
|
|
|
|
|
|
|
push_self $host_port
|
|
|
|
|
|
|
|
echo do something
|
|
|
|
}
|
|
|
|
|
|
|
|
function main() {
|
|
|
|
local command=run
|
|
|
|
local host_port=$(cat forgejo-ip):3000
|
|
|
|
local url=http://$host_port
|
|
|
|
local token=$(cat forgejo-token)
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
case "$1" in
|
|
|
|
--verbose)
|
|
|
|
shift
|
|
|
|
verbose
|
|
|
|
;;
|
|
|
|
--debug)
|
|
|
|
shift
|
|
|
|
debug
|
|
|
|
;;
|
2023-10-11 15:50:12 +02:00
|
|
|
--host_port)
|
|
|
|
shift
|
|
|
|
host_port=$1
|
|
|
|
;;
|
|
|
|
--url)
|
|
|
|
shift
|
|
|
|
url=$1
|
|
|
|
;;
|
|
|
|
--token)
|
|
|
|
shift
|
|
|
|
token=$1
|
|
|
|
;;
|
2023-10-11 15:39:52 +02:00
|
|
|
*)
|
|
|
|
"${1:-run}" "$host_port" "$url" "$token"
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
${MAIN:-main} "${@}"
|