#!/bin/sh
# 4093056

BACKUPDIR="$3/etc/xinetd.d-migrated2launchd"
XINETDD="$3/etc/xinetd.d"

mkdir -p "${BACKUPDIR}"

cd "$3/System/Library/LaunchDaemons"
ls | sed 's,\.plist$,,g' | while read
do
        if [ -f "${XINETDD}/${REPLY}" ]
        then
                egrep "disable.*=.*no" "${XINETDD}/${REPLY}" >/dev/null 2>&1 && launchctl load -w ${REPLY}.plist
                mv "${XINETDD}/${REPLY}" "${BACKUPDIR}"
        fi
done

TMPFILE="${INSTALLER_TEMP}/tftpd.plist.new"

/bin/cat "$3/System/Library/LaunchDaemons/tftp.plist" | sed 's,<string>-s</string>,<string>-i</string>,g' > "${TMPFILE}"
/bin/cp -P "${TMPFILE}" "$3/System/Library/LaunchDaemons/tftp.plist"
/bin/chmod 0644 "$3/System/Library/LaunchDaemons/tftp.plist"

/bin/rm "${TMPFILE}"
/bin/rm -f "${XINETDD}/ssh.save"
