Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/service/service.sh
Show All 36 Lines | usage () { | ||||
echo "${0##*/} [-j <jail name or id>] -e" | echo "${0##*/} [-j <jail name or id>] -e" | ||||
echo "${0##*/} [-j <jail name or id>] -R" | echo "${0##*/} [-j <jail name or id>] -R" | ||||
echo "${0##*/} [-j <jail name or id>] [-v] -l | -r" | echo "${0##*/} [-j <jail name or id>] [-v] -l | -r" | ||||
echo "${0##*/} [-j <jail name or id>] [-v] <rc.d script> start|stop|etc." | echo "${0##*/} [-j <jail name or id>] [-v] <rc.d script> start|stop|etc." | ||||
echo "${0##*/} -h" | echo "${0##*/} -h" | ||||
echo '' | echo '' | ||||
echo "-j Perform actions within the named jail" | echo "-j Perform actions within the named jail" | ||||
echo '-e Show services that are enabled' | echo '-e Show services that are enabled' | ||||
echo '-s Show status of (enabled) services' | |||||
echo "-R Stop and start enabled $local_startup services" | echo "-R Stop and start enabled $local_startup services" | ||||
echo "-l List all scripts in /etc/rc.d and $local_startup" | echo "-l List all scripts in /etc/rc.d and $local_startup" | ||||
echo '-r Show the results of boot time rcorder' | echo '-r Show the results of boot time rcorder' | ||||
echo '-v Verbose' | echo '-v Verbose' | ||||
echo '' | echo '' | ||||
} | } | ||||
while getopts 'j:ehlrRv' COMMAND_LINE_ARGUMENT ; do | while getopts 'ehj:lrRsv' COMMAND_LINE_ARGUMENT ; do | ||||
0mp: Could you sort the flag list? | |||||
case "${COMMAND_LINE_ARGUMENT}" in | case "${COMMAND_LINE_ARGUMENT}" in | ||||
j) JAIL="${OPTARG}" ;; | |||||
e) ENABLED=eopt ;; | e) ENABLED=eopt ;; | ||||
h) usage ; exit 0 ;; | h) usage ; exit 0 ;; | ||||
Done Inline ActionsWould be nice to keep this list sorted. 0mp: Would be nice to keep this list sorted. | |||||
j) JAIL="${OPTARG}" ;; | |||||
l) LIST=lopt ;; | l) LIST=lopt ;; | ||||
r) RCORDER=ropt ;; | r) RCORDER=ropt ;; | ||||
R) RESTART=Ropt ;; | R) RESTART=Ropt ;; | ||||
s) STATUS=sopt ;; | |||||
v) VERBOSE=vopt ;; | v) VERBOSE=vopt ;; | ||||
*) usage ; exit 1 ;; | *) usage ; exit 1 ;; | ||||
esac | esac | ||||
done | done | ||||
shift $(( $OPTIND - 1 )) | shift $(( $OPTIND - 1 )) | ||||
if [ -n "${JAIL}" ]; then | if [ -n "${JAIL}" ]; then | ||||
# We need to rebuild the command line before passing it on. | # We need to rebuild the command line before passing it on. | ||||
Show All 38 Lines | if grep -q ^rcvar $file; then | ||||
eval `grep ^rcvar $file` | eval `grep ^rcvar $file` | ||||
checkyesno $rcvar 2>/dev/null && run_rc_script ${file} start | checkyesno $rcvar 2>/dev/null && run_rc_script ${file} start | ||||
fi | fi | ||||
done | done | ||||
exit 0 | exit 0 | ||||
fi | fi | ||||
if [ -n "$ENABLED" -o -n "$RCORDER" ]; then | if [ -n "$ENABLED" -o -n "$RCORDER" -o -n "$STATUS" ]; then | ||||
# Copied from /etc/rc | # Copied from /etc/rc | ||||
skip="-s nostart" | skip="-s nostart" | ||||
if [ `/sbin/sysctl -n security.jail.jailed` -eq 1 ]; then | if [ `/sbin/sysctl -n security.jail.jailed` -eq 1 ]; then | ||||
skip="$skip -s nojail" | skip="$skip -s nojail" | ||||
if [ `/sbin/sysctl -n security.jail.vnet` -ne 1 ]; then | if [ `/sbin/sysctl -n security.jail.vnet` -ne 1 ]; then | ||||
skip="$skip -s nojailvnet" | skip="$skip -s nojailvnet" | ||||
fi | fi | ||||
fi | fi | ||||
[ -n "$local_startup" ] && find_local_scripts_new | [ -n "$local_startup" ] && find_local_scripts_new | ||||
files=`rcorder ${skip} /etc/rc.d/* ${local_rc} 2>/dev/null` | files=`rcorder ${skip} /etc/rc.d/* ${local_rc} 2>/dev/null` | ||||
fi | |||||
if [ -n "$STATUS" ]; then | |||||
for file in $files; do | |||||
if grep -q ^rcvar $file; then | |||||
eval `grep ^name= $file` | |||||
eval `grep ^rcvar $file` | |||||
if [ -n "$rcvar" ]; then | |||||
load_rc_config_var ${name} ${rcvar} | |||||
fi | |||||
if [ -n "$ENABLED" ] ; then | |||||
if ! checkyesno $rcvar 2>/dev/null; then | |||||
continue; | |||||
fi | |||||
fi | |||||
if $file 2>&1 | grep -q "status"; then | |||||
status="Not running" | |||||
$file onestatus 1>/dev/null 2>&1 && status="Running" | |||||
printf "%s^%s\n" "${name}" "${status}" | |||||
fi | |||||
fi | |||||
done | column -ts^ | |||||
exit 0 | |||||
fi | fi | ||||
if [ -n "$ENABLED" ]; then | if [ -n "$ENABLED" ]; then | ||||
for file in $files; do | for file in $files; do | ||||
if grep -q ^rcvar $file; then | if grep -q ^rcvar $file; then | ||||
eval `grep ^name= $file` | eval `grep ^name= $file` | ||||
eval `grep ^rcvar $file` | eval `grep ^rcvar $file` | ||||
if [ -n "$rcvar" ]; then | if [ -n "$rcvar" ]; then | ||||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |
Could you sort the flag list?