67 lines
1.3 KiB
Bash
Executable file
67 lines
1.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# CONSTANTS
|
|
readonly PKGVER="0.0.1"
|
|
readonly LICENSE="GNU AGPLv3"
|
|
readonly ROOTPATH="$(dirname $(readlink -f $(which ${0})))"
|
|
readonly CONFIG="/usr/local/noveria/etc/raclette/config.json"
|
|
|
|
# VARIABLES
|
|
declare testmode=0
|
|
|
|
function usage() {
|
|
cat << EOF
|
|
Usage: $(basename ${0}) [options] <function> [arguments]
|
|
|
|
$(basename $0) is used to execute module functions locally on a Raclette Minion
|
|
|
|
Options:
|
|
--version show program's version number and exit
|
|
-h, --help show this help message and exit
|
|
EOF
|
|
}
|
|
|
|
function version() {
|
|
cat << EOF
|
|
Raclette v${PKGVER}
|
|
Copyright (C) 2024 Noveria Network
|
|
|
|
This program may be freely redistributed under
|
|
the terms of the ${LICENSE}
|
|
EOF
|
|
}
|
|
|
|
###
|
|
## SCRIPT START
|
|
###
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$(echo $1 | cut -d. -f1 | cut -d= -f1)" in
|
|
-h|--help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
--version)
|
|
version
|
|
exit 0
|
|
;;
|
|
state)
|
|
command="$(echo $1 | cut -d. -f2)"
|
|
;;
|
|
test)
|
|
if [[ "$(echo $1 | cut -d= -f2)" == "false" ]]; then
|
|
testmode=0
|
|
else
|
|
testmode=1
|
|
fi
|
|
;;
|
|
*)
|
|
echo "Invalid argument. Type $(basename $0) -h for help!"
|
|
exit 1
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
source ${ROOTPATH}/functions/call/$command
|
|
state_${command} $@
|