mirror of
https://github.com/bigbeartechworld/big-bear-scripts.git
synced 2026-03-31 06:24:02 -04:00
Add script to install or update Dockge
containerized application
This commit is contained in:
11
install-or-update-dockge/README.md
Normal file
11
install-or-update-dockge/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
## Why?
|
||||
|
||||
The script is a Bash script designed to facilitate the installation and management of Dockge, a containerized application. It begins by checking whether Docker CE 20+ or Podman is installed on the system and offers the user the option to install either of these container runtimes if they are not already present. It also checks the operating system version and architecture for compatibility.
|
||||
|
||||
If Dockge is not already installed or if the user chooses to update it, the script proceeds to set up Dockge. It creates directories, downloads the necessary configuration file (compose.yaml) from a remote source, and starts Dockge using the installed container runtime. Additionally, if Dockge is already installed, the script offers the user the option to update it by pulling the latest Docker images and restarting the application.
|
||||
|
||||
## How to use?
|
||||
|
||||
```bash
|
||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/bigbeartechworld/big-bear-scripts/master/install-or-update-dockge/run.sh)"
|
||||
```
|
||||
97
install-or-update-dockge/run.sh
Normal file
97
install-or-update-dockge/run.sh
Normal file
@@ -0,0 +1,97 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Check if the script is run as root
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if Docker CE 20+ is installed
|
||||
DOCKER_INSTALLED=false
|
||||
if command -v docker &> /dev/null; then
|
||||
DOCKER_INSTALLED=true
|
||||
fi
|
||||
|
||||
# Check if Podman is installed
|
||||
PODMAN_INSTALLED=false
|
||||
if command -v podman &> /dev/null; then
|
||||
PODMAN_INSTALLED=true
|
||||
fi
|
||||
|
||||
# Check if either Docker CE or Podman is installed, and give the user the option to install if not
|
||||
if [ "$DOCKER_INSTALLED" = false ] && [ "$PODMAN_INSTALLED" = false ]; then
|
||||
echo "Neither Docker CE nor Podman is installed."
|
||||
|
||||
read -p "Do you want to install Docker CE (y/n)? " INSTALL_DOCKER
|
||||
|
||||
if [ "$INSTALL_DOCKER" = "y" ] || [ "$INSTALL_DOCKER" = "Y" ]; then
|
||||
# Install Docker CE
|
||||
curl -fsSL https://get.docker.com -o get-docker.sh
|
||||
sh get-docker.sh
|
||||
rm get-docker.sh
|
||||
systemctl start docker
|
||||
systemctl enable docker
|
||||
else
|
||||
read -p "Do you want to install Podman (y/n)? " INSTALL_PODMAN
|
||||
|
||||
if [ "$INSTALL_PODMAN" = "y" ] || [ "$INSTALL_PODMAN" = "Y" ]; then
|
||||
# Install Podman
|
||||
apt-get update
|
||||
apt-get install -y podman
|
||||
else
|
||||
echo "Please install Docker CE or Podman manually to proceed."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if Dockge is installed
|
||||
DOCKGE_DIR="/opt/dockge"
|
||||
if [ -d "$DOCKGE_DIR" ]; then
|
||||
read -p "Dockge is already installed. Do you want to update it (y/n)? " UPDATE_DOCKGE
|
||||
|
||||
if [ "$UPDATE_DOCKGE" = "y" ] || [ "$UPDATE_DOCKGE" = "Y" ]; then
|
||||
# Change to Dockge directory
|
||||
cd "$DOCKGE_DIR"
|
||||
|
||||
# Pull the latest Docker images
|
||||
docker compose pull
|
||||
|
||||
# Start Dockge
|
||||
docker compose up -d
|
||||
|
||||
echo "Dockge has been updated."
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# If Dockge is not installed or not updated, continue with the installation
|
||||
|
||||
# Set default values
|
||||
STACKS_DIR="/opt/stacks"
|
||||
PORT="5001"
|
||||
|
||||
# Create directories if they don't exist
|
||||
mkdir -p "$STACKS_DIR" "$DOCKGE_DIR"
|
||||
|
||||
# Download the compose.yaml
|
||||
curl https://raw.githubusercontent.com/louislam/dockge/master/compose.yaml --output "$DOCKGE_DIR/compose.yaml"
|
||||
|
||||
# Start Dockge based on the installed container runtime
|
||||
if [ "$DOCKER_INSTALLED" = true ]; then
|
||||
# Using Docker CE
|
||||
echo "Starting Dockge with Docker CE..."
|
||||
docker compose -f "$DOCKGE_DIR/compose.yaml" -p dockge up -d
|
||||
elif [ "$PODMAN_INSTALLED" = true ]; then
|
||||
# Using Podman
|
||||
echo "Starting Dockge with Podman..."
|
||||
podman-compose -f "$DOCKGE_DIR/compose.yaml" up -d
|
||||
else
|
||||
echo "Neither Docker CE nor Podman is installed. Cannot proceed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the IP address of the host
|
||||
LAN_IP=$(hostname -I | awk '{print $1}')
|
||||
|
||||
echo "Dockge is now running on http://$LAN_IP:$PORT"
|
||||
Reference in New Issue
Block a user