2

I'm trying to build my own installer for my own Arch Linux distro based but i can't get this error off of me!!!!

i know it can be a open if or while or do or something else but i can't find it!!!! And i tried converting with notepad++ and dos2unix but it still gets the same error!!!

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

Here is the code:

#!/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: I'm a little new to bash scripting, so can someone help me?

0

1 Answer 1

4

The website https://www.shellcheck.net/ is a great tool for this sort of thing.

In your case, you have a malformed while here:

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

You can do either while true; do ... or you can do while :; do ... because both true and : are real commands that always succeed. But you can't do while true: because true: is not a real command and in any case, the syntax for while needs a do:

while condition; do something; done
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.