-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·206 lines (168 loc) · 7.22 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/usr/bin/env bash
source non_sudo_check.sh
START_TIME=${EPOCHREALTIME::-7}
# ENV VARS
if [ -z "$LOGS_DIR_PATH" ]; then
LOGS_DIR_PATH="/var/log/asus-dialpad-driver"
fi
source install_logs.sh
echo
# log output from every installing attempt aswell
LOGS_INSTALL_LOG_FILE_NAME=install-"$(date +"%d-%m-%Y-%H-%M-%S")".log
LOGS_INSTALL_LOG_FILE_PATH="$LOGS_DIR_PATH/$LOGS_INSTALL_LOG_FILE_NAME"
{
# pip pywayland requires gcc
if [[ $(command -v apt-get 2>/dev/null) ]]; then
PACKAGE_MANAGER="apt"
sudo apt-get -y install ibus libevdev2 curl xinput i2c-tools python3-dev python3-virtualenv libxml2-utils libxkbcommon-dev gcc pkg-config libsystemd-dev
# wayland (https://github.com/asus-linux-drivers/asus-numberpad-driver/issues/198#issuecomment-2483268464)
if [ "$XDG_SESSION_TYPE" == "wayland" ]; then
sudo apt-get -y install libwayland-dev
fi
elif [[ $(command -v pacman 2>/dev/null) ]]; then
PACKAGE_MANAGER="pacman"
# arch does not have header packages (python3-dev), headers are shipped with base? python package should contains almost latest version python3.*
sudo pacman --noconfirm --needed -S ibus libevdev curl xorg-xinput i2c-tools python python-virtualenv libxml2 libxkbcommon gcc pkgconf systemd
# wayland (https://github.com/asus-linux-drivers/asus-numberpad-driver/issues/198#issuecomment-2483268464)
if [ "$XDG_SESSION_TYPE" == "wayland" ]; then
sudo pacman --noconfirm --needed -S wayland
fi
elif [[ $(command -v dnf 2>/dev/null) ]]; then
# dnf5 has --help
# https://github.com/asus-linux-drivers/asus-numberpad-driver/issues/204
PACKAGE_MANAGER="dnf"
sudo dnf -y install ibus libevdev curl xinput i2c-tools python3-devel python3-virtualenv libxml2 libxkbcommon-devel gcc pkg-config systemd-devel
# wayland
if [ "$XDG_SESSION_TYPE" == "wayland" ]; then
sudo dnf -y install wayland-devel
fi
elif [[ $(command -v yum 2>/dev/null) ]]; then
PACKAGE_MANAGER="yum"
# yum was replaced with newer dnf above
sudo yum --y install ibus libevdev curl xinput i2c-tools python3-devel python3-virtualenv libxml2 libxkbcommon-devel gcc pkg-config systemd-devel
# wayland
if [ "$XDG_SESSION_TYPE" == "wayland" ]; then
sudo yum --y install wayland-devel
fi
elif [[ $(command -v zypper 2>/dev/null) ]]; then
PACKAGE_MANAGER="zypper"
sudo zypper --non-interactive install ibus libevdev2 curl xinput i2c-tools python3-devel python3-virtualenv libxml2 libxkbcommon-devel gcc pkg-config systemd-devel
# wayland
if [ "$XDG_SESSION_TYPE" == "wayland" ]; then
sudo zypper --non-interactive install wayland-devel
fi
elif [[ $(command -v xbps-install 2>/dev/null) ]]; then
PACKAGE_MANAGER="xbps-install"
sudo xbps-install -Suy ibus-devel libevdev-devel curl xinput i2c-tools python3-devel python3-virtualenv libxml2 libxkbcommon-devel gcc pkg-config systemd
# wayland
if [ "$XDG_SESSION_TYPE" == "wayland" ]; then
sudo xbps-install -Suy wayland-devel
fi
elif [[ $(command -v emerge 2>/dev/null) ]]; then
PACKAGE_MANAGER="portage"
sudo emerge app-i18n/ibus dev-libs/libevdev net-misc/curl x11-apps/xinput sys-apps/i2c-tools dev-lang/python dev-python/virtualenv dev-libs/libxml2 x11-libs/libxkbcommon sys-devel/gcc virtual/pkgconfig sys-apps/systemd
# wayland
if [ "$XDG_SESSION_TYPE" == "wayland" ]; then
sudo emerge dev-libs/wayland
fi
elif [[ $(command -v rpm-ostree 2>/dev/null) ]]; then
PACKAGE_MANAGER="rpm-ostree"
sudo rpm-ostree install xinput virtualenv python3-devel wayland-protocols-devel pkg-config systemd-devel
# wayland
if [ "$XDG_SESSION_TYPE" == "wayland" ]; then
sudo rpm-ostree install wayland-devel
fi
elif [[ $(command -v eopkg 2>/dev/null) ]]; then
PACKAGE_MANAGER="eopkg"
sudo eopkg install -y ibus libevdev curl xinput i2c-tools python3-devel python3-virtualenv libxml2-devel libxkbcommon-devel gcc pkg-config systemd-devel
# wayland
if [ "$XDG_SESSION_TYPE" == "wayland" ]; then
sudo eopkg install -y wayland-devel
fi
else
echo "Not detected package manager. Driver may not work properly because required packages have not been installed. Please create an issue (https://github.com/asus-linux-drivers/asus-dialpad-driver/issues)."
fi
if [[ $? != 0 ]]; then
echo "Something went wrong when installing packages"
source install_begin_send_anonymous_report.sh
exit 1
else
source install_begin_send_anonymous_report.sh
fi
echo
source install_user_groups.sh
echo
source install_device_check.sh
echo
# do not install __pycache__
if [[ -d layouts/__pycache__ ]]; then
rm -rf layouts/__pycache__
fi
# ENV VARS
if [ -z "$INSTALL_DIR_PATH" ]; then
INSTALL_DIR_PATH="/usr/share/asus-dialpad-driver"
fi
if [ -z "$CONFIG_FILE_DIR_PATH" ]; then
CONFIG_FILE_DIR_PATH="$INSTALL_DIR_PATH"
fi
if [ -z "$CONFIG_FILE_NAME" ]; then
CONFIG_FILE_NAME="dialpad_dev"
fi
CONFIG_FILE_PATH="$CONFIG_FILE_DIR_PATH/$CONFIG_FILE_NAME"
sudo mkdir -p "$INSTALL_DIR_PATH/layouts"
sudo chown -R $USER "$INSTALL_DIR_PATH"
sudo install dialpad.py "$INSTALL_DIR_PATH"
sudo install -t "$INSTALL_DIR_PATH/layouts" layouts/*.py
if [[ -f "$CONFIG_FILE_PATH" ]]; then
read -r -p "In system remains config file from previous installation. Do you want replace that config with default config? [y/N]" RESPONSE
case "$RESPONSE" in [yY][eE][sS]|[yY])
# default will be autocreated, that is why is removed
sudo rm -f $CONFIG_FILE_PATH
if [[ $? != 0 ]]; then
echo "$CONFIG_FILE_PATH cannot be removed correctly..."
exit 1
fi
;;
*)
source install_config_send_anonymous_report.sh
;;
esac
else
echo "Default config will be autocreated during the first run and available for futher modifications here:"
echo "$CONFIG_FILE_PATH"
fi
echo
# create Python3 virtual environment
virtualenv --python=$(command -v python3) $INSTALL_DIR_PATH/.env
source $INSTALL_DIR_PATH/.env/bin/activate
pip3 install --upgrade pip
pip3 install --upgrade setuptools
pip3 install -r requirements.txt
deactivate
echo
if [ -z "$LAYOUT_NAME" ]; then
source install_layout_auto_suggestion.sh
echo
if [ -z "$LAYOUT_NAME" ]; then
source install_layout_select.sh
echo
fi
fi
source install_service.sh
echo
echo "Installation finished successfully"
echo
END_TIME=${EPOCHREALTIME::-7}
source install_finished_send_anonymous_report.sh
echo "Installation finished successfully"
echo
read -r -p "Reboot is required. Do you want reboot now? [y/N]" response
case "$response" in [yY][eE][sS]|[yY])
sudo /sbin/reboot
;;
*)
;;
esac
echo
exit 0
} 2>&1 | sudo tee "$LOGS_INSTALL_LOG_FILE_PATH"