summaryrefslogtreecommitdiff
path: root/src/xorriso-usb.sh
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2016-05-03 14:36:19 +0200
committerAndrew Cady <d@jerkface.net>2016-05-03 14:36:19 +0200
commitf200e83db0dea1d120cf91d6c71c2d74b00b9706 (patch)
treea699211164782f21606a08377ad1ec9a691338fe /src/xorriso-usb.sh
parent26de82e40c38cb1f09fb1e232a12b09c131a7573 (diff)
fix everything
Diffstat (limited to 'src/xorriso-usb.sh')
-rw-r--r--src/xorriso-usb.sh19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/xorriso-usb.sh b/src/xorriso-usb.sh
index ef26cb2..0d7773d 100644
--- a/src/xorriso-usb.sh
+++ b/src/xorriso-usb.sh
@@ -12,29 +12,35 @@ efi_dir=$samizdat_grub_efi_dir
12 12
13die() { printf "%s: Error: %s\n" "$0" "$*" >&2; exit 1; } 13die() { printf "%s: Error: %s\n" "$0" "$*" >&2; exit 1; }
14 14
15TEMP="$(getopt -o '' --long adam,usb,detach,in:,out:,test -n "$0" -- "$@")" || 15TEMP="$(getopt -o '' --long bootloader,adam,usb,detach,in:,out:,test -n "$0" -- "$@")" ||
16 die 'getopt error' 16 die 'getopt error'
17eval set -- "$TEMP" 17eval set -- "$TEMP"
18 18
19ADAM=; DETACH=; USB= 19ADAM=; DETACH=; USB=y
20while [ $# -gt 0 ]; do 20while [ $# -gt 0 ]; do
21 case "$1" in 21 case "$1" in
22 --adam) shift; ADAM=y;; 22 --adam) shift; ADAM=y;;
23 --usb) shift; USB=y;; 23 --bootloader) shift; BOOTLOADER_ONLY=y;;
24 --cdrom) shift; USB=;;
24 --detach) shift; DETACH=y;; 25 --detach) shift; DETACH=y;;
25 --test) shift; QUICK_TEST=y;; 26 --test) shift; QUICK_TEST=y;;
26 --out) CMDLINE_OUTDEV="$2"; shift 2;; 27 --out) CMDLINE_OUTDEV="$2"; USB=; shift 2;;
27 --in) INPUT_DEVICE="$2"; shift 2;; 28 --in) INPUT_DEVICE="$2"; shift 2;;
28 --) shift; break;; 29 --) shift; break;;
29 *) die 'getopt error';; 30 *) die 'getopt error';;
30 esac 31 esac
31done 32done
32 33
33if [ -z "$INPUT_DEVICE" -a $# = 0 ]; then 34if [ -z "$INPUT_DEVICE" -a $# = 0 -a -z "$BOOTLOADER_ONLY" ]; then
34 if mountpoint -q /cdrom; then 35 if mountpoint -q /cdrom; then
35 INPUT_DEVICE=/cdrom 36 INPUT_DEVICE=/cdrom
36 elif [ -e debian-live-8.4.0-amd64-standard.btrfs -a -e layer.btrfs ]; then 37 elif [ -e debian-live-8.4.0-amd64-standard.btrfs -a -e layer.btrfs ]; then
37 set -- debian-live-8.4.0-amd64-standard.btrfs layer.btrfs 38 set -- debian-live-8.4.0-amd64-standard.btrfs layer.btrfs
39 elif [ -e /srv/nbd.btrfs ]; then
40 set -- /srv/nbd.btrfs
41 elif [ "$(blockdev --getsz /dev/nbd0)" -gt 0 ]; then
42 (set -x; dd if=/dev/nbd0 of=/srv/nbd.btrfs~ && mv /srv/nbd.btrfs~ /srv/nbd.btrfs) || die "failed to copy network block device"
43 set -- /srv/nbd.btrfs
38 else 44 else
39 die "no input device and no input btrfs layers: aborting." 45 die "no input device and no input btrfs layers: aborting."
40 fi 46 fi
@@ -113,7 +119,7 @@ choose_outdev()
113 119
114generate_keys() 120generate_keys()
115{ 121{
116 if [ "$ADAM" ]; then 122 if [ "$ADAM" -o "$BOOTLOADER_ONLY" ]; then
117 kiki init || die 'kiki init failed' 123 kiki init || die 'kiki init failed'
118 gnupghome=/root/.gnupg 124 gnupghome=/root/.gnupg
119 else 125 else
@@ -170,6 +176,7 @@ if [ "$REPLACE_INITRD" ]; then
170 # support tftp pointing to the cdrom. This probably means a tftp directory 176 # support tftp pointing to the cdrom. This probably means a tftp directory
171 # that contains a symlink to /cdrom/linux which gets updated on success here 177 # that contains a symlink to /cdrom/linux which gets updated on success here
172 mv "${vmlinuz_dir}" "${vmlinuz_dir}".bak 178 mv "${vmlinuz_dir}" "${vmlinuz_dir}".bak
179 mkdir "${vmlinuz_dir}"
173 initrd.sh || { 180 initrd.sh || {
174 mv "${vmlinuz_dir}.bak" "${vmlinuz_dir}" 181 mv "${vmlinuz_dir}.bak" "${vmlinuz_dir}"
175 die 'initrd.sh failed' 182 die 'initrd.sh failed'