#!/bin/sh set -e PATH="/sbin:/bin:/usr/sbin:/usr/bin" PACKAGE=$(basename $0 | sed 's/\..*//') WWWDIR=/var/www/html conf=/etc/inetd.conf pkgdir=/usr/share/$PACKAGE port="www" entry="$port\tstream\ttcp\tnowait nobody:www-data\t/usr/sbin/tcpd /usr/sbin/$PACKAGE $WWWDIR" Debhelper () { : # Automatically added by dh_installsystemd/13.10 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # The following line should be removed in trixie or trixie+1 deb-systemd-helper unmask 'micro-httpd.socket' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'micro-httpd.socket'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'micro-httpd.socket' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'micro-httpd.socket' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.10 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -d /run/systemd/system ]; then systemctl --system daemon-reload >/dev/null || true if [ -n "$2" ]; then _dh_action=restart else _dh_action=start fi deb-systemd-invoke $_dh_action 'micro-httpd.socket' >/dev/null || true fi fi # End automatically added section } Which () { which "$1" > /dev/null 2>&1 } Warn () { echo "$*" >&2 } IsInetd () { [ -x /usr/sbin/update-inetd ] } IsInetdConf () { [ -f $conf ] } IsInInetd () { [ -f $conf ] || return 10 # Debian may have inetd.conf entry already grep -q "^[[:space:]]*$port.*$PACKAGE" $conf || # check for other PORT alias name as well grep -q "^[[:space:]]*(http|80)[[:space:]].*$PACKAGE" $conf } IsConflictInetd () { # Check if some other service already uses PORT grep -q "^[[:space:]#]*$port" $conf } HttpdWarning () { # There isn't much point of inetd if apache already installed and # occupies port 80 if ls /etc/init.d/apache* > /dev/null 2>&1 ; then Warn "$0: [WARN] Apache found. $PACKAGE $conf uses port '$port'" \ "which may be same as in Apache (you may need to change $PACKAGE port)" fi } InetdName () { local name= if [ -f /etc/init.d/inetutils-inetd ]; then name=inetutils-inetd elif [ -f /etc/init.d/openbsd-inetd ]; then name="openbsd-inetd" elif [ -f /etc/init.d/rlinetd ]; then name="rlinetd" fi [ ! "$name" ] || echo $name } CallInetd () { local name=$1 local cmd=$2 [ "$cmd" ] || return 0 if Which invoke-rc.d ; then invoke-rc.d $name $cmd else /etc/init.d/$name $cmd fi } InstallInetd () { Warn "$0: adding new $conf entry" update-inetd --group STANDARD --add "$entry" # This directory must be there [ ! -d $WWWDIR ] && mkdir -p $WWWDIR local name=$(InetdName) CallInetd $name reload } MainInetd () { if [ "$1" = "install" ] || [ "$1" = "configure" ] then if IsConflictInetd ; then Warn "$PACKAGE: [WARNING] Not installing to $conf" \ "due to existing '$port' entry" else IsInInetd || InstallInetd HttpdWarning fi fi } Main () { if IsInetd ; then MainInetd "$@" fi Debhelper "$@" } Main "$@" # End of file