From fb792e0c38f5541ef814ec575d3d70df7718d4f6 Mon Sep 17 00:00:00 2001 From: cyber-sushi Date: Wed, 25 Dec 2024 14:02:42 +0100 Subject: [PATCH] Added install script --- install.sh | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100755 install.sh diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..83cd2b4 --- /dev/null +++ b/install.sh @@ -0,0 +1,89 @@ +#!/bin/sh + + +# Define variables +binary_name="makima" +service_name="makima.service" +rules_name="50-makima.rules" + + +# Check for root +if [ "$EUID" -ne 0 ]; then + echo "Please run this script with sudo." + exit +fi + + +# Function to display help +display_help() { + echo + echo "Install $binary_name system wide. Usage: $0 [|-u|-h]" + echo "Options:" + echo " -u Undo the changes made by the script" + echo " -h, --help Display this help message" + echo +} + + +# Function to undo changes +undo_changes() { + systemctl stop $service_name + systemctl disable $service_name + rm /usr/local/bin/$binary_name + rm /etc/udev/rules.d/$rules_name + rm /etc/systemd/system/$service_name + rm /etc/modules-load.d/uinput.conf + systemctl daemon-reload + echo "Uninstalled successfully." +} + + +# Check for arguments +if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then + display_help + exit +elif [ "$1" = "-u" ]; then + undo_changes + exit +elif [ -n "$1" ]; then + user_name="$1" +else + echo "Please provide a username to install $binary_name. Usage: $0 [|-u|-h]" + exit 1 +fi + + +# Copy the binary, udev rules and create the configuration folder +chmod +x "$binary_name" +cp "$binary_name" /usr/local/bin/ +cp "$rules_name" /etc/udev/rules.d/ +echo "uinput" > /etc/modules-load.d/uinput.conf +mkdir /home/"$user_name"/.config/makima + + +# Create the systemd unit file +tee "/etc/systemd/system/$service_name" > /dev/null <