Loading src/etc/init.d/one-context##apk.one +1 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ name="OpenNebula contextualization" depend() { use one-context-local net before sshd use logger after logger keyword -stop -shutdown } Loading src/etc/init.d/one-context-local##apk.one +2 −2 Original line number Diff line number Diff line Loading @@ -15,13 +15,13 @@ # See the License for the specific language governing permissions and # # limitations under the License. # #--------------------------------------------------------------------------- # # name="OpenNebula pre-networking contextualization" depend() { need localmount udev udev-trigger udev-settle before net use logger after logger keyword -stop -shutdown } Loading src/etc/one-context.d/net-15-hostname +36 −12 Original line number Diff line number Diff line Loading @@ -23,29 +23,53 @@ else SED_I="sed -i''" fi # Detects suitable running syslog service and restarts it # to propagate the changed hostname into the logs # (otherwise old or default value remains until reboot) function restart_syslog() { for _name in syslog syslogd rsyslog; do if LANG=C systemctl is-active "${_name}" >/dev/null 2>&1; then systemctl restart "${_name}" && return elif service "${_name}" status >/dev/null 2>&1; then service "${_name}" restart && return fi done } function set_hostname() { local hostname=$1 local _hostname=$1 # remember currently set hostname to detect a change local _old_hostname _old_hostname=$(hostname) if [ -d /run/systemd/system/ ] && hostnamectl status >/dev/null 2>/dev/null; then hostnamectl set-hostname --static "${hostname}" hostnamectl set-hostname --static "${_hostname}" else if [ -f /etc/sysconfig/network ]; then eval "${SED_I} '/^HOSTNAME=.*$/d' /etc/sysconfig/network" echo "HOSTNAME=${hostname}" >>/etc/sysconfig/network echo "HOSTNAME=${_hostname}" >>/etc/sysconfig/network elif [ "${_kernel}" = 'FreeBSD' ]; then sysrc hostname="${hostname}" sysrc hostname="${_hostname}" else echo "${hostname}" >/etc/hostname echo "${_hostname}" >/etc/hostname fi hostname "${hostname}" hostname "${_hostname}" fi # restart syslog if actual hostname changed if [ "${_old_hostname}" != "$(hostname)" ]; then restart_syslog fi } function set_domainname() { domain=$1 local _domain=$1 touch /etc/resolv.conf eval "${SED_I} -e '/^domain .*/d' /etc/resolv.conf" echo "domain ${domain}" >>/etc/resolv.conf echo "domain ${_domain}" >>/etc/resolv.conf } function get_first_ip() { Loading Loading @@ -131,6 +155,10 @@ if [ -n "${name}" ]; then domain='' fi if [ -n "${domain}" ]; then set_domainname "${domain}" fi # FreeBSD if [ "${_kernel}" = 'FreeBSD' ]; then set_hostname "${name}" Loading @@ -138,10 +166,6 @@ if [ -n "${name}" ]; then set_hostname "${hostname}" fi if [ -n "${domain}" ]; then set_domainname "${domain}" fi if [ -n "${DNS_HOSTNAME}" ]; then host_ip=$first_ip else Loading Loading
src/etc/init.d/one-context##apk.one +1 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ name="OpenNebula contextualization" depend() { use one-context-local net before sshd use logger after logger keyword -stop -shutdown } Loading
src/etc/init.d/one-context-local##apk.one +2 −2 Original line number Diff line number Diff line Loading @@ -15,13 +15,13 @@ # See the License for the specific language governing permissions and # # limitations under the License. # #--------------------------------------------------------------------------- # # name="OpenNebula pre-networking contextualization" depend() { need localmount udev udev-trigger udev-settle before net use logger after logger keyword -stop -shutdown } Loading
src/etc/one-context.d/net-15-hostname +36 −12 Original line number Diff line number Diff line Loading @@ -23,29 +23,53 @@ else SED_I="sed -i''" fi # Detects suitable running syslog service and restarts it # to propagate the changed hostname into the logs # (otherwise old or default value remains until reboot) function restart_syslog() { for _name in syslog syslogd rsyslog; do if LANG=C systemctl is-active "${_name}" >/dev/null 2>&1; then systemctl restart "${_name}" && return elif service "${_name}" status >/dev/null 2>&1; then service "${_name}" restart && return fi done } function set_hostname() { local hostname=$1 local _hostname=$1 # remember currently set hostname to detect a change local _old_hostname _old_hostname=$(hostname) if [ -d /run/systemd/system/ ] && hostnamectl status >/dev/null 2>/dev/null; then hostnamectl set-hostname --static "${hostname}" hostnamectl set-hostname --static "${_hostname}" else if [ -f /etc/sysconfig/network ]; then eval "${SED_I} '/^HOSTNAME=.*$/d' /etc/sysconfig/network" echo "HOSTNAME=${hostname}" >>/etc/sysconfig/network echo "HOSTNAME=${_hostname}" >>/etc/sysconfig/network elif [ "${_kernel}" = 'FreeBSD' ]; then sysrc hostname="${hostname}" sysrc hostname="${_hostname}" else echo "${hostname}" >/etc/hostname echo "${_hostname}" >/etc/hostname fi hostname "${hostname}" hostname "${_hostname}" fi # restart syslog if actual hostname changed if [ "${_old_hostname}" != "$(hostname)" ]; then restart_syslog fi } function set_domainname() { domain=$1 local _domain=$1 touch /etc/resolv.conf eval "${SED_I} -e '/^domain .*/d' /etc/resolv.conf" echo "domain ${domain}" >>/etc/resolv.conf echo "domain ${_domain}" >>/etc/resolv.conf } function get_first_ip() { Loading Loading @@ -131,6 +155,10 @@ if [ -n "${name}" ]; then domain='' fi if [ -n "${domain}" ]; then set_domainname "${domain}" fi # FreeBSD if [ "${_kernel}" = 'FreeBSD' ]; then set_hostname "${name}" Loading @@ -138,10 +166,6 @@ if [ -n "${name}" ]; then set_hostname "${hostname}" fi if [ -n "${domain}" ]; then set_domainname "${domain}" fi if [ -n "${DNS_HOSTNAME}" ]; then host_ip=$first_ip else Loading