#!/bin/sh -
# Extra post-upgrade for nosh-bundles
# vim: set filetype=sh:

# /run is now in the root.
test -e /var/run || ln -s -f -- /run /var/

# adjust to new log users
for i in \
	devd \
	natd \
	sppp \
	sysinit \
	;
do
	if test -d /var/log/sv/$i/
	then
                find /var/log/sv/$i/ \( -name '@*' -o -name lock -o -name current \) -print0|xargs -0 chown "$i"-log
	fi
done
# Adjust to new relationships.
for I in \
	kmod@vboxguest \
	kmod@vboxsf \
	kmod@vboxvideo \
	kmod@vboxadd \
	kmod@vboxdrv \
	kmod@vboxnetadp \
	kmod@vboxnetflt \
	kmod@vboxpci \
	;
do
	if svcdir="`system-control find cyclog@"$I".service 2>/dev/null`"
	then
		rm -f -- "${svcdir}"/wanted-by/workstation/wants/cyclog@"$I"
		rm -f -- "${svcdir}"/wanted-by/workstation
	fi
done
for I in \
	dbus-broker \
	dbus-daemon \
	;
do
	if svcdir="`system-control find "$I".service 2>/dev/null`"
	then
		rm -f -- "${svcdir}"/wanted-by/workstation/wants/"$I"
		rm -f -- "${svcdir}"/wanted-by/workstation
	fi
done
for I in \
	cyclog@cleanvar \
	cleanvar \
	;
do
	if svcdir="`system-control find "$I".service 2>/dev/null`"
	then
		rm -f -- "${svcdir}"/wanted-by/workstation/wants/"$I"
		rm -f -- "${svcdir}"/wanted-by/sysinit/wants/"$I"
	fi
done
for I in \
	kernel-vt-kbdcontrol \
	kernel-vt-vidcontrol \
	cleanuucp \
	;
do
	if svcdir="`system-control find "$I".service 2>/dev/null`"
	then
		rm -f -- "${svcdir}"/wanted-by/sysinit/wants/"$I"
		rm -f -- "${svcdir}"/wanted-by/sysinit
	fi
done
for I in \
	static-networking \
	cyclog@static-networking \
	;
do
	if svcdir="`system-control find "$I".service 2>/dev/null`"
	then
		rm -f -- "${svcdir}"/wanted-by/workstation/wants/"$I"
		rm -f -- "${svcdir}"/stopped-by/shutdown/conflicts/"$I"
	fi
done
for I in \
	normal \
	graphics \
	workstation \
	server \
	;
do
	if svcdir="`system-control find "$I".target 2>/dev/null`"
	then
		rm -f -- "${svcdir}"/wants/basic
		rm -f -- "${svcdir}"/after/basic
	fi
done
for I in \
	appcafe \
	extra-shared-libraries \
	name-services \
	jails \
	uhidd \
	warden \
	sockets \
	remote-fs \
	remote-fs-pre \
	;
do
	if svcdir="`system-control find "$I".target 2>/dev/null`"
	then
		rm -f -- "${svcdir}"/wanted-by/sysinit/wants/"$I"
		rm -f -- "${svcdir}"/wanted-by/sysinit
	fi
done
for I in \
	avahi-daemon \
	gpsd \
	initctld \
	lircd \
	;
do
	if svcdir="`system-control find "$I".service 2>/dev/null`"
	then
		rm -f -- "${svcdir}"/wanted-by/server/wants/"$I"
		rm -f -- "${svcdir}"/wanted-by/server
	fi
done

# Do not set up http and ftp access control defaults.
# Do not set up head0.
