Update install.sh
This commit is contained in:
35
install.sh
35
install.sh
@@ -1,33 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
PREFIX_BIN="/usr/local/bin"
|
||||
BIN_DIR="/usr/local/bin"
|
||||
SYSTEMD_DIR="/etc/systemd/system"
|
||||
|
||||
SCRIPT_NAME="killsw"
|
||||
TARGET_NAME="killswitch.target"
|
||||
|
||||
# assume running from repo root
|
||||
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
main_script="$(find "$REPO_DIR" -maxdepth 1 -type f -name "killswitch*" ! -name "*.target" | head -n 1)"
|
||||
target_file="$(find "$REPO_DIR" -maxdepth 1 -type f -name "*.target" | head -n 1)"
|
||||
# install binary
|
||||
install -m 755 "$REPO_DIR/$SCRIPT_NAME" "$BIN_DIR/$SCRIPT_NAME"
|
||||
|
||||
if [[ -z "${main_script:-}" ]]; then
|
||||
echo "main script not found"
|
||||
exit 1
|
||||
fi
|
||||
# install systemd target
|
||||
install -m 644 "$REPO_DIR/$TARGET_NAME" "$SYSTEMD_DIR/$TARGET_NAME"
|
||||
|
||||
if [[ -z "${target_file:-}" ]]; then
|
||||
echo "systemd target not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "installing cli"
|
||||
install -m 755 "$main_script" "$PREFIX_BIN/$(basename "$main_script")"
|
||||
|
||||
echo "installing systemd target"
|
||||
install -m 644 "$target_file" "$SYSTEMD_DIR/$(basename "$target_file")"
|
||||
|
||||
echo "reloading systemd"
|
||||
# reload systemd daemon
|
||||
systemctl daemon-reload
|
||||
|
||||
echo "done"
|
||||
echo "binary: $PREFIX_BIN/$(basename "$main_script")"
|
||||
echo "target: $SYSTEMD_DIR/$(basename "$target_file")"
|
||||
echo "Installation complete."
|
||||
echo "CLI: $BIN_DIR/$SCRIPT_NAME"
|
||||
echo "Systemd target: $SYSTEMD_DIR/$TARGET_NAME"
|
||||
Reference in New Issue
Block a user