shellcheck step 0

This commit is contained in:
Jesús 2022-05-24 07:53:38 +08:00
parent 7c908d5f68
commit d458a57e56
No known key found for this signature in database
GPG Key ID: F6EE7BC59A315766

154
hyperfi
View File

@ -130,7 +130,7 @@ setkeymap(){
if [ "$?" = "0" ]; then
clear
echo "loadkeys ${keymap}"
loadkeys ${keymap}
loadkeys "${keymap}"
pressanykey
fi
}
@ -179,7 +179,7 @@ selectdisk(){
then
return 1
fi
echo ${result%%\ *}
echo "${result%%\ *}"
return 0
}
@ -242,18 +242,18 @@ diskpartautodos(){
if (whiptail --backtitle "${apptitle}" --title "${txtautoparts} (dos)" --yesno "${txtautopartsconfirm//%1/${device}}" --defaultno 0 0); then
clear
echo "${txtautopartclear}"
parted ${device} mklabel msdos
parted "${device}" mklabel msdos
sleep 1
echo "${txtautopartcreate//%1/boot}"
echo -e "n\np\n\n\n+512M\na\nw" | fdisk ${device}
echo -e "n\np\n\n\n+512M\na\nw" | fdisk "${device}"
sleep 1
echo "${txtautopartcreate//%1/swap}"
swapsize=$(grep MemTotal /proc/meminfo | awk '{ print $2 }')
swapsize=$((swapsize/1000))"M"
echo -e "n\np\n\n\n+${swapsize}\nt\n\n82\nw" | fdisk ${device}
echo -e "n\np\n\n\n+${swapsize}\nt\n\n82\nw" | fdisk "${device}"
sleep 1
echo "${txtautopartcreate//%1/root}"
echo -e "n\np\n\n\n\nw" | fdisk ${device}
echo -e "n\np\n\n\n\nw" | fdisk "${device}"
sleep 1
echo ""
pressanykey
@ -277,17 +277,17 @@ diskpartautogpt(){
if (whiptail --backtitle "${apptitle}" --title "${txtautoparts} (gpt)" --yesno "${txtautopartsconfirm//%1/${device}}" --defaultno 0 0); then
clear
echo "${txtautopartclear}"
parted ${device} mklabel gpt
parted "${device}" mklabel gpt
echo "${txtautopartcreate//%1/BIOS boot}"
sgdisk ${device} -n=1:0:+31M -t=1:ef02
sgdisk "${device}" -n=1:0:+31M -t=1:ef02
echo "${txtautopartcreate//%1/boot}"
sgdisk ${device} -n=2:0:+512M
sgdisk "${device}" -n=2:0:+512M
echo "${txtautopartcreate//%1/swap}"
swapsize=$(grep MemTotal /proc/meminfo | awk '{ print $2 }')
swapsize=$((swapsize/1000))"M"
sgdisk ${device} -n=3:0:+${swapsize} -t=3:8200
sgdisk "${device}" -n=3:0:+${swapsize} -t=3:8200
echo "${txtautopartcreate//%1/root}"
sgdisk ${device} -n=4:0:0
sgdisk "${device}" -n=4:0:0
echo ""
pressanykey
if [ "${device::8}" == "/dev/nvm" ]; then
@ -310,15 +310,15 @@ diskpartautoefi(){
if (whiptail --backtitle "${apptitle}" --title "${txtautoparts} (gpt,efi)" --yesno "${txtautopartsconfirm//%1/${device}}" --defaultno 0 0); then
clear
echo "${txtautopartclear}"
parted ${device} mklabel gpt
parted "${device}" mklabel gpt
echo "${txtautopartcreate//%1/EFI boot}"
sgdisk ${device} -n=1:0:+1024M -t=1:ef00
sgdisk "${device}" -n=1:0:+1024M -t=1:ef00
echo "${txtautopartcreate//%1/swap}"
swapsize=$(grep MemTotal /proc/meminfo | awk '{ print $2 }')
swapsize=$((swapsize/1000))"M"
sgdisk ${device} -n=3:0:+${swapsize} -t=3:8200
sgdisk "${device}" -n=3:0:+${swapsize} -t=3:8200
echo "${txtautopartcreate//%1/root}"
sgdisk ${device} -n=4:0:0
sgdisk "${device}" -n=4:0:0
echo ""
pressanykey
if [ "${device::8}" == "/dev/nvm" ]; then
@ -341,13 +341,13 @@ diskpartautoefiusb(){
if (whiptail --backtitle "${apptitle}" --title "${txtautoparts} (gpt,efi)" --yesno "${txtautopartsconfirm//%1/${device}}" --defaultno 0 0); then
clear
echo "${txtautopartclear}"
parted ${device} mklabel gpt
parted "${device}" mklabel gpt
echo "${txtautopartcreate//%1/EFI boot}"
sgdisk ${device} -n=1:0:+1024M -t=1:ef00
sgdisk "${device}" -n=1:0:+1024M -t=1:ef00
echo "${txtautopartcreate//%1/BIOS boot}"
sgdisk ${device} -n=3:0:+31M -t=3:ef02
sgdisk "${device}" -n=3:0:+31M -t=3:ef02
echo "${txtautopartcreate//%1/root}"
sgdisk ${device} -n=4:0:0
sgdisk "${device}" -n=4:0:0
echo "${txthybridpartcreate}"
echo -e "r\nh\n3\nN\n\nY\nN\nw\nY\n" | gdisk ${device}
echo ""
@ -370,7 +370,7 @@ diskpartcfdisk(){
device=$( selectdisk "${txteditparts} (cfdisk)" )
if [ "$?" = "0" ]; then
clear
cfdisk ${device}
cfdisk "${device}"
fi
}
@ -378,7 +378,7 @@ diskpartcgdisk(){
device=$( selectdisk "${txteditparts} (cgdisk)" )
if [ "$?" = "0" ]; then
clear
cgdisk ${device}
cgdisk "${device}"
fi
}
# --------------------------------------------------------
@ -490,14 +490,14 @@ formatdevices(){
if (whiptail --backtitle "${apptitle}" --title "${txtformatdevices}" --yesno "${txtformatdeviceconfirm}" --defaultno 0 0); then
fspkgs=""
if [ ! "${bootdev}" = "" ]; then
formatbootdevice boot ${bootdev}
formatbootdevice boot "${bootdev}"
fi
if [ ! "${swapdev}" = "" ]; then
formatswapdevice swap ${swapdev}
formatswapdevice swap" ${swapdev}"
fi
formatdevice root ${rootdev}
formatdevice root "${rootdev}"
if [ ! "${homedev}" = "" ]; then
formatdevice home ${homedev}
formatdevice home "${homedev}"
fi
fi
}
@ -524,20 +524,20 @@ formatbootdevice(){
case ${sel} in
ext2)
echo "mkfs.ext2 ${2}"
mkfs.ext2 ${2}
mkfs.ext2 "${2}"
;;
ext3)
echo "mkfs.ext3 ${2}"
mkfs.ext3 ${2}
mkfs.ext3 "${2}"
;;
ext4)
echo "mkfs.ext4 ${2}"
mkfs.ext4 ${2}
mkfs.ext4 "${2}"
;;
fat32)
fspkgs="${fspkgs[@]} dosfstools"
echo "mkfs.fat ${2}"
mkfs.fat ${2}
mkfs.fat "${2}"
;;
esac
echo ""
@ -558,7 +558,7 @@ formatswapdevice(){
case ${sel} in
swap)
echo "mkswap ${swapdev}"
mkswap ${swapdev}
mkswap "${swapdev}"
echo ""
pressanykey
;;
@ -591,13 +591,13 @@ formatdevice(){
btrfs)
fspkgs="${fspkgs[@]} btrfs-progs"
echo "mkfs.btrfs -f ${2}"
mkfs.btrfs -f ${2}
mkfs.btrfs -f "${2}"
if [ "${1}" = "root" ]; then
echo "mount ${2} /mnt"
echo "btrfs subvolume create /mnt/root"
echo "btrfs subvolume set-default /mnt/root"
echo "umount /mnt"
mount ${2} /mnt
mount "${2}" /mnt
btrfs subvolume create /mnt/root
btrfs subvolume set-default /mnt/root
umount /mnt
@ -605,40 +605,40 @@ formatdevice(){
;;
ext4)
echo "mkfs.ext4 ${2}"
mkfs.ext4 ${2}
mkfs.ext4 "${2}"
;;
ext3)
echo "mkfs.ext3 ${2}"
mkfs.ext3 ${2}
mkfs.ext3 "${2}"
;;
ext2)
echo "mkfs.ext2 ${2}"
mkfs.ext2 ${2}
mkfs.ext2 "${2}"
;;
xfs)
fspkgs="${fspkgs[@]} xfsprogs"
echo "mkfs.xfs -f ${2}"
mkfs.xfs -f ${2}
mkfs.xfs -f "${2}"
;;
f2fs)
fspkgs="${fspkgs[@]} f2fs-tools"
echo "mkfs.f2fs $2"
mkfs.f2fs $2
mkfs.f2fs "${2}"
;;
jfs)
fspkgs="${fspkgs[@]} jfsutils"
echo "mkfs.xfs -f ${2}"
mkfs.jfs -f ${2}
mkfs.jfs -f "${2}"
;;
reiserfs)
fspkgs="${fspkgs[@]} reiserfsprogs"
echo "mkfs.reiserfs -f ${2}"
mkfs.reiserfs -f ${2}
mkfs.reiserfs -f "${2}"
;;
luks)
echo "${txtcreateluksdevice}"
echo "cryptsetup luksFormat ${2}"
cryptsetup luksFormat ${2}
cryptsetup luksFormat "${2}"
if [ ! "$?" = "0" ]; then
pressanykey
return 1
@ -647,7 +647,7 @@ formatdevice(){
echo ""
echo "${txtopenluksdevice}"
echo "cryptsetup luksOpen ${2} ${1}"
cryptsetup luksOpen ${2} ${1}
cryptsetup luksOpen "${2}" "${1}"
if [ ! "$?" = "0" ]; then
pressanykey
return 1
@ -663,11 +663,11 @@ formatdevice(){
case ${sel} in
normal)
echo "dd if=/dev/zero of=/dev/mapper/${1}"
dd if=/dev/zero of=/dev/mapper/${1} & PID=$! &>/dev/null
dd if=/dev/zero of=/dev/mapper/"${1}" & PID=$! &>/dev/null
;;
fast)
echo "dd if=/dev/zero of=/dev/mapper/${1} bs=60M"
dd if=/dev/zero of=/dev/mapper/${1} bs=60M & PID=$! &>/dev/null
dd if=/dev/zero of=/dev/mapper/"${1}" bs=60M & PID=$! &>/dev/null
;;
esac
clear
@ -679,15 +679,15 @@ formatdevice(){
fi
echo ""
pressanykey
formatdevice ${1} /dev/mapper/${1} noluks
formatdevice "${1}" /dev/mapper/"${1}" noluks
if [ "${1}" = "root" ]; then
realrootdev=${rootdev}
rootdev=/dev/mapper/${1}
luksroot=1
luksrootuuid=$(cryptsetup luksUUID ${2})
luksrootuuid=$(cryptsetup luksUUID "${2}")
else
case ${1} in
home) homedev=/dev/mapper/${1} ;;
home) homedev=/dev/mapper/"${1}" ;;
esac
luksdrive=1
crypttab="\n${1} UUID=$(cryptsetup luksUUID ${2}) none"
@ -703,20 +703,20 @@ formatdevice(){
mountparts(){
clear
echo "mount ${rootdev} /mnt"
mount ${rootdev} /mnt
mount "${rootdev}" /mnt
echo "mkdir /mnt/{boot,home}"
mkdir /mnt/{boot,home} 2>/dev/null
if [ ! "${bootdev}" = "" ]; then
echo "mount ${bootdev} /mnt/boot"
mount ${bootdev} /mnt/boot
mount "${bootdev}" /mnt/boot
fi
if [ ! "${swapdev}" = "" ]; then
echo "swapon ${swapdev}"
swapon ${swapdev}
swapon "${swapdev}"
fi
if [ ! "${homedev}" = "" ]; then
echo "mount ${homedev} /mnt/home"
mount ${homedev} /mnt/home
mount "${homedev}" /mnt/home
fi
pressanykey
installmenu
@ -876,7 +876,7 @@ installbase(){
clear
echo "pacstrap /mnt ${pkgs}"
pacstrap /mnt ${pkgs}
pacstrap /mnt "${pkgs}"
pressanykey
}
@ -886,7 +886,7 @@ unmountdevices(){
umount -R /mnt
if [ ! "${swapdev}" = "" ]; then
echo "swapoff ${swapdev}"
swapoff ${swapdev}
swapoff "${swapdev}"
fi
pressanykey
}
@ -1034,9 +1034,9 @@ archmenu(){
archchroot(){
echo "arch-chroot /mnt /root"
cp ${0} /mnt/root
cp "${0}" /mnt/root
chmod 755 /mnt/root/$(basename "${0}")
arch-chroot /mnt /root/$(basename "${0}") --chroot ${1} ${2}
arch-chroot /mnt /root/$(basename "${0}") --chroot "${1}" "${2}"
rm /mnt/root/$(basename "${0}")
echo "exit"
}
@ -1143,7 +1143,7 @@ archsettime(){
fi
items=$(ls /mnt/usr/share/zoneinfo/${timezone}/)
items=$(ls /mnt/usr/share/zoneinfo/"${timezone}"/)
options=()
for item in ${items}; do
options+=("${item}" "")
@ -1158,7 +1158,7 @@ archsettime(){
clear
echo "ln -sf /mnt/usr/share/zoneinfo/${timezone} /mnt/etc/localtime"
ln -sf /usr/share/zoneinfo/${timezone} /mnt/etc/localtime
ln -sf /usr/share/zoneinfo/"${timezone}" /mnt/etc/localtime
pressanykey
options=()
@ -1411,15 +1411,15 @@ archgrubinstallbootloader(){
if [ "$?" = "0" ]; then
clear
case ${sel} in
"BIOS") archchroot grubbootloaderinstall ${device};;
"EFI") archchroot grubbootloaderefiinstall ${device};;
"BIOS+EFI") archchroot grubbootloaderefiusbinstall ${device};;
"BIOS") archchroot grubbootloaderinstall "${device}";;
"EFI") archchroot grubbootloaderefiinstall "${device}";;
"BIOS+EFI") archchroot grubbootloaderefiusbinstall "${device}";;
esac
pressanykey
fi
else
clear
archchroot grubbootloaderinstall ${device}
archchroot grubbootloaderinstall "${device}"
pressanykey
fi
fi
@ -1427,14 +1427,14 @@ archgrubinstallbootloader(){
archgrubinstallbootloaderchroot(){
if [ ! "${1}" = "none" ]; then
echo "grub-install --target=i386-pc --recheck ${1}"
grub-install --target=i386-pc --recheck ${1}
grub-install --target=i386-pc --recheck "${1}"
fi
exit
}
archgrubinstallbootloaderefichroot(){
if [ ! "${1}" = "none" ]; then
echo "grub-install --target=x86_64-efi --efi-directory=/boot --recheck ${1}"
grub-install --target=x86_64-efi --efi-directory=/boot --recheck ${1}
grub-install --target=x86_64-efi --efi-directory=/boot --recheck "${1}"
isvbox=$(lspci | grep "VirtualBox G")
if [ "${isvbox}" ]; then
echo "VirtualBox detected, creating startup.nsh..."
@ -1446,9 +1446,9 @@ archgrubinstallbootloaderefichroot(){
archgrubinstallbootloaderefiusbchroot(){
if [ ! "${1}" = "none" ]; then
echo "grub-install --target=i386-pc --recheck ${1}"
grub-install --target=i386-pc --recheck ${1}
grub-install --target=i386-pc --recheck "${1}"
echo "grub-install --target=x86_64-efi --efi-directory=/boot --removable --recheck ${1}"
grub-install --target=x86_64-efi --efi-directory=/boot --removable --recheck ${1}
grub-install --target=x86_64-efi --efi-directory=/boot --removable --recheck "${1}"
isvbox=$(lspci | grep "VirtualBox G")
if [ "${isvbox}" ]; then
echo "VirtualBox detected, creating startup.nsh..."
@ -1536,9 +1536,9 @@ archsyslinuxinstall(){
archsyslinuxinstallbootloader(){
clear
if [ "${efimode}" == "1" ]||[ "${efimode}" == "2" ]; then
archchroot syslinuxbootloaderefiinstall ${bootdev}
archchroot syslinuxbootloaderefiinstall "${bootdev}"
else
archchroot syslinuxbootloaderinstall ${bootdev}
archchroot syslinuxbootloaderinstall "${bootdev}"
fi
pressanykey
}
@ -1606,8 +1606,8 @@ archrefindinstall(){
echo "echo \"\\\"Hyperbola GNU+Linux-libre Fallback\\\" \\\"root=UUID=${rootuuid} rw add_efi_memmap initrd=/initramfs-linux-fallback.img\\\"\" >> /mnt/boot/refind_linux.conf"
pacstrap /mnt refind-efi
archchroot refindbootloaderinstall ${realrootdev}
rootuuid=$(blkid -s UUID -o value ${realrootdev})
archchroot refindbootloaderinstall "${realrootdev}"
rootuuid=$(blkid -s UUID -o value "${realrootdev}")
echo "\"Hyperbola GNU+Linux-libre \" \"root=UUID=${rootuuid} rw add_efi_memmap\"" > /mnt/boot/refind_linux.conf
echo "\"Hyperbola GNU+Linux-libre Fallback\" \"root=UUID=${rootuuid} rw add_efi_memmap initrd=/initramfs-linux-fallback.img\"" >> /mnt/boot/refind_linux.conf
pressanykey
@ -1645,7 +1645,7 @@ archextrasmenu(){
done
clear
echo "pacstrap /mnt ${pkgs}"
pacstrap /mnt ${pkgs}
pacstrap /mnt "${pkgs}"
if [[ "${pkgs}" == *"dhcpcd"* ]]; then
archchroot enabledhcpcd
fi
@ -1868,8 +1868,8 @@ while (( "$#" )); do
;;
-sf | --skip-font) skipfont=1;;
-t | --test)
wget -O hyperfi https://hgit.ga/${2}/hyperfi/raw/branch/${3}/hyperfi
sh hyperfi -tt ${2} ${3}
wget -O hyperfi "https://hgit.ga/${2}/hyperfi/raw/branch/${3}/hyperfi"
sh hyperfi -tt "${2}" "${3}"
exit 0
;;
-tt) baseurl="https://hgit.ga/${2}/hyperfi/raw/branch/${3}";;
@ -1902,12 +1902,12 @@ if [ "${chroot}" = "1" ]; then
'genmkinitcpio') archgenmkinitcpiochroot;;
'enabledhcpcd') archenabledhcpcdchroot;;
'grubinstall') archgrubinstallchroot;;
'grubbootloaderinstall') archgrubinstallbootloaderchroot ${args};;
'grubbootloaderefiinstall') archgrubinstallbootloaderefichroot ${args};;
'grubbootloaderefiusbinstall') archgrubinstallbootloaderefiusbchroot ${args};;
'syslinuxbootloaderinstall') archsyslinuxinstallbootloaderchroot ${args};;
'syslinuxbootloaderefiinstall') archsyslinuxinstallbootloaderefichroot ${args};;
'refindbootloaderinstall') archrefindinstallchroot ${args};;
'grubbootloaderinstall') archgrubinstallbootloaderchroot "${args}";;
'grubbootloaderefiinstall') archgrubinstallbootloaderefichroot "${args}";;
'grubbootloaderefiusbinstall') archgrubinstallbootloaderefiusbchroot "${args}";;
'syslinuxbootloaderinstall') archsyslinuxinstallbootloaderchroot "${args}";;
'syslinuxbootloaderefiinstall') archsyslinuxinstallbootloaderefichroot "${args}";;
'refindbootloaderinstall') archrefindinstallchroot "${args}";;
'hyperdiinstallandlaunch') hyperdiinstallandlaunchchroot;;
'hyperdiinstall') hyperdiinstallchroot;;
'hyperdilaunch') hyperdilaunchchroot;;