forked from NeroReflex/ROGueENEMY
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
88 lines (69 loc) · 2.18 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
# Define variables
REPO_URL="https://github.com/corando98/ROGueENEMY"
BUILD_DIR="/tmp/ROGueENEMY"
INSTALL_DIR="/usr/bin"
SYSTEMD_DIR="/etc/systemd/system"
UDEV_RULES_DIR="/usr/lib/udev/rules.d"
CONFIG_DIR="/etc/ROGueENEMY"
echo "Starting installation of ROGueENEMY..."
echo "Disabling handycon..."
systemctl disable --now handycon.service
# Ensure running as root
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root." >&2
exit 1
fi
echo "Installing dependencies..."
# apt-get update
# apt-get install -y cmake libconfig-dev libevdev libconfig git
# Preparation
echo "Preparing installation..."
echo "Preparing installation..."
rm -rf "$BUILD_DIR"
git clone "$REPO_URL" "$BUILD_DIR"
echo "Copying udev rule..."
cp "$BUILD_DIR/99-rogue.rules" "$UDEV_RULES_DIR"
cp "$BUILD_DIR/99-disable-sonypad.rules" "$UDEV_RULES_DIR"
echo "Downloading the latest release..."
echo "Downloading the latest release..."
curl -L $(curl -s https://api.github.com/repos/corando98/ROGueENEMY/releases/latest | grep "browser_download_url" | cut -d '"' -f 4) -o $BUILD_DIR/rogue-enemy
# Installation
echo "Installing executable..."
mkdir -p "$INSTALL_DIR"
cp "$BUILD_DIR/rogue-enemy" "$INSTALL_DIR/rogue-enemy"
chmod +x $INSTALL_DIR/rogue-enemy
echo "Creating and setting up system service..."
echo "Setting up system service..."
mkdir -p "$SYSTEMD_DIR"
mkdir -p "$UDEV_RULES_DIR"
mkdir -p "$CONFIG_DIR"
# Create systemd service file
cat <<EOF > "$SYSTEMD_DIR/rogue-enemy.service"
[Unit]
Description=ROGueENEMY service
[Service]
Type=simple
Nice=-15
Restart=always
RestartSec=5
WorkingDirectory=$INSTALL_DIR
ExecStart=$INSTALL_DIR/rogue-enemy
[Install]
WantedBy=multi-user.target
EOF
# Install other files
install -m 644 "$BUILD_DIR/99-rogue.rules" "$UDEV_RULES_DIR/"
# Uncomment the following if the configuration file is necessary
# install -m 644 "$BUILD_DIR/config.cfg" "$CONFIG_DIR/config.cfg"
# Post-installation
echo "Reloading system daemons and applying new udev rules..."
systemctl daemon-reload
systemctl enable rogue-enemy.service
systemctl start rogue-enemy.service
udevadm control --reload-rules
udevadm trigger
# Cleanup
echo "Cleaning up..."
rm -rf "$BUILD_DIR"
echo "Installation complete."