diff options
Diffstat (limited to 'buildtools/freebsd-skeleton/rpki-rp/pkg-install')
-rw-r--r-- | buildtools/freebsd-skeleton/rpki-rp/pkg-install | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/buildtools/freebsd-skeleton/rpki-rp/pkg-install b/buildtools/freebsd-skeleton/rpki-rp/pkg-install new file mode 100644 index 00000000..c9e28875 --- /dev/null +++ b/buildtools/freebsd-skeleton/rpki-rp/pkg-install @@ -0,0 +1,82 @@ +#!/bin/sh - + +case $2 in + +PRE-INSTALL) + if /usr/sbin/pw groupshow "rcynic" 2>/dev/null; then + echo "You already have a group \"rcynic\", so I will use it." + elif /usr/sbin/pw groupadd rcynic; then + echo "Added group \"rcynic\"." + else + echo "Adding group \"rcynic\" failed..." + echo "Please create it, then try again." + exit 1 + fi + if /usr/sbin/pw usershow "rcynic" 2>/dev/null; then + echo "You already have a user \"rcynic\", so I will use it." + elif /usr/sbin/pw useradd rcynic -g rcynic -h - -d /nonexistant -s /usr/sbin/nologin -c "RPKI validation system"; then + echo "Added user \"rcynic\"." + else + echo "Adding user \"rcynic\" failed..." + echo "Please create it, then try again." + exit 1 + fi + ;; + +POST-INSTALL) + htmldir=/usr/local/www/apache22/data/rcynic + if ! test -d $htmldir ; then + echo "Creating $htmldir" + install -o rcynic -g rcynic -d $htmldir + fi + sockdir=/var/rcynic/rpki-rtr/sockets + if ! test -d $sockdir ; then + echo "Creating $sockdir" + install -o nobody -g rcynic -d $sockdir + fi + echo "Setting up rcynic's crontab to run rcynic-cron script" + /usr/bin/crontab -l -u rcynic 2>/dev/null | + /usr/bin/awk -v t=`hexdump -n 2 -e '"%u\n"' /dev/random` ' + BEGIN { + cmd = "exec /usr/local/bin/rcynic-cron"; + } + $0 !~ cmd { + print; + } + END { + printf "%u * * * *\t%s\n", t % 60, cmd; + }' | + /usr/bin/crontab -u rcynic - + echo "Setting up rpki-rtr listener under inetd" + if /usr/bin/egrep -q '^rpki-rtr' /etc/services ; then + echo "You already have a /etc/services entry for rpki-rtr, so I will use it." + elif echo >>/etc/services "rpki-rtr 43779/tcp #RFC 6810" ; then + echo "Added rpki-rtr to /etc/services." + else + echo "Adding rpki-rtr to /etc/services failed, please fix this, then try again." + exit 1 + fi + if /usr/bin/egrep -q "rpki-rtr[ ]+stream[ ]+tcp[ ]" /etc/inetd.conf; then + echo "You already have an inetd.conf entry for rpki-rtr on TCPv4, so I will use it." + elif echo >>/etc/inetd.conf "rpki-rtr stream tcp nowait nobody /usr/local/bin/rtr-origin rtr-origin --server /var/rcynic/rpki-rtr"; then + echo "Added rpki-rtr for TCPv4 to /etc/inetd.conf." + else + echo "Adding rpki-rtr for TCPv4 to /etc/inetd.conf failed, please fix this, then try again." + exit 1 + fi + if /usr/bin/egrep -q "rpki-rtr[ ]+stream[ ]+tcp6[ ]" /etc/inetd.conf; then + echo "You already have an inetd.conf entry for rpki-rtr on TCPv6, so I will use it." + elif echo >>/etc/inetd.conf "rpki-rtr stream tcp6 nowait nobody /usr/local/bin/rtr-origin rtr-origin --server /var/rcynic/rpki-rtr"; then + echo "Added rpki-rtr for TCPv6 to /etc/inetd.conf." + else + echo "Adding rpki-rtr for TCPv6 to /etc/inetd.conf failed, please fix this, then try again." + exit 1 + fi + ;; + +*) + echo "No clue what this script is meant to do when invoked with arguments \"$*\". Punting." + exit 1 + ;; + +esac |