-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathinstall_user_groups.sh
61 lines (48 loc) · 1.79 KB
/
install_user_groups.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
#!/usr/bin/env bash
source non_sudo_check.sh
# ENV VARS
if [ -z "$INSTALL_UDEV_DIR_PATH" ]; then
INSTALL_UDEV_DIR_PATH="/usr/lib/udev"
fi
sudo groupadd "input"
sudo groupadd "i2c"
sudo groupadd "uinput"
sudo usermod -a -G "i2c,input,uinput,numberpad" $USER
if [[ $? != 0 ]]; then
echo "Something went wrong when adding the groups to current user"
exit 1
else
echo "Added groups input, i2c, uinput, numberpad to current user"
fi
sudo modprobe uinput
# check if the uinput module is successfully loaded
if [[ $? != 0 ]]; then
echo "uinput module cannot be loaded"
exit 1
else
echo "uinput module loaded"
fi
sudo modprobe i2c-dev
# check if the i2c-dev module is successfully loaded
if [[ $? != 0 ]]; then
echo "i2c-dev module cannot be loaded. Make sure you have installed i2c-tools package"
exit 1
else
echo "i2c-dev module loaded"
fi
echo 'KERNEL=="uinput", GROUP="uinput", MODE="0660"' | sudo tee $INSTALL_UDEV_DIR_PATH/rules.d/99-asus-numberpad-driver-uinput.rules >/dev/null
echo 'uinput' | sudo tee /etc/modules-load.d/uinput-asus-numberpad-driver.conf >/dev/null
echo 'SUBSYSTEM=="i2c-dev", GROUP="i2c", MODE="0660"' | sudo tee $INSTALL_UDEV_DIR_PATH/rules.d/99-asus-numberpad-driver-i2c-dev.rules >/dev/null
echo "i2c-dev" | sudo tee /etc/modules-load.d/i2c-dev-asus-numberpad-driver.conf >/dev/null
if [[ $? != 0 ]]; then
echo "Something went wrong when adding uinput module to auto loaded modules"
exit 1
else
echo "uinput module added to auto loaded modules"
fi
sudo udevadm control --reload-rules && sudo udevadm trigger --sysname-match=uinput && sudo udevadm trigger --attr-match=subsystem=i2c-dev
if [[ $? != 0 ]]; then
echo "Something went wrong when reloading or triggering uinput udev rules"
else
echo "Udev rules reloaded and triggered"
fi