2023-01-09 10:28:15 -08:00
|
|
|
{{- if eq .host.distro.family "linux" -}}
|
|
|
|
#!/usr/bin/env bash
|
2023-04-11 20:57:02 -07:00
|
|
|
# @file Linux Bloatware Removal
|
|
|
|
# @brief Removes Linux bloatware defined in `.removeLinuxPackages` of the `home/.chezmoidata.yaml` file
|
|
|
|
# @description
|
|
|
|
# This script removes some of the software deemed to be "bloatware" by cycling through the values defined in
|
|
|
|
# `.removeLinuxPackages` of the `home/.chezmoidata.yaml` file.
|
2023-01-09 10:28:15 -08:00
|
|
|
|
2023-01-24 20:36:59 -08:00
|
|
|
{{ includeTemplate "universal/profile-before" }}
|
|
|
|
{{ includeTemplate "universal/logg-before" }}
|
2023-01-09 10:43:01 -08:00
|
|
|
|
2023-01-09 11:20:36 -08:00
|
|
|
{{- $removePackages := join " " .removeLinuxPackages }}
|
2023-01-09 10:28:15 -08:00
|
|
|
|
|
|
|
### Remove bloatware packages defined in .chezmoidata.yaml
|
|
|
|
for PKG in {{ $removePackages }}; do
|
2023-01-09 10:43:01 -08:00
|
|
|
if command -v apk > /dev/null; then
|
2023-01-09 11:21:19 -08:00
|
|
|
if apk list "$PKG" | grep "$PKG" > /dev/null; then
|
2023-01-09 10:43:01 -08:00
|
|
|
sudo apk delete "$PKG"
|
|
|
|
fi
|
|
|
|
elif command -v apt-get > /dev/null; then
|
2023-01-24 03:33:42 -08:00
|
|
|
if dpkg -l "$PKG" | grep -E '^ii' > /dev/null; then
|
2023-01-09 10:28:15 -08:00
|
|
|
sudo apt-get remove -y "$PKG"
|
2023-01-09 10:43:01 -08:00
|
|
|
logg success 'Removed `'"$PKG"'` via apt-get'
|
2023-01-09 10:28:15 -08:00
|
|
|
fi
|
|
|
|
elif command -v dnf > /dev/null; then
|
2023-01-09 10:33:22 -08:00
|
|
|
if rpm -qa | grep "$PKG" > /dev/null; then
|
|
|
|
sudo dnf remove -y "$PKG"
|
2023-01-09 10:43:01 -08:00
|
|
|
logg success 'Removed `'"$PKG"'` via dnf'
|
2023-01-09 10:33:22 -08:00
|
|
|
fi
|
2023-01-09 10:28:15 -08:00
|
|
|
elif command -v yum > /dev/null; then
|
2023-01-09 10:33:22 -08:00
|
|
|
if rpm -qa | grep "$PKG" > /dev/null; then
|
|
|
|
sudo yum remove -y "$PKG"
|
2023-01-09 10:43:01 -08:00
|
|
|
logg success 'Removed `'"$PKG"'` via yum'
|
2023-01-09 10:33:22 -08:00
|
|
|
fi
|
2023-01-09 10:28:15 -08:00
|
|
|
elif command -v pacman > /dev/null; then
|
|
|
|
if pacman -Qs "$PKG" > /dev/null; then
|
|
|
|
sudo pacman -R "$PKG"
|
2023-01-09 10:43:01 -08:00
|
|
|
logg success 'Removed `'"$PKG"'` via pacman'
|
2023-01-09 10:28:15 -08:00
|
|
|
fi
|
2023-01-09 10:33:22 -08:00
|
|
|
elif command -v zypper > /dev/null; then
|
|
|
|
if rpm -qa | grep "$PKG" > /dev/null; then
|
|
|
|
sudo zypper remove -y "$PKG"
|
2023-01-09 10:43:01 -08:00
|
|
|
logg success 'Removed `'"$PKG"'` via zypper'
|
2023-01-09 10:33:22 -08:00
|
|
|
fi
|
2023-01-09 10:28:15 -08:00
|
|
|
fi
|
2023-01-09 10:33:22 -08:00
|
|
|
done
|
|
|
|
|
|
|
|
{{- end }}
|