diff options
author | Rob Austein <sra@hactrn.net> | 2013-05-04 20:40:30 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2013-05-04 20:40:30 +0000 |
commit | 23fbe9a7ac2688cf162626ed4536aa986105050a (patch) | |
tree | 2de1a253d17abb42c333c340c3fb99feb6e94d84 | |
parent | e60d23548584b8bf506bb5881094df5eb42a1d49 (diff) |
Absolute pathnames, crontab. See #526.
svn path=/trunk/; revision=5321
-rw-r--r-- | buildtools/freebsd-skeleton/rpki-ca/pkg-deinstall | 41 | ||||
-rw-r--r-- | buildtools/freebsd-skeleton/rpki-ca/pkg-install | 40 |
2 files changed, 58 insertions, 23 deletions
diff --git a/buildtools/freebsd-skeleton/rpki-ca/pkg-deinstall b/buildtools/freebsd-skeleton/rpki-ca/pkg-deinstall index e06815e9..fb184390 100644 --- a/buildtools/freebsd-skeleton/rpki-ca/pkg-deinstall +++ b/buildtools/freebsd-skeleton/rpki-ca/pkg-deinstall @@ -4,33 +4,46 @@ case $2 in DEINSTALL) + /usr/bin/crontab -l -u root 2>/dev/null | + /usr/bin/awk ' + BEGIN { + empty = 1; + } + $0 !~ "/usr/local/libexec/rpkigui-import-routes" && + $0 !~ "/usr/local/libexec/rpkigui-check-expired" && + $0 !~ "/usr/local/sbin/rpkic update_bpki" { + empty = 0; + print | "/usr/bin/crontab -u root -"; + } + END { + if (empty) + system("/usr/bin/crontab -u root -r"); + }' + # Clean up BPKI files. These are all stored in SQL anyway, no great loss. - rm -f /usr/local/share/rpki/ca.cer - rm -f /usr/local/share/rpki/irbe.cer - rm -f /usr/local/share/rpki/irdbd.cer - rm -f /usr/local/share/rpki/pubd.cer - rm -f /usr/local/share/rpki/pubd.key - rm -f /usr/local/share/rpki/rpkid.cer - rm -f /usr/local/share/rpki/rpkid.key + /bin/rm -f /usr/local/share/rpki/ca.cer + /bin/rm -f /usr/local/share/rpki/irbe.cer + /bin/rm -f /usr/local/share/rpki/irdbd.cer + /bin/rm -f /usr/local/share/rpki/pubd.cer + /bin/rm -f /usr/local/share/rpki/pubd.key + /bin/rm -f /usr/local/share/rpki/rpkid.cer + /bin/rm -f /usr/local/share/rpki/rpkid.key # If we were automatically dropping SQL databases, this would be # where we'd want to record what databases to drop. - # If we had cron jobs installed, this is where we'd get rid of - # them (or maybe before whacking the BPKI files). - # Clean up what we did to Apache. /usr/local/libexec/rpkigui-apache-conf-gen --freebsd --remove --verbose - # Clean up configuration file + # Clean up configuration file. - if cmp -s /usr/local/etc/rpki.conf.sample /usr/local/etc/rpki.conf + if /usr/bin/cmp -s /usr/local/etc/rpki.conf.sample /usr/local/etc/rpki.conf then - rm -f /usr/local/etc/rpki.conf + /bin/rm -f /usr/local/etc/rpki.conf fi - rm -f /usr/local/etc/rpki.conf.sample + /bin/rm -f /usr/local/etc/rpki.conf.sample ;; diff --git a/buildtools/freebsd-skeleton/rpki-ca/pkg-install b/buildtools/freebsd-skeleton/rpki-ca/pkg-install index c6f62bf8..b9c1b285 100644 --- a/buildtools/freebsd-skeleton/rpki-ca/pkg-install +++ b/buildtools/freebsd-skeleton/rpki-ca/pkg-install @@ -9,8 +9,8 @@ POST-INSTALL) /usr/local/libexec/rpkigui-apache-conf-gen --freebsd --install --verbose - hostname=`hostname` - handle=`hostname | sed 's/[.]/_/g'` + hostname=`/bin/hostname` + handle=`/bin/hostname | /usr/bin/sed 's/[.]/_/g'` /usr/local/sbin/rpki-confgen \ --read-xml /usr/local/etc/rpki/rpki-confgen.xml \ --autoconf \ @@ -23,18 +23,40 @@ POST-INSTALL) if test ! -f /usr/local/etc/rpki.conf then - cp -p /usr/local/etc/rpki.conf.sample /usr/local/etc/rpki.conf + /bin/cp -p /usr/local/etc/rpki.conf.sample /usr/local/etc/rpki.conf fi - install -o root -g wheel -d /usr/local/share/rpki/publication + /usr/bin/install -o root -g wheel -d /usr/local/share/rpki/publication - rpki-sql-setup - rpki-manage syncdb --noinput - rpki-manage migrate app + /usr/local/sbin/rpki-sql-setup + /usr/local/sbin/rpki-manage syncdb --noinput + /usr/local/sbin/rpki-manage migrate app - rpkic initialize_server_bpki + /usr/local/sbin/rpkic initialize_server_bpki - # We should be setting up a crontab here, but debug the rest of this first. + # We should be setting up crontab to run as user rpkid, but we + # don't have any of the rest of the code running as user rpkid yet + # either, so run this as root too for now. + + /usr/bin/crontab -l -u root 2>/dev/null | + /usr/bin/awk -v t=`/usr/bin/hexdump -n 2 -e '"%u\n"' /dev/random` ' + BEGIN { + cmd["/usr/local/libexec/rpkigui-import-routes"] = sprintf("%2u */2 * * *", t % 60); + cmd["/usr/local/libexec/rpkigui-check-expired"] = "@daily "; + cmd["/usr/local/sbin/rpkic update_bpki" ] = "30 3 * * * "; + } + { + print; + for (i in cmd) + if ($0 ~ i) + found[i] = $0; + } + END { + for (i in cmd) + if (!found[i]) + print cmd[i] "\t" i; + }' | + /usr/bin/crontab -u root - ;; |