diff options
Diffstat (limited to 'src/scripts/iso-efiboot.sh')
| -rw-r--r-- | src/scripts/iso-efiboot.sh | 190 |
1 files changed, 0 insertions, 190 deletions
diff --git a/src/scripts/iso-efiboot.sh b/src/scripts/iso-efiboot.sh deleted file mode 100644 index f3e5d68..0000000 --- a/src/scripts/iso-efiboot.sh +++ /dev/null | |||
| @@ -1,190 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # IP Engineering Rescue Disk | ||
| 4 | # Copyright (C) 2018 David M. Syzdek <david@syzdek.net>. | ||
| 5 | # | ||
| 6 | # @SYZDEK_BSD_LICENSE_START@ | ||
| 7 | # | ||
| 8 | # Redistribution and use in source and binary forms, with or without | ||
| 9 | # modification, are permitted provided that the following conditions are | ||
| 10 | # met: | ||
| 11 | # | ||
| 12 | # * Redistributions of source code must retain the above copyright | ||
| 13 | # notice, this list of conditions and the following disclaimer. | ||
| 14 | # * Redistributions in binary form must reproduce the above copyright | ||
| 15 | # notice, this list of conditions and the following disclaimer in the | ||
| 16 | # documentation and/or other materials provided with the distribution. | ||
| 17 | # * Neither the name of David M. Syzdek nor the | ||
| 18 | # names of its contributors may be used to endorse or promote products | ||
| 19 | # derived from this software without specific prior written permission. | ||
| 20 | # | ||
| 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
| 22 | # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
| 23 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 24 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID M. SYZDEK BE LIABLE FOR | ||
| 25 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 29 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 30 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 31 | # SUCH DAMAGE. | ||
| 32 | # | ||
| 33 | # @SYZDEK_BSD_LICENSE_END@ | ||
| 34 | # | ||
| 35 | |||
| 36 | # +-=-=-=-=-=-+ | ||
| 37 | # | | | ||
| 38 | # | Headers | | ||
| 39 | # | | | ||
| 40 | # +-=-=-=-=-=-+ | ||
| 41 | |||
| 42 | # set PROG_NAME and load profile | ||
| 43 | PROG_NAME="$(basename "${0}")" | ||
| 44 | IPERD_PROFILE="$(dirname "${0}")/iperd.profile" | ||
| 45 | if test ! -f "${IPERD_PROFILE}";then | ||
| 46 | echo "${PROG_NAME}: unable to find iperd.profile" 1>&2; | ||
| 47 | exit 1; | ||
| 48 | fi | ||
| 49 | . "${IPERD_PROFILE}" | ||
| 50 | |||
| 51 | |||
| 52 | # +-=-=-=-=-=-=-+ | ||
| 53 | # | | | ||
| 54 | # | Functions | | ||
| 55 | # | | | ||
| 56 | # +-=-=-=-=-=-=-+ | ||
| 57 | |||
| 58 | cleanup() | ||
| 59 | { | ||
| 60 | # unmount image | ||
| 61 | if test ! -z "${MKTEMP}";then | ||
| 62 | mount | grep "${MKTEMP}" && sudo umount -f "${MKTEMP}" | ||
| 63 | rm -Rf "${MKTEMP}" | ||
| 64 | unset MKTEMP | ||
| 65 | fi | ||
| 66 | |||
| 67 | # remove loop dev | ||
| 68 | test -z "${LOOPDEV}" || sudo losetup -d "${LOOPDEV}" | ||
| 69 | unset LOOPDEV | ||
| 70 | } | ||
| 71 | |||
| 72 | |||
| 73 | exit_witherr() | ||
| 74 | { | ||
| 75 | cleanup | ||
| 76 | rm -f "${OUTPUT}" | ||
| 77 | exit 1 | ||
| 78 | } | ||
| 79 | |||
| 80 | |||
| 81 | usage() | ||
| 82 | { | ||
| 83 | printf "Usage: %s [OPTIONS] <file>\n" "$PROG_NAME" | ||
| 84 | printf "OPTIONS:\n" | ||
| 85 | printf " -h display this message\n" | ||
| 86 | printf " -q quiet\n" | ||
| 87 | printf " -v verbose\n" | ||
| 88 | printf "\n" | ||
| 89 | } | ||
| 90 | |||
| 91 | |||
| 92 | # +-=-=-=-=-=-=-+ | ||
| 93 | # | | | ||
| 94 | # | Main Body | | ||
| 95 | # | | | ||
| 96 | # +-=-=-=-=-=-=-+ | ||
| 97 | |||
| 98 | # set defaults | ||
| 99 | unset VERBOSE | ||
| 100 | unset MKTEMP | ||
| 101 | |||
| 102 | |||
| 103 | # parse CLI arguments | ||
| 104 | while getopts :hqs:t:v OPT; do | ||
| 105 | case ${OPT} in | ||
| 106 | h) usage; exit 0;; | ||
| 107 | v) VERBOSE="1";; | ||
| 108 | q) unset VERBOSE;; | ||
| 109 | ?) | ||
| 110 | echo "${PROG_NAME}: illegal option -- ${OPTARG}" 1>&2 | ||
| 111 | echo "Try '${PROG_NAME} -h' for more information." 1>&2 | ||
| 112 | exit 1; | ||
| 113 | ;; | ||
| 114 | *) | ||
| 115 | ;; | ||
| 116 | esac | ||
| 117 | done | ||
| 118 | shift "$((OPTIND-1))" | ||
| 119 | OUTPUT="${1}" | ||
| 120 | |||
| 121 | |||
| 122 | # check configuration options | ||
| 123 | if test -z "${OUTPUT}";then | ||
| 124 | echo "${PROG_NAME}: missing file" | ||
| 125 | echo "Try '${PROG_NAME} -h' for more information." 1>&2 | ||
| 126 | exit 1 | ||
| 127 | fi | ||
| 128 | |||
| 129 | |||
| 130 | # check for required files/directories/devices | ||
| 131 | for FILE in "${BASEDIR}/EFI/BOOT/BOOTX64.EFI" "${BASEDIR}/EFI/BOOT/BOOTIA32.EFI" \ | ||
| 132 | "${BASEDIR}/EFI/BOOT/ldlinux.e32" "${BASEDIR}/EFI/BOOT/ldlinux.e64" \ | ||
| 133 | "${BASEDIR}/EFI/BOOT/isolia32.cfg" "${BASEDIR}/EFI/BOOT/isolx64.cfg";do | ||
| 134 | if test ! -f "${FILE}";then | ||
| 135 | echo "${PROG_NAME}: $(basename "${FILE}"): file not found" | ||
| 136 | exit 1 | ||
| 137 | fi | ||
| 138 | done | ||
| 139 | if test -f "${OUTPUT}";then | ||
| 140 | echo "${PROG_NAME}: ${OUTPUT}: already exists" | ||
| 141 | exit 1 | ||
| 142 | fi | ||
| 143 | |||
| 144 | |||
| 145 | # set up exit traps | ||
| 146 | trap exit_witherr SIGHUP SIGINT SIGTERM | ||
| 147 | trap cleanup EXIT | ||
| 148 | |||
| 149 | |||
| 150 | # create empty 1900MB disk image | ||
| 151 | dd \ | ||
| 152 | if=/dev/zero \ | ||
| 153 | of="${OUTPUT}" \ | ||
| 154 | count=2880 \ | ||
| 155 | bs=512 \ | ||
| 156 | || { rm -f "${OUTPUT}"; exit 1; } | ||
| 157 | |||
| 158 | |||
| 159 | # create file-system | ||
| 160 | mkfs.msdos -F 12 -n 'EFIBOOT' "${OUTPUT}" || { rm -f "${OUTPUT}"; exit 1; } | ||
| 161 | |||
| 162 | |||
| 163 | # set up loop block device | ||
| 164 | LOOPDEV=$(sudo losetup -P -f --show "${OUTPUT}") | ||
| 165 | if test -z "${LOOPDEV}";then | ||
| 166 | rm -f "${OUTPUT}" | ||
| 167 | exit 1 | ||
| 168 | fi | ||
| 169 | |||
| 170 | |||
| 171 | # mount disk image | ||
| 172 | MKTEMP="$(mktemp -d -p "${BASEDIR}/tmp" efiboot.XXXXXX)" | ||
| 173 | if test -z "${MKTEMP}";then | ||
| 174 | rm -f "${OUTPUT}" | ||
| 175 | exit 1 | ||
| 176 | fi | ||
| 177 | sudo mount -o rw,uid=${USER} ${LOOPDEV} "${MKTEMP}" || exit_witherr | ||
| 178 | |||
| 179 | |||
| 180 | # create directory structure and copy files | ||
| 181 | mkdir -p "${MKTEMP}/EFI/BOOT/" || exit_witherr | ||
| 182 | cp "${BASEDIR}/EFI/BOOT/BOOTX64.EFI" "${MKTEMP}/EFI/BOOT/" || exit_witherr | ||
| 183 | cp "${BASEDIR}/EFI/BOOT/BOOTIA32.EFI" "${MKTEMP}/EFI/BOOT/" || exit_witherr | ||
| 184 | cp "${BASEDIR}/EFI/BOOT/ldlinux.e32" "${MKTEMP}/EFI/BOOT/" || exit_witherr | ||
| 185 | cp "${BASEDIR}/EFI/BOOT/ldlinux.e64" "${MKTEMP}/EFI/BOOT/" || exit_witherr | ||
| 186 | cp "${BASEDIR}/EFI/BOOT/isolia32.cfg" "${MKTEMP}/EFI/BOOT/syslia32.cfg" || exit_witherr | ||
| 187 | cp "${BASEDIR}/EFI/BOOT/isolx64.cfg" "${MKTEMP}/EFI/BOOT/syslx64.cfg" || exit_witherr | ||
| 188 | |||
| 189 | |||
| 190 | # end of script | ||
