1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#/bin/bash #author:禅剑一如 #date:2017-06-07 #判断是否有root权限,如果没有就提示并退出 if [ ` id -u` - ne 0 ]; then
echo "plesae use super privilege,eg: sudo $0"
exit 1
#添加ip和域名映射 else cat >> /etc/hosts <<EOF
10.0.0.2 gitlab.a.com 10.0.0.3 gitlab.b.com 10.0.0.4 gitlab.c.com EOF #判断执行失败则提示失败 if [ $? != 0 ];
then
echo "添加hosts文件失败"
else
echo "add hosts successfully"
fi
fi
|
本文转自 yanconggod 51CTO博客,原文链接:http://blog.51cto.com/yanconggod/1933152