6 |
help_network_hostname() |
help_network_hostname() |
7 |
{ |
{ |
8 |
mecho "get network.hostname" |
mecho "get network.hostname" |
9 |
mecho " displays the current hostname" |
mecho " Displays the current hostname" |
10 |
mecho |
mecho |
11 |
mecho "set network.hostname [hostname]" |
mecho "set network.hostname [hostname]" |
12 |
mecho " Sets the hostname of the system" |
mecho " Sets the hostname of the system" |
15 |
|
|
16 |
get_network_hostname() |
get_network_hostname() |
17 |
{ |
{ |
18 |
hostname |
local val |
19 |
|
|
20 |
|
if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
21 |
|
then |
22 |
|
val=$(hostname) |
23 |
|
else |
24 |
|
val=$(< /etc/hostname) |
25 |
|
fi |
26 |
|
|
27 |
|
rvecho "${val}" |
28 |
} |
} |
29 |
|
|
30 |
# set_network_hostname $value |
# set_network_hostname $value |
68 |
|
|
69 |
help_network_iface() |
help_network_iface() |
70 |
{ |
{ |
71 |
|
mecho "get network.iface" |
72 |
|
mecho " Lists all configured network interfaces" |
73 |
|
mecho |
74 |
mecho "set network.iface [iface] [networking] [ip] [netmask] [broadcast] [network]" |
mecho "set network.iface [iface] [networking] [ip] [netmask] [broadcast] [network]" |
75 |
|
mecho " Configure network interfaces" |
76 |
mecho " iface - the interface name" |
mecho " iface - the interface name" |
77 |
mecho " networking - may be 'static' or 'dhcp'" |
mecho " networking - may be 'static' or 'dhcp'" |
78 |
mecho " ip, netmask, broadcast and network are optional and only required on static networking" |
mecho " ip, netmask, broadcast and network are optional and only required on static networking" |
79 |
} |
} |
80 |
|
|
81 |
|
get_network_iface() |
82 |
|
{ |
83 |
|
local iface |
84 |
|
for iface in $(find ${MROOT}/etc/conf.d -maxdepth 1 -name 'net.*' -printf '%f\n') |
85 |
|
do |
86 |
|
case ${iface} in |
87 |
|
# exclude routes and samples |
88 |
|
net.sample|net.routes) continue ;; |
89 |
|
esac |
90 |
|
rvecho -n "${iface//net.}" |
91 |
|
( cat ${MROOT}/etc/conf.d/${iface}; echo ) | while read line |
92 |
|
do |
93 |
|
rvecho -n ";${line}" |
94 |
|
done |
95 |
|
rvecho |
96 |
|
done |
97 |
|
} |
98 |
|
|
99 |
set_network_iface() |
set_network_iface() |
100 |
{ |
{ |
101 |
local iface="$1" |
local iface="$1" |
105 |
local broadcast="$5" |
local broadcast="$5" |
106 |
local network="$6" |
local network="$6" |
107 |
local CONFIG |
local CONFIG |
108 |
|
local dhcp_prog |
109 |
|
|
110 |
[[ -z ${iface} ]] && help_network_iface && return 1 |
[[ -z ${iface} ]] && help_network_iface && return 1 |
111 |
[[ -z ${networking} ]] && help_network_iface && return 1 |
[[ -z ${networking} ]] && help_network_iface && return 1 |
136 |
;; |
;; |
137 |
esac |
esac |
138 |
|
|
139 |
if [[ ! -z $(ip addr | grep "${iface}.*UP.*") ]] |
if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
140 |
then |
then |
141 |
set_system_service restart network "${iface}" |
if [[ ! -z $(ip addr | grep "${iface}.*UP.*") ]] |
142 |
|
then |
143 |
|
set_system_service restart network "${iface}" |
144 |
|
else |
145 |
|
set_system_service start network "${iface}" |
146 |
|
fi |
147 |
else |
else |
148 |
set_system_service start network "${iface}" |
case ${networking} in |
149 |
|
static) |
150 |
|
ifconfig "${iface}" "${ip}" netmask "${netmask}" broadcast "${broadcast}" |
151 |
|
;; |
152 |
|
dhcp) |
153 |
|
source /etc/conf.d/network |
154 |
|
[[ ! -z $(pidof ${dhcp_prog}) ]] && killall ${DEFAULT_DHCP_PROG} |
155 |
|
${DEFAULT_DHCP_PROG} ${DEFAULT_DHCP_START} "${iface}" |
156 |
|
;; |
157 |
|
esac |
158 |
fi |
fi |
159 |
} |
} |
160 |
|
|