mirror of
https://github.com/telekom-security/tpotce.git
synced 2025-11-02 13:32:53 +00:00
Compare commits
1 commit
0bcc325c69
...
3198215ee2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3198215ee2 |
1 changed files with 51 additions and 61 deletions
112
install.sh
112
install.sh
|
|
@ -1,77 +1,67 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
print_help() {
|
|
||||||
cat <<EOF
|
|
||||||
Usage: $0 [-s] -t <type> [-u <webuser>] [-p <password>]
|
|
||||||
|
|
||||||
Options:
|
print_help() {
|
||||||
-s Suppress installation confirmation prompt (sets myQST=y)
|
echo "Usage: $0 [-s y|n] [-t h|s|l|i|m|t] -u <webuser name> -p <password for web user>"
|
||||||
-t <type> Type of installation (required if -s is used):
|
echo " -s: Supress Install(y/n) question. Value accepted: yes or no (optional)"
|
||||||
h - hive (requires -u and -p)
|
echo " -t: Type of installation. Value accepted: h (hive),s (sensor), l (llm), i(mini),m(mobile),t(tarpit) (optional)"
|
||||||
s - sensor (no user/pass required)
|
echo " -u: web username (mandatory for hive installation, otherwirse optional)"
|
||||||
l - llm (requires -u and -p)
|
echo " -p: password for web user (mandatory for hive installation, otherwirse optional)"
|
||||||
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_type() {
|
validate_s() {
|
||||||
[[ "$myTPOT_TYPE" =~ ^[hslimtHSLIMT]$ ]] || {
|
if [[ -n "$myQST" ]]; then
|
||||||
echo "Invalid installation type: $myTPOT_TYPE"
|
if [[ "$myQST" =~ ^[yYnN]$ ]]; then
|
||||||
|
return 1 # Valid
|
||||||
|
else
|
||||||
|
print_help
|
||||||
|
fi
|
||||||
|
else
|
||||||
print_help
|
print_help
|
||||||
}
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Defaults
|
validate_t() {
|
||||||
myQST=""
|
if [[ -n "$myTPOT_TYPE" ]]; then
|
||||||
myTPOT_TYPE=""
|
if [[ "$myTPOT_TYPE" =~ ^[hslimtHSLIMT]$ ]]; then
|
||||||
myWEB_USER=""
|
return 1 # Valid
|
||||||
myWEB_PW=""
|
else
|
||||||
|
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="y"
|
myQST="${OPTARG}"
|
||||||
;;
|
validate_s
|
||||||
t)
|
;;
|
||||||
myTPOT_TYPE="${OPTARG,,}"
|
t)
|
||||||
validate_type
|
myTPOT_TYPE="${OPTARG}"
|
||||||
;;
|
validate_t
|
||||||
u)
|
;;
|
||||||
export myWEB_USER="${OPTARG}"
|
u)
|
||||||
;;
|
export myWEB_USER="${OPTARG}"
|
||||||
p)
|
;;
|
||||||
export myWEB_PW="${OPTARG}"
|
p)
|
||||||
;;
|
export myWEB_PW="${OPTARG}"
|
||||||
h|\?)
|
;;
|
||||||
print_help
|
:)
|
||||||
;;
|
echo "Option -${OPTARG} requires an argument."
|
||||||
:)
|
print_help
|
||||||
echo "Option -${OPTARG} requires an argument."
|
exit 1
|
||||||
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"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue