From ce67fd6767c3071876f39726c8d64a900a9521f3 Mon Sep 17 00:00:00 2001 From: d3v1l0n Date: Tue, 24 Dec 2024 03:23:39 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20perf:=20improved=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../snigdhaos-system-installation.install | 69 +++++++++++++++++-- 1 file changed, 64 insertions(+), 5 deletions(-) diff --git a/snigdhaos-system-installation/snigdhaos-system-installation.install b/snigdhaos-system-installation/snigdhaos-system-installation.install index c70c9729..7106c9a7 100644 --- a/snigdhaos-system-installation/snigdhaos-system-installation.install +++ b/snigdhaos-system-installation/snigdhaos-system-installation.install @@ -1,14 +1,73 @@ +#!/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 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