"Fossies" - the Fresh Open Source Software Archive

Member "backup2l-1.5/install-sh" (4 Jan 2004, 3469 Bytes) of package /linux/privat/backup2l_1.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/bash
    2 
    3 set -e
    4 
    5 NO_PROMPT=0
    6 TOUCH_CONF=1
    7 UNINST=0
    8 case $1 in
    9     -f)
   10         NO_PROMPT=1
   11         TOUCH_CONF=0
   12         shift
   13         ;;
   14     -fc)
   15         NO_PROMPT=1
   16         shift
   17         ;;
   18     -u)
   19         NO_PROMPT=1
   20         UNINST=1
   21         TOUCH_CONF=0
   22         shift
   23         ;;
   24     -uc)
   25         NO_PROMPT=1
   26         UNINST=1
   27         shift
   28         ;;
   29 esac
   30 
   31 if [[ "$1" != "" ]]; then
   32     PREFIX=${1%/}
   33 else
   34     PREFIX="/usr/local"
   35 fi
   36 if [[ "$2" != "" ]]; then
   37     PREFIX_BIN=${2%/}
   38 else
   39     PREFIX_BIN="$PREFIX/bin"
   40 fi
   41 if [[ "$3" != "" ]]; then
   42     PREFIX_CONF=${3%/}
   43 else
   44     PREFIX_CONF="/etc"
   45 fi
   46 
   47 if [[ "$NO_PROMPT" == "0" ]]; then
   48     cat << EOF
   49 Usage: install-sh [ -f | -fc | -u | -uc ] [ <prefix> ] [ <bin-prefix> ] [ <conf-prefix> ]
   50 Where
   51     -f:  (Re-)Install program
   52     -fc: (Re-)Install program and configuration files
   53     -u:  Uninstall program
   54     -uc: Uninstall program and configuration files
   55 
   56     <prefix>:      Location (default: /usr/local)
   57     <bin-prefix>:  Location for binary files (default: <prefix>/bin)
   58     <conf-prefix>: Location for configuration files (default: /etc)
   59 
   60 
   61 EOF
   62 fi
   63 
   64 CRON_FILE=""
   65 if [[ "$TOUCH_CONF" == "1" ]]; then
   66     if [ -d $PREFIX_CONF/cron.daily ]; then
   67         # standard cron/daily path for some Linux's...
   68         CRON_FILE=$PREFIX_CONF/cron.daily/zz-backup2l
   69     elif [ -d $PREFIX_CONF/periodic/daily ]; then
   70         # standard cron/daily path for Mac OS X...
   71         CRON_FILE=$PREFIX_CONF/periodic/daily/zz-backup2l
   72     fi
   73 fi
   74 
   75 PROG_FILES="$PREFIX_BIN/backup2l $PREFIX/man/man8/backup2l.8.gz"
   76 CONF_FILES="$PREFIX_CONF/backup2l.conf $CRON_FILE"
   77 
   78 if [[ "$UNINST" == "0" ]]; then
   79 
   80     # Installation...
   81     if [[ "$NO_PROMPT" == "0" ]]; then
   82         echo -e "I am about to install the following program file(s):\n  $PROG_FILES\n"
   83         read -p "Do you want to continue? [y/N] " ANSWER
   84         echo
   85         if [[ "$ANSWER" != "y" ]]; then
   86             echo "Stopping."
   87             exit 1
   88         fi
   89     fi
   90 
   91     mkdir -p $PREFIX_BIN $PREFIX/man/man8
   92     cp -af backup2l $PREFIX_BIN
   93     gzip -9 -c backup2l.8 > $PREFIX/man/man8/backup2l.8.gz
   94     echo "Program files installed."
   95 
   96     if [[ "$TOUCH_CONF" == "1" && "$NO_PROMPT" == "0" ]]; then
   97         echo -e "\nI can install the following configuration file(s):\n  $CONF_FILES\n"
   98         echo "This is recommended for a first-time installation."
   99         echo -e "Warning: Previously existing files will be overwritten!\n"
  100         read -p "Do you want to continue? [y/N] " ANSWER
  101         echo
  102         if [[ "$ANSWER" != "y" ]]; then
  103             TOUCH_CONF=0
  104         fi
  105     fi
  106 
  107     if [[ "$TOUCH_CONF" == "1" ]]; then
  108         mkdir -p $PREFIX_CONF
  109         cp -af first-time.conf $PREFIX_CONF/backup2l.conf
  110         echo "Configuration files installed."
  111         if [[ "$CRON_FILE" != "" ]]; then
  112             cp -af zz-backup2l $CRON_FILE
  113         else
  114             echo -e "\nNote: No suitable cron directory found - file 'zz-backup2l' not (un-)installed automatically."
  115         fi
  116     else
  117         echo "No configuration files installed."
  118     fi
  119 
  120 else
  121 
  122     # Un-installation...
  123     echo "Removing program file(s): $PROG_FILES"
  124     rm -f $PROG_FILES
  125     if [[ "$TOUCH_CONF" == "1" ]]; then
  126         echo "Removing configuration file(s): $CONF_FILES"
  127         rm -f $CONF_FILES
  128         if [[ "$CRON_FILE" == "" ]]; then
  129             echo -e "\nNote: Cron directory not found - eventually remove 'zz-backup2l' manually."
  130         fi
  131     else
  132         echo "Configuration files NOT removed."
  133     fi
  134 fi