Sophie

Sophie

distrib > Fedora > 18 > x86_64 > media > updates > by-pkgid > 88d0573cd3cadb5731d86a4ccbb84955 > scriptlet

dhcp-4.2.5-15.fc18.x86_64.rpm

PREIN

/bin/sh
# /usr/share/doc/setup/uidgid
getent group dhcpd >/dev/null || groupadd --force --gid 177 --system dhcpd
if ! getent passwd dhcpd >/dev/null ; then
    if ! getent passwd 177 >/dev/null ; then
      useradd --system --uid 177 --gid dhcpd --home / --shell /sbin/nologin --comment "DHCP server" dhcpd
    else
      useradd --system --gid dhcpd --home / --shell /sbin/nologin --comment "DHCP server" dhcpd
    fi
fi
exit 0

PREUN

/bin/sh
# Package removal, not upgrade

if [ $1 -eq 0 ] ; then 
        # Package removal, not upgrade 
        /usr/bin/systemctl --no-reload disable dhcpd.service dhcpd6.service dhcrelay.service > /dev/null 2>&1 || : 
        /usr/bin/systemctl stop dhcpd.service dhcpd6.service dhcrelay.service > /dev/null 2>&1 || : 
fi

POSTIN

/bin/sh
# Initial installation

if [ $1 -eq 1 ] ; then 
        # Initial installation 
        /usr/bin/systemctl preset dhcpd.service dhcpd6.service dhcrelay.service >/dev/null 2>&1 || : 
fi 

# Update
if [ $1 -gt 1 ] ; then
  chown -R dhcpd:dhcpd /var/lib/dhcpd/
fi

POSTUN

/bin/sh
# Package upgrade, not uninstall

/usr/bin/systemctl daemon-reload >/dev/null 2>&1 || : 
if [ $1 -ge 1 ] ; then 
        # Package upgrade, not uninstall 
        /usr/bin/systemctl try-restart dhcpd.service dhcpd6.service dhcrelay.service >/dev/null 2>&1 || : 
fi

Triggers

dhcp

/bin/sh
# convert DHC*ARGS from /etc/sysconfig/dhc* to /etc/systemd/system/dhc*.service
for servicename in dhcpd dhcpd6 dhcrelay; do
  if [ -f /etc/sysconfig/${servicename} ]; then
    # get DHCPDARGS/DHCRELAYARGS value from /etc/sysconfig/${servicename}
    source /etc/sysconfig/${servicename}
    if [ "${servicename}" == "dhcrelay" ]; then
        args=$DHCRELAYARGS
    else
        args=$DHCPDARGS
    fi
    # value is non-empty (i.e. user modified) and there isn't a service unit yet
    if [ -n "${args}" -a ! -f /etc/systemd/system/${servicename}.service ]; then
      # in $args replace / with \/ otherwise the next sed won't take it
      args=$(echo $args | sed 's/\//\\\//'g)
      # add $args to the end of ExecStart line
      sed -r -e "/ExecStart=/ s/$/ ${args}/" \
                < /usr/lib/systemd/system/${servicename}.service \
                > /etc/systemd/system/${servicename}.service
    fi
  fi
done