forked from QuokkaLight/rkduck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
forever.sh
executable file
·52 lines (44 loc) · 1.21 KB
/
forever.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
#!/bin/bash
MODULE_NAME="rkduck"
DRIVER="PulseAudio"
KERNEL_VERSION=$(uname -r)
DRIVER_DIRECTORY="/lib/modules/$KERNEL_VERSION/kernel/drivers/$DRIVER/$MODULE_NAME"
PWD="$(cd "$(dirname ${BASH_SOURCE[0]})" && pwd)/"
function install_rk {
if [ ! -d $DRIVER_DIRECTORY ]
then
mkdir -p $DRIVER_DIRECTORY
fi
cp "$PWD/rkduck/$MODULE_NAME.ko" "$DRIVER_DIRECTORY"
for f in $(find /etc -type f -maxdepth 1 \( ! -wholename /etc/os-release ! -wholename /etc/lsb-release -wholename /etc/\*release -o -wholename /etc/\*version \) 2> /dev/null)
do
SYSTEM=${f:5:${#f}-13}
done
if [ "$SYSTEM" == "" ]; then
#TODO: error message
exit
fi
if [ "$SYSTEM" == "debian" ] || [ "$SYSTEM" == "ubuntu" ]
then
echo "$MODULE_NAME" >> /etc/modules
elif [ "$SYSTEM" == "redhat" ] || [ "$SYSTEM" == "centos" ] || [ "$SYSTEM" == "fedora" ]
then
echo "$MODULE_NAME" >> /etc/rc.modules
chmod +x /etc/rc.modules
fi
depmod
}
function remove_rk {
rm -rf $DRIVER_DIRECTORY
rm -rf /etc/rc.modules
echo '' > /etc/modules
depmod
}
case $1 in
install)
install_rk
;;
remove)
remove_rk
;;
esac