fix || rg

This commit is contained in:
Tobias Powalowski 2024-06-28 11:26:27 +02:00
parent 6f25fc153e
commit 564d26f233
4 changed files with 28 additions and 28 deletions

View file

@ -1,13 +1,13 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-or-later
# created by Tobias Powalowski <tpowa@archlinux.org>
if [[ "${_RUNNING_ARCH}" == "x86_64" ]] && grep -q 'Intel' /proc/cpuinfo; then
if [[ "${_RUNNING_ARCH}" == "x86_64" ]] && rg -q 'Intel' /proc/cpuinfo; then
_UCODE="intel-ucode.img"
_UCODE_PKG="intel-ucode"
fi
if [[ "${_RUNNING_ARCH}" == "aarch64" || "${_RUNNING_ARCH}" == "x86_64" ]]; then
if grep -q 'AMD' /proc/cpuinfo; then
if rg -q 'AMD' /proc/cpuinfo; then
_UCODE="amd-ucode.img"
_UCODE_PKG="amd-ucode"
fi
@ -27,14 +27,14 @@ _getrootflags() {
_getraidarrays() {
_RAIDARRAYS=""
if [[ -f "${_DESTDIR}/etc/mdadm.conf" ]] && ! grep -q '^ARRAY' "${_DESTDIR}"/etc/mdadm.conf 2>"${_NO_LOG}"; then
if [[ -f "${_DESTDIR}/etc/mdadm.conf" ]] && ! rg -q '^ARRAY' "${_DESTDIR}"/etc/mdadm.conf 2>"${_NO_LOG}"; then
_RAIDARRAYS="$(echo -n "$(grep ^md /proc/mdstat 2>"${_NO_LOG}" | sed -e 's#\[[0-9]\]##g' -e 's# :.* raid[0-9]##g' -e 's#md#md=#g' -e 's# #,/dev/#g' -e 's#_##g')")"
fi
}
_getcryptsetup() {
_LUKSSETUP=""
if ! cryptsetup status "$(basename "${_ROOTDEV}")" | grep -q inactive; then
if ! cryptsetup status "$(basename "${_ROOTDEV}")" | rg -q 'inactive'; then
if cryptsetup status "$(basename "${_ROOTDEV}")" 2>"${_NO_LOG}"; then
if [[ "${_NAME_SCHEME_PARAMETER}" == "FSUUID" ]]; then
_LUKSDEV="UUID=$(${_LSBLK} UUID "$(cryptsetup status "$(basename "${_ROOTDEV}")" 2>"${_NO_LOG}" | grep device: | sed -e 's#device:##g')" 2>"${_NO_LOG}")"
@ -103,7 +103,7 @@ _common_bootloader_checks() {
_check_bootpart() {
_SUBDIR=""
_BOOTDEV="$(mount | grep "${_DESTDIR}/boot " | cut -d' ' -f 1)"
_BOOTDEV="$(mount | rg -o "(${_DESTDIR}/boot) .*" -r '$1')"
if [[ -z "${_BOOTDEV}" ]]; then
_SUBDIR="/boot"
_BOOTDEV="${_ROOTDEV}"
@ -120,7 +120,7 @@ _abort_uboot(){
}
_abort_bcachefs_bootpart() {
if ${_LSBLK} FSTYPE "${_BOOTDEV}" 2>"${_NO_LOG}" | grep -q "bcachefs"; then
if ${_LSBLK} FSTYPE "${_BOOTDEV}" 2>"${_NO_LOG}" | rg -q 'bcachefs'; then
_dialog --title " ERROR " --no-mouse --infobox "Your selected bootloader cannot boot from bcachefs partition with /boot on it." 0 0
return 1
fi
@ -144,18 +144,18 @@ _uefi_common() {
# automounted /boot and ESP needs to be mounted first, trigger mount with ls
ls "${_DESTDIR}/boot" &>"${_NO_LOG}"
ls "${_DESTDIR}/efi" &>"${_NO_LOG}"
_BOOTDEV="$(${_FINDMNT} "${_DESTDIR}/boot" | grep -vw 'systemd-1')"
_BOOTDEV="$(${_FINDMNT} "${_DESTDIR}/boot" | rg -vw 'systemd-1')"
if mountpoint -q "${_DESTDIR}/efi" ; then
_UEFISYS_MP=efi
else
_UEFISYS_MP=boot
fi
_UEFISYSDEV="$(${_FINDMNT} "${_DESTDIR}/${_UEFISYS_MP}" | grep -vw 'systemd-1')"
_UEFISYSDEV="$(${_FINDMNT} "${_DESTDIR}/${_UEFISYS_MP}" | rg -vw 'systemd-1')"
_UEFISYSDEV_FS_UUID="$(_getfsuuid "${_UEFISYSDEV}")"
}
_uefi_efibootmgr() {
for _bootnum in $(efibootmgr | grep '^Boot[0-9]' | grep -F -i "${_BOOTMGR_LABEL}" | cut -b5-8) ; do
for _bootnum in $(efibootmgr | rg '^Boot[0-9]' | grep -F -i "${_BOOTMGR_LABEL}" | cut -b5-8) ; do
efibootmgr --quiet -b "${_bootnum}" -B >> "${_LOG}"
done
_BOOTMGRDEV=$(${_LSBLK} PKNAME "${_UEFISYSDEV}" 2>"${_NO_LOG}")

View file

@ -5,11 +5,11 @@
_freeze_xfs() {
sync
if [[ -x /usr/bin/xfs_freeze ]]; then
if grep "${_DESTDIR}/boot " /proc/mounts | grep -q " xfs "; then
if mount | rg -q "${_DESTDIR}/boot type xfs"; then
xfs_freeze -f "${_DESTDIR}"/boot &>"${_NO_LOG}"
xfs_freeze -u "${_DESTDIR}"/boot &>"${_NO_LOG}"
fi
if grep "${_DESTDIR} " /proc/mounts | grep -q " xfs "; then
if mount | rg -q "${_DESTDIR} type xfs"; then
xfs_freeze -f "${_DESTDIR}" &>"${_NO_LOG}"
xfs_freeze -u "${_DESTDIR}" &>"${_NO_LOG}"
fi
@ -59,16 +59,16 @@ _grub_config() {
if [[ "${_ROOTDEV_FS_UUID}" == "${_BOOTDEV_FS_UUID}" ]]; then
_SUBDIR="/boot"
# on btrfs we need to check on subvol
if mount | grep "${_DESTDIR} " | grep btrfs | grep -q subvol; then
if mount | rg -q "${_DESTDIR} type btrfs .*subvol"; then
_SUBDIR="/$(btrfs subvolume show "${_DESTDIR}/" | grep Name | cut -c 11-60)"/boot
fi
if mount | grep "${_DESTDIR}/boot " | grep btrfs | grep -q subvol; then
if mount | rg -q "${_DESTDIR}/boot type btrfs .*subvol"; then
_SUBDIR="/$(btrfs subvolume show "${_DESTDIR}/boot" | grep Name | cut -c 11-60)"
fi
else
_SUBDIR=""
# on btrfs we need to check on subvol
if mount | grep "${_DESTDIR}/boot " | grep btrfs | grep -q subvol; then
if mount | rg -q "${_DESTDIR}/boot type btrfs .*subvol"; then
_SUBDIR="/$(btrfs subvolume show "${_DESTDIR}/boot" | grep Name | cut -c 11-60)"
fi
fi
@ -261,7 +261,7 @@ _grub_bios() {
# try to auto-configure GRUB(2)...
_check_bootpart
# check if raid, raid partition, or device devicemapper is used
if echo "${_BOOTDEV}" | grep -q /dev/md || echo "${_BOOTDEV}" | grep -q /dev/mapper; then
if echo "${_BOOTDEV}" | rg -q '/dev/md|/dev/mapper'; then
# boot from lvm, raid, partitioned and raid devices is supported
_FAIL_COMPLEX=""
if cryptsetup status "${_BOOTDEV}"; then
@ -271,13 +271,13 @@ _grub_bios() {
fi
if [[ -z "${_FAIL_COMPLEX}" ]]; then
# check if mapper is used
if echo "${_BOOTDEV}" | grep -q /dev/mapper; then
if echo "${_BOOTDEV}" | rg -q '/dev/mapper'; then
_RAID_ON_LVM=""
#check if mapper contains a md device!
for devpath in $(pvs -o pv_name --noheading); do
if echo "${devpath}" | grep -v "/dev/md.p" | grep -q /dev/md; then
if echo "${devpath}" | rg -v "/dev/md.p" | rg -q '/dev/md'; then
_DETECTEDVOLUMEGROUP="$(pvs -o vg_name --noheading "${devpath}")"
if echo /dev/mapper/"${_DETECTEDVOLUMEGROUP}"-* | grep -q "${_BOOTDEV}"; then
if echo /dev/mapper/"${_DETECTEDVOLUMEGROUP}"-* | rg -q "${_BOOTDEV}"; then
# change _BOOTDEV to md device!
_BOOTDEV=$(pvs -o pv_name --noheading "${devpath}")
_RAID_ON_LVM=1
@ -288,7 +288,7 @@ _grub_bios() {
fi
#check if raid is used
_USE_RAID=""
if echo "${_BOOTDEV}" | grep -q /dev/md; then
if echo "${_BOOTDEV}" | rg -q '/dev/md'; then
_USE_RAID=1
fi
fi

View file

@ -31,7 +31,7 @@ _limine_bios() {
_limine_common
_common_bootloader_checks
_check_bootpart
if ! ${_LSBLK} FSTYPE "${_BOOTDEV}" 2>"${_NO_LOG}" | grep -q "vfat"; then
if ! ${_LSBLK} FSTYPE "${_BOOTDEV}" 2>"${_NO_LOG}" | rg -q 'vfat'; then
_dialog --title " ERROR " --no-mouse --infobox "LIMINE BIOS can only boot from vfat partition with /boot on it." 3 70
return 1
fi

View file

@ -46,7 +46,7 @@ _find_btrfs_subvolume() {
if [[ -z "${_DETECT_CREATE_FILESYSTEM}" ]]; then
# existing btrfs subvolumes
_mount_btrfs
for i in $(btrfs subvolume list "${_BTRFSMP}" | cut -d ' ' -f 9 | grep -v 'var/lib/machines' | grep -v 'var/lib/portables'); do
for i in $(btrfs subvolume list "${_BTRFSMP}" | cut -d ' ' -f 9 | rg -v 'var/lib/machines|var/lib/portables'); do
echo "${i}"
[[ "${1}" ]] && echo "${1}"
done
@ -70,7 +70,7 @@ _find_btrfs_bootloader_subvolume() {
_subvolumes_in_use() {
_SUBVOLUME_IN_USE=""
while read -r i; do
echo "${i}" | grep -q "|btrfs|" && _SUBVOLUME_IN_USE="${_SUBVOLUME_IN_USE} $(echo "${i}" | cut -d '|' -f 9)"
echo "${i}" | rg -q "\|btrfs\|" && _SUBVOLUME_IN_USE="${_SUBVOLUME_IN_USE} $(echo "${i}" | cut -d '|' -f 9)"
done < /tmp/.parts
}
@ -80,11 +80,11 @@ _check_btrfs_filesystem_creation() {
_SKIP_FILESYSTEM=""
#shellcheck disable=SC2013
for i in $(grep "${_DEV}[|#]" /tmp/.parts); do
if echo "${i}" | grep -q "|btrfs|"; then
if echo "${i}" | rg -q "\|btrfs\|"; then
_FSTYPE="btrfs"
_SKIP_FILESYSTEM=1
# check on filesystem creation, skip subvolume asking then!
echo "${i}" | cut -d '|' -f 4 | grep -q 1 && _DETECT_CREATE_FILESYSTEM=1
echo "${i}" | cut -d '|' -f 4 | rg -q 1 && _DETECT_CREATE_FILESYSTEM=1
fi
done
}
@ -136,7 +136,7 @@ _select_btrfsraid_devices () {
_BTRFS_DEVS=""
#shellcheck disable=SC2001,SC2086
for i in ${_DEVS}; do
echo "${i}" | grep -q /dev && _BTRFS_DEVS="${_BTRFS_DEVS} ${i} _ "
echo "${i}" | rg -q '/dev' && _BTRFS_DEVS="${_BTRFS_DEVS} ${i} _ "
done
_BTRFS_DEVS=${_BTRFS_DEVS//${_BTRFS_DEV} _/}
_RAIDNUMBER=2
@ -195,7 +195,7 @@ _check_btrfs_subvolume(){
if [[ -z "${_DETECT_CREATE_FILESYSTEM}" && -z "${_CREATE_MOUNTPOINTS}" ]]; then
_mount_btrfs
for i in $(btrfs subvolume list "${_BTRFSMP}" | cut -d ' ' -f 9); do
if echo "${i}" | grep -q "${_BTRFS_SUBVOLUME}"; then
if echo "${i}" | rg -q "${_BTRFS_SUBVOLUME}"; then
_dialog --title " ERROR " --no-mouse --infobox "You have defined 2 identical SUBVOLUMES! Please enter another name." 3 75
read -r -t 3
_BTRFS_SUBVOLUME=""
@ -205,7 +205,7 @@ _check_btrfs_subvolume(){
else
# existing subvolumes
_subvolumes_in_use
if echo "${_SUBVOLUME_IN_USE}" | grep -Eq "${_BTRFS_SUBVOLUME}"; then
if echo "${_SUBVOLUME_IN_USE}" | rg -q "${_BTRFS_SUBVOLUME}"; then
_dialog --title " ERROR " --no-mouse --infobox "You have defined 2 identical SUBVOLUMES! Please enter another name." 3 75
read -r -t 3
_BTRFS_SUBVOLUME=""
@ -216,7 +216,7 @@ _check_btrfs_subvolume(){
# create btrfs subvolume
_create_btrfs_subvolume() {
_mount_btrfs
if ! btrfs subvolume list "${_BTRFSMP}" | grep -q "${_BTRFS_SUBVOLUME}$"; then
if ! btrfs subvolume list "${_BTRFSMP}" | rg -q "${_BTRFS_SUBVOLUME}$"; then
btrfs subvolume create "${_BTRFSMP}"/"${_BTRFS_SUBVOLUME}" >"${_LOG}"
fi
_umount_btrfs