NetBSD/etc/rc.d/securelevel
2004-10-11 15:00:51 +00:00

41 lines
877 B
Bash
Executable File

#!/bin/sh
#
# $NetBSD: securelevel,v 1.6 2004/10/11 15:00:51 christos Exp $
#
# PROVIDE: securelevel
# REQUIRE: aftermountlkm ipnat mountd
# BEFORE: DAEMON
$_rc_subr_loaded . /etc/rc.subr
name="securelevel"
start_cmd="securelevel_start"
stop_cmd=":"
securelevel_start()
{
# if $securelevel is set higher, change it here, else if
# it is 0, change it to 1 here, before we start daemons
# or login services.
#
osecurelevel=$(sysctl -n kern.securelevel)
if [ -n "$securelevel" -a "$securelevel" != "$osecurelevel" ]; then
if [ "$securelevel" -lt "$osecurelevel" ]; then
echo "Can't lower securelevel."
exit 1
else
echo -n "Setting securelevel: "
sysctl -w kern.securelevel=$securelevel
fi
else
if [ "$osecurelevel" = 0 ]; then
echo -n "Setting securelevel: "
sysctl -w kern.securelevel=1
fi
fi
}
load_rc_config $name
run_rc_command "$1"