Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F145721879
D451.1778461871.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D451.1778461871.diff
View Options
Index: usr.sbin/service/service.sh
===================================================================
--- usr.sbin/service/service.sh
+++ usr.sbin/service/service.sh
@@ -36,6 +36,7 @@
echo "${0##*/} -R"
echo "${0##*/} [-v] -l | -r"
echo "${0##*/} [-v] <rc.d script> start|stop|etc."
+ echo "${0##*/} [-v] <rc.d script> enable|disable|rcvar|rcopts|rcdelete"
echo "${0##*/} -h"
echo ''
echo '-e Show services that are enabled'
@@ -135,14 +136,70 @@
exit 1
fi
+case $1 in
+enable)
+ RC_ACTION=YES
+ RC_ACTION_TEXT=enabled
+ shift
+ ;;
+disable)
+ RC_ACTION=NO
+ RC_ACTION_TEXT=disabled
+ shift
+ ;;
+rcdelete)
+ RC_ACTION=DELETE
+ RC_ACTION_TEXT=deleted
+ shift
+ ;;
+rcopts)
+ RC_ACTION=RC_OPTS
+ shift
+ ;;
+*)
+ ;;
+esac
+
cd /
for dir in /etc/rc.d $local_startup; do
if [ -x "$dir/$script" ]; then
[ -n "$VERBOSE" ] && echo "$script is located in $dir"
- exec env -i HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin $dir/$script $*
+
+ # This part touches /etc/rc.conf
+ if [ -n "$RC_ACTION" ]; then
+ eval `grep ^name= $dir/$script`
+ eval `grep ^rcvar $dir/$script`
+ if [ $RC_ACTION = "YES" -o $RC_ACTION = "NO" ];then
+ /usr/sbin/sysrc $rcvar=${RC_ACTION} > /dev/null
+ elif [ $RC_ACTION = "DELETE" ]; then
+ /usr/sbin/sysrc -x $rcvar > /dev/null
+ elif [ $RC_ACTION = "RC_OPTS" ]; then
+ echo "Available rc.conf options for $script:"
+ awk '
+ /^#\ [A-Z]+:.*$/ {flag=1;next}
+ /^\.\ \/etc\/rc.subr/ {exit}
+ flag == 1 {print $0}' \
+ $dir/$script
+ exit 0
+ fi
+ exitflag=$?
+ # XXX: At the moment sysrc(8) exits with exit code 0
+ # even if the variable to be deleted is not in
+ # rc.conf. So the text below is printed
+ # unconditionally. (Fixed in r268860)
+ [ $exitflag -eq 0 ] &&
+ echo "$script $RC_ACTION_TEXT in /etc/rc.conf"
+ fi
+
+ [ $# -gt 0 ] &&
+ exec env -i HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin $dir/$script $*
fi
done
+# If an rc.conf action was made but no additional rc command was given, exit
+# with sysrc's exit code.
+[ -n "$exitflag" ] && exit $exitflag
+
# If the script was not found
echo "$script does not exist in /etc/rc.d or the local startup"
echo "directories (${local_startup}), or is not executable"
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, May 11, 1:11 AM (56 m, 43 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28656784
Default Alt Text
D451.1778461871.diff (2 KB)
Attached To
Mode
D451: Add new switches to service(8): enable, disable, rcopts and rcdelete
Attached
Detach File
Event Timeline
Log In to Comment