Skip to content

Commit

Permalink
Docker: adjust module options to match changes
Browse files Browse the repository at this point in the history
  • Loading branch information
igorpecovnik committed Dec 23, 2024
1 parent 28f5838 commit a0d0db9
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 61 deletions.
25 changes: 12 additions & 13 deletions tools/json/config.software.json
Original file line number Diff line number Diff line change
Expand Up @@ -878,48 +878,47 @@
"sub": [
{
"id": "CON001",
"description": "Install Docker Minimal",
"description": "Docker Minimal Install",
"about": "This operation will install Docker Minimal.",
"command": [
"install_docker"
"module_docker install minimal"
],
"status": "Stable",
"author": "@schwar3kat",
"condition": "! pkg_installed docker-ce"
"condition": "! module_docker status docker-ce"
},
{
"id": "CON002",
"description": "Install Docker Engine",
"description": "Docker Engine Install",
"about": "This operation will install Docker Engine.",
"command": [
"install_docker engine"
"module_docker install engine"
],
"status": "Stable",
"author": "@schwar3kat",
"condition": "! pkg_installed docker-compose-plugin"
"condition": "! module_docker status docker-compose-plugin"
},
{
"id": "CON003",
"description": "Remove Docker",
"description": "Docker Remove",
"about": "This operation will purge Docker.",
"command": [
"pkg_remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras"
"module_docker remove"
],
"status": "Stable",
"author": "@schwar3kat",
"condition": "pkg_installed docker-ce"
"condition": "module_docker status docker-ce"
},
{
"id": "CON004",
"description": "Purge all Docker images, containers, and volumes",
"description": "Docker Purge all images, containers, and volumes",
"about": "This operation will delete all Docker images, containers, and volumes.",
"command": [
"rm -rf /var/lib/docker",
"rm -rf /var/lib/containerd"
"module_docker purge"
],
"status": "Stable",
"author": "@schwar3kat",
"condition": "! pkg_installed docker-ce && [ -d /var/lib/docker ]"
"condition": "! module_docker status docker-ce && [ -d /var/lib/docker ]"
},
{
"id": "CON005",
Expand Down
41 changes: 0 additions & 41 deletions tools/modules/software/install_docker.sh

This file was deleted.

4 changes: 1 addition & 3 deletions tools/modules/software/install_swag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ function module_swag() {
# adjust hostname
hostnamectl set-hostname $(echo ${SWAG_URL} | sed -E 's/^\s*.*:\/\///g')
# install docker
pkg_installed docker-ce || install_docker
# add additional bridge where containers see each other
docker network create lsio 2> /dev/null
pkg_installed docker-ce || module_docker install

[[ -d "$SWAG_BASE" ]] || mkdir -p "$SWAG_BASE" || { echo "Couldn't create storage directory: $SWAG_BASE"; exit 1; }

Expand Down
4 changes: 2 additions & 2 deletions tools/modules/software/module_bazarr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module_options+=(
["module_bazarr,doc_link"]="https://wiki.bazarr.media/"
["module_bazarr,group"]="Downloaders"
["module_bazarr,port"]="6767"
["module_bazarr,arch"]="x86-64,arm64"
["module_bazarr,arch"]="x86-64 arm64"
)
#
# Module Bazarr
Expand All @@ -29,7 +29,7 @@ function module_bazarr () {

case "$1" in
"${commands[0]}")
pkg_installed docker-ce || install_docker
pkg_installed docker-ce || module_docker install
[[ -d "$BAZARR_BASE" ]] || mkdir -p "$BAZARR_BASE" || { echo "Couldn't create storage directory: $BAZARR_BASE"; exit 1; }
docker run -d \
--name=bazarr \
Expand Down
4 changes: 2 additions & 2 deletions tools/modules/software/module_deluge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module_options+=(
["module_deluge,doc_link"]="https://deluge-torrent.org/userguide/"
["module_deluge,group"]="Downloaders"
["module_deluge,port"]="8112 6181 58846"
["module_deluge,arch"]="x86-64,arm64"
["module_deluge,arch"]="x86-64 arm64"
)
#
# Module deluge
Expand All @@ -29,7 +29,7 @@ function module_deluge () {

case "$1" in
"${commands[0]}")
pkg_installed docker-ce || install_docker
pkg_installed docker-ce || module_docker install
[[ -d "$DELUGE_BASE" ]] || mkdir -p "$DELUGE_BASE" || { echo "Couldn't create storage directory: $DELUGE_BASE"; exit 1; }
docker run -d \
--name=deluge \
Expand Down
93 changes: 93 additions & 0 deletions tools/modules/software/module_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
module_options+=(
["module_docker,author"]="@schwar3kat"
["module_docker,maintainer"]="@igorpecovnik"
["module_docker,feature"]="install_docker"
["module_docker,example"]="install remove purge status help"
["module_docker,desc"]="Install docker from a repo using apt"
["module_docker,status"]="Active"
["module_docker,doc_link"]="https://wiki.bazarr.media/"
["module_docker,group"]="Containers"
["module_docker,port"]=""
["module_docker,arch"]="x86-64 arm64 armhf"
)
#
# Install Docker from repo using apt
# Setup sources list and GPG key then install the app. If you want a full desktop then $1=desktop
#
function module_docker() {

local title="bazarr"
local condition=$(which "$title" 2>/dev/null)

local commands
IFS=' ' read -r -a commands <<< "${module_options["module_docker,example"]}"

case "$1" in
"${commands[0]}")
# Check if repo for distribution exists.
URL="https://download.docker.com/linux/${DISTRO,,}/dists/$DISTROID"
if wget --spider "${URL}" 2> /dev/null; then
# Add Docker's official GPG key:
wget -qO - https://download.docker.com/linux/${DISTRO,,}/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/docker.gpg > /dev/null
if [[ $? -eq 0 ]]; then
# Add the repository to Apt sources:
cat <<- EOF > "/etc/apt/sources.list.d/docker.list"
deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/${DISTRO,,} $DISTROID stable
EOF
pkg_update
# Install docker
if [ "$2" = "engine" ]; then
pkg_install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
else
pkg_install docker-ce docker-ce-cli containerd.io
fi

groupadd docker 2>/dev/null || true
usermod -aG docker $SUDO_USER
systemctl enable docker.service > /dev/null 2>&1
systemctl enable containerd.service > /dev/null 2>&1
docker network create lsio 2> /dev/null
fi
else
$DIALOG --msgbox "ERROR ! ${DISTRO} $DISTROID distribution not found in repository!" 7 70
fi
;;
"${commands[1]}")
pkg_remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
;;
"${commands[2]}")
rm -rf /var/lib/docker
rm -rf /var/lib/containerd
;;
"${commands[3]}")
if [ "$2" = "docker-ce" ]; then
if pkg_installed docker-ce; then
return 0
else
return 1
fi
fi
if [ "$2" = "docker-compose-plugin" ]; then
if pkg_installed docker-compose-plugin; then
return 0
else
return 1
fi
fi
;;
"${commands[4]}")
echo -e "\nUsage: ${module_options["module_docker,feature"]} <command>"
echo -e "Commands: ${module_options["module_docker,example"]}"
echo "Available commands:"
echo -e "\tinstall\t- Install $title."
echo -e "\tstatus\t- Installation status $title."
echo -e "\tremove\t- Remove $title."
echo -e "\tremove\t- Purge $title."
echo
;;
*)
${module_options["module_docker,feature"]} ${commands[4]}
;;
esac
}

0 comments on commit a0d0db9

Please sign in to comment.