CONF=/etc/xinetd.conf
INETDCONF=/etc/inetd.conf
DEFAULT=/etc/default/xinetd
+BACKUPDIR=/var/backups/xinetd-cn
need_restart=0
temp_files=
+xinetd_conf_did=0
# cleanup()
#
# First, we do backup (inetd, xinetd)
#
-if cp_check_and_backup "$INETDCONF"; then
- cp_echo "CN: Old $INETDCONF saved as /var/backups/`basename $INETDCONF`.bak."
+if cp_backup_conffile -r -d $BACKUPDIR -p $INETDCONF; then
+ cp_echo "CN: Old $INETDCONF saved as $BACKUPDIR/`basename $INETDCONF`.bak."
fi
-if cp_check_and_backup "$CONF"; then
- cp_echo "CN: Old $CONF saved as /var/backups/`basename $CONF`.bak."
+if cp_backup_conffile -r -d $BACKUPDIR -p $CONF; then
+ cp_echo "CN: Old $CONF saved as $BACKUPDIR/`basename $CONF`.bak."
fi
CONFTMP=`mktemp $CONF.tmp.XXXXXX`
#
conffile_list="$CONFTMP"
if [ -f "$CONF" ]; then
- conffile_list="$CONF $conffile_list"
+ if egrep -q "^service[[:space:]]+" "$CONF"; then
+ conffile_list="$CONF $conffile_list"
+ xinetd_conf_did=1
+ fi
fi
-services_list="`cat $conffile_list | grep "^service " | uniq | sed 's/service //g'`" || true
+services_list="`cat $conffile_list | egrep "^service[[:space:]]+" | sed -r 's/service[[:space:]]+//g' | uniq`" || true
if [ -n "$services_list" ]; then
if [ -f "/etc/xinetd.d/$service" ]; then
- if cp_check_and_backup "/etc/xinetd.d/$service"; then
- cp_echo "CN: Old /etc/xinetd.d/$service saved as /var/backups/`basename /etc/xinetd.d/$service`.bak."
+ if cp_backup_conffile -r -d $BACKUPDIR -p /etc/xinetd.d/$service; then
+ cp_echo "CN: Old /etc/xinetd.d/$service saved as $BACKUPDIR/`basename /etc/xinetd.d/$service`.bak."
fi
rm -f /etc/xinetd.d/$service
touch /etc/xinetd.d/$service || true
# cat "$CONF" "$CONFTMP" | sed -n "/^service $service/,/^}/p" | cp-update "$PKG" "/etc/xinetd.d/$service"
- cat "$CONF" "$CONFTMP" | sed -n "/^service $service/,/^}/p" >> "/etc/xinetd.d/$service"
+ cat $conffile_list | sed -rn "/^service[[:space:]]+$service/,/^}/p" >> "/etc/xinetd.d/$service"
need_restart=1
done
- if egrep -q "service " "$CONFTMP"; then
+ if egrep -q "^service[[:space:]]+" "$CONFTMP"; then
cp_echo "CN: All services were converted from $INETDCONF file to separated"
cp_echo "CN: configuration files located in /etc/xinetd.d/ directory."
fi
- if [ -f "$CONF" ]; then
+ if [ $xinetd_conf_did -eq 1 ]; then
cp_echo "CN: All services were converted from $CONF file to separated"
cp_echo "CN: configuration files located in /etc/xinetd.d/ directory."
fi
# Remove services from /etc/xinetd.conf file
#
-cp_check_and_sed "^service " \
- "/^service/,/^}/d" \
+cp_check_and_sed "^service[[:space:]]+" \
+ "/^service[[:space:]]/,/^}/d" \
"$CONF" && need_restart=1 || true
# Check if there is no defaults block in /etc/xinetd.conf