From dabe5fb0042ad306b0d8eedc143c55fb4b830629 Mon Sep 17 00:00:00 2001 From: Ben de Roo Date: Tue, 24 Mar 2026 18:20:17 +0100 Subject: [PATCH] Update install.sh --- install.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/install.sh b/install.sh index cd677c7..21bddc0 100644 --- a/install.sh +++ b/install.sh @@ -1,2 +1,35 @@ # this script automaticly sets up the progam and makes it executeable. +#!/usr/bin/env bash +set -euo pipefail + +PREFIX_BIN="/usr/local/bin" +SYSTEMD_DIR="/etc/systemd/system" + +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)" + +if [[ -z "${main_script:-}" ]]; then + echo "main script not found" + exit 1 +fi + +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" +systemctl daemon-reload + +echo "done" +echo "binary: $PREFIX_BIN/$(basename "$main_script")" +echo "target: $SYSTEMD_DIR/$(basename "$target_file")" \ No newline at end of file