From 6ba3667375546028842e63f8db0101b671217ee1 Mon Sep 17 00:00:00 2001 From: Albert-LGTM Date: Wed, 9 Oct 2024 13:25:25 +0200 Subject: [PATCH] Added support for installing podman --- core/tabs/applications-setup/podman-setup.sh | 83 ++++++++++++++++++++ core/tabs/applications-setup/tab_data.toml | 6 ++ 2 files changed, 89 insertions(+) create mode 100644 core/tabs/applications-setup/podman-setup.sh diff --git a/core/tabs/applications-setup/podman-setup.sh b/core/tabs/applications-setup/podman-setup.sh new file mode 100644 index 00000000..77ec3aef --- /dev/null +++ b/core/tabs/applications-setup/podman-setup.sh @@ -0,0 +1,83 @@ +#!/bin/sh -e + +. ../common-script.sh + +# Function to prompt the user for installation choice +choose_installation() { + clear + printf "%b\n" "${YELLOW}Choose what to install:${RC}" + printf "%b\n" "1. ${YELLOW}Podman${RC}" + printf "%b\n" "2. ${YELLOW}Podman Compose${RC}" + printf "%b\n" "3. ${YELLOW}Both${RC}" + printf "%b" "Enter your choice [1-3]: " + read -r CHOICE + + case "$CHOICE" in + 1) INSTALL_PODMAN=1; INSTALL_COMPOSE=0 ;; + 2) INSTALL_PODMAN=0; INSTALL_COMPOSE=1 ;; + 3) INSTALL_PODMAN=1; INSTALL_COMPOSE=1 ;; + *) printf "%b\n" "${RED}Invalid choice. Exiting.${RC}"; exit 1 ;; + esac +} + +install_podman() { + printf "%b\n" "${YELLOW}Installing Podman...${RC}" + case "$PACKAGER" in + apt-get|nala) + "$ESCALATION_TOOL" "$PACKAGER" install -y podman + ;; + zypper) + "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install podman + ;; + pacman) + "$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm podman + ;; + dnf) + "$ESCALATION_TOOL" "$PACKAGER" install -y podman + ;; + *) + printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" + exit 1 + ;; + esac +} + +install_podman_compose() { + printf "%b\n" "${YELLOW}Installing Podman Compose...${RC}" + case "$PACKAGER" in + apt-get|nala|zypper|pacman) + "$ESCALATION_TOOL" pip3 install podman-compose + ;; + dnf) + "$ESCALATION_TOOL" "$PACKAGER" install -y podman-compose + ;; + *) + printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" + exit 1 + ;; + esac +} + +install_components() { + choose_installation + + if [ "$INSTALL_PODMAN" -eq 1 ]; then + if ! command_exists podman; then + install_podman + else + printf "%b\n" "${GREEN}Podman is already installed.${RC}" + fi + fi + + if [ "$INSTALL_COMPOSE" -eq 1 ]; then + if ! command_exists podman-compose; then + install_podman_compose + else + printf "%b\n" "${GREEN}Podman Compose is already installed.${RC}" + fi + fi +} + +checkEnv +checkEscalationTool +install_components diff --git a/core/tabs/applications-setup/tab_data.toml b/core/tabs/applications-setup/tab_data.toml index ef6af7de..2a70285d 100644 --- a/core/tabs/applications-setup/tab_data.toml +++ b/core/tabs/applications-setup/tab_data.toml @@ -222,6 +222,12 @@ description = "Docker is an open platform that uses OS-level virtualization to d script = "docker-setup.sh" task_list = "I SS" +[[data]] +name = "Podman" +description = "Podman is a daemon-less open platform that uses OS-level virtualization to deliver software in packages called containers." +script = "podman-setup.sh" +task_list = "I SS" + [[data]] name = "Fastfetch" description = "Fastfetch is a neofetch-like tool for fetching system information and displaying it prettily.\nIt is written mainly in C, with performance and customizability in mind.\nThis command installs fastfetch and configures from CTT's mybash repository.\nhttps://github.com/ChrisTitusTech/mybash"