forked from p34709852/monkey
Deploy: Set appimage executable, rename assert_flag to assert_parameter_supplied
This commit is contained in:
parent
a671c11f74
commit
4f3b2253d5
|
@ -61,23 +61,21 @@ uninstall_service() {
|
||||||
echo "The Infection Monkey service has been uninstalled"
|
echo "The Infection Monkey service has been uninstalled"
|
||||||
}
|
}
|
||||||
|
|
||||||
user_can_execute() {
|
|
||||||
sudo -u "$1" test -x "$2"
|
|
||||||
}
|
|
||||||
|
|
||||||
move_appimage() {
|
move_appimage() {
|
||||||
sudo mkdir -p "${MONKEY_BIN}"
|
sudo mkdir -p "${MONKEY_BIN}"
|
||||||
|
|
||||||
if [ "$1" != "${MONKEY_BIN}/${APPIMAGE_NAME}" ] ; then
|
if [ "$1" != "${MONKEY_BIN}/${APPIMAGE_NAME}" ] ; then
|
||||||
sudo cp "$appimage_path" "${MONKEY_BIN}/${APPIMAGE_NAME}"
|
sudo cp "$appimage_path" "${MONKEY_BIN}/${APPIMAGE_NAME}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
sudo chmod a+x "${MONKEY_BIN}/${APPIMAGE_NAME}"
|
||||||
}
|
}
|
||||||
|
|
||||||
user_exists() {
|
user_exists() {
|
||||||
id -u "$1" &>/dev/null
|
id -u "$1" &>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_flag() {
|
assert_parameter_supplied() {
|
||||||
if [ -z "$2" ] ; then
|
if [ -z "$2" ] ; then
|
||||||
echo "Error: missing flag '$1'"
|
echo "Error: missing flag '$1'"
|
||||||
echo_help
|
echo_help
|
||||||
|
@ -142,8 +140,8 @@ if $do_uninstall ; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
assert_flag "--user" "$uname"
|
assert_parameter_supplied "--user" "$uname"
|
||||||
assert_flag "--appimage" "$appimage_path"
|
assert_parameter_supplied "--appimage" "$appimage_path"
|
||||||
|
|
||||||
if ! user_exists "$uname" ; then
|
if ! user_exists "$uname" ; then
|
||||||
echo "Error: User '$uname' does not exist"
|
echo "Error: User '$uname' does not exist"
|
||||||
|
@ -158,10 +156,5 @@ if [ ! -f "$appimage_path" ] ; then
|
||||||
appimage_path="${SCRIPT_DIR}/$appimage_path"
|
appimage_path="${SCRIPT_DIR}/$appimage_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! user_can_execute "$uname" "$appimage_path" ; then
|
|
||||||
echo "Error: User '$uname' does not have execute permission on '$appimage_path'"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
install_service "$uname" "$appimage_path"
|
install_service "$uname" "$appimage_path"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue