diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 3eb52c7e..86a70947 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,3 +1,3 @@ # https://help.github.com/articles/about-codeowners/ -* @eshanized @iconized \ No newline at end of file +* @eshanized @iconized @d3v1l0n \ No newline at end of file diff --git a/snigdhaos-assistant/PKGBUILD b/snigdhaos-assistant/PKGBUILD index a0cf23a1..bea6cee1 100644 --- a/snigdhaos-assistant/PKGBUILD +++ b/snigdhaos-assistant/PKGBUILD @@ -1,14 +1,15 @@ # Maintainer: Eshan Roy +# Contributor: d3v1l0n pkgname=snigdhaos-assistant pkgver=r251.f2df36f4 -_pkgver=a1.0.0 +_pkgver=$(curl -s https://api.github.com/repos/Snigdha-OS/snigdhaos-assistant/releases/latest | jq -r .tag_name) pkgrel=1 pkgdesc="A setup utility for Snigdha OS which helps setting up & installing applications" arch=('any') url="https://gitlab.com/snigdhaos/snigdhaos-assistant/" license=('MIT') -depends=('yad' 'wget' 'qt5-base') +depends=('yad' 'wget' 'qt5-base' 'curl' 'jq') optdepends=('pamac') makedepends=('git' 'cmake') groups=() @@ -16,8 +17,8 @@ source=("https://github.com/Snigdha-OS/${pkgname}/archive/refs/tags/${_pkgver}.t sha256sums=('SKIP') pkgver() { - # cd "$srcdir/$pkgname" || exit - printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" + # Print package version as 'rX.XXXX' + printf "%s" "${_pkgver#v}" } build() { diff --git a/snigdhaos-libs/PKGBUILD b/snigdhaos-libs/PKGBUILD index 9932413e..7b849ba9 100644 --- a/snigdhaos-libs/PKGBUILD +++ b/snigdhaos-libs/PKGBUILD @@ -1,4 +1,5 @@ # Maintainer: Eshan Roy +# Contributor: d3v1l0n pkgname=snigdhaos-libs org=Snigdha-OS @@ -10,7 +11,7 @@ license=('MIT') depends=( 'libnotify' 'expect' - ) +) source=( "exec-termianl" "snigdhaos.shlib" @@ -18,14 +19,15 @@ source=( "install-package" "org.snigdhaos.libs.pkexec.policy" "pkexec-gui" - ) +) sha256sums=( 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' - ) +) + pkgver(){ printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" } diff --git a/snigdhaos-libs/check-snapshot-boot b/snigdhaos-libs/check-snapshot-boot index e52e3efa..b55aadd0 100755 --- a/snigdhaos-libs/check-snapshot-boot +++ b/snigdhaos-libs/check-snapshot-boot @@ -1,6 +1,14 @@ #!/bin/bash -if grep -qE 'subvol=@/.snapshots/[0-9]+/snapshot' /proc/cmdline; then - exit 0 +if [[ -f /proc/cmdline ]]; then + if grep -qE 'subvol=@/.snapshots/[0-9]+/snapshot' /proc/cmdline; then + echo "Booting from a Btrfs snapshot." + exit 0 + else + echo "Not booting from a Btrfs snapshot." + exit 1 + fi +else + echo "/proc/cmdline not found." + exit 2 fi -exit 1 diff --git a/snigdhaos-libs/org.snigdhaos.libs.pkexec.policy b/snigdhaos-libs/org.snigdhaos.libs.pkexec.policy index 1fddba5a..d5084d63 100644 --- a/snigdhaos-libs/org.snigdhaos.libs.pkexec.policy +++ b/snigdhaos-libs/org.snigdhaos.libs.pkexec.policy @@ -7,9 +7,9 @@ https://snigdhaos.org - Install software with pacman - Authentication is required to install software. - snigdha-os + Install software using the pacman package manager + Authentication is required to install software with pacman. + snigdhaos-pacman no no @@ -18,9 +18,11 @@ /usr/lib/snigdhaos/install-package true + - Run GUI program as root - Authentication is required to run a GUI program as root. + Run a graphical program as root + Authentication is required to run a graphical program with elevated privileges. + gnome-session no no diff --git a/snigdhaos-libs/pkexec-gui b/snigdhaos-libs/pkexec-gui index 8f4b9149..c02d8340 100755 --- a/snigdhaos-libs/pkexec-gui +++ b/snigdhaos-libs/pkexec-gui @@ -7,21 +7,25 @@ if ! command -v pkexec &>/dev/null; then fi # Check if running as root -if [ $EUID -ne 0 ]; then +if [[ $EUID -ne 0 ]]; then + # Attempt to execute the script as root via pkexec exec pkexec /usr/lib/snigdhaos/pkexec-gui "$@" exit 1 fi -# Need some previous vars +# Shellcheck disable: Read environment variables from parent process # shellcheck disable=SC2163 -while IFS= read -rd '' var; do export "$var"; done < <(grep --null-data -ae "^\($XDG_CURRENT_DESKTOP\|WAYLAND_DISPLAY\|XDG_RUNTIME_DIR\|XDG_SESSION_TYPE\|XCURSOR_SIZE\|LC_*\|LANG\|LANGUAGE\|QT_WAYLAND_FORCE_DPI\|QT_QPA_PLATFORMTHEME\|QT_STYLE-OVERRIDE\|\)=.*\$" /proc/$PPID/environ) +# Read the necessary environment variables from the parent process +while IFS= read -rd '' var; do + export "$var" +done < <(grep --null-data -ae "^\($XDG_CURRENT_DESKTOP\|WAYLAND_DISPLAY\|XDG_RUNTIME_DIR\|XDG_SESSION_TYPE\|XCURSOR_SIZE\|LC_*\|LANG\|LANGUAGE\|QT_WAYLAND_FORCE_DPI\|QT_QPA_PLATFORMTHEME\|QT_STYLE-OVERRIDE\|\)=.*\$" /proc/$PPID/environ) -# If on Wayland, adjust WAYLAND_DISPLAY variable -if [[ -v WAYLAND_DISPLAY ]]; then +# Adjust WAYLAND_DISPLAY if running on Wayland +if [[ -n "$WAYLAND_DISPLAY" ]]; then export WAYLAND_DISPLAY="$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" fi -# Set root's runtime directory +# Set the root user's XDG_RUNTIME_DIR export XDG_RUNTIME_DIR="/run/user/0" # Execute the provided command with root privileges diff --git a/snigdhaos-libs/snigdhaos.shlib b/snigdhaos-libs/snigdhaos.shlib index 1fa20413..8fdc2a9a 100755 --- a/snigdhaos-libs/snigdhaos.shlib +++ b/snigdhaos-libs/snigdhaos.shlib @@ -2,14 +2,29 @@ snigdhaoslib_add_update_notice() { # Ensure the directory exists - mkdir -p /var/lib/snigdhaos/tmp + if ! mkdir -p /var/lib/snigdhaos/tmp; then + echo "Error: Failed to create directory /var/lib/snigdhaos/tmp" >&2 + return 1 + fi # Get the current date current_date=$(date +%F) - - # Replace multiple spaces with a single space in the input string + + # Ensure the input message is not empty + if [ -z "$1" ]; then + echo "Error: No update message provided." >&2 + return 1 + fi + + # Replace multiple spaces with a single space message="${1//[[:space:]]+/ }" # Append the message to the file with the current date - echo "$current_date $message" >> /var/lib/snigdhaos/tmp/update_notices + if ! printf "%s %s\n" "$current_date" "$message" >> /var/lib/snigdhaos/tmp/update_notices; then + echo "Error: Failed to write to /var/lib/snigdhaos/tmp/update_notices" >&2 + return 1 + fi + + # Optionally, display a success message (for debugging/logging purposes) + echo "Update notice successfully added for $current_date." } diff --git a/snigdhaos-lsb-release/PKGBUILD b/snigdhaos-lsb-release/PKGBUILD new file mode 100644 index 00000000..150f4fab --- /dev/null +++ b/snigdhaos-lsb-release/PKGBUILD @@ -0,0 +1,37 @@ +# Maintainer : RiO + +pkgname=snigdhaos-lsb-release +pkgver=2.0.r55.a25a4fc +_commit=a25a4fcd73c79bd5af0dd8d948a7c96dcbfd2d07 +pkgrel=1 +pkgdesc='LSB version query program for Snigdha OS' +arch=('any') +url='https://refspecs.linuxfoundation.org/lsb.shtml' +license=('GPL-2.0-or-later') +depends=('sh') +makedepends=('git') +source=("git+https://github.com/LinuxStandardBase/lsb-samples.git#commit=${_commit}" + 'lsb-release' + 'lsb_release_make_man_page_reproducible.patch') +sha256sums=('SKIP' + 'SKIP' + 'SKIP') + +pkgver() { + cd lsb-samples/lsb_release/src + printf '%s.r%s.%s' "$(grep -Po 'SCRIPTVERSION="\K[^"]*' lsb_release)" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" +} + +prepare() { + patch -d lsb-samples/lsb_release/src -Np1 -i "${srcdir}/lsb_release_make_man_page_reproducible.patch" +} + +build() { + make -C lsb-samples/lsb_release/src +} + +package() { + install -D -m755 lsb-samples/lsb_release/src/lsb_release -t "${pkgdir}/usr/bin" + install -D -m644 lsb-samples/lsb_release/src/lsb_release.1.gz -t "${pkgdir}/usr/share/man/man1" + install -D -m644 lsb-release -t "${pkgdir}/etc" +} diff --git a/snigdhaos-lsb-release/lsb-release b/snigdhaos-lsb-release/lsb-release new file mode 100644 index 00000000..f4a7f0df --- /dev/null +++ b/snigdhaos-lsb-release/lsb-release @@ -0,0 +1,3 @@ +DISTRIB_ID="Arch" +DISTRIB_RELEASE="rolling" +DISTRIB_DESCRIPTION="Snigdha OS" diff --git a/snigdhaos-lsb-release/lsb_release_make_man_page_reproducible.patch b/snigdhaos-lsb-release/lsb_release_make_man_page_reproducible.patch new file mode 100644 index 00000000..db4801c1 --- /dev/null +++ b/snigdhaos-lsb-release/lsb_release_make_man_page_reproducible.patch @@ -0,0 +1,34 @@ +From 1f5eb29ad59e7302e0407855333fbf1377f6f127 Mon Sep 17 00:00:00 2001 +From: Jonas Witschel +Date: Sat, 11 Jul 2020 17:02:59 +0200 +Subject: [PATCH] Make man page reproducible + +Respect SOURCE_DATE_EPOCH and remove the embedded timestamp from the gzipped +man page. +--- + Makefile | 2 +- + help2man | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +--- a/Makefile ++++ b/Makefile +@@ -22,7 +22,7 @@ man: lsb_release.1.gz + + lsb_release.1.gz: lsb_release + @./help2man -N --include ./lsb_release.examples --alt_version_key=program_version ./lsb_release >lsb_release.1 +- @gzip -9f lsb_release.1 ++ @gzip -9f -n lsb_release.1 + + install: all + install -D -m 644 lsb_release.1.gz ${mandir}/man1/lsb_release.1.gz +--- a/help2man ++++ b/help2man +@@ -173,7 +173,7 @@ my ($help_text, $version_text) = map { + or die "$this_program: can't get `--$_' info from $ARGV[0]\n" + } qw(help), $opt_version_key; + +-my $date = strftime "%B %Y", localtime; ++my $date = strftime "%B %Y", gmtime($ENV{SOURCE_DATE_EPOCH} || time); + (my $program = $ARGV[0]) =~ s!.*/!!; + my $package = $program; + my $version; diff --git a/snigdhaos-powershell/PKGBUILD b/snigdhaos-powershell/PKGBUILD index 4d4d912b..ce74e6c4 100644 --- a/snigdhaos-powershell/PKGBUILD +++ b/snigdhaos-powershell/PKGBUILD @@ -1,33 +1,25 @@ # Maintainer: Eshan Roy +# Contributor: d3v1l0n pkgname=snigdhaos-powershell org="Snigdha-OS" branch="master" -pkgver=r75.ba4f5f5 +pkgver=r$(git rev-list --count HEAD).$(git rev-parse --short HEAD) pkgrel=1 -pkgdesc="Snigdha OS PowerShell Config!" +pkgdesc="Snigdha OS PowerShell Config" arch=('any') license=('MIT') -depends=( - 'powershell-bin' -) +depends=('powershell-bin') source=( "$pkgname.tar.xz" "${pkgname}.desktop" ) -sha256sums=( - 'SKIP' - ) +sha256sums=('SKIP' 'SKIP') install=$pkgname.install -pkgver(){ - printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" -} - -package(){ - mkdir -p "${pkgdir}/etc/skel" - cp -rf "${srcdir}/etc/skel/.config" "${pkgdir}/etc/skel/" - - # rm "${pkgdir}/usr/share/applications/snigdhaos-powershell.desktop" - # install -Dm644 "${pkgname}.desktop" "${pkgdir}/usr/share/applications/${pkgname}.desktop" +package() { + mkdir -p "${pkgdir}/etc/skel/.config" + cp -r "${srcdir}/etc/skel/.config"/* "${pkgdir}/etc/skel/.config/" + + install -Dm644 "${srcdir}/${pkgname}.desktop" "${pkgdir}/usr/share/applications/${pkgname}.desktop" } diff --git a/snigdhaos-powershell/etc/skel/.config/powershell/Microsoft.PowerShell_profile.ps1 b/snigdhaos-powershell/etc/skel/.config/powershell/Microsoft.PowerShell_profile.ps1 index f644291a..e631a4db 100755 --- a/snigdhaos-powershell/etc/skel/.config/powershell/Microsoft.PowerShell_profile.ps1 +++ b/snigdhaos-powershell/etc/skel/.config/powershell/Microsoft.PowerShell_profile.ps1 @@ -1,6 +1,15 @@ $Host.UI.RawUI.WindowTitle = "SNIGDHA OS > PowerShellπŸ”₯" -function prompt() -{ - $ESC=$([char]27) - "$ESC[0;36mβ”Œβ”€β”€I'm $(whoami)➜ $ESC[0;31m$($executionContext.SessionState.Path.CurrentLocation)$("`r`n$ESC[0;36m└──eshanized PowerShellπŸ”₯>$ESC[00m" * ($nestedPromptLevel + 1)) "; + +function prompt { + $ESC = [char]27 + $user = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name + $currentLocation = $executionContext.SessionState.Path.CurrentLocation + $gitBranch = "" + if (Test-Path .git -or (Get-Command git -ErrorAction SilentlyContinue)) { + $gitBranch = $(git rev-parse --abbrev-ref HEAD 2>$null) + if ($gitBranch) { + $gitBranch = " ($gitBranch)" + } + } + "$ESC[0;36mβ”Œβ”€β”€ $user $gitBranch ➜ $ESC[0;31m$currentLocation$($([char]13))`n$ESC[0;36m└── 🌟 SnigdhaOS PowerShell πŸ”₯ > $ESC[00m" } diff --git a/snigdhaos-powershell/snigdhaos-powershell.desktop b/snigdhaos-powershell/snigdhaos-powershell.desktop new file mode 100644 index 00000000..c23fcb6a --- /dev/null +++ b/snigdhaos-powershell/snigdhaos-powershell.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Version=1.0 +Name=Snigdha OS PowerShell +Comment=PowerShell Configuration for Snigdha OS +Exec=pwsh -NoExit -Command "& {if (Test-Path '$HOME/.config/powershell/Microsoft.PowerShell_profile.ps1') { . '$HOME/.config/powershell/Microsoft.PowerShell_profile.ps1' } }" +Icon=/usr/share/pixmaps/snigdhaos-powershell.png +Terminal=true +Type=Application +Categories=Utility;System;Development; +StartupNotify=true diff --git a/snigdhaos-system-config/snigdhaos-system-config.install b/snigdhaos-system-config/snigdhaos-system-config.install index 72e2d33f..2182e8f6 100644 --- a/snigdhaos-system-config/snigdhaos-system-config.install +++ b/snigdhaos-system-config/snigdhaos-system-config.install @@ -1,160 +1,130 @@ -post_install(){ - tput setaf 3; - echo - echo "[WARNING] WARNING!" - echo - echo "If you are on Grub, please install the following package..." - echo "sudo pacman -S snigdhaos-bootloader-grub" - echo - echo "If you are using systemd-boot then isntall the following package..." - echo "sudo pacman -S snigdhaos-bootloader-systemd" - echo - echo "[WARNING] WARNING!" - echo - tput setaf 2; +#!/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 - echo - echo "systemd-bootloader found!" - echo "Install the following package for your safety!" - echo - echo "sudo pacman -S snigdhaos-bootloader-systemd" - echo "It has all the pacman-hooks which are essentials." - echo - elif [ $bootloader = "GRUB" ]; then - echo - echo "GRUB bootloader found!" - echo "Install the following package for your safety!" - echo - echo "sudo pacman -S snigdhaos-bootloader-grub" - echo "It has all the pacman-hooks which are essentials." - echo + 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 - tput sgr0 - # Confirmation for package installation - package_installed(){ - if pacman -Qi "$1" &> /dev/null; then - return 0 - else - return 1 - fi - } + confirm_package_installed "snigdhaos-bootloader-grub" + confirm_package_installed "snigdhaos-bootloader-systemd" - tput setaf 6; - if package_installed snigdhaos-bootloader-grub; then - echo - echo "snigdhaos-bootloader-grub found!" - echo "Bootloader is safe!" - echo + 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 - tput sgr0 - - tput setaf 6; - if package_installed snigdhaos-bootloader-systemd; then - echo - echo "snigdhaos-bootloader-systemd found!" - echo "Bootloader is safe!" - echo - fi - tput sgr0 - - tput setaf 1; - if ! package_installed snigdhaos-bootloader-systemd && ! package_installed snigdhaos-bootloader-grub; then - echo - echo "snigdhaos-bootloader-systemd or snigdhaos-bootloader-grub not found!" - echo "[WARNING] WARNING!" - echo "Install the package for systemd or grub!" - echo - fi - tput sgr0 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 } -post_upgrade(){ - tput setaf 3; - echo - echo "[WARNING] WARNING!" - echo - echo "If you are on Grub, please install the following package..." - echo "sudo pacman -S snigdhaos-bootloader-grub" - echo - echo "If you are using systemd-boot then isntall the following package..." - echo "sudo pacman -S snigdhaos-bootloader-systemd" - echo - echo "[WARNING] WARNING!" - echo - tput setaf 2; +# 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 - echo - echo "systemd-bootloader found!" - echo "Install the following package for your safety!" - echo - echo "sudo pacman -S snigdhaos-bootloader-systemd" - echo "It has all the pacman-hooks which are essentials." - echo - elif [ $bootloader = "GRUB" ]; then - echo - echo "GRUB bootloader found!" - echo "Install the following package for your safety!" - echo - echo "sudo pacman -S snigdhaos-bootloader-grub" - echo "It has all the pacman-hooks which are essentials." - echo + 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 - tput sgr0 - # Confirmation for package installation - package_installed(){ - if pacman -Qi "$1" &> /dev/null; then - return 0 - else - return 1 - fi - } + confirm_package_installed "snigdhaos-bootloader-grub" + confirm_package_installed "snigdhaos-bootloader-systemd" - tput setaf 6; - if package_installed snigdhaos-bootloader-grub; then - echo - echo "snigdhaos-bootloader-grub found!" - echo "Bootloader is safe!" - echo + 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 - tput sgr0 - - tput setaf 6; - if package_installed snigdhaos-bootloader-systemd; then - echo - echo "snigdhaos-bootloader-systemd found!" - echo "Bootloader is safe!" - echo - fi - tput sgr0 - - tput setaf 1; - if ! package_installed snigdhaos-bootloader-systemd && ! package_installed snigdhaos-bootloader-grub; then - echo - echo "snigdhaos-bootloader-systemd or snigdhaos-bootloader-grub not found!" - echo "[WARNING] WARNING!" - echo "Install the package for systemd or grub!" - echo - fi - tput sgr0 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 } -pre_remove(){ +# 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 diff --git a/snigdhaos-system-installation/PKGBUILD b/snigdhaos-system-installation/PKGBUILD index 651ec9d8..4b28b5c6 100644 --- a/snigdhaos-system-installation/PKGBUILD +++ b/snigdhaos-system-installation/PKGBUILD @@ -1,4 +1,5 @@ # Maintainer: Eshan Roy +# Contributor: [Contributor Name] <[Contributor Email]> pkgname=snigdhaos-system-installation org=Snigdha-OS @@ -22,8 +23,8 @@ sha256sums=('SKIP') install="${pkgname}.install" pkgver() { - # cd "$srcdir/$pkgname" - printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" + # cd "$srcdir/$pkgname" + printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" } package() { @@ -38,4 +39,4 @@ package() { install -dm755 "$pkgdir$_destname3" cp -r "$srcdir/$pkgname/$_destname3/"* "$pkgdir/$_destname3" -} \ No newline at end of file +} diff --git a/snigdhaos-system-installation/snigdhaos-system-installation.install b/snigdhaos-system-installation/snigdhaos-system-installation.install index c70c9729..dc451f10 100644 --- a/snigdhaos-system-installation/snigdhaos-system-installation.install +++ b/snigdhaos-system-installation/snigdhaos-system-installation.install @@ -1,14 +1,71 @@ +# 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 handle enabling/disabling a service +manage_service() { + local service=$1 + local action=$2 + + if systemctl $action $service; then + success "Service $service ${action}d successfully." + else + error "Failed to ${action} service $service." + fi +} + +# Function to handle starting/stopping a service +manage_service_start() { + local service=$1 + local action=$2 + + if systemctl $action $service; then + success "Service $service ${action}ed successfully." + else + error "Failed to ${action} service $service." + fi +} + +# Function to handle post-install tasks post_install() { - systemctl enable snigdhaos-graphical-target.service - systemctl start snigdhaos-graphical-target.service + info "Enabling and starting snigdhaos-graphical-target.service..." + manage_service "snigdhaos-graphical-target.service" "enable" + manage_service_start "snigdhaos-graphical-target.service" "start" } +# Function to handle post-upgrade tasks post_upgrade() { - systemctl enable snigdhaos-graphical-target.service - systemctl start snigdhaos-graphical-target.service + info "Enabling and starting snigdhaos-graphical-target.service..." + manage_service "snigdhaos-graphical-target.service" "enable" + manage_service_start "snigdhaos-graphical-target.service" "start" } +# Function to handle pre-remove tasks pre_remove() { - systemctl disable snigdhaos-graphical-target.service + info "Disabling snigdhaos-graphical-target.service..." + manage_service "snigdhaos-graphical-target.service" "disable" } \ No newline at end of file diff --git a/snigdhaos-tabliss-config/snigdhaos-tabliss-config.install b/snigdhaos-tabliss-config/snigdhaos-tabliss-config.install index 0d68e32a..041c52d3 100644 --- a/snigdhaos-tabliss-config/snigdhaos-tabliss-config.install +++ b/snigdhaos-tabliss-config/snigdhaos-tabliss-config.install @@ -1,7 +1,28 @@ -post_install() { - echo -e "\n** The files have been installed in /usr/share/tabliss/tabliss.json **\n" +# Function to display a success message +success() { + tput setaf 6 + echo "$1" + tput sgr0 } +# Function to display an informational message +info() { + tput setaf 2 + echo "$1" + tput sgr0 +} + +# Function to handle post-install tasks +post_install() { + info "The files have been installed in /usr/share/tabliss/tabliss.json" +} + +# Function to handle post-upgrade tasks post_upgrade() { post_install +} + +# Function to handle pre-remove tasks +pre_remove() { + info "Preparing to remove the files from /usr/share/tabliss/tabliss.json" } \ No newline at end of file diff --git a/snigdhaos-utils/snigdhaos-fastest-mirror.sh b/snigdhaos-utils/snigdhaos-fastest-mirror.sh new file mode 100755 index 00000000..648441ae --- /dev/null +++ b/snigdhaos-utils/snigdhaos-fastest-mirror.sh @@ -0,0 +1,146 @@ +#!/bin/bash + +# Define color codes +RESET='\033[0m' +BOLD='\033[1m' +RED='\033[31m' +GREEN='\033[32m' +YELLOW='\033[33m' +BLUE='\033[34m' + +# Define the mirror list files +ARCH_MIRROR_LIST="/etc/pacman.d/mirrorlist" +BLACKARCH_MIRROR_LIST="/etc/pacman.d/blackarch-mirrorlist" +CHAOTIC_AUR_MIRROR_LIST="/etc/pacman.d/chaotic-mirrorlist" + +# Define a backup directory for safety +BACKUP_DIR="/tmp/backup_mirrorlists_$(date +%Y%m%d_%H%M%S)" + +# Error handling function +error_exit() { + echo -e "${RED}ERROR: $1${RESET}" >&2 + exit 1 +} + +# Create backup directory safely +mkdir -p "$BACKUP_DIR" || error_exit "Failed to create backup directory" + +# Function to check if rankmirrors is installed +check_rankmirrors_installed() { + if ! command -v rankmirrors &> /dev/null; then + echo -e "${RED}rankmirrors is not installed.${RESET}" + read -p "Would you like to install rankmirrors now? (y/n): " choice + if [[ "$choice" =~ ^[yY]$ ]]; then + echo -e "${BLUE}Installing rankmirrors...${RESET}" + sudo pacman -S --noconfirm pacman-contrib || error_exit "Failed to install rankmirrors" + echo -e "${GREEN}rankmirrors installed successfully!${RESET}" + else + error_exit "rankmirrors is required to proceed." + fi + fi +} + +# Function to auto-detect the country based on the system's timezone +get_country_from_timezone() { + local timezone + # Try multiple methods to get timezone + timezone=$(timedatectl show --property=Timezone --value 2>/dev/null) || + timezone=$(cat /etc/timezone 2>/dev/null) || + timezone=$(readlink -f /etc/localtime 2>/dev/null) + + # Extract country from timezone + local country + country=$(echo "$timezone" | sed -E 's:.*/([^/]+):\1:' | cut -d'_' -f1) + + # Fallback to default if country can't be determined + if [[ -z "$country" || "$country" == "Etc" || "$country" == "GMT" ]]; then + country="United States" + fi + + echo "$country" +} + +# Main script execution +main() { + # Get the country based on the system's timezone + local country + country=$(get_country_from_timezone) + echo -e "${BLUE}Detected country based on timezone: ${GREEN}$country${RESET}" + + # Check for root/sudo permissions + if [[ $EUID -eq 0 ]]; then + error_exit "Do not run this script as root. Use sudo if needed." + fi + + # Check if rankmirrors is installed + check_rankmirrors_installed + + # Backup current mirror lists + echo -e "${BLUE}Backing up current mirror lists...${RESET}" + for list in "$ARCH_MIRROR_LIST" "$BLACKARCH_MIRROR_LIST" "$CHAOTIC_AUR_MIRROR_LIST"; do + if [[ -f "$list" ]]; then + cp "$list" "$BACKUP_DIR/$(basename "$list").bak" || error_exit "Failed to backup $list" + fi + done + + # Ensure backup was successful + [[ "$(ls -A "$BACKUP_DIR")" ]] || error_exit "No mirror lists were backed up" + + # Update system packages + echo -e "${YELLOW}Updating system packages...${RESET}" + sudo pacman -Sy || error_exit "Failed to update package databases" + + # Prepare temporary directory for new mirror lists + temp_dir=$(mktemp -d) || error_exit "Failed to create temporary directory" + trap 'rm -rf "$temp_dir"' EXIT + + # Use rankmirrors to generate new mirror lists + echo -e "${GREEN}Selecting fastest mirrors using rankmirrors...${RESET}" + + # Rank and save Arch Linux mirror list + sudo rankmirrors -n 6 /etc/pacman.d/mirrorlist | tee "$temp_dir/mirrorlist" || + error_exit "Failed to generate Arch mirror list" + + # Rank and save BlackArch mirror list + sudo rankmirrors -n 6 /etc/pacman.d/blackarch-mirrorlist | tee "$temp_dir/blackarch-mirrorlist" || + error_exit "Failed to generate BlackArch mirror list" + + # Rank and save Chaotic-AUR mirror list + sudo rankmirrors -n 6 /etc/pacman.d/chaotic-mirrorlist | tee "$temp_dir/chaotic-mirrorlist" || + error_exit "Failed to generate Chaotic-AUR mirror list" + + # Check if the files exist before copying + if [[ -f "$temp_dir/mirrorlist" ]]; then + sudo cp "$temp_dir/mirrorlist" "$ARCH_MIRROR_LIST" || error_exit "Failed to copy Arch mirror list" + else + error_exit "Arch mirror list not found in $temp_dir" + fi + + if [[ -f "$temp_dir/blackarch-mirrorlist" ]]; then + sudo cp "$temp_dir/blackarch-mirrorlist" "$BLACKARCH_MIRROR_LIST" || error_exit "Failed to copy BlackArch mirror list" + else + error_exit "BlackArch mirror list not found in $temp_dir" + fi + + if [[ -f "$temp_dir/chaotic-mirrorlist" ]]; then + sudo cp "$temp_dir/chaotic-mirrorlist" "$CHAOTIC_AUR_MIRROR_LIST" || error_exit "Failed to copy Chaotic-AUR mirror list" + else + error_exit "Chaotic-AUR mirror list not found in $temp_dir" + fi + + # Success messages + echo -e "${GREEN}Mirror lists have been updated successfully!${RESET}" + echo -e "${BLUE}Your system's mirror lists have been optimized.${RESET}" + + # Optional system update + read -p "Would you like to perform a full system update now? (y/n): " choice + if [[ "$choice" =~ ^[yY]$ ]]; then + sudo pacman -Syu + echo -e "${GREEN}System update completed!${RESET}" + else + echo -e "${YELLOW}Mirror update complete. You can run 'sudo pacman -Syu' later.${RESET}" + fi +} + +# Run the main function +main diff --git a/snigdhaos-utils/snigdhaos-reset.sh b/snigdhaos-utils/snigdhaos-reset.sh new file mode 100755 index 00000000..ac26367a --- /dev/null +++ b/snigdhaos-utils/snigdhaos-reset.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +# ✨ Script Developed by: D3V1L0N ✨ +# 🌟 Version: 1.0 🌟 + +echo "────────────────────────────────────────────────────────────────────" +echo "πŸŽ‰ Hard Reset Script for Snigdha OS πŸŽ‰" +echo "πŸ‘¨β€πŸ’» Developed by: D3V1L0N" +echo "────────────────────────────────────────────────────────────────────" + +read -p "⚠️ WARNING: This script will reset the system by removing non-essential packages and overwriting configurations. Do you want to continue? (y/n): " confirm +if [[ ! "$confirm" =~ ^[Yy]$ ]]; then + echo "🚨 Operation aborted by user. Exiting... 🚨" + exit 1 +fi + +essential_packages=( + base + base-devel + linux + linux-firmware + systemd + grub + mkinitcpio + udev + vi + coreutils + bash +) + +is_essential() { + for pkg in "${essential_packages[@]}"; do + if [[ "$1" == "$pkg" ]]; then + return 0 + fi + done + return 1 +} + +echo "🌐 Updating package database..." +pacman -Sy --noconfirm + +installed_packages=$(pacman -Qq) + +echo "🧹 Cleaning up: Removing non-essential packages..." +for pkg in $installed_packages; do + if ! is_essential "$pkg"; then + echo "πŸ—‘οΈ Removing package: $pkg" + pacman -Rns --noconfirm "$pkg" + fi +done + +echo "βš™οΈ Resetting configuration files..." +echo "⚠️ WARNING: Resetting /etc will overwrite existing configurations! Backup any important configs before proceeding." +read -p "Are you sure you want to continue with the hard reset and overwrite /etc configuration files? (y/n): " confirm +if [[ ! "$confirm" =~ ^[Yy]$ ]]; then + echo "🚨 Operation aborted by user. Exiting... 🚨" + exit 1 +fi + +rm -rf /etc/* +cp -r /etc/skel/* /etc/ + +echo "πŸ”„ Reinstalling essential packages..." +for pkg in "${essential_packages[@]}"; do + pacman -S --noconfirm --needed "$pkg" +done + +echo "πŸ”§ Rebuilding initramfs..." +mkinitcpio -P + +echo "πŸŽ‰ Hard reset complete! Essential packages reinstalled, system cleaned, and ready to go. πŸš€" + +echo "πŸ”„ It's recommended to reboot your system now for changes to take effect." diff --git a/snigdhaos-welcome/PKGBUILD b/snigdhaos-welcome/PKGBUILD index 5cce3d75..7adf5eae 100644 --- a/snigdhaos-welcome/PKGBUILD +++ b/snigdhaos-welcome/PKGBUILD @@ -1,5 +1,5 @@ - # Maintainer: Eshan Roy +# Contributor: RiO pkgname=snigdhaos-welcome _pkgname=snigdhaos-welcome @@ -24,19 +24,29 @@ provides=("${pkgname}") conflicts=('snigdhaos-welcome-dev') install=$pkgname.install options=(!strip !emptydirs) -source=(${_pkgname}::"git+${url}") +source=("${pkgname}::git+${url}") sha256sums=('SKIP') pkgver() { - cd "$srcdir/$pkgname" - printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" + cd "$srcdir/$pkgname" + # Retrieve the version based on Git commits + printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" } package() { - install -dm755 ${pkgdir}${_licensedir}${_pkgname} - install -m644 ${srcdir}/${_pkgname}/LICENSE ${pkgdir}${_licensedir}${_pkgname} - mkdir -p "${pkgdir}${_destname1}" - cp -r "${srcdir}/${_pkgname}/${_destname1}/"* "${pkgdir}${_destname1}" - mkdir -p "${pkgdir}${_destname2}" - cp -r "${srcdir}/${_pkgname}/${_destname2}/"* "${pkgdir}${_destname2}" -} \ No newline at end of file + # Create directories for the license and app data + install -dm755 ${pkgdir}${_licensedir}${_pkgname} + install -m644 ${srcdir}/${_pkgname}/LICENSE ${pkgdir}${_licensedir}${_pkgname} + + # Install configuration files to the user's default skeleton directory + mkdir -p "${pkgdir}${_destname1}" + cp -r "${srcdir}/${_pkgname}/${_destname1}/"* "${pkgdir}${_destname1}" + + # Install the main application files to /usr + mkdir -p "${pkgdir}${_destname2}" + cp -r "${srcdir}/${_pkgname}/${_destname2}/"* "${pkgdir}${_destname2}" + + # Optionally clean up any unnecessary files (e.g., .git, build files, etc.) + # This ensures the final package only contains the necessary files + find "$pkgdir" -type f -name "*.git*" -exec rm -f {} \; +}