-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·53 lines (44 loc) · 951 Bytes
/
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
#!/bin/bash
# Target: Auto install autovm.sh script
# Update date: 2017/3/1
# Version: 1.34
# system path
home="/opt/vminit"
tmp=$home/install.tmp
curr_path=$(cd $(dirname $0); pwd)
if [ -f /etc/os-release ] && [ $(grep '^ID' /etc/os-release | grep -c -i 'opensuse') -ge 1 ]
then
rc_path=/etc/init.d/boot.local
else
rc_path=/etc/rc.local
fi
if [ -d $home ]
then
rm -fr $home/*
else
mkdir -p $home
fi
cp -f "${curr_path}/autovm.sh" "$home"
chmod 744 $home/autovm.sh
if [ -f $rc_path ]
then
if [ $(grep -c "${home}/autovm.sh" ${rc_path}) -ge 1 ]
then
sed -e "/autovm.sh/d" $rc_path > $tmp
cat $tmp > $rc_path
fi
else
touch $rc_path && chmod 755 $rc_path
fi
if [ -f $home/autovm.sh ]
then
if [ $(grep -c '^exit' $rc_path) -ge 1 ]
then
sed -i '/^exit/i\'$home'\/autovm.sh' $rc_path
else
echo "$home/autovm.sh" >> $rc_path
fi
fi
echo "[OK]: install success" !
rm -f ${curr_path}/install.sh ${curr_path}/autovm.sh $tmp
exit 0