forked from huaweicse/weathermap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
69 lines (63 loc) · 1.3 KB
/
start.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
#!/bin/sh
isInstalledNodejs()
{
which node >/dev/null 2>&1
return $?
}
InstallNodeJs()
{
curPath=`pwd`
nodejsPath="$curPath"/pkg
if [ ! -d $nodejsPath ]; then
echo "node js pkg not found"
return 1
fi
which tar >/dev/null 2>&1
rst=$?
if [ $rst != 0 ];then
echo "There is no tar, please first install tar!"
return $rst
fi
nodejsPathName="$nodejsPath"/node-v8.9.4-linux-x64.tar.xz
if [ ! -f $nodejsPathName ];then
echo "There is no node pkg, the weather pkg is wrong!"
return 1
fi
tar -xvf $nodejsPathName > /dev/null
tarRst=$?
if [ $tarRst != 0 ];then
echo "tar node js pkg failed!"
return 1
fi
nodeBinPath="$curPath"/node-v8.9.4-linux-x64/bin/node
ln -s $nodeBinPath /usr/local/bin/
npmBinPath="$curPath"/node-v8.9.4-linux-x64/bin/npm
ln -s $npmBinPath /usr/local/bin/
node -v
rst=$?
if [ $rst != 0 ];then
echo "install nodejs failed, return code is $rst"
return $rst
fi
echo "install nodejs successful"
}
main()
{
isInstalledNodejs
if [ $? != 0 ];then
InstallNodeJs
if [ $rst != 0 ]; then
return $rst
fi
fi
curPath=`pwd`
bash "$curPath"/startup_all.sh > /dev/null 2>&1 &
rst=$?
if [ $rst != 0 ];then
echo "install weather failed"
return $rst
fi
echo "install weather successful"
}
main
return $?