Allow the `MULTIBOOT_MNT` environment to be passed in. My usage of this
variable is as follows:
```shell
$ MULTIBOOT_MNT="$(findmnt -n -o target LABEL=multiboot)" ./multiboot-setup grubcfg
```
This allows simple updates of the grub config, while taking advantage of
the auto mounter provided by Gnome.
set -eu
PARTITION_LABEL="multiboot"
set -eu
PARTITION_LABEL="multiboot"
-MULTIBOOT_MNT="/mnt/multiboot"
+MULTIBOOT_MNT="${MULTIBOOT_MNT:-/mnt/multiboot}"
function cmd_format {
if [ ! -b "${1:-}" ]; then
function cmd_format {
if [ ! -b "${1:-}" ]; then
}
function install_grub_cfg {
}
function install_grub_cfg {
- print_grub_cfg | sudo tee "${MULTIBOOT_MNT}/grub/grub.cfg" > /dev/null
+ if [[ -w "${MULTIBOOT_MNT}/grub/" ]]; then
+ # We already have write access, no need to use sudo
+ print_grub_cfg > "${MULTIBOOT_MNT}/grub/grub.cfg"
+ else
+ print_grub_cfg | sudo tee "${MULTIBOOT_MNT}/grub/grub.cfg" > /dev/null
+ fi