From 8e108f45d7f448eb8713dc7be73432ee9a6152bd Mon Sep 17 00:00:00 2001 From: pika Date: Mon, 30 Dec 2024 18:41:08 +0100 Subject: [PATCH] addet docker script --- core/tabs/applications-setup/docker-setup.sh | 168 ++++++++++++------- core/tabs/applications-setup/tab_data.toml | 6 + core/tabs/system-setup/tab_data.toml | 3 +- 3 files changed, 113 insertions(+), 64 deletions(-) diff --git a/core/tabs/applications-setup/docker-setup.sh b/core/tabs/applications-setup/docker-setup.sh index afcd157..0c8889b 100755 --- a/core/tabs/applications-setup/docker-setup.sh +++ b/core/tabs/applications-setup/docker-setup.sh @@ -4,84 +4,126 @@ # 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}Docker${RC}" - printf "%b\n" "2. ${YELLOW}Docker Compose${RC}" - printf "%b\n" "3. ${YELLOW}Both${RC}" - printf "%b" "Enter your choice [1-3]: " - read -r CHOICE + clear + printf "%b\n" "${YELLOW}Choose what to install:${RC}" + printf "%b\n" "1. ${YELLOW}Docker${RC}" + printf "%b\n" "2. ${YELLOW}Docker Compose${RC}" + printf "%b\n" "3. ${YELLOW}Both${RC}" + printf "%b" "Enter your choice [1-3]: " + read -r CHOICE - case "$CHOICE" in - 1) INSTALL_DOCKER=1; INSTALL_COMPOSE=0 ;; - 2) INSTALL_DOCKER=0; INSTALL_COMPOSE=1 ;; - 3) INSTALL_DOCKER=1; INSTALL_COMPOSE=1 ;; - *) printf "%b\n" "${RED}Invalid choice. Exiting.${RC}"; exit 1 ;; - esac + case "$CHOICE" in + 1) + INSTALL_DOCKER=1 + INSTALL_COMPOSE=0 + ;; + 2) + INSTALL_DOCKER=0 + INSTALL_COMPOSE=1 + ;; + 3) + INSTALL_DOCKER=1 + INSTALL_COMPOSE=1 + ;; + *) + printf "%b\n" "${RED}Invalid choice. Exiting.${RC}" + exit 1 + ;; + esac } install_docker() { - printf "%b\n" "${YELLOW}Installing Docker...${RC}" - case "$PACKAGER" in - apt-get|nala) - curl -fsSL https://get.docker.com | sh - ;; - zypper) - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install docker - "$ESCALATION_TOOL" systemctl enable docker - "$ESCALATION_TOOL" systemctl start docker - ;; - pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm docker - "$ESCALATION_TOOL" systemctl enable docker - "$ESCALATION_TOOL" systemctl start docker - ;; - *) - printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" - exit 1 - ;; - esac + printf "%b\n" "${YELLOW}Installing Docker...${RC}" + case "$PACKAGER" in + apt-get | nala) + curl -fsSL https://get.docker.com | sh + ;; + zypper) + "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install docker + "$ESCALATION_TOOL" systemctl enable docker + "$ESCALATION_TOOL" systemctl start docker + ;; + pacman) + "$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm docker + "$ESCALATION_TOOL" systemctl enable docker + "$ESCALATION_TOOL" systemctl start docker + ;; + *) + printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" + exit 1 + ;; + esac } install_docker_compose() { - printf "%b\n" "${YELLOW}Installing Docker Compose...${RC}" - case "$PACKAGER" in - apt-get|nala) - "$ESCALATION_TOOL" "$PACKAGER" install -y docker-compose-plugin - ;; - zypper) - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install docker-compose - ;; - pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm docker-compose - ;; - *) - printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" - exit 1 - ;; - esac + printf "%b\n" "${YELLOW}Installing Docker Compose...${RC}" + case "$PACKAGER" in + apt-get | nala) + "$ESCALATION_TOOL" "$PACKAGER" install -y docker-compose-plugin + ;; + zypper) + "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install docker-compose + ;; + pacman) + "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm docker-compose + ;; + *) + printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" + exit 1 + ;; + esac } install_components() { - choose_installation + choose_installation - if [ "$INSTALL_DOCKER" -eq 1 ]; then - if ! command_exists docker; then - install_docker - else - printf "%b\n" "${GREEN}Docker is already installed.${RC}" - fi + if [ "$INSTALL_DOCKER" -eq 1 ]; then + if ! command_exists docker; then + install_docker + else + printf "%b\n" "${GREEN}Docker is already installed.${RC}" fi + fi - if [ "$INSTALL_COMPOSE" -eq 1 ]; then - if ! command_exists docker-compose || ! command_exists docker compose version; then - install_docker_compose - else - printf "%b\n" "${GREEN}Docker Compose is already installed.${RC}" - fi + if [ "$INSTALL_COMPOSE" -eq 1 ]; then + if ! command_exists docker-compose || ! command_exists docker compose version; then + install_docker_compose + else + printf "%b\n" "${GREEN}Docker Compose is already installed.${RC}" fi + fi +} + +init_groups() { + clear + if command_exists usermod; then + printf "%b\n" "${YELLOW}Do you want to add $(whoami) to the docker group?:${RC}" + printf "%b" "Enter your choice [Y/n]: " + read -r CHOICE_2 + + case "$CHOICE_2" in + N | n) + return 0 + ;; + *) + "$ESCALATION_TOOL" usermod -aG docker "$(whoami)" + ;; + esac + else + printf "%b\n" "${RED}The command 'usermod' does not exist!${RC}" + fi +} + +setup_autostart() { + if command_exists systemctl; then + "$ESCALATION_TOOL" systemctl enable --now docker + else + printf "%b\n" "${RED}The command 'systemctl' does not exist!${RC}" + fi } checkEnv checkEscalationTool -install_components \ No newline at end of file +install_components +init_groups + diff --git a/core/tabs/applications-setup/tab_data.toml b/core/tabs/applications-setup/tab_data.toml index 974e460..e190471 100644 --- a/core/tabs/applications-setup/tab_data.toml +++ b/core/tabs/applications-setup/tab_data.toml @@ -13,6 +13,12 @@ description = "Flatpak is a universal application sandbox for Linux that uses is script = "setup-flatpak.sh" task_list = "I" +[[data]] +name = "Docker" +description = "Installs docker and handles the group permissions correctly" +script = "docker-setup.sh" +task_list = "I" + [[data]] name = "github-desktop" description = "GitHub Desktop is a free Git client that allows you to manage your GitHub repositories on your desktop." diff --git a/core/tabs/system-setup/tab_data.toml b/core/tabs/system-setup/tab_data.toml index 42e7547..3f5e4ec 100644 --- a/core/tabs/system-setup/tab_data.toml +++ b/core/tabs/system-setup/tab_data.toml @@ -30,7 +30,8 @@ task_list = "I" [[data.entries]] name = "Blackarch setup" description = "You can install blackarch repositories and packages through this script, if your on arch already (which you should, if you're seeing this)" -script = "arch/blackarch.sh" = "I" +script = "arch/blackarch.sh" +task_list = "I" [[data]] name = "Debian"