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 ===
|
||||
|
||||
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
|
||||
"darwin"* ) DISTRO="apple" ;;
|
||||
* ) DISTRO="$(cat /etc/*-release | grep ^ID | head -n1 | cut -d '=' -f2 | cut -d '"' -f2)" ;;
|
||||
esac
|
||||
[ "$SUDO" = "" ] && { [ $(is_package_exists doas) = 1 ] && SUDO="doas" || SUDO="sudo"; }
|
||||
[ "$SUDO" = "" ] && { is_package_exists doas && SUDO="doas" || SUDO="sudo"; }
|
||||
[ "$PACMAN" = "" ] && {
|
||||
case $DISTRO in
|
||||
"arch" ) PACMAN="pacman" ;;
|
||||
|
@ -71,14 +71,14 @@ install_aur_package() {
|
|||
# >> Paranoia checks
|
||||
[ $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; }
|
||||
# <<
|
||||
|
||||
case "$AUR" in
|
||||
"paru" ) $AUR -S --noconfirm --skipreview "$@"
|
||||
* ) $AUR -S --noconfirm "$@"
|
||||
"paru" ) $AUR -S --noconfirm --skipreview "$@" ;;
|
||||
* ) $AUR -S --noconfirm "$@" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -112,13 +112,15 @@ $SUDO $ZI_DOTFILES/zsh-xdg-setup
|
|||
echo "Installing zsh config..."
|
||||
ln -si $ZI_DOTFILES/.config/zsh $HOME/.config/zsh
|
||||
|
||||
is_package_exists doas && {
|
||||
echo "Configuring doas..."
|
||||
echo """permit persist :wheel
|
||||
permit nopass root as root""" > /tmp/doas.conf.tmp
|
||||
echo "permit persist :wheel" > /tmp/doas.conf.tmp
|
||||
echo "permit nopass root as root" >> /tmp/doas.conf.tmp
|
||||
echo "=======/etc/doas.conf======="
|
||||
cat /tmp/doas.conf.tmp
|
||||
echo "============================"
|
||||
$SUDO cp -i /tmp/doas.conf.tmp /etc/doas.conf
|
||||
}
|
||||
|
||||
echo "============================"
|
||||
echo "Bootstrap completed, please restart your shell!"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue