/bin/hostname "${base_hostname}"
echo "${base_hostname}" > '/etc/hostname'
+ # Setting the hostname with hostnamectl ...
+ echo "Setting the hostname ..."
+ hostnamectl set-hostname --static "${base_hostname}"
+ hostnamectl set-hostname --transient "${base_hostname}"
+ hostnamectl set-deployment "${system_status}"
+ hostnamectl set-location "L105 / VMWare"
+
+ hostnamectl status
+
+ echo
echo "Updating '/etc/hosts' ..."
echo >>'/etc/hosts'
echo "${ip_address_eth0} ${hostname} ${base_hostname}" >>'/etc/hosts'
echo "Generated /etc/hosts:"
- cat '/etc/hosts' | true
+ cat '/etc/hosts' || true
echo
for ifcfg_file in ${nw_script_dir}/ifcfg-* ; do
log "Generating network configuration ..."
local temp_dir=$( mktemp -p /tmp -d 'tmp.XXXXXXXXXX.cobbler' )
- local tmp_nw_cfg="${temp_dir}/network"
local tmp_nw_script_dir="${temp_dir}/network-scripts"
local nw_script_dir="/etc/sysconfig/network-scripts"
- local nw_old_dir="${nw_script_dir}/.old"
local nm_cfg_dir='/etc/NetworkManager/system-connections'
local nm_old_dir="${nm_cfg_dir}/.old"
local ifcfg_file=
local if_uuid=$( uuidgen -r )
mkdir -pv "${tmp_nw_script_dir}"
- mkdir -pv "${nw_old_dir}"
mkdir -pv "${nm_old_dir}"
- echo "Generating /etc/sysconfig/network ..."
+ # Setting the hostname with hostnamectl ...
+ echo "Setting the hostname ..."
+ hostnamectl hostname --static "${base_hostname}"
+ hostnamectl hostname --transient "${base_hostname}"
+ hostnamectl deployment "${system_status}"
+ hostnamectl location "L105 / VMWare"
- grep -v 'GATEWAY|HOSTNAME' /etc/sysconfig/network > "${tmp_nw_cfg}"
- echo "GATEWAY=${gateway}" >> "${tmp_nw_cfg}"
- echo "HOSTNAME=${hostname}" >> "${tmp_nw_cfg}"
- mv -v /etc/sysconfig/network "/etc/sysconfig/network.orig.$( date -r /etc/sysconfig/network +'%Y-%m-%d_%H:%M:%S' )"
- mv -v "${tmp_nw_cfg}" /etc/sysconfig/network
+ hostnamectl status --json pretty
- echo "Generated /etc/sysconfig/network:"
- cat /etc/sysconfig/network || true
echo
-
- # Also set the hostname now, some applications require it
- echo "Generating '/etc/hostname' ..."
- /bin/hostname "${base_hostname}"
- echo "${base_hostname}" > '/etc/hostname'
-
echo "Updating '/etc/hosts' ..."
echo >>'/etc/hosts'
echo "${ip_address_eth0} ${hostname} ${base_hostname}" >>'/etc/hosts'
echo "Generated /etc/hosts:"
- cat '/etc/hosts' | true
+ cat '/etc/hosts' || true
echo
- for ifcfg_file in ${nw_script_dir}/ifcfg-* ; do
- if [[ ! -f "${ifcfg_file}" ]] ; then
- continue
- fi
- local bname=$(basename "${ifcfg_file}" )
- if [[ "${bname}" == "ifcfg-lo" ]] ; then
- continue
- fi
- mv -v "${ifcfg_file}" "${nw_old_dir}"
- done
-
for ifcfg_file in ${nm_cfg_dir}/*.nmconnection ; do
if [[ ! -f "${ifcfg_file}" ]] ; then
continue