-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall.sh
executable file
·94 lines (80 loc) · 2.39 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
#!/bin/sh
###############################################################################
# Environment / Portability
###############################################################################
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
umask 022
###############################################################################
# Global Variables
###############################################################################
PRODUCT=Zoom
ROTATERIGHT_DIR="/opt/rotateright"
KMOD_NAME=""
if [ "${UID}" = "" ]; then
UID=`id -u`
fi
###############################################################################
# Main
###############################################################################
if [ -d "${ROTATERIGHT_DIR}/${PRODUCT}" ]; then
ROTATERIGHT_DIR="${ROTATERIGHT_DIR}/${PRODUCT}"
fi
if [ $# -eq 0 ]; then
echo "Installing to path: ${ROTATERIGHT_DIR}"
elif [ $# -eq 1 ]; then
echo "Installing to path: $1"
ROTATERIGHT_DIR=$1
else
echo "Error: Wrong number of arguments"
exit 2
fi
curr_dir=`basename $PWD`
echo ${curr_dir} | grep rrnotify >/dev/null
rrnotify_ret_val=$?
echo ${curr_dir} | grep rrprofile >/dev/null
rrprofile_ret_val=$?
echo ${curr_dir} | grep oprofile >/dev/null
oprofile_ret_val=$?
if [ $rrnotify_ret_val -eq 0 ]; then
KMOD_NAME=rrnotify
elif [ $rrprofile_ret_val -eq 0 ]; then
KMOD_NAME=rrprofile
elif [ $oprofile_ret_val -eq 0 ]; then
KMOD_NAME=oprofile
else
echo "Error: Failed to locate driver."
exit 2
fi
# Test for root
if [ "$UID" -eq 0 ]; then
if [ $KMOD_NAME != "oprofile" ]; then
# Check if kmod is built
if [ ! -f ${KMOD_NAME}.ko ]; then
echo "Error: ${KMOD_NAME}.ko is not found."
exit 2
fi
rm -rf /lib/modules/`uname -r`/extra/${KMOD_NAME}
rm -f /lib/modules/`uname -r`/extra/${KMOD_NAME}.ko
# Install
mkdir -p /lib/modules/`uname -r`/extra/${KMOD_NAME}
cp ${KMOD_NAME}.ko /lib/modules/`uname -r`/extra/${KMOD_NAME}/${KMOD_NAME}.ko
fi
/sbin/depmod
# Install startup scripts into ${ROTATERIGHT_DIR}
INIT_DIR=${ROTATERIGHT_DIR}/etc/init.d
mkdir -p ${INIT_DIR}
cp common/${KMOD_NAME}-generic ${INIT_DIR}/${KMOD_NAME}
${INIT_DIR}/${KMOD_NAME} status 2&> /dev/null
if [ $? -eq 0 ]; then
${INIT_DIR}/${KMOD_NAME} stop
sleep 1
fi
# ${INIT_DIR}/${KMOD_NAME} start
# if [ $? -ne 0 ]; then
# echo "Error: Failed to start ${KMOD_NAME}."
# exit 2
# fi
else
echo "Error: You must be root to install the ${KMOD_NAME} driver."
exit 2
fi