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 SERVICE_SUFFIX="@SERVICE_SUFFIX@"
17 INETDCONF=/etc/inetd.conf
18 [ ! -f $INETDCONF ] && INETDCONF=/usr/etc/inetd.conf
20 SERVICES=/etc/services
21 [ ! -f $SERVICES ] && SERVICES=/usr/etc/services
26 "@DEFAULT_SERVER@" | "@DEFAULT_SERVER@".*)
44 SERVICE_SUFFIX=`echo $1 | sed -e 's/[^=]*=//'`;;
46 SUF=`echo $1 | sed -e 's/[^=]*=//'`;;
48 INETDCONF=`echo $1 | sed -e 's/[^=]*=//' -e 's%^$%/dev/null%'`;;
50 SERVICES=`echo $1 | sed -e 's/[^=]*=//' -e 's%^$%/dev/null%'`;;
52 libexecdir=`echo $1 | sed -e 's/[^=]*=//'`;;
54 USER=`echo $1 | sed -e 's/[^=]*=//'`;;
58 ENABLE_AMANDAD=false;;
68 CLIENT_PORT=`echo $1 | sed -e 's/[^=]*=//'`;;
70 KCLIENT_PORT=`echo $1 | sed -e 's/[^=]*=//'`;;
72 INDEX_PORT=`echo $1 | sed -e 's/[^=]*=//'`;;
74 TAPE_PORT=`echo $1 | sed -e 's/[^=]*=//'`;;
75 --usage | --help | -h)
76 echo `_ 'call this script with zero or more of the following arguments:'`
77 echo `_ '--version-suffix=<suffix>: deprecated option' ""`
78 echo `_ '--service-suffix=<suffix>: append to service names [%s]' "$SERVICE_SUFFIX"`
79 echo `_ '--libexecdir=<dirname>: where daemons should be looked for [%s]' "$libexecdir"`
80 echo `_ '--inetd=<pathname>: full pathname of inetd.conf [%s]' "$INETDCONF"`
81 echo `_ '--services=<pathname>: full pathname of services [%s]' "$SERVICES"`
82 echo `_ '\tan empty pathname or /dev/null causes that file to be skipped'`
83 echo `_ '--user=<username>: run deamons as this user [%s]' "$USER"`
84 echo `_ '--enable/disable-client: enable/disable amandad [%s]' \`$ENABLE_AMANDAD && echo enabled || echo disabled\``
85 echo `_ '--enable/disable-index: enable/disable index server [%s]' \`$ENABLE_INDEX && echo enabled || echo disabled\``
86 echo `_ '--enable/disable-tape: enable/disable tape server [%s]' \`$ENABLE_TAPE && echo enabled || echo disabled\``
87 echo `_ '--client-port=<num>: amandad port number [%s]' "$CLIENT_PORT"`
88 echo `_ '--kclient-port=<num>: kamandad port number [%s]' "$KCLIENT_PORT"`
89 echo `_ '--index-port=<num>: index server port number [%s]' "$INDEX_PORT"`
90 echo `_ '--tape-port=<num>: tape server port number [%s]' "$TAPE_PORT"`
93 echo `_ '%s: invalid argument %s. run with -h for usage\n' "$0" "$1"` >&2
99 if [ "$SERVICES" = /dev/null ]; then :
100 elif [ -f "$SERVICES" ]; then
103 egrep < "$SERVICES" -v "^(amanda|kamanda|amandaidx|amidxtape)${SERVICE_SUFFIX}[ ]"
104 echo "amanda${SERVICE_SUFFIX} ${CLIENT_PORT}/udp"
105 echo "amanda${SERVICE_SUFFIX} ${CLIENT_PORT}/tcp"
106 echo "kamanda${SERVICE_SUFFIX} ${KCLIENT_PORT}/udp"
107 echo "amandaidx${SERVICE_SUFFIX} ${INDEX_PORT}/tcp"
108 echo "amidxtape${SERVICE_SUFFIX} ${TAPE_PORT}/tcp"
110 if diff "$SERVICES" "$TEMP" >/dev/null 2>/dev/null; then
111 echo `_ '%s is up to date' "$SERVICES"`
113 cp "$TEMP" "$SERVICES" || echo `_ 'cannot patch %s' "$SERVICES"`
117 echo `_ '%s not found!' "$SERVICES"`
119 if [ "$INETDCONF" = /dev/null ]; then :
120 elif [ -f "$INETDCONF" ]; then
121 err=`_ 'warning: %s/amandad%s does not exist' "$libexecdir" ""`
122 $ENABLE_AMANDAD && test ! -f $libexecdir/amandad && echo "$err" >&2
123 err=`_ 'warning: %s/amindexd%s does not exist' "$libexecdir" ""`
124 $ENABLE_INDEX && test ! -f $libexecdir/amindexd && echo "$err" >&2
125 err=`_ 'warning: %s/amidxtaped%s does not exist' "$libexecdir" ""`
126 $ENABLE_TAPE && test ! -f $libexecdir/amidxtaped && echo "$err" >&2
127 TEMP="$INETDCONF.new"
129 egrep < "$INETDCONF" -v "^(amanda|amandaidx|amidxtape)${SERVICE_SUFFIX}[ ]"
130 $ENABLE_AMANDAD && echo "amanda${SERVICE_SUFFIX} dgram udp wait $USER $libexecdir/amandad amandad"
131 $ENABLE_INDEX && echo "amandaidx${SERVICE_SUFFIX} stream tcp nowait $USER $libexecdir/amindexd amindexd"
132 $ENABLE_TAPE && echo "amidxtape${SERVICE_SUFFIX} stream tcp nowait $USER $libexecdir/amidxtaped amidxtaped"
134 if diff "$INETDCONF" "$TEMP" >/dev/null 2>/dev/null; then
135 fmt="%s is up to date\n"
136 printf $fmt $INETDCONF
138 fmt="cannot patch %s\n"
139 cp "$TEMP" "$INETDCONF" || printf $fmt $INETDCONF
143 fmt="%s not found!\n"
144 printf $fmt $INETDCONF