home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_amanda.idb / usr / freeware / libexec / patch-system.z / patch-system
Encoding:
Text File  |  1999-07-16  |  4.5 KB  |  139 lines

  1. #! /bin/sh
  2. #
  3. # patch inetd.conf and services
  4. # originally by Axel Zinser (fifi@hiss.han.de)
  5. #
  6.  
  7. prefix="/usr/freeware"
  8. exec_prefix="${prefix}"
  9. libexecdir="/usr/freeware/libexec"
  10.  
  11. USE_VERSION_SUFFIXES="no"
  12. if test "$USE_VERSION_SUFFIXES" = "yes"; then
  13.     SUF="-2.4.1p1"
  14. else
  15.     SUF=
  16. fi
  17.  
  18. SERVICE_SUFFIX=""
  19.  
  20. USER="root"
  21.  
  22. INETDCONF=/etc/inetd.conf
  23. [ ! -f $INETDCONF ] && INETDCONF=/usr/etc/inetd.conf
  24.  
  25. SERVICES=/etc/services
  26. [ ! -f $SERVICES ] && SERVICES=/usr/etc/services
  27.  
  28. ENABLE_AMANDAD=true
  29.  
  30. case `uname -n` in
  31. "amanda-server" | "amanda-server".*)
  32.     ENABLE_INDEX=true
  33.     ENABLE_TAPE=true
  34.     ;;
  35. *)
  36.     ENABLE_INDEX=false
  37.     ENABLE_TAPE=false
  38.     ;;
  39. esac
  40.  
  41. CLIENT_PORT=10080
  42. INDEX_PORT=10082
  43. TAPE_PORT=10083
  44.  
  45. while [ $# != 0 ]; do
  46.     case "$1" in
  47.     --service-suffix=*)
  48.     SERVICE_SUFFIX=`echo $1 | sed -e 's/[^=]*=//'`;;
  49.     --version-suffix=*)
  50.     SUF=`echo $1 | sed -e 's/[^=]*=//'`;;
  51.     --inetd=*)
  52.         INETDCONF=`echo $1 | sed -e 's/[^=]*=//' -e 's%^$%/dev/null%'`;;
  53.     --services=*)
  54.     SERVICES=`echo $1 | sed -e 's/[^=]*=//' -e 's%^$%/dev/null%'`;;
  55.     --libexecdir=?*)
  56.     libexecdir=`echo $1 | sed -e 's/[^=]*=//'`;;
  57.     --user=?*)
  58.     USER=`echo $1 | sed -e 's/[^=]*=//'`;;
  59.     --enable-client)
  60.     ENABLE_AMANDAD=true;;
  61.     --disable-client)
  62.     ENABLE_AMANDAD=false;;
  63.     --enable-index)
  64.     ENABLE_INDEX=true;;
  65.     --disable-index)
  66.     ENABLE_INDEX=false;;
  67.     --enable-tape)
  68.     ENABLE_TAPE=true;;
  69.     --disable-tape)
  70.     ENABLE_TAPE=false;;
  71.     --client-port=?*)
  72.     CLIENT_PORT=`echo $1 | sed -e 's/[^=]*=//'`;;
  73.     --index-port=?*)
  74.     INDEX_PORT=`echo $1 | sed -e 's/[^=]*=//'`;;
  75.     --tape-port=?*)
  76.     TAPE_PORT=`echo $1 | sed -e 's/[^=]*=//'`;;
  77.     --usage | --help | -h)
  78.     echo "call this script with zero or more of the following arguments:"
  79.     echo "--version-suffix=<suffix>: append to program names [$SUF]"
  80.     echo "--service-suffix=<suffix>: append to service names [$SERVICE_SUFFIX]"
  81.     echo "--libexecdir=<dirname>: where daemons should be looked for [$libexecdir]"
  82.     echo "--inetd=<pathname>: full pathname of inetd.conf [$INETDCONF]"
  83.     echo "--services=<pathname>: full pathname of services [$SERVICES]"
  84.     echo "    an empty pathname or /dev/null causes that file to be skipped"
  85.     echo "--user=<username>: run deamons as this user [$USER]"
  86.     echo "--enable/disable-client: enable/disable amandad [`$ENABLE_AMANDAD && echo enabled || echo disabled`]"
  87.     echo "--enable/disable-index: enable/disable index server [`$ENABLE_INDEX && echo enabled || echo disabled`]"
  88.     echo "--enable/disable-tape: enable/disable tape server [`$ENABLE_TAPE && echo enabled || echo disabled`]"
  89.     echo "--client-port=<num>: amandad port number [$CLIENT_PORT]"
  90.     echo "--index-port=<num>: index server port number [$INDEX_PORT]"
  91.     echo "--tape-port=<num>: tape server port number [$TAPE_PORT]"
  92.     exec true;;
  93.     *)
  94.     echo "$0: invalid argument $1.  run with -h for usage" >&2
  95.     exec false;;
  96.     esac
  97.     shift
  98. done
  99.  
  100. if [ "$SERVICES" = /dev/null ]; then :
  101. elif [ -f "$SERVICES" ]; then
  102.     TEMP="$SERVICES.new"
  103.     {
  104.         egrep < "$SERVICES" -v "^(amanda|amandaidx|amidxtape)${SERVICE_SUFFIX}[     ]"
  105.         $ENABLE_AMANDAD && echo "amanda${SERVICE_SUFFIX} ${CLIENT_PORT}/udp"
  106.         $ENABLE_INDEX && echo "amandaidx${SERVICE_SUFFIX} ${INDEX_PORT}/tcp"
  107.         $ENABLE_TAPE && echo "amidxtape${SERVICE_SUFFIX} ${TAPE_PORT}/tcp"
  108.     } > "$TEMP"
  109.     if diff "$SERVICES" "$TEMP" >/dev/null 2>/dev/null; then
  110.         echo "$SERVICES is up to date"
  111.     else
  112.         cp "$TEMP" "$SERVICES" || echo "cannot patch $SERVICES"
  113.     fi
  114.     rm -f "$TEMP"
  115. else
  116.     echo "$SERVICES not found!"
  117. fi
  118. if [ "$INETDCONF" = /dev/null ]; then :
  119. elif [ -f "$INETDCONF" ]; then
  120.     $ENABLE_AMANDAD && test ! -f $libexecdir/amandad$SUF && echo "warning: $libexecdir/amandad$SUF does not exist" >&2
  121.     $ENABLE_INDEX && test ! -f $libexecdir/amindexd$SUF && echo "warning: $libexecdir/amindexd$SUF does not exist" >&2
  122.     $ENABLE_TAPE && test ! -f $libexecdir/amidxtaped$SUF && echo "warning: $libexecdir/amidxtaped$SUF does not exist" >&2
  123.     TEMP="$INETDCONF.new"
  124.     {
  125.         egrep < "$INETDCONF" -v "^(amanda|amandaidx|amidxtape)${SERVICE_SUFFIX}[     ]"
  126.         $ENABLE_AMANDAD && echo "amanda${SERVICE_SUFFIX}    dgram  udp wait   $USER $libexecdir/amandad$SUF    amandad$SUF"
  127.         $ENABLE_INDEX && echo "amandaidx${SERVICE_SUFFIX} stream tcp nowait $USER $libexecdir/amindexd$SUF   amindexd$SUF"
  128.         $ENABLE_TAPE && echo "amidxtape${SERVICE_SUFFIX} stream tcp nowait $USER $libexecdir/amidxtaped$SUF amidxtaped$SUF"
  129.     } > "$TEMP"
  130.     if diff "$INETDCONF" "$TEMP" >/dev/null 2>/dev/null; then
  131.         echo "$INETDCONF is up to date"
  132.     else
  133.         cp "$TEMP" "$INETDCONF" || echo "cannot patch $INETDCONF"
  134.     fi
  135.     rm -f "$TEMP"
  136. else
  137.     echo "$INETDCONF not found!"
  138. fi
  139.