-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall_hmpi_service.sh
executable file
·48 lines (37 loc) · 1.21 KB
/
uninstall_hmpi_service.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
#!/bin/bash
SYSDIR=/sys/kernel/config/usb_gadget
DEVDIR=$SYSDIR/g1
HMPIG=/etc/systemd/system/headmousepi-gadgets.service
HMPI=/etc/systemd/system/headmouse-pi.service
echo "Stopping headmouse-pi"
sudo systemctl stop headmouse-pi
echo "Stopping headmouse-gadgets"
sudo systemctl stop headmousepi-gadgets
echo "Disabling UDC"
echo '' | sudo tee $DEVDIR/UDC
echo "Removing strings from configurations"
for dir in "$DEVDIR"/configs/*/strings/*; do
[ -d "$dir" ] && sudo rmdir "$dir"
done
echo "Removing functions from configurations"
for func in "$DEVDIR"/configs/*.*/*.*; do
[ -e "$func" ] && sudo rm "$func"
done
echo "Removing configurations"
for conf in "$DEVDIR"/configs/*; do
[ -d "$conf" ] && sudo rmdir "$conf"
done
echo "Removing functions"
for func in "$DEVDIR"/functions/*.*; do
[ -d "$func" ] && sudo rmdir "$func"
done
echo "Removing strings"
for str in "$DEVDIR"/strings/*; do
[ -d "$str" ] && sudo rmdir "$str"
done
echo "Removing gadget"
[ -d "$DEVDIR" ] && sudo rmdir "$DEVDIR"
echo "Removing headmousepi-gadgets.service"
[ -e "$HMPIG" ] && sudo systemctl disable headmousepi-gadgets && sudo rm "$HMPIG"
echo "Removing headmouse-pi.service"
[ -e "$HMPI" ] && sudo systemctl disable headmouse-pi && sudo rm "$HMPI"