fix(script/bootstrap): Fix some error
* Missing ;; in case statement * Should only configure doas if doas is installed * Refactor is_package_exists function to use return
This commit is contained in:
parent
6f569742b5
commit
0349769225
1 changed files with 15 additions and 13 deletions
16
bootstrap
16
bootstrap
|
@ -25,14 +25,14 @@
|
||||||
# === Function and Variable ===
|
# === Function and Variable ===
|
||||||
|
|
||||||
is_package_exists() {
|
is_package_exists() {
|
||||||
[ $(command -v "$1" | wc -l) -gt 0 ] && echo 1 || echo 0
|
[ $(command -v "$1" | wc -l) -gt 0 ] && return 0 || return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$OSTYPE" in
|
case "$OSTYPE" in
|
||||||
"darwin"* ) DISTRO="apple" ;;
|
"darwin"* ) DISTRO="apple" ;;
|
||||||
* ) DISTRO="$(cat /etc/*-release | grep ^ID | head -n1 | cut -d '=' -f2 | cut -d '"' -f2)" ;;
|
* ) DISTRO="$(cat /etc/*-release | grep ^ID | head -n1 | cut -d '=' -f2 | cut -d '"' -f2)" ;;
|
||||||
esac
|
esac
|
||||||
[ "$SUDO" = "" ] && { [ $(is_package_exists doas) = 1 ] && SUDO="doas" || SUDO="sudo"; }
|
[ "$SUDO" = "" ] && { is_package_exists doas && SUDO="doas" || SUDO="sudo"; }
|
||||||
[ "$PACMAN" = "" ] && {
|
[ "$PACMAN" = "" ] && {
|
||||||
case $DISTRO in
|
case $DISTRO in
|
||||||
"arch" ) PACMAN="pacman" ;;
|
"arch" ) PACMAN="pacman" ;;
|
||||||
|
@ -71,14 +71,14 @@ install_aur_package() {
|
||||||
# >> Paranoia checks
|
# >> Paranoia checks
|
||||||
[ $DISTRO = "arch" ] || { echo "AUR only available in Arch, skipping..."; return; }
|
[ $DISTRO = "arch" ] || { echo "AUR only available in Arch, skipping..."; return; }
|
||||||
|
|
||||||
[ $(is_package_exists $AUR) = 1 ] || { echo "AUR helper '$AUR' is not installed, skipping..."; return; }
|
is_package_exists $AUR || { echo "AUR helper '$AUR' is not installed, skipping..."; return; }
|
||||||
|
|
||||||
[ "$1" = "" ] && { echo "No AUR package candidate is specified, skipping..."; return; }
|
[ "$1" = "" ] && { echo "No AUR package candidate is specified, skipping..."; return; }
|
||||||
# <<
|
# <<
|
||||||
|
|
||||||
case "$AUR" in
|
case "$AUR" in
|
||||||
"paru" ) $AUR -S --noconfirm --skipreview "$@"
|
"paru" ) $AUR -S --noconfirm --skipreview "$@" ;;
|
||||||
* ) $AUR -S --noconfirm "$@"
|
* ) $AUR -S --noconfirm "$@" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,13 +112,15 @@ $SUDO $ZI_DOTFILES/zsh-xdg-setup
|
||||||
echo "Installing zsh config..."
|
echo "Installing zsh config..."
|
||||||
ln -si $ZI_DOTFILES/.config/zsh $HOME/.config/zsh
|
ln -si $ZI_DOTFILES/.config/zsh $HOME/.config/zsh
|
||||||
|
|
||||||
|
is_package_exists doas && {
|
||||||
echo "Configuring doas..."
|
echo "Configuring doas..."
|
||||||
echo """permit persist :wheel
|
echo "permit persist :wheel" > /tmp/doas.conf.tmp
|
||||||
permit nopass root as root""" > /tmp/doas.conf.tmp
|
echo "permit nopass root as root" >> /tmp/doas.conf.tmp
|
||||||
echo "=======/etc/doas.conf======="
|
echo "=======/etc/doas.conf======="
|
||||||
cat /tmp/doas.conf.tmp
|
cat /tmp/doas.conf.tmp
|
||||||
echo "============================"
|
echo "============================"
|
||||||
$SUDO cp -i /tmp/doas.conf.tmp /etc/doas.conf
|
$SUDO cp -i /tmp/doas.conf.tmp /etc/doas.conf
|
||||||
|
}
|
||||||
|
|
||||||
echo "============================"
|
echo "============================"
|
||||||
echo "Bootstrap completed, please restart your shell!"
|
echo "Bootstrap completed, please restart your shell!"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue