Skip to content

Commit

Permalink
rc: reverse list on stop action
Browse files Browse the repository at this point in the history
Suggested by:	David Mora
PR:		#4891
  • Loading branch information
fichtner committed Apr 7, 2021
1 parent 2fe4de6 commit 7316071
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/etc/rc.freebsd
@@ -1,7 +1,7 @@
#!/bin/sh

# Copyright (c) 2015-2017 Ad Schellevis <ad@opnsense.org>
# Copyright (c) 2015-2020 Franco Fichtner <franco@opnsense.org>
# Copyright (c) 2015-2021 Franco Fichtner <franco@opnsense.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -81,6 +81,7 @@ rc_enabled()

rc_filenames="$(${RCORDER} /etc/rc.d/[a-z]* /usr/local/etc/rc.d/[a-z]* 2> /dev/null)"
rc_filenames_defer=
rc_filenames_reverse=
rc_filenames_skip=

for rc_filename in ${rc_filenames}; do
Expand All @@ -102,8 +103,10 @@ if [ -z "${1}" ]; then
exit 1
fi

rc_filenames="${rc_filenames} ${rc_filenames_defer}"

# run our bootstrap command on startup
if [ "${1}" == "start" ]; then
if [ "${1}" = "start" ]; then
for rc_filename in ${rc_filenames}; do
eval "$(grep "^name[[:blank:]]*=" ${rc_filename})"

Expand All @@ -115,10 +118,15 @@ if [ "${1}" == "start" ]; then
eval "pre_run_cmd=\$${pre_run_var}"
${pre_run_cmd}
done
elif [ "${1}" = "stop" ]; then

This comment has been minimized.

Copy link
@lattera

lattera Apr 7, 2021

Contributor

Would it make sense to use sort -r?

This comment has been minimized.

Copy link
@fichtner

fichtner via email Apr 7, 2021

Author Member

This comment has been minimized.

Copy link
@lattera

lattera Apr 7, 2021

Contributor

Gotcha. Thanks for the clarification!

for rc_filename in ${rc_filenames}; do
rc_filenames_reverse="${rc_filename} ${rc_filenames_reverse}"
done
rc_filenames=${rc_filenames_reverse}
fi

# pass all commands to script now
for rc_filename in ${rc_filenames} ${rc_filenames_defer}; do
for rc_filename in ${rc_filenames}; do
eval "$(grep "^name[[:blank:]]*=" ${rc_filename})"

if ! rc_enabled ${rc_filename} ${name}; then
Expand Down

0 comments on commit 7316071

Please sign in to comment.