posix formatting with shfmt

This commit is contained in:
Dejan Kutle 2022-07-05 20:02:28 +02:00
parent 846d2fb7ad
commit e2eb921348
No known key found for this signature in database
GPG Key ID: 909D771047A9F6D8

View File

@ -57,14 +57,17 @@ usercheck() {
preinstallmsg() { preinstallmsg() {
whiptail --title "Let's get this party started!" --yes-button "Let's go!" \ whiptail --title "Let's get this party started!" --yes-button "Let's go!" \
--no-button "No, nevermind!" \ --no-button "No, nevermind!" \
--yesno "The rest of the installation will now be totally automated, so you can sit back and relax.\\n\\nIt will take some time, but when done, you can relax even more with your complete system.\\n\\nNow just press <Let's go!> and the system will begin installation!" 13 60 || { clear; exit 1; } --yesno "The rest of the installation will now be totally automated, so you can sit back and relax.\\n\\nIt will take some time, but when done, you can relax even more with your complete system.\\n\\nNow just press <Let's go!> and the system will begin installation!" 13 60 || {
clear
exit 1
}
} }
adduserandpass() { adduserandpass() {
# Adds user `$name` with password $pass1. # Adds user `$name` with password $pass1.
whiptail --infobox "Adding user \"$name\"..." 7 50 whiptail --infobox "Adding user \"$name\"..." 7 50
useradd -m -g wheel -s /bin/zsh "$name" >/dev/null 2>&1 \ useradd -m -g wheel -s /bin/zsh "$name" >/dev/null 2>&1 ||
|| usermod -a -G wheel "$name" && mkdir -p /home/"$name" && chown "$name":wheel /home/"$name" usermod -a -G wheel "$name" && mkdir -p /home/"$name" && chown "$name":wheel /home/"$name"
export repodir="/home/$name/.local/src" export repodir="/home/$name/.local/src"
mkdir -p "$repodir" mkdir -p "$repodir"
chown -R "$name":wheel "$(dirname "$repodir")" chown -R "$name":wheel "$(dirname "$repodir")"
@ -110,7 +113,10 @@ manualinstall() {
sudo -u "$name" mkdir -p "$repodir/$1" sudo -u "$name" mkdir -p "$repodir/$1"
sudo -u "$name" git -C "$repodir" clone --depth 1 --single-branch \ sudo -u "$name" git -C "$repodir" clone --depth 1 --single-branch \
--no-tags -q "https://aur.archlinux.org/$1.git" "$repodir/$1" || --no-tags -q "https://aur.archlinux.org/$1.git" "$repodir/$1" ||
{ cd "$repodir/$1" || return 1 ; sudo -u "$name" git pull --force origin master ;} {
cd "$repodir/$1" || return 1
sudo -u "$name" git pull --force origin master
}
cd "$repodir/$1" || exit 1 cd "$repodir/$1" || exit 1
sudo -u "$name" -D "$repodir/$1" \ sudo -u "$name" -D "$repodir/$1" \
makepkg --noconfirm -si >/dev/null 2>&1 || return 1 makepkg --noconfirm -si >/dev/null 2>&1 || return 1
@ -130,7 +136,10 @@ gitmakeinstall() {
--infobox "Installing \`$progname\` ($n of $total) via \`git\` and \`make\`. $(basename "$1") $2" 8 70 --infobox "Installing \`$progname\` ($n of $total) via \`git\` and \`make\`. $(basename "$1") $2" 8 70
sudo -u "$name" git -C "$repodir" clone --depth 1 --single-branch \ sudo -u "$name" git -C "$repodir" clone --depth 1 --single-branch \
--no-tags -q "$1" "$dir" || --no-tags -q "$1" "$dir" ||
{ cd "$dir" || return 1 ; sudo -u "$name" git pull --force origin master ;} {
cd "$dir" || return 1
sudo -u "$name" git pull --force origin master
}
cd "$dir" || exit 1 cd "$dir" || exit 1
make >/dev/null 2>&1 make >/dev/null 2>&1
make install >/dev/null 2>&1 make install >/dev/null 2>&1
@ -152,14 +161,14 @@ pipinstall() {
} }
installationloop() { installationloop() {
([ -f "$progsfile" ] && cp "$progsfile" /tmp/progs.csv) \ ([ -f "$progsfile" ] && cp "$progsfile" /tmp/progs.csv) ||
|| curl -Ls "$progsfile" | sed '/^#/d' > /tmp/progs.csv curl -Ls "$progsfile" | sed '/^#/d' >/tmp/progs.csv
total=$(wc -l </tmp/progs.csv) total=$(wc -l </tmp/progs.csv)
aurinstalled=$(pacman -Qqm) aurinstalled=$(pacman -Qqm)
while IFS=, read -r tag program comment; do while IFS=, read -r tag program comment; do
n=$((n + 1)) n=$((n + 1))
echo "$comment" | grep -q "^\".*\"$" \ echo "$comment" | grep -q "^\".*\"$" &&
&& comment="$(echo "$comment" | sed -E "s/(^\"|\"$)//g")" comment="$(echo "$comment" | sed -E "s/(^\"|\"$)//g")"
case "$tag" in case "$tag" in
"A") aurinstall "$program" "$comment" ;; "A") aurinstall "$program" "$comment" ;;
"G") gitmakeinstall "$program" "$comment" ;; "G") gitmakeinstall "$program" "$comment" ;;