From de60d4bdd7e634320f3c9e1248d51bd5e947808e Mon Sep 17 00:00:00 2001 From: Jakub Jankowski Date: Tue, 21 Nov 2017 03:02:35 +0100 Subject: rc.inet1: Avoid code duplication by combining case/esac There's no reason to have separate cases for start) ... ;; up) ... ;; if they both have the same bodies. Let's combine such cases to avoid code duplication. Also, this is that one time where quoting isn't really needed :) Signed-off-by: Robby Workman --- rc.inet1 | 39 +++++++++------------------------------ 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/rc.inet1 b/rc.inet1 index b29c285..d6ccea6 100644 --- a/rc.inet1 +++ b/rc.inet1 @@ -312,28 +312,28 @@ stop() { ############ case "$1" in -'start') # "start" brings up all configured interfaces: +start|up) # "start" (or "up") brings up all configured interfaces: start ;; -'stop') # "stop" takes down all configured interfaces: +stop|down) # "stop" (or "down") takes down all configured interfaces: stop ;; -'restart') # "restart" restarts the network: +restart) # "restart" restarts the network: stop start ;; -'lo_start') # Start the loopback interface: +lo_start|lo_up) # Start the loopback interface: lo_up ;; -*_start) # Example: "eth1_start" will start the specified interface 'eth1' +lo_stop|lo_down) # Stop the loopback interface: + lo_down + ;; +*_start|*_up) # Example: "eth1_start" (or "eth1_up") will start the specified interface 'eth1' INTERFACE=$(echo $1 | /bin/cut -d '_' -f 1) if_up $INTERFACE gateway_up ;; -'lo_stop') # Stop the loopback interface: - lo_down - ;; -*_stop) # Example: "eth0_stop" will stop the specified interface 'eth0' +*_stop|*_down) # Example: "eth0_stop" (or "eth0_down") will stop the specified interface 'eth0' INTERFACE=$(echo $1 | /bin/cut -d '_' -f 1) if_down $INTERFACE ;; @@ -344,27 +344,6 @@ case "$1" in if_up $INTERFACE gateway_up ;; -'up') # "up" does the same thing as "start" - start - ;; -'down') # "down" does the same thing as "stop" - stop - ;; -'lo_up') # Start the loopback interface: - lo_up - ;; -*_up) # "*_up" does the same thing as "*_start" - INTERFACE=$(echo $1 | /bin/cut -d '_' -f 1) - if_up $INTERFACE - gateway_up - ;; -'lo_down') # Stop the loopback interface: - lo_down - ;; -*_down) # "*_down" does the same thing as "*_stop" - INTERFACE=$(echo $1 | /bin/cut -d '_' -f 1) - if_down $INTERFACE - ;; *) # The default is to bring up all configured interfaces: start esac -- cgit v1.2.3