#!/bin/sh

CMD="/usr/sbin/sysv-rc-conf"

if command -v pkexec > /dev/null
then
  pkexec $CMD
  retval=$?
  if [ $retval -eq 126 ]
  then
    # User dismissed elevation prompt: deliberately select read-only.
    exec $CMD --RO
  elif [ $retval -lt 126 ]
  then
    # sysv-rc-conf ran: report its exit code.
    exit $retval
  fi
fi

# Error running pkexec or no pkexec: try out luck with the tool directly.
exec $CMD
