From 2c8f80ee3a4660044c578e49f0d49df9f4e658c1 Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Thu, 15 Jun 2017 17:30:08 -0700 Subject: [PATCH] debianpkg: Register/remove init script on init.d based systems - Ubuntu 12.04 and Ubuntu 14.04 need init script registered during install and removed at uninstall Signed-off-by: Martin Winter --- debianpkg/Makefile.am | 3 ++ .../backports/ubuntu12.04/debian/frr.postinst | 41 +----------------- .../backports/ubuntu12.04/debian/frr.postrm | 1 + .../backports/ubuntu14.04/debian/frr.postinst | 42 +++++++++++++++++++ .../backports/ubuntu14.04/debian/frr.postrm | 14 +++++++ 5 files changed, 61 insertions(+), 40 deletions(-) mode change 100644 => 120000 debianpkg/backports/ubuntu12.04/debian/frr.postinst create mode 120000 debianpkg/backports/ubuntu12.04/debian/frr.postrm create mode 100644 debianpkg/backports/ubuntu14.04/debian/frr.postinst create mode 100644 debianpkg/backports/ubuntu14.04/debian/frr.postrm diff --git a/debianpkg/Makefile.am b/debianpkg/Makefile.am index dd301aaf6e..c46cfb1c4e 100644 --- a/debianpkg/Makefile.am +++ b/debianpkg/Makefile.am @@ -10,12 +10,15 @@ EXTRA_DIST = README.Debian README.Maintainer \ backports/ubuntu12.04/debian/control \ backports/ubuntu12.04/debian/frr.install \ backports/ubuntu12.04/debian/frr.postinst \ + backports/ubuntu12.04/debian/frr.postrm \ backports/ubuntu12.04/debian/rules \ backports/ubuntu12.04/debian/source/format \ backports/ubuntu12.04/exclude \ backports/ubuntu12.04/versionext \ backports/ubuntu14.04/debian/control \ backports/ubuntu14.04/debian/frr.install \ + backports/ubuntu14.04/debian/frr.postinst \ + backports/ubuntu14.04/debian/frr.postrm \ backports/ubuntu14.04/debian/rules \ backports/ubuntu14.04/debian/source/format \ backports/ubuntu14.04/exclude \ diff --git a/debianpkg/backports/ubuntu12.04/debian/frr.postinst b/debianpkg/backports/ubuntu12.04/debian/frr.postinst deleted file mode 100644 index 9020d7bf7a..0000000000 --- a/debianpkg/backports/ubuntu12.04/debian/frr.postinst +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -e - -###################### -PASSWDFILE=/etc/passwd -GROUPFILE=/etc/group - -frruid=`egrep "^frr:" $PASSWDFILE | awk -F ":" '{ print $3 }'` -frrgid=`egrep "^frr:" $GROUPFILE | awk -F ":" '{ print $3 }'` -frrvtygid=`egrep "^frrvty:" $GROUPFILE | awk -F ":" '{ print $3 }'` - -[ -n ${frruid} ] || (echo "No uid for frr in ${PASSWDFILE}" && /bin/false) -[ -n ${frrgid} ] || (echo "No gid for frr in ${GROUPFILE}" && /bin/false) -[ -n ${frrVTYgid} ] || (echo "No gid for frrvty in ${GROUPFILE}" && /bin/false) - -chown -R ${frruid}:${frrgid} /etc/frr -touch /etc/frr/vtysh.conf -chgrp ${frrvtygid} /etc/frr/vtysh* -chmod 644 /etc/frr/* - -ENVIRONMENTFILE=/etc/environment -if ! grep --quiet VTYSH_PAGER=/bin/cat ${ENVIRONMENTFILE}; then - echo "VTYSH_PAGER=/bin/cat" >> ${ENVIRONMENTFILE} -fi -################################################## - -if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi -${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*"} - -# This is most likely due to the answer "no" to the "really stop the server" -# question in the prerm script. -if [ "$1" = "abort-upgrade" ]; then - exit 0 -fi - -. /usr/share/debconf/confmodule - -db_stop - -#DEBHELPER# - diff --git a/debianpkg/backports/ubuntu12.04/debian/frr.postinst b/debianpkg/backports/ubuntu12.04/debian/frr.postinst new file mode 120000 index 0000000000..eb98053c7b --- /dev/null +++ b/debianpkg/backports/ubuntu12.04/debian/frr.postinst @@ -0,0 +1 @@ +../../ubuntu14.04/debian/frr.postinst \ No newline at end of file diff --git a/debianpkg/backports/ubuntu12.04/debian/frr.postrm b/debianpkg/backports/ubuntu12.04/debian/frr.postrm new file mode 120000 index 0000000000..4f4380872f --- /dev/null +++ b/debianpkg/backports/ubuntu12.04/debian/frr.postrm @@ -0,0 +1 @@ +../../ubuntu14.04/debian/frr.postrm \ No newline at end of file diff --git a/debianpkg/backports/ubuntu14.04/debian/frr.postinst b/debianpkg/backports/ubuntu14.04/debian/frr.postinst new file mode 100644 index 0000000000..568b43e1ec --- /dev/null +++ b/debianpkg/backports/ubuntu14.04/debian/frr.postinst @@ -0,0 +1,42 @@ +#!/bin/bash -e + +###################### +PASSWDFILE=/etc/passwd +GROUPFILE=/etc/group + +frruid=`egrep "^frr:" $PASSWDFILE | awk -F ":" '{ print $3 }'` +frrgid=`egrep "^frr:" $GROUPFILE | awk -F ":" '{ print $3 }'` +frrvtygid=`egrep "^frrvty:" $GROUPFILE | awk -F ":" '{ print $3 }'` + +[ -n ${frruid} ] || (echo "No uid for frr in ${PASSWDFILE}" && /bin/false) +[ -n ${frrgid} ] || (echo "No gid for frr in ${GROUPFILE}" && /bin/false) +[ -n ${frrVTYgid} ] || (echo "No gid for frrvty in ${GROUPFILE}" && /bin/false) + +chown -R ${frruid}:${frrgid} /etc/frr +touch /etc/frr/vtysh.conf +chgrp ${frrvtygid} /etc/frr/vtysh* +chmod 644 /etc/frr/* + +ENVIRONMENTFILE=/etc/environment +if ! grep --quiet VTYSH_PAGER=/bin/cat ${ENVIRONMENTFILE}; then + echo "VTYSH_PAGER=/bin/cat" >> ${ENVIRONMENTFILE} +fi +################################################## + +if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi +${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*"} + +# This is most likely due to the answer "no" to the "really stop the server" +# question in the prerm script. +if [ "$1" = "abort-upgrade" ]; then + exit 0 +fi + +. /usr/share/debconf/confmodule + +db_stop + +update-rc.d frr defaults > /dev/null + +#DEBHELPER# + diff --git a/debianpkg/backports/ubuntu14.04/debian/frr.postrm b/debianpkg/backports/ubuntu14.04/debian/frr.postrm new file mode 100644 index 0000000000..48c23321f7 --- /dev/null +++ b/debianpkg/backports/ubuntu14.04/debian/frr.postrm @@ -0,0 +1,14 @@ +#!/bin/bash -e + +if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi +${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*"} +# set -u not because of debhelper + +update-rc.d -f frr remove >> /dev/null + +if [ "$1" = "purge" ]; then + rm -rf /etc/frr /var/run/frr /var/log/frr + userdel frr >/dev/null 2>&1 || true +fi + +#DEBHELPER# -- 2.39.5