내 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
추신: 저는 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