【问题标题】:Bash script creating hybrid iso generates “unexpected end of file”创建混合 iso 的 Bash 脚本会生成“意外的文件结尾”
【发布时间】:2014-09-23 10:49:42
【问题描述】:

我创建了一个简单的 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

【问题讨论】:

  • 脚本中的while 循环没有终止。因此,这个错误。在适当的位置使用done 终止它。
  • $iqstatic 真让我尴尬。谢谢。

标签: linux bash scripting iso


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-07-31
    • 1970-01-01
    • 2022-11-10
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    • 1970-01-01
    • 2021-09-06
    相关资源
    最近更新 更多