#!/bin/sh # PROVIDE: test # REQUIRE: FILESYSTEMS NETWORKING SERVERS DAEMON LOGIN # REQUIRE: mountcritlocal # KEYWORD: shutdown . /etc/rc.subr name='test' desc='test' rcvar='test_enable' command='/bin/echo' procname="${command}" : "${test_enable=NO}" start_cmd='test_cmd' stop_cmd=':' test_sh_escape() { for s ; do echo "$s" | sed -e 's/\([][ '\''`";&<>()|*?{}\$!#^~]\)/\\\1/g' done } test_sh_q_escape() { for s ; do echo "$s" | sed -e 's/\(['\'']\)/\1\\\1\1/g' done } test_sh_qq_escape() { for s ; do echo "$s" | sed -e 's/\([`"\$]\)/\\\1/g' done } test_cmd() { # Perhaps, this function is the same behavior as default operation on run_rc_command. set -x _doit= case "${rc_arg}" in start) _doit="$command $rc_flags $command_args" if [ -n "$_chroot" ] ; then _doit="\ ${_nice:+nice -n $_nice }\ ${_fib:+setfib -F $_fib }\ chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\ $_chroot $_doit" else _doit="\ ${_chdir:+cd $_chdir && }\ ${_fib:+setfib -F $_fib }\ $_doit" if [ -n "$_user" ] ; then # use double quote to -c of su because su -c is likely to execute by csh (root's login shell). # it will be easy to quote. _doit="su -m $_user -c \"sh -c '$(test_sh_qq_escape "$(test_sh_q_escape "$_doit")")'\"" fi if [ -n "$_nice" ] ; then if [ -z "$_user" ] ; then _doit="sh -c '$(test_sh_q_escape "$_doit")'" # case single quote #_doit="sh -c $(test_sh_escape "$_doit")" # case without quote fi _doit="nice -n $_nice $_doit" fi fi ;; esac if ! _run_rc_doit "${_doit}" ; then set +x warn "failed to start ${name}" return 1 fi set +x return 0 } load_rc_config "${name}" # /etc/rc.conf test_nice="5" #test_user="nobody" test_flags="\"test test\"" run_rc_command "${1}"