rc.subr (272393) | rc.subr (272974) |
---|---|
1# $NetBSD: rc.subr,v 1.67 2006/10/07 11:25:15 elad Exp $ | 1# $NetBSD: rc.subr,v 1.67 2006/10/07 11:25:15 elad Exp $ |
2# $FreeBSD: head/etc/rc.subr 272393 2014-10-02 01:16:30Z hrs $ | 2# $FreeBSD: head/etc/rc.subr 272974 2014-10-11 23:49:27Z hrs $ |
3# 4# Copyright (c) 1997-2004 The NetBSD Foundation, Inc. 5# All rights reserved. 6# 7# This code is derived from software contributed to The NetBSD Foundation 8# by Luke Mewburn. 9# 10# Redistribution and use in source and binary forms, with or without --- 733 unchanged lines hidden (view full) --- 744# 745# ${name}_chdir n Directory to cd to before running ${command} 746# (if not using ${name}_chroot). 747# 748# ${name}_flags n Arguments to call ${command} with. 749# NOTE: $flags from the parent environment 750# can be used to override this. 751# | 3# 4# Copyright (c) 1997-2004 The NetBSD Foundation, Inc. 5# All rights reserved. 6# 7# This code is derived from software contributed to The NetBSD Foundation 8# by Luke Mewburn. 9# 10# Redistribution and use in source and binary forms, with or without --- 733 unchanged lines hidden (view full) --- 744# 745# ${name}_chdir n Directory to cd to before running ${command} 746# (if not using ${name}_chroot). 747# 748# ${name}_flags n Arguments to call ${command} with. 749# NOTE: $flags from the parent environment 750# can be used to override this. 751# |
752# ${name}_env n Environment variables to run ${command} with. 753# |
|
752# ${name}_fib n Routing table number to run ${command} with. 753# 754# ${name}_nice n Nice level to run ${command} at. 755# 756# ${name}_user n User to run ${command} as, using su(1) if not 757# using ${name}_chroot. 758# Requires /usr to be mounted. 759# 760# ${name}_group n Group to run chrooted ${command} as. 761# Requires /usr to be mounted. 762# 763# ${name}_groups n Comma separated list of supplementary groups 764# to run the chrooted ${command} with. 765# Requires /usr to be mounted. 766# | 754# ${name}_fib n Routing table number to run ${command} with. 755# 756# ${name}_nice n Nice level to run ${command} at. 757# 758# ${name}_user n User to run ${command} as, using su(1) if not 759# using ${name}_chroot. 760# Requires /usr to be mounted. 761# 762# ${name}_group n Group to run chrooted ${command} as. 763# Requires /usr to be mounted. 764# 765# ${name}_groups n Comma separated list of supplementary groups 766# to run the chrooted ${command} with. 767# Requires /usr to be mounted. 768# |
769# ${name}_prepend n Command added before ${command}. 770# |
|
767# ${rc_arg}_cmd n If set, use this as the method when invoked; 768# Otherwise, use default command (see below) 769# 770# ${rc_arg}_precmd n If set, run just before performing the 771# ${rc_arg}_cmd method in the default 772# operation (i.e, after checking for required 773# bits and process (non)existence). 774# If this completes with a non-zero exit code, --- 157 unchanged lines hidden (view full) --- 932 if [ -n "$flags" ]; then # allow override from environment 933 rc_flags=$flags 934 else 935 eval rc_flags=\$${name}_flags 936 fi 937 eval _chdir=\$${name}_chdir _chroot=\$${name}_chroot \ 938 _nice=\$${name}_nice _user=\$${name}_user \ 939 _group=\$${name}_group _groups=\$${name}_groups \ | 771# ${rc_arg}_cmd n If set, use this as the method when invoked; 772# Otherwise, use default command (see below) 773# 774# ${rc_arg}_precmd n If set, run just before performing the 775# ${rc_arg}_cmd method in the default 776# operation (i.e, after checking for required 777# bits and process (non)existence). 778# If this completes with a non-zero exit code, --- 157 unchanged lines hidden (view full) --- 936 if [ -n "$flags" ]; then # allow override from environment 937 rc_flags=$flags 938 else 939 eval rc_flags=\$${name}_flags 940 fi 941 eval _chdir=\$${name}_chdir _chroot=\$${name}_chroot \ 942 _nice=\$${name}_nice _user=\$${name}_user \ 943 _group=\$${name}_group _groups=\$${name}_groups \ |
940 _fib=\$${name}_fib | 944 _fib=\$${name}_fib _env=\$${name}_env \ 945 _prepend=\$${name}_prepend |
941 942 if [ -n "$_user" ]; then # unset $_user if running as that user 943 if [ "$_user" = "$(eval $IDCMD)" ]; then 944 unset _user 945 fi 946 fi 947 948 [ -z "$autoboot" ] && eval $_pidcmd # determine the pid if necessary --- 68 unchanged lines hidden (view full) --- 1017 1018 # setup the full command to run 1019 # 1020 check_startmsgs && echo "Starting ${name}." 1021 if [ -n "$_chroot" ]; then 1022 _doit="\ 1023${_nice:+nice -n $_nice }\ 1024${_fib:+setfib -F $_fib }\ | 946 947 if [ -n "$_user" ]; then # unset $_user if running as that user 948 if [ "$_user" = "$(eval $IDCMD)" ]; then 949 unset _user 950 fi 951 fi 952 953 [ -z "$autoboot" ] && eval $_pidcmd # determine the pid if necessary --- 68 unchanged lines hidden (view full) --- 1022 1023 # setup the full command to run 1024 # 1025 check_startmsgs && echo "Starting ${name}." 1026 if [ -n "$_chroot" ]; then 1027 _doit="\ 1028${_nice:+nice -n $_nice }\ 1029${_fib:+setfib -F $_fib }\ |
1030${_env:+env $_env }\ |
|
1025chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\ 1026$_chroot $command $rc_flags $command_args" 1027 else 1028 _doit="\ 1029${_chdir:+cd $_chdir && }\ 1030${_fib:+setfib -F $_fib }\ | 1031chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\ 1032$_chroot $command $rc_flags $command_args" 1033 else 1034 _doit="\ 1035${_chdir:+cd $_chdir && }\ 1036${_fib:+setfib -F $_fib }\ |
1037${_env:+env $_env }\ |
|
1031$command $rc_flags $command_args" 1032 if [ -n "$_user" ]; then 1033 _doit="su -m $_user -c 'sh -c \"$_doit\"'" 1034 fi 1035 if [ -n "$_nice" ]; then 1036 if [ -z "$_user" ]; then 1037 _doit="sh -c \"$_doit\"" 1038 fi 1039 _doit="nice -n $_nice $_doit" 1040 fi | 1038$command $rc_flags $command_args" 1039 if [ -n "$_user" ]; then 1040 _doit="su -m $_user -c 'sh -c \"$_doit\"'" 1041 fi 1042 if [ -n "$_nice" ]; then 1043 if [ -z "$_user" ]; then 1044 _doit="sh -c \"$_doit\"" 1045 fi 1046 _doit="nice -n $_nice $_doit" 1047 fi |
1048 if [ -n "$_prepend" ]; then 1049 _doit="$_prepend $_doit" 1050 fi |
|
1041 fi 1042 1043 # run the full command 1044 # 1045 if ! _run_rc_doit "$_doit"; then 1046 warn "failed to start ${name}" 1047 return 1 1048 fi --- 1030 unchanged lines hidden --- | 1051 fi 1052 1053 # run the full command 1054 # 1055 if ! _run_rc_doit "$_doit"; then 1056 warn "failed to start ${name}" 1057 return 1 1058 fi --- 1030 unchanged lines hidden --- |