创建混合iso的Bash脚本生成“意外的文件结束”

时间:2014-09-23 10:49:42

标签: linux bash scripting iso

我创建了一个简单的bash脚本,用于创建混合iso。但是当我尝试运行它时,我得到输出:

hybridiso.sh: line 58: syntax error: unexpected end of file.

我检查了脚本并尝试对其进行更改,但我仍然得到相同的输出。脚本有什么问题?

#!/bin/bash

##Sanity Cheks##
if [ "$(whoami)" != root ]; then
    echo "You must be root to execute this script."
fi

if [ ! -x /usr/bin/xorriso ]; then
    echo "xorriso is not installed. Run 'apt-get install xorriso' to install it."
exit 1
fi

if [ ! -x /usr/bin/live-build ]; then
    echo "live-build is not installed. Run 'apt-get install live-build' to install it."
exit 1
fi

if [ ! -x /usr/bin/syslinux ]; then
    echo "syslinux is not insatlled. Run 'apt-get install syslinux' to install it."
exit 1
fi

if [ ! -x /usr/bin/mksquashfs ]; then
    echo "squashfs-tools is not installed. Run 'apt-get install squashfs-tools' to install it."
exit 1
fi
###############

mkdir $PWD/hybridiso
cd hybridiso
mkdir -p binary/live && mkdir -p binary/isolinux
read -e -p "Enter local file path for linux kernel " kernel
read -e -p "Enter local file path for initrd " initrd
cp $kernel binary/live/ && cp $initrd binary/live/
#mksquashfs chroot binary/live/filesystem.squashfs -comp xz -e boot
cp /usr/lib/syslinux/isolinux.bin binary/isolinux/
cp /usr/lib/syslinux/menu.c32 binary/isolinux/
while true; do
read -p "Do you have an isolinux.cfg? " resp
if [ $resp -eq no ]; then
    echo "You need to create a valid isolinux.cfg file!"
    echo "Creating example file $PWD/isolinux.cfg.example"
    echo -e "ui menu.c32\nprompt 0\nmenu title Boot Menu\ntimeout 300\n\n\nlabel live-amd64\n       menu label ^Live (amd64)\n       menu default\n       linux /live/linux\n        append initrd=/live/initrd.gz boot=live persistence quiet\n\n\nlabel live-amd64-failsafe\n        menu label ^Live (amd64 failsafe)\nlinux /live/linux\nappend initrd=/live/initrd.gz boot=live persistence config memtest noapic noapm nodma nomce nolapic nomodest nosmp nosplash vga=normal\n\n\nendtext" >> isolinux.cfg.example
exit 1
elif [ $resp -eq yes ]; then
    break
else
    "Put only in yes or no"
fi

read -e -p "Enter local file path for isolinux.cfg" isolinux
cp $isolinux binary/isolinux/

xorriso -as mkisofs -r -J -joliet-long -l -cache-inodes -isohybrid-mbr /usr/lib/syslinux/isohdpfx.bin -partition_offset 16 -A "Debian Live" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o kiosk.iso binary

echo "Script is succesfull!"
exit 0

1 个答案:

答案 0 :(得分:2)

您还没有在任何地方while循环done循环;在适当的位置添加done