#!/bin/sh # # start/stop portmap daemon. # Don't modify these lines, change or create /etc/default/portmap portmap_chroot_dir=/srv/portmap/chroot portmap_chroot_img=/srv/portmap/chroot.dmg portmap_use_loopback=no test -x /sbin/portmap || exit 0 test -f /etc/default/portmap && . /etc/default/portmap OPTIONS="-t $portmap_chroot_dir" function setup_chroot { oldumask=$(umask) umask 022 if [ ! -d "$portmap_chroot_dir" ]; then mkdir -p "$portmap_chroot_dir" chown root:root "$portmap_chroot_dir" chmod 0755 "$portmap_chroot_dir" fi if [ x$portmap_use_loopback = xyes ]; then if [ ! -f "$portmap_chroot_img" ]; then dd if=/dev/zero of="$portmap_chroot_img" bs=1M count=1 \ > /dev/null 2>&1 fi chmod 0600 "$portmap_chroot_img" chown root:root "$portmap_chroot_img" if ! file "$portmap_chroot_img" | grep -q 'ext2 filesystem'; then mkfs.ext2 -F -m 0 -q "$portmap_chroot_img" > /dev/null 2>&1 fi if ! mount | grep -q "$portmap_chroot_img"; then fsck.ext2 -p "$portmap_chroot_img" > /dev/null mount -o loop,noexec,nosuid "$portmap_chroot_img" \ "$portmap_chroot_dir" fi fi if [ x$portmap_use_loopback = xyes ]; then # Catch the case where the chroot has already been mounted ro mount -o remount,rw "$portmap_chroot_dir" fi mkdir -p "$portmap_chroot_dir" cp /etc/localtime "$portmap_chroot_dir" if [ x$portmap_use_loopback = xyes ]; then mount -o remount,ro "$portmap_chroot_dir" fi umask $oldumask } case "$1" in start) echo -n "Starting portmap daemon:" echo -n " portmap" setup_chroot start-stop-daemon --start --quiet --exec /sbin/portmap -- $OPTIONS echo "." if [ -f /var/run/portmap.upgrade-state ]; then echo -n "Restoring old RPC service information..." sleep 1 # needs a short pause or pmap_set won't work. :( pmap_set /var/run/portmap.state $0 stop $0 start if [ ! -f /var/run/portmap.upgrade-state ]; then sleep 1 pmap_set