Build: Use writable location for temporary systemd unit file

As set, the $SCRIPT_DIR was read-only (since the AppImage's squashfs is
readonly). Use $PWD instead.
This commit is contained in:
Mike Salvatore 2022-05-05 09:53:31 -04:00
parent 27ac518f2e
commit a81462e617
1 changed files with 4 additions and 4 deletions

View File

@ -3,8 +3,8 @@
set -e
SCRIPT_NAME="$(basename "${APPIMAGE}")"
SCRIPT_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
SYSTEMD_UNIT_FILENAME="infection-monkey.service"
TMP_SYSTEMD_UNIT="${PWD}/${SYSTEMD_UNIT_FILENAME}"
SYSTEMD_DIR="/lib/systemd/system"
MONKEY_BIN="/opt/infection-monkey/bin"
APPIMAGE_NAME="InfectionMonkey.AppImage"
@ -25,9 +25,9 @@ echo_help() {
install_service() {
move_appimage
umask 077
cat > "${SCRIPT_DIR}/${SYSTEMD_UNIT_FILENAME}" << EOF
umask 077
cat > "${TMP_SYSTEMD_UNIT}" << EOF
[Unit]
Description=Infection Monkey Runner
After=network.target
@ -41,7 +41,7 @@ ExecStart="${MONKEY_BIN}/${APPIMAGE_NAME}"
WantedBy=multi-user.target
EOF
sudo mv "${SCRIPT_DIR}/${SYSTEMD_UNIT_FILENAME}" "${SYSTEMD_DIR}/${SYSTEMD_UNIT_FILENAME}"
sudo mv "${TMP_SYSTEMD_UNIT}" "${SYSTEMD_DIR}/${SYSTEMD_UNIT_FILENAME}"
sudo systemctl enable "${SYSTEMD_UNIT_FILENAME}" &>/dev/null
echo -e "The Infection Monkey service has been installed and will start on boot.\n\