forked from p34709852/monkey
Build: Ensure either --install or --uninstall are specified
This commit is contained in:
parent
6d50814c19
commit
7e039f73ff
|
@ -13,12 +13,13 @@ echo_help() {
|
||||||
echo "Installs the Infection Monkey service to run on boot."
|
echo "Installs the Infection Monkey service to run on boot."
|
||||||
echo ""
|
echo ""
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo " ${SCRIPT_NAME} service --user <USERNAME>"
|
echo " ${SCRIPT_NAME} service --install --user <USERNAME>"
|
||||||
echo " ${SCRIPT_NAME} service --uninstall"
|
echo " ${SCRIPT_NAME} service --uninstall"
|
||||||
echo " ${SCRIPT_NAME} service -h|--help"
|
echo " ${SCRIPT_NAME} service -h|--help"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " --user Install Infection Monkey service and run as User"
|
echo " --install Install the Infection Monkey service"
|
||||||
|
echo " --user Configure the Infection Monkey service to run as a specific user"
|
||||||
echo " --uninstall Uninstall Infection Monkey service"
|
echo " --uninstall Uninstall Infection Monkey service"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +77,7 @@ user_exists() {
|
||||||
id -u "$1" &>/dev/null
|
id -u "$1" &>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# s/parameter/argument
|
||||||
assert_parameter_supplied() {
|
assert_parameter_supplied() {
|
||||||
if [ -z "$2" ] ; then
|
if [ -z "$2" ] ; then
|
||||||
echo "Error: missing required parameter '$1'"
|
echo "Error: missing required parameter '$1'"
|
||||||
|
@ -149,11 +151,17 @@ if $do_uninstall ; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
assert_parameter_supplied "--user" "$username"
|
if $do_install ; then
|
||||||
|
assert_parameter_supplied "--user" "$username"
|
||||||
|
|
||||||
if ! user_exists "$username" ; then
|
if ! user_exists "$username" ; then
|
||||||
echo "Error: User '$username' does not exist"
|
echo "Error: User '$username' does not exist"
|
||||||
exit 1
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
install_service "$username"
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
install_service "$username"
|
echo "You must specify either the --install or --uninstall flag"
|
||||||
|
exit 1
|
||||||
|
|
Loading…
Reference in New Issue