-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstallNodejs.sh
More file actions
executable file
·43 lines (35 loc) · 902 Bytes
/
Copy pathinstallNodejs.sh
File metadata and controls
executable file
·43 lines (35 loc) · 902 Bytes
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
#!/bin/bash
# Description: install Node.js
# Author: tlanyan<https://tlanyan.me>
function checkSystem()
{
result=$(id | awk '{print $1}')
if [ $result != "uid=0(root)" ]; then
echo "action must be carried out by root!"
exit 1
fi
if [ ! -f /etc/centos-release ];then
echo false
return
fi
result=`cat /etc/centos-release|grep "CentOS Linux release 7"`
if [ "$result" = "" ]; then
echo false
fi
echo true
}
function installNodeJS()
{
curl -sL https://rpm.nodesource.com/setup_10.x | bash -
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install -g jshint csshint
echo 'alias npm=cnpm' >> ~/.bashrc
}
result=$(checkSystem)
if [ "$result" != "true" ]; then
echo "scripts only tested on centos 7!"
exit 1
fi
echo -n "system version : "
cat /etc/centos-release
installNodeJS