-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.sh
executable file
·86 lines (71 loc) · 1.98 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
#!/usr/bin/env bash
# Checking if the script is runned as root (via sudo or other)
if [[ $(id -u) != 0 ]]
then
echo "Please run the installation script as root (using sudo for example)"
exit 1
fi
if [[ $(apt install 2>/dev/null) ]]; then
echo 'apt is here' && apt -y install libevdev2 python3-libevdev
elif [[ $(pacman -h 2>/dev/null) ]]; then
echo 'pacman is here' && pacman --noconfirm -S libevdev python-libevdev
elif [[ $(dnf help 2>/dev/null) ]]; then
echo 'dnf is here' && dnf -y install libevdev python-libevdev
fi
if [[ -d conf/__pycache__ ]] ; then
rm -rf conf/__pycache__
fi
echo
echo "Select configuration layout:"
PS3='Please enter your choice '
options=($(ls conf) "Quit")
select selected_opt in "${options[@]}"
do
if [ "$selected_opt" = "Quit" ]
then
exit 0
fi
for option in $(ls conf);
do
if [ "$option" = "$selected_opt" ] ; then
model=${selected_opt::-3}
break
fi
done
if [ -z "$model" ] ; then
echo "invalid option $REPLY"
else
break
fi
done
echo "Add asus fliplock service in /etc/systemd/system/"
cat asus_fliplock.service | LAYOUT=$model envsubst '$LAYOUT' > /etc/systemd/system/asus_fliplock.service
mkdir -p /usr/share/asus_fliplock-driver/conf
mkdir -p /var/log/asus_fliplock-driver
install asus_fliplock.py /usr/share/asus_fliplock-driver/
install -t /usr/share/asus_fliplock-driver/conf conf/*.py
systemctl daemon-reload
if [[ $? != 0 ]]; then
echo "Something went wrong when was called systemctl daemon reload"
exit 1
else
echo "Systemctl daemon realod called succesfully"
fi
systemctl enable asus_fliplock
if [[ $? != 0 ]]
then
echo "Something gone wrong while enabling asus_fliplock.service"
exit 1
else
echo "Asus fliplock service enabled"
fi
systemctl restart asus_fliplock
if [[ $? != 0 ]]
then
echo "Something gone wrong while enabling asus_fliplock.service"
exit 1
else
echo "Asus fliplock service started"
fi
echo "Install finished"
exit 0