-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·47 lines (35 loc) · 936 Bytes
/
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
#!/bin/sh
INSTALL_DIR="/opt/acpi_wakeup"
CONFIG="acpi_wakeup.conf"
CONFIG_DIR="/etc"
SERVICE="acpi_wakeup.service"
SERVICE_DIR="/etc/systemd/system"
if [ $(id -u) != 0 ]; then
echo "root required!"
exit
fi
if ! pidof systemd 2>&1 1>/dev/null; then
echo "Systemd is required!"
exit
fi
echo "Installing in $INSTALL_DIR"
systemctl stop "$SERVICE" >/dev/null 2>&1
mkdir -p "$INSTALL_DIR" >/dev/null 2>&1
set -e
cd "$(dirname "$0")"
cp -f ./acpi_wakeup.py ./LICENSE ./README.md ./install.sh "$INSTALL_DIR"
cp -f ./$SERVICE "$SERVICE_DIR"
if [ ! -f "$CONFIG_DIR/$CONFIG" ]; then
echo "Copying config to $CONFIG_DIR/$CONFIG"
cp ./$CONFIG "$CONFIG_DIR/$CONFIG"
else
echo "Config already exists at $CONFIG_DIR/$CONFIG"
fi
echo "Building virtual env"
cd "$INSTALL_DIR"
python3 -m venv venv
. ./venv/bin/activate
systemctl daemon-reload
systemctl enable "$SERVICE"
systemctl start "$SERVICE"
echo "Success"