-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstallUniverseDriver.sh
executable file
·146 lines (137 loc) · 2.59 KB
/
installUniverseDriver.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
#!/bin/sh
#
# Install script, this will grab most recent version
# from the repo and install it. Repo changed to github
#
# Run (as root, from a temp directory):
#
# cd tmp
# sh /path/to/installUniverseDriver.sh install
#
#
name=universe
version=newest
FILEURL=https://github.com/mgmarino/VMELinux/tarball/master
output_file=$name-$version.tar.gz
check()
{
lsmod | grep -q $name
STATUS=$?
if [ $STATUS -eq 0 ]; then
echo "Universe module running."
else
echo "Universe module not running."
fi
return $STATUS
}
download()
{
echo "Downloading file at: $FILEURL"
wget --timeout=10 --no-check-certificate $FILEURL -O $output_file
if [ ! -f $output_file ]; then
echo "Can't obtain $output_file, try manually copying to this directory"
return 1
else
return 0
fi
}
inflate()
{
echo "Inflating..."
tmp_dir_name="/tmp/universe_tmp_output_$$.tmp"
mkdir $tmp_dir_name
tar xmfz $output_file -C $tmp_dir_name
mv $tmp_dir_name/mgmarino-VMELinux-* $name-$version
rm -rf $tmp_dir_name
}
install()
{
my_cwd=`pwd`
if [ ! -f $output_file ]; then
download
return_val=$?
if [ "$return_val" -eq "1" ]; then
echo "Exiting"
exit
fi
fi
if [ ! -d $name-$version ]; then
inflate
fi
cd $name-$version
echo "Building driver..."
cd driver && make && make install || exit $?
cd ../
echo "Building api..."
cd universe_api && make && make install || exit $?
echo "Installation done."
cd $my_cwd
}
uninstall()
{
my_cwd=`pwd`
if [ ! -d $name-$version ]; then
if [ ! -f $output_file ]; then
echo "It doesn't look like the install folder exists, trying to obtain..."
download
return_val=$?
if [ "$return_val" -eq "1" ]; then
echo "Exiting"
exit
fi
fi
inflate
fi
cd $name-$version
echo "Uninstalling driver..."
cd driver && make uninstall || exit $?
cd ../
echo "Uninstalling api..."
cd universe_api && make uninstall || exit $?
echo "Uninstallation done."
cd $my_cwd
}
upgrade()
{
check
if [ $? -ne 0 ]; then
echo "Universe not installed, installing new version"
cleanup
install
else
echo "Universe installed, upgrading to new version"
uninstall
cleanup
install
fi
}
cleanup()
{
rm -f $name-$version.tar.gz
rm -fr $name-$version
}
# See how we were called.
case "$1" in
install)
install
;;
uninstall)
uninstall
;;
check)
check
;;
cleanup)
cleanup
;;
upgrade)
upgrade
;;
download)
download
;;
*)
echo $"Usage: $0 {install|uninstall|upgrade|cleanup|check|download}"
exit 1
esac
exit 0