dotfiles/.chezmoiscripts/run_onchange_fedora-install-pkgs.sh.tmpl
2024-03-03 21:41:52 +08:00

40 lines
1.3 KiB
Cheetah

{{- if (and (and (eq .chezmoi.os "linux")
(eq .chezmoi.osRelease.id "fedora"))
(eq .chezmoi.osRelease.versionID "39")) -}}
#!/bin/bash
# fedora39 packages hash: {{ .packages.fedora39 | quote | sha256sum }}
bold=$(tput bold)
normal=$(tput sgr0)
function custom_echo() {
echo -e "${bold}$1${normal}"
}
{{ if gt (len .packages.fedora39.dnf.pkgs) 0 -}}
# Install dnf packages
custom_echo "[Info] Installing dnf packages... Please input your password if requested."
sudo dnf install {{ range .packages.fedora39.dnf.pkgs }} {{- . | quote }} {{ end }}
{{- end }}
{{ if gt (len .packages.fedora39.brew.pkgs) 0 -}}
# Check if Homebrew is installed
if ! command -v brew &> /dev/null; then
custom_echo "[Info] Homebrew is not installed. Installing..."
# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Check if installation was successful
if ! command -v brew &> /dev/null; then
custom_echo "[Error] Failed to install Homebrew. Exiting."
exit 1
fi
custom_echo "[Success] Homebrew has been successfully installed."
else
custom_echo "[Info] Homebrew is already installed."
fi
# Install Homebrew packages
custom_echo "[Info] Installing homebrew packages..."
brew install {{ range .packages.fedora39.brew.pkgs }} {{- . | quote }} {{ end }}
{{- end }}
{{- end }}