3 # patch inetd.conf and services
4 # originally by Axel Zinser (fifi@hiss.han.de)
8 exec_prefix="@exec_prefix@"
10 amlibexecdir="@amlibexecdir@"
11 . "${amlibexecdir}/amanda-sh-lib.sh"
13 USE_VERSION_SUFFIXES="@USE_VERSION_SUFFIXES@"
14 if test "$USE_VERSION_SUFFIXES" = "yes"; then
20 SERVICE_SUFFIX="@SERVICE_SUFFIX@"
24 INETDCONF=/etc/inetd.conf
25 [ ! -f $INETDCONF ] && INETDCONF=/usr/etc/inetd.conf
27 SERVICES=/etc/services
28 [ ! -f $SERVICES ] && SERVICES=/usr/etc/services
33 "@DEFAULT_SERVER@" | "@DEFAULT_SERVER@".*)
51 SERVICE_SUFFIX=`echo $1 | sed -e 's/[^=]*=//'`;;
53 SUF=`echo $1 | sed -e 's/[^=]*=//'`;;
55 INETDCONF=`echo $1 | sed -e 's/[^=]*=//' -e 's%^$%/dev/null%'`;;
57 SERVICES=`echo $1 | sed -e 's/[^=]*=//' -e 's%^$%/dev/null%'`;;
59 libexecdir=`echo $1 | sed -e 's/[^=]*=//'`;;
61 USER=`echo $1 | sed -e 's/[^=]*=//'`;;
65 ENABLE_AMANDAD=false;;
75 CLIENT_PORT=`echo $1 | sed -e 's/[^=]*=//'`;;
77 KCLIENT_PORT=`echo $1 | sed -e 's/[^=]*=//'`;;
79 INDEX_PORT=`echo $1 | sed -e 's/[^=]*=//'`;;
81 TAPE_PORT=`echo $1 | sed -e 's/[^=]*=//'`;;
82 --usage | --help | -h)
83 echo `_ 'call this script with zero or more of the following arguments:'`
84 echo `_ '--version-suffix=<suffix>: append to program names [%s]' "$SUF"`
85 echo `_ '--service-suffix=<suffix>: append to service names [%s]' "$SERVICE_SUFFIX"`
86 echo `_ '--libexecdir=<dirname>: where daemons should be looked for [%s]' "$libexecdir"`
87 echo `_ '--inetd=<pathname>: full pathname of inetd.conf [%s]' "$INETDCONF"`
88 echo `_ '--services=<pathname>: full pathname of services [%s]' "$SERVICES"`
89 echo `_ '\tan empty pathname or /dev/null causes that file to be skipped'`
90 echo `_ '--user=<username>: run deamons as this user [%s]' "$USER"`
91 echo `_ '--enable/disable-client: enable/disable amandad [%s]' \`$ENABLE_AMANDAD && echo enabled || echo disabled\``
92 echo `_ '--enable/disable-index: enable/disable index server [%s]' \`$ENABLE_INDEX && echo enabled || echo disabled\``
93 echo `_ '--enable/disable-tape: enable/disable tape server [%s]' \`$ENABLE_TAPE && echo enabled || echo disabled\``
94 echo `_ '--client-port=<num>: amandad port number [%s]' "$CLIENT_PORT"`
95 echo `_ '--kclient-port=<num>: kamandad port number [%s]' "$KCLIENT_PORT"`
96 echo `_ '--index-port=<num>: index server port number [%s]' "$INDEX_PORT"`
97 echo `_ '--tape-port=<num>: tape server port number [%s]' "$TAPE_PORT"`
100 echo `_ '%s: invalid argument %s. run with -h for usage\n' "$0" "$1"` >&2
106 if [ "$SERVICES" = /dev/null ]; then :
107 elif [ -f "$SERVICES" ]; then
110 egrep < "$SERVICES" -v "^(amanda|kamanda|amandaidx|amidxtape)${SERVICE_SUFFIX}[ ]"
111 echo "amanda${SERVICE_SUFFIX} ${CLIENT_PORT}/udp"
112 echo "amanda${SERVICE_SUFFIX} ${CLIENT_PORT}/tcp"
113 echo "kamanda${SERVICE_SUFFIX} ${KCLIENT_PORT}/udp"
114 echo "amandaidx${SERVICE_SUFFIX} ${INDEX_PORT}/tcp"
115 echo "amidxtape${SERVICE_SUFFIX} ${TAPE_PORT}/tcp"
117 if diff "$SERVICES" "$TEMP" >/dev/null 2>/dev/null; then
118 echo `_ '%s is up to date' "$SERVICES"`
120 cp "$TEMP" "$SERVICES" || echo `_ 'cannot patch %s' "$SERVICES"`
124 echo `_ '%s not found!' "$SERVICES"`
126 if [ "$INETDCONF" = /dev/null ]; then :
127 elif [ -f "$INETDCONF" ]; then
128 err=`_ 'warning: %s/amandad%s does not exist' "$libexecdir" "$SUF"`
129 $ENABLE_AMANDAD && test ! -f $libexecdir/amandad$SUF && echo "$err" >&2
130 err=`_ 'warning: %s/amindexd%s does not exist' "$libexecdir" "$SUF"`
131 $ENABLE_INDEX && test ! -f $libexecdir/amindexd$SUF && echo "$err" >&2
132 err=`_ 'warning: %s/amidxtaped%s does not exist' "$libexecdir" "$SUF"`
133 $ENABLE_TAPE && test ! -f $libexecdir/amidxtaped$SUF && echo "$err" >&2
134 TEMP="$INETDCONF.new"
136 egrep < "$INETDCONF" -v "^(amanda|amandaidx|amidxtape)${SERVICE_SUFFIX}[ ]"
137 $ENABLE_AMANDAD && echo "amanda${SERVICE_SUFFIX} dgram udp wait $USER $libexecdir/amandad$SUF amandad$SUF"
138 $ENABLE_INDEX && echo "amandaidx${SERVICE_SUFFIX} stream tcp nowait $USER $libexecdir/amindexd$SUF amindexd$SUF"
139 $ENABLE_TAPE && echo "amidxtape${SERVICE_SUFFIX} stream tcp nowait $USER $libexecdir/amidxtaped$SUF amidxtaped$SUF"
141 if diff "$INETDCONF" "$TEMP" >/dev/null 2>/dev/null; then
142 fmt="%s is up to date\n"
143 printf $fmt $INETDCONF
145 fmt="cannot patch %s\n"
146 cp "$TEMP" "$INETDCONF" || printf $fmt $INETDCONF
150 fmt="%s not found!\n"
151 printf $fmt $INETDCONF