File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed
Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # info: change hostname
3+ # options: HOSTNAME
4+ #
5+ # The function for changing system hostname.
6+
7+
8+ # ----------------------------------------------------------#
9+ # Variable&Function #
10+ # ----------------------------------------------------------#
11+
12+ # Argument defenition
13+ domain=$1
14+
15+ # Includes
16+ source $VESTA /func/main.sh
17+ source $VESTA /conf/vesta.conf
18+
19+
20+ # ----------------------------------------------------------#
21+ # Verifications #
22+ # ----------------------------------------------------------#
23+
24+ check_args ' 1' " $# " ' HOSTNAME'
25+ validate_format ' domain'
26+
27+
28+ # ----------------------------------------------------------#
29+ # Action #
30+ # ----------------------------------------------------------#
31+
32+ hostname $domain
33+
34+ # RHEL/CentOS
35+ if [ -e " /etc/redhat-release" ]; then
36+ touch /etc/sysconfig/network
37+ if [ -z " $( grep HOSTNAME /etc/sysconfig/network) " ]; then
38+ echo " HOSTNAME='$domain '" >> /etc/sysconfig/network
39+ else
40+ sed -i " s/HOSTNAME=.*/HOSTNAME='$domain '/" /etc/sysconfig/network
41+ fi
42+ fi
43+
44+ # Debian/Ubuntu
45+ if [ ! -e " /etc/redhat-release" ]; then
46+ echo " $domain " > /etc/hostname
47+ fi
48+
49+
50+ # ----------------------------------------------------------#
51+ # Vesta #
52+ # ----------------------------------------------------------#
53+
54+ # Logging
55+ log_event " $OK " " $EVENT "
56+
57+ exit
You can’t perform that action at this time.
0 commit comments