#!/bin/sh
pkg_postinst () {
	local crypt=$(grep "^root:" etc/shadow | cut -f 2 -d :)
	crypt=${crypt//\\/\\\\}
	crypt=${crypt//\//\\\/}
	sed -i "s/root:XXX/root:${crypt}/" etc/webmin/miniserv.users
}

pkg_postinst

# Keep same perms on rc.webmin.new:
if [ -e etc/rc.d/rc.webmin ]; then
  cp -a etc/rc.d/rc.webmin etc/rc.d/rc.webmin.new.incoming
  cat etc/rc.d/rc.webmin.new > etc/rc.d/rc.webmin.new.incoming
  mv etc/rc.d/rc.webmin.new.incoming etc/rc.d/rc.webmin.new
fi

echo ""
echo "To make webmin start at boot time, add this lines to your "/etc/rc.d/rc.local""
echo "# Start Webmin:"
echo "if [ -x /etc/rc.d/rc.webmin ]; then"
echo "   /etc/rc.d/rc.webmin start"
echo "fi"
echo "Point your web browser to http://localhost:10000 to use webmin."
echo "and login with your root user."
