From: Daniel Kahn Gillmor Date: Fri, 12 Sep 2008 21:10:49 +0000 (-0400) Subject: streamlined pkg-install and pkg-deinstall, based on mysql and postgresql ports X-Git-Tag: monkeysphere_0.16-1~62 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=85b105c27fb67921199d282dc90d612c9b525bee;p=monkeysphere.git streamlined pkg-install and pkg-deinstall, based on mysql and postgresql ports --- diff --git a/packaging/freebsd/pkg-deinstall b/packaging/freebsd/pkg-deinstall index 84217d5..03db8e8 100755 --- a/packaging/freebsd/pkg-deinstall +++ b/packaging/freebsd/pkg-deinstall @@ -8,11 +8,17 @@ # FIXME: is /var/lib/monkeysphere the right place for this stuff on # FreeBSD? -VARLIB="/var/lib/monkeysphere" +VARLIB="/var/monkeysphere" +case $2 in +POST-DEINSTALL) # FIXME: This needs to be filled in! Under what circumstances do we -# want to actually purge all of /var/lib/monkeysphere? +# want to actually purge all of /var/monkeysphere? # (note: FreeBSD does not seem to want the package-specific user to be # purged at package removal) + echo "Warning: If you will *NOT* use this package anymore, please remove the monkeysphere user manually." + echo " You may also want to remove the cached authentication data and keyrings in $VARLIB" +;; +esac diff --git a/packaging/freebsd/pkg-install b/packaging/freebsd/pkg-install index c2af960..dc75cf7 100755 --- a/packaging/freebsd/pkg-install +++ b/packaging/freebsd/pkg-install @@ -1,123 +1,67 @@ #!/bin/sh # an installation script for monkeysphere (borrowing liberally from -# Wnn6's port and from monkeysphere's debian/monkeysphere.postinst) +# postgresql and mysql pkg-install scripts, and from monkeysphere's +# debian/monkeysphere.postinst) # Author: Daniel Kahn Gillmor # Copyright 2008 # FIXME: is /var/lib/monkeysphere the right place for this stuff on # FreeBSD? -VARLIB="/var/lib/monkeysphere" -check_pw() -{ - if which -s pw; then - : - else - cat </dev/null; then + echo "You already have a group \"${GROUP}\", so I will use it." + else + if pw groupadd ${GROUP} -g ${GID}; then + echo "Added group \"${GROUP}\"." + else + echo "Adding group \"${GROUP}\" failed..." + exit 1 + fi + fi + + if pw user show "${USER}" 2>/dev/null; then + echo "You already have a user \"${USER}\", so I will use it." + else + if pw useradd ${USER} -u ${UID} -g ${GROUP} -h - \ + -d "$VARLIB" -s /sbin/sh -c "monkeysphere authentication user,,," + then + echo "Added user \"${USER}\"." + else + echo "Adding user \"${USER}\" failed..." + exit 1 + fi + fi + + ## set up the cache directories: + + install --owner root --group monkeysphere --mode 750 -d "$VARLIB"/gnupg-host + cat < "$VARLIB"/gnupg-host/gpg.conf +list-options show-uid-validity EOF - exit 1 - fi -} - -ask() { - local question default answer - - question=$1 - default=$2 - if [ -z "${PACKAGE_BUILDING}" ]; then - read -p "${question} (y/n) [${default}]? " answer - fi - if [ x${answer} = x ]; then - answer=${default} - fi - echo ${answer} -} - -yesno() { - local dflt question answer - - question=$1 - dflt=$2 - while :; do - answer=$(ask "${question}" "${dflt}") - case "${answer}" in - [Yy]*) return 0;; - [Nn]*) return 1;; - esac - echo "Please answer yes or no." - done -} - -failure() { - local retval badgroups badusers - retval=$1 - badgroups=`getent group monkeysphere 641` - badusers=`getent passwd monkeysphere 641` - - if [ X"$badgroups" != X ]; then - badgroups=" -Conflicting group(s): -$badgroups" - fi - - if [ X"$badusers" != X ]; then - badusers="Conflicting user(s): - -$badusers" - fi - - cat < "$VARLIB"/gnupg-authentication/gpg.conf +list-options show-uid-validity +primary-keyring $VARLIB/gnupg-authentication/pubring.gpg +keyring $VARLIB/gnupg-host/pubring.gpg EOF - exit $retval -} - -case $2 in -POST-INSTALL) + chown monkeysphere:monkeysphere "$VARLIB"/gnupg-authentication/gpg.conf - # make sure that the correct user and group are present: - id_monkeysphere=`id -u monkeysphere 2> /dev/null` - gid_monkeysphere=`getent group monkeysphere | cut -f3 -d: 2> /dev/null` - if [ X"$id_monkeysphere" = X641 ] && [ X"$gid_monkeysphere" = X641 ];then - exit 0 - else - # add an account 'monkeysphere' to this system - echo "" - echo "You need an account 'monkeysphere' whose ID number is 641, with group 'monkeysphere' (GID 641)" - if yesno "Would you like to create it automatically?" y; then - # We need a command 'pw(8)' - check_pw - pw groupadd monkeysphere -g 641 || failure $? - pw useradd monkeysphere -u 641 -g 641 -h - -d "$VARLIB" \ - -s /bin/sh -c 'monkeysphere authentication user,,,' || failure $? - # FIXME: should we really be using a real shell? Convention - # (/usr/ports/UIDs) seems to indicate /nonexistent is - # preferred - else - echo "Please create it, and try again." - exit 1 - fi - fi - # FIXME: we should create $VARLIB and chown the relevant subdirs - # (see debian/monkeysphere.postinst) - - ;; + ;; esac