mirror of
https://github.com/Snigdha-OS/snigdhaos-pkgbuilds.git
synced 2025-12-06 08:03:50 +01:00
131 lines
4.1 KiB
Bash
131 lines
4.1 KiB
Bash
#!/bin/bash
|
|
|
|
# Function to display a warning message
|
|
warn() {
|
|
tput setaf 3
|
|
echo "[WARNING] $1"
|
|
tput sgr0
|
|
}
|
|
|
|
# Function to display an informational message
|
|
info() {
|
|
tput setaf 2
|
|
echo "$1"
|
|
tput sgr0
|
|
}
|
|
|
|
# Function to display a success message
|
|
success() {
|
|
tput setaf 6
|
|
echo "$1"
|
|
tput sgr0
|
|
}
|
|
|
|
# Function to display an error message
|
|
error() {
|
|
tput setaf 1
|
|
echo "[ERROR] $1"
|
|
tput sgr0
|
|
}
|
|
|
|
# Function to check if a package is installed
|
|
package_installed() {
|
|
if pacman -Qi "$1" &> /dev/null; then
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# Function to handle package installation confirmation
|
|
confirm_package_installed() {
|
|
local package=$1
|
|
if package_installed "$package"; then
|
|
success "$package found!"
|
|
info "Bootloader is safe!"
|
|
else
|
|
error "$package not found!"
|
|
warn "Install the package for your safety!"
|
|
fi
|
|
}
|
|
|
|
# Function to handle post-install tasks
|
|
post_install() {
|
|
warn "If you are on Grub, please install the following package..."
|
|
info "sudo pacman -S snigdhaos-bootloader-grub"
|
|
warn "If you are using systemd-boot then install the following package..."
|
|
info "sudo pacman -S snigdhaos-bootloader-systemd"
|
|
|
|
bootloader=$(bootctl status | grep "Product" | awk '{print $2}')
|
|
|
|
if [ "$bootloader" = "systemd-boot" ]; then
|
|
info "systemd-bootloader found!"
|
|
info "Install the following package for your safety!"
|
|
info "sudo pacman -S snigdhaos-bootloader-systemd"
|
|
info "It has all the pacman-hooks which are essentials."
|
|
elif [ "$bootloader" = "GRUB" ]; then
|
|
info "GRUB bootloader found!"
|
|
info "Install the following package for your safety!"
|
|
info "sudo pacman -S snigdhaos-bootloader-grub"
|
|
info "It has all the pacman-hooks which are essentials."
|
|
fi
|
|
|
|
confirm_package_installed "snigdhaos-bootloader-grub"
|
|
confirm_package_installed "snigdhaos-bootloader-systemd"
|
|
|
|
if ! package_installed "snigdhaos-bootloader-systemd" && ! package_installed "snigdhaos-bootloader-grub"; then
|
|
error "snigdhaos-bootloader-systemd or snigdhaos-bootloader-grub not found!"
|
|
warn "Install the package for systemd or grub!"
|
|
fi
|
|
|
|
if systemctl --all --type service | grep -q "virtual-machine-check"; then
|
|
systemctl disable virtual-machine-check.service
|
|
fi
|
|
|
|
sh /usr/local/bin/snigdhaos-lsb-release
|
|
sh /usr/local/bin/snigdhaos-os-release
|
|
}
|
|
|
|
# Function to handle post-upgrade tasks
|
|
post_upgrade() {
|
|
warn "If you are on Grub, please install the following package..."
|
|
info "sudo pacman -S snigdhaos-bootloader-grub"
|
|
warn "If you are using systemd-boot then install the following package..."
|
|
info "sudo pacman -S snigdhaos-bootloader-systemd"
|
|
|
|
bootloader=$(bootctl status | grep "Product" | awk '{print $2}')
|
|
|
|
if [ "$bootloader" = "systemd-boot" ]; then
|
|
info "systemd-bootloader found!"
|
|
info "Install the following package for your safety!"
|
|
info "sudo pacman -S snigdhaos-bootloader-systemd"
|
|
info "It has all the pacman-hooks which are essentials."
|
|
elif [ "$bootloader" = "GRUB" ]; then
|
|
info "GRUB bootloader found!"
|
|
info "Install the following package for your safety!"
|
|
info "sudo pacman -S snigdhaos-bootloader-grub"
|
|
info "It has all the pacman-hooks which are essentials."
|
|
fi
|
|
|
|
confirm_package_installed "snigdhaos-bootloader-grub"
|
|
confirm_package_installed "snigdhaos-bootloader-systemd"
|
|
|
|
if ! package_installed "snigdhaos-bootloader-systemd" && ! package_installed "snigdhaos-bootloader-grub"; then
|
|
error "snigdhaos-bootloader-systemd or snigdhaos-bootloader-grub not found!"
|
|
warn "Install the package for systemd or grub!"
|
|
fi
|
|
|
|
if systemctl --all --type service | grep -q "virtual-machine-check"; then
|
|
systemctl disable virtual-machine-check.service
|
|
fi
|
|
|
|
sh /usr/local/bin/snigdhaos-lsb-release
|
|
sh /usr/local/bin/snigdhaos-os-release
|
|
}
|
|
|
|
# Function to handle pre-remove tasks
|
|
pre_remove() {
|
|
if systemctl --all --type service | grep -q "virtual-machine-check"; then
|
|
systemctl disable virtual-machine-check.service
|
|
fi
|
|
} |