Skip to content
Snippets Groups Projects
Verified Commit 591a3023 authored by Michal Hrusecky's avatar Michal Hrusecky :mouse:
Browse files

Move the rest of configuration parsing back

Turns out that we are actually using the parsed configuration in showing
help, so let's keep all the configuration together. It is nicer that way
anyway. But let's move the die function to the top so we can use it
during configuration parsing. Fortunately we don't need die_hepling
function which would cause a cycle.
parent 20f21310
Branches
Tags v2.4.1
1 merge request!33Few small fixes
......@@ -41,6 +41,12 @@ GPG_PASS=""
ROOT_DEV="$(btrfs fi show / | sed -n 's|.*\(/dev/[^[:blank:]]*\)$|\1|p' | head -n 1)"
VERSION="@VERSION@"
die() {
echo "$@" >&2
ERR="${ERR:-1}"
exit 1
}
# Read uci configuration if available
if [ -f "/lib/functions.sh" ]; then
. /lib/functions.sh
......@@ -58,6 +64,17 @@ if [ -f "/lib/functions.sh" ]; then
config_get GPG_PASS encrypt pass "$GPG_PASS"
fi
[ \! -f /etc/schnapps/config ] || . /etc/schnapps/config
if [ "x$1" == "x-d" ]; then
ROOT_DEV="$(btrfs fi show $2 | sed -n 's|.*\(/dev/[^[:blank:]]*\)$|\1|p')"
shift 2
fi
[ -n "$ROOT_DEV" ] || die "Can't figure out device to work on"
ROOT_LABEL="$(btrfs fi label "$ROOT_DEV")"
[ -z "$ROOT_LABEL" ] || [ \! -f /etc/schnapps/"$ROOT_LABEL" ] || . /etc/schnapps/"$ROOT_LABEL"
# Usage help
USAGE="Usage: $(basename "$0") [-d root] command [options]
......@@ -147,13 +164,6 @@ Commands:
version Display version
"
die() {
echo "$@" >&2
ERR="${ERR:-1}"
exit 1
}
show_help() {
echo "$USAGE"
}
......@@ -861,17 +871,6 @@ trap_cleanup() {
exit "$ERR"
}
[ \! -f /etc/schnapps/config ] || . /etc/schnapps/config
if [ "x$1" == "x-d" ]; then
ROOT_DEV="$(btrfs fi show $2 | sed -n 's|.*\(/dev/[^[:blank:]]*\)$|\1|p')"
shift 2
fi
[ -n "$ROOT_DEV" ] || die "Can't figure out device to work on"
ROOT_LABEL="$(btrfs fi label "$ROOT_DEV")"
[ -z "$ROOT_LABEL" ] || [ \! -f /etc/schnapps/"$ROOT_LABEL" ] || . /etc/schnapps/"$ROOT_LABEL"
trap 'trap_cleanup' EXIT INT QUIT TERM ABRT
mount_root
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment