post_common() {
	/bin/udevadm hwdb --update
	/bin/journalctl --update-catalog
	/bin/systemd-machine-id-setup
	/bin/systemctl --quiet disable getty@.service
	/bin/systemctl --quiet enable \
		xorg-set-resolution.service \
		getty@tty1.service \
		remote-fs.target

	# remove obsolete fstab entries
	if [ -e /etc/fstab ]; then
		sed -i '\/proc\/bus\/usb/d' /etc/fstab
	fi 

	if [ -p /run/systemd/initctl/fifo ] && [ ! -L /dev/initctl ]; then
		ln -sf /run/systemd/initctl/fifo /dev/initctl

	fi

	if [ -S /run/systemd/journal/dev-log ] && [ ! -L /dev/log ]; then
		ln -sf /run/systemd/journal/dev-log /dev/log
	fi
	
}

post_install() {
	post_common

	true
}

post_upgrade() {
	post_common

	# reload systemd (not for big update.. better do a reboot)
	# well better but some won't so reload the units and reexec the deamons -- crazy ---
	/bin/systemctl daemon-reload
	## disable this .. since is causing the screen to die for some reason
	##/bin/systemctl daemon-reexec
	echo "You may want to reboot the system"

	true
}

post_remove() {
	/usr/bin/getent group lock 2>&1 > /dev/null && /usr/sbin/groupdel lock
	/usr/bin/getent group systemd-journal 2>&1 > /dev/null && /usr/sbin/groupdel systemd-journal
	/usr/bin/getent passwd systemd-journal-gateway 2>&1 > /dev/null && /usr/sbin/userdel systemd-journal-gateway
	/usr/bin/getent group systemd-journal-gateway 2>&1 > /dev/null && /usr/sbin/groupdel systemd-journal-gateway

	/usr/bin/getent group input 2>&1 > /dev/null && /usr/sbin/groupdel input
}

op=$1
shift
$op $*

