Bash:install.sh:行185:構文エラー:予期しないファイルの終わり

Bash:install.sh:行185:構文エラー:予期しないファイルの終わり

私のArch Linuxベースのディストリビューション用のインストーラを作成しようとしていますが、このエラーを削除することはできません! ! ! !

私はそれが開いている場合、または途中で、または何かをすることができることを知っていますが、見つかりません! ! ! ! notepad ++とdos2unixを使用して変換しようとしましたが、まだ同じエラーが発生します!

install.sh: line 185: syntax error: unexpected end of file

コードは次のとおりです。

#!/bin/bash

echo -e "Hello there. So, you want to install DogOS...\nWell, thats my job.\nMy name is Captain Install, and im going to help install your new home and move your best friend. Doggy Linux!"

sleep 2

echo "Lets begin!"

read -p "Press enter to continue"

clear

echo "So, first i need your keyboard layout, will display a loooooonnnnnggggggg list of all layouts, and search your layout, then write it in this terminal in the input 'Layout> '."

read -p "Press enter to continue"

ls /usr/share/kbd/keymaps/**/*

read -p "Layout> " layout

loadkeys $layout

clear
sleep 1
echo "Verifying if your system is booted in EFI or BIOS/CSM."
sleep 1
echo "Verifying if your system is booted in EFI or BIOS/CSM.."
sleep 1
echo "Verifying if your system is booted in EFI or BIOS/CSM..."
sleep 1
if [ -d "/sys/firmware/efi/efivars" ]
then
        EFI="True"
else
        EFI="False"
fi
echo "RESULT: EFI=$EFI"
sleep 2
clear
echo "Now it's the network step, please configure the network in KDE and then press enter to move on..."
read -p "Press enter to check the internet connection..."
echo "Testing internet please standby..."
ping www.google.com -c 5

if [ "$?" = "0" ]
then
        echo "Connected with sucess, with code $?"
else
        echo "ERROR: NOT CONNECTED, CODE EXIT $?"
        exit 1
fi

timedatectl set-ntp true

fdisk -l

read -p "Disk (exemple: /dev/sda)> " disk_to_part

while true:
        echo "1 - Entire disk (WILL BE ERASE ALL OF DATA)"
        echo "2 - Manual (using fdisk)"
        read -p "Option> " part_mode

        if [ "$part_mode" = "1" ]
        then
                if [ "$EFI" = "True" ]
                then
                        parted $disk_to_part -- mklabel gpt
                        parted $disk_to_part -- mkpart primary 512Mib -1Gib
                        parted $disk_to_part -- mkpart primary linux-swap -1Gib 100%
                        parted $disk_to_part -- mkpart ESP fat32 1Mib 512Mib
                        parted $disk_to_part -- set 3 esp on

                        mkfs.ext4 -L dogos {$disk_to_part}1
                        mkswap -L swap {$disk_to_part}2
                        mkfs.fat -F 32 -n boot {$disk_to_part}3
                fi
                if [ "$EFI" = "False" ]
                then
                        parted $disk_to_part -- mklabel msdos
                        parted $disk_to_part -- mkpart primary 1Mib -1Gib
                        parted $disk_to_part -- mkpart primary linux-swap -1Gib 100%
                        mkfs.ext4 -L dogos {$disk_to_part}1
                        mkswap -L swap {$disk_to_part}2
                fi
        break
        fi
        if [ "$part_mode" = "2" ]
        then
                fdisk $disk_to_part
                read -p "ROOT_PART=" root_part
                read -p "SWAP_PART=" swap_part
                if [ "$EFI" = "True" ]
                then
                        read -p "UEFI_PART=" uefi_part
                fi
                if [ "$EFI" = "True" ]
                then
                        mkfs.ext4 -L dogos $root_part
                        mkswap -L swap $swap_part
                        mkfs.fat -F 32 -n boot $uefi_part
                fi
                if [ "$EFI" = "False" ]
                then
                        mkfs.ext4 -L dogos $root_part
                        mkswap -L swap $swap_part
                fi
                break
        else
                echo "Not a option"
        fi
echo "Partition done"

sleep 2
fdisk -l

#ROOT=dogos
#SWAP=swap
#UEFI=boot


if [ "$EFI" = "True" ]
then
        mount /dev/disk/by-label/dogos /mnt
        mkdir -p /mnt/boot
        mount /dev/disk/by-label/boot /mnt/boot
        swapon /dev/disk/by-label/swap
fi
if [ "$EFI" = "False" ]
then
        mount /dev/disk/by-label/dogos /mnt
        swapon /dev/disk/by-label/swap
fi

pacman -Syy --noconfirm
pacman -Syy --noconfirm archlinux-keyring
until pacstrap /mnt base linux linux-firmware
do
        pacman -Syy --noconfirm
        echo "Trying again..."
done
genfstab -U /mnt >> /mnt/etc/fstab

read -p "Region: " region
ls /usr/share/zoneinfo/$region/
read -p "City: " city
arch-chroot /mnt ln -sf /usr/share/zoneinfo/$region/$city /etc/localtime

arch-chroot /mnt hwclock --systohc

echo "KEYMAP=$layout" > /mnt/etc/vconsole.conf

read -p "Hostname> " hostname

echo "$hostname" > /mnt/etc/hostname

echo "root:root" | chpasswd

arch-chroot /mnt pacman -S dosfstools os-prober mtools network-manager-applet networkmanager wpa_supplicant wireless_tools dialog sudo nano vim ed

if [ "$EFI" = "True" ]
then
        arch-chroot /mnt pacman -S grub efibootmgr
        arch-chroot /mnt grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB --recheck
        arch-chroot /mnt cp /etc/default/grub /etc/default/.grub.bak
        arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg
fi
if ["$EFI" = "False" ]
then
        arch-chroot /mnt pacman -S grub
        arch-chroot /mnt grub-install --target=i386-pc $disk_to_part --recheck
        arch-chroot /mnt cp /etc/default/grub /etc/default/.grub.bak
        arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg
fi

echo "The installation is done!"

sleep 5

arch-chroot /mnt exit

umount -R /mnt

reboot

PS:私はbashスクリプトが初めてです。誰でも助けることができますか?

ベストアンサー1

ウェブサイトhttps://www.shellcheck.net/これを行うための素晴らしいツールです。

あなたの場合、ここに間違った形式がありますwhile

 while true:
        echo "1 - Entire disk (WILL BE ERASE ALL OF DATA)"
        echo "2 - Manual (using fdisk)"
        read -p "Option> " part_mode

どちらかを実行することも、while true; do ...両方を実行することもできます。どちらも本当のコマンドであり、常に成功しているからwhile :; do ...です。ただし、これは実際にはコマンドではないため、これを行うことはできません。いずれの場合でも、while構文には次のものが必要です。true:while true:true:do

while condition; do something; done

おすすめ記事