Update install.sh

I tested it extensively and made some adjustments.
Let me know if it works for your tests as well and merge it into the PR.
Thanks for taking the time!
This commit is contained in:
Marco Ochse 2025-07-04 19:47:32 +02:00 committed by GitHub
parent 7c912e656f
commit 0bb6e50930
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,67 +1,77 @@
#!/usr/bin/env bash #!/usr/bin/env bash
print_help() { print_help() {
echo "Usage: $0 [-s y|n] [-t h|s|l|i|m|t] -u <webuser name> -p <password for web user>" cat <<EOF
echo " -s: Supress Install(y/n) question. Value accepted: yes or no (optional)" Usage: $0 [-s] -t <type> [-u <webuser>] [-p <password>]
echo " -t: Type of installation. Value accepted: h (hive),s (sensor), l (llm), i(mini),m(mobile),t(tarpit) (optional)"
echo " -u: web username (mandatory for hive installation, otherwirse optional)" Options:
echo " -p: password for web user (mandatory for hive installation, otherwirse optional)" -s Suppress installation confirmation prompt (sets myQST=y)
-t <type> Type of installation (required if -s is used):
h - hive (requires -u and -p)
s - sensor (no user/pass required)
l - llm (requires -u and -p)
i - mini (requires -u and -p)
m - mobile (no user/pass required)
t - tarpit (requires -u and -p)
-u <webuser> Web interface username (required for h/l/i/t)
-p <password> Web interface password (required for h/l/i/t)
-h Show this help message
EOF
exit 1 exit 1
} }
validate_s() { validate_type() {
if [[ -n "$myQST" ]]; then [[ "$myTPOT_TYPE" =~ ^[hslimtHSLIMT]$ ]] || {
if [[ "$myQST" =~ ^[yYnN]$ ]]; then echo "Invalid installation type: $myTPOT_TYPE"
return 1 # Valid
else
print_help
fi
else
print_help print_help
fi }
} }
validate_t() { # Defaults
if [[ -n "$myTPOT_TYPE" ]]; then myQST=""
if [[ "$myTPOT_TYPE" =~ ^[hslimtHSLIMT]$ ]]; then myTPOT_TYPE=""
return 1 # Valid myWEB_USER=""
else myWEB_PW=""
print_help
fi
else
print_help
fi
} while getopts ":st:u:p:h" opt; do
while getopts ":s:t:u:p:" opt; do
case "$opt" in case "$opt" in
s) s)
myQST="${OPTARG}" myQST="y"
validate_s ;;
;; t)
t) myTPOT_TYPE="${OPTARG,,}"
myTPOT_TYPE="${OPTARG}" validate_type
validate_t ;;
;; u)
u) export myWEB_USER="${OPTARG}"
export myWEB_USER="${OPTARG}" ;;
;; p)
p) export myWEB_PW="${OPTARG}"
export myWEB_PW="${OPTARG}" ;;
;; h|\?)
:) print_help
echo "Option -${OPTARG} requires an argument." ;;
print_help :)
exit 1 echo "Option -${OPTARG} requires an argument."
;; print_help
\?) ;;
print_help
;;
esac esac
done done
# -s requires -t
if [[ "$myQST" == "y" && -z "$myTPOT_TYPE" ]]; then
echo "Error: -t is required when using -s to suppress interaction."
print_help
fi
# Determine if user/pass are required based on install type
if [[ "$myTPOT_TYPE" =~ ^[hlit]$ ]]; then
[[ -n "$myWEB_USER" && -n "$myWEB_PW" ]] || {
echo "Error: -u and -p are required for installation type '$myTPOT_TYPE'."
print_help
}
fi
myINSTALL_NOTIFICATION="### Now installing required packages ..." myINSTALL_NOTIFICATION="### Now installing required packages ..."
myUSER=$(whoami) myUSER=$(whoami)
myTPOT_CONF_FILE="/home/${myUSER}/tpotce/.env" myTPOT_CONF_FILE="/home/${myUSER}/tpotce/.env"