Bin: fix installation script issues
This commit is contained in:
parent
722285807d
commit
7f3f8f1ba0
|
@ -3,6 +3,11 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
if [ "$(id -u)" != "0" ]; then
|
||||||
|
echo "This script must be run as root" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Configuration parameters
|
# Configuration parameters
|
||||||
ask_root_password=false # Whether to prompt for a root user password
|
ask_root_password=false # Whether to prompt for a root user password
|
||||||
boot_partition="" # The drive to install the bootloader to
|
boot_partition="" # The drive to install the bootloader to
|
||||||
|
@ -19,6 +24,8 @@ function usage() {
|
||||||
exit 2
|
exit 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Argument processing logic shamelessly stolen from https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
|
||||||
|
POSITIONAL_ARGS=()
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--ask-root-password|-a)
|
--ask-root-password|-a)
|
||||||
|
@ -26,11 +33,13 @@ while [[ $# -gt 0 ]]; do
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--boot|-b)
|
--boot|-b)
|
||||||
boot_partition=$1
|
boot_partition="$2"
|
||||||
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--luks|-l)
|
--luks|-l)
|
||||||
luks_partition=1
|
luks_partition="$2"
|
||||||
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--help|-h)
|
--help|-h)
|
||||||
|
@ -38,15 +47,13 @@ while [[ $# -gt 0 ]]; do
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
break
|
POSITIONAL_ARGS+=("$1") # save positional arg
|
||||||
|
shift # past argument
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$(id -u)" != "0" ]; then
|
set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters
|
||||||
echo "This script must be run as root" 1>&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cryptsetup --label=nixos-crypt --type=luks2 luksFormat $luks_partition
|
cryptsetup --label=nixos-crypt --type=luks2 luksFormat $luks_partition
|
||||||
cryptsetup luksOpen $luks_partition nixos-crypt
|
cryptsetup luksOpen $luks_partition nixos-crypt
|
||||||
|
|
Loading…
Reference in a new issue