aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2019-01-10 09:56:56 +0800
committerAaron LI <aly@aaronly.me>2019-01-10 09:57:27 +0800
commit9b9f22a7faf78882576270e1a99577e3e7828fb9 (patch)
tree19c63b7fb5f839609a4dbebd32038ec90452b29b
parentdf72339dbe0d4ae72f70773ea4a86c9220cad37b (diff)
downloaddfly-update-9b9f22a7faf78882576270e1a99577e3e7828fb9.tar.bz2
Clean up the config file loading code
Adjust the whitespace style in the meantime.
-rwxr-xr-xdfly-update72
1 files changed, 34 insertions, 38 deletions
diff --git a/dfly-update b/dfly-update
index 8d37772..a0827e1 100755
--- a/dfly-update
+++ b/dfly-update
@@ -438,39 +438,43 @@ _EOF_
}
-CONFIGFILE=""
ISTART=0
-ISTOP=999
+ISTOP=99
while getopts :c:dhs:S: opt; do
- case ${opt} in
- c)
- CONFIGFILE="${OPTARG}"
- ;;
- d)
- DEBUG=yes
- ;;
- h)
- usage
- exit ${EC_USAGE}
- ;;
- s)
- ISTART="${OPTARG}"
- ;;
- S)
- ISTOP="${OPTARG}"
- ;;
- \?)
- log "Invalid option -${OPTARG}"
- usage
- exit ${EC_ARGS}
- ;;
- :)
- log "Option -${OPTARG} requires an argument"
- usage
- exit ${EC_ARGS}
- ;;
- esac
+ case ${opt} in
+ c)
+ CONFIGFILE="${OPTARG}"
+ if [ -r "${CONFIGFILE}" ]; then
+ . ${CONFIGFILE}
+ else
+ error ${EC_CONFIG} "cannot read config file: ${CONFIGFILE}"
+ fi
+ ;;
+ d)
+ DEBUG=yes
+ ;;
+ h)
+ usage
+ exit ${EC_USAGE}
+ ;;
+ s)
+ ISTART="${OPTARG}"
+ ;;
+ S)
+ ISTOP="${OPTARG}"
+ ;;
+ \?)
+ log "Invalid option -${OPTARG}"
+ usage
+ exit ${EC_ARGS}
+ ;;
+ :)
+ log "Option -${OPTARG} requires an argument"
+ usage
+ exit ${EC_ARGS}
+ ;;
+ esac
done
shift $((OPTIND - 1))
@@ -478,14 +482,6 @@ shift $((OPTIND - 1))
IMGFILE="$1"
[ -r "${IMGFILE}" ] || error ${EC_NOFILE} "file not exists: ${IMGFILE}"
-if [ -n "${CONFIGFILE}" ]; then
- if [ -r "${CONFIGFILE}" ]; then
- . ${CONFIGFILE}
- else
- error ${EC_CONFIG} "cannot read config file: ${CONFIGFILE}"
- fi
-fi
-
istep=0
echo "[${istep}] Mounting image ${IMGFILE} to ${MNT_DIR} ..."
[ ${istep} -ge ${ISTART} -a ${istep} -le ${ISTOP} ] &&