NetBSD/etc/rc.d/securelevel
2008-11-12 12:35:50 +00:00

41 lines
857 B
Bash
Executable File

#!/bin/sh
#
# $NetBSD: securelevel,v 1.7 2008/11/12 12:35:52 ad Exp $
#
# PROVIDE: securelevel
# REQUIRE: 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"