# HG changeset patch # User Changaco # Date 1334528699 -7200 # Node ID 0d4378996672d5175b34646c309c8b4dee4fbb9e # Parent 292896092ee6de013ac6ec297e27dead630722dd improve setup script Signed-off-by: Changaco diff --git a/README b/README --- a/README +++ b/README @@ -8,7 +8,6 @@ Dependencies: Compatibility: gamin only works on Linux and FreeBSD as of April 2012 -Installation: ./setup install -Removal: ./setup uninstall +Installation/Removal/Update: ./setup install|uninstall|update Configuration: see examples/ diff --git a/setup b/setup --- a/setup +++ b/setup @@ -1,7 +1,7 @@ #!/bin/sh usage () { - echo "usage: [DESTDIR=/] [PREFIX=/usr] $(basename "$0") install|uninstall" && exit 1 + echo "usage: [DESTDIR=/] [PREFIX=/usr] $(basename "$0") install|uninstall|update" && exit 1 } remove () { @@ -22,15 +22,22 @@ install_dir () { [ ! -w "$DESTDIR" ] && echo "You don't have write access on $DESTDIR" && exit 1 progname=feed-push +confdir="${DESTDIR}etc/$progname" if [ "$action" == install ]; then install -v -m 755 -D $progname "$_PREFIX/bin/$progname" install_dir examples "$_PREFIX/share/$progname" - [ -d /etc/rc.d ] && install_dir rc.d "${DESTDIR}etc" + [ -d /etc/rc.d ] && install_dir rc.d "${DESTDIR}etc" && mkdir -v "$confdir" elif [ "$action" == uninstall ]; then - remove "$PREFIX/bin/$progname" - remove "$PREFIX/share/$progname/examples" - remove "/etc/rc.d/$progname" + remove "$_PREFIX/bin/$progname" + remove "$_PREFIX/share/$progname/examples" + remove "${DESTDIR}etc/rc.d/$progname" + if [ $(ls -a "$confdir") -eq 2 ]; then rmdir "$confdir" + else echo "not removing config dir $confdir (not empty)" + fi +elif [ "$action" == update ]; then + $0 uninstall &>/dev/null + $0 install else usage fi