Skip to content

Commit

Permalink
feat: Display version number
Browse files Browse the repository at this point in the history
  • Loading branch information
kroese authored Nov 10, 2024
1 parent d29c8b8 commit 09d2e07
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions entry.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,50 @@
#!/usr/bin/env bash
set -Eeuo pipefail

info () { printf "%b%s%b" "\E[1;34m❯ \E[1;36m" "${1:-}" "\E[0m\n"; }
error () { printf "%b%s%b" "\E[1;31m❯ " "ERROR: ${1:-}" "\E[0m\n" >&2; }
warn () { printf "%b%s%b" "\E[1;31m❯ " "Warning: ${1:-}" "\E[0m\n" >&2; }

trap 'error "Status $? while: $BASH_COMMAND (line $LINENO/$BASH_LINENO)"' ERR

[ ! -f "/run/entry.sh" ] && error "Script must run inside Docker container!" && exit 11
[ "$(id -u)" -ne "0" ] && error "Script must be executed with root privileges." && exit 12

echo "❯ Starting umbrelOS for Docker v$(</run/version)..."
echo "❯ For support visit https://github.com/dockur/umbrel/issues"

if [ ! -S /var/run/docker.sock ]; then
echo "ERROR: Docker socket is missing? Please bind /var/run/docker.sock in your compose file." && exit 13
error "Docker socket is missing? Please bind /var/run/docker.sock in your compose file." && exit 13
fi

if ! docker network inspect umbrel_main_network &>/dev/null; then
if ! docker network create --driver=bridge --subnet="10.21.0.0/16" umbrel_main_network >/dev/null; then
echo "ERROR: Failed to create network 'umbrel_main_network'!" && exit 14
error "Failed to create network 'umbrel_main_network'!" && exit 14
fi
if ! docker network inspect umbrel_main_network &>/dev/null; then
echo "ERROR: Network 'umbrel_main_network' does not exist?" && exit 15
error "Network 'umbrel_main_network' does not exist?" && exit 15
fi
fi

target=$(hostname)

if ! docker inspect "$target" &>/dev/null; then
echo "ERROR: Failed to find a container with name '$target'!" && exit 16
error "Failed to find a container with name '$target'!" && exit 16
fi

resp=$(docker inspect "$target")
network=$(echo "$resp" | jq -r '.[0].NetworkSettings.Networks["umbrel_main_network"]')

if [ -z "$network" ] || [[ "$network" == "null" ]]; then
if ! docker network connect umbrel_main_network "$target"; then
echo "ERROR: Failed to connect container to network!" && exit 17
error "Failed to connect container to network!" && exit 17
fi
fi

mount=$(echo "$resp" | jq -r '.[0].Mounts[] | select(.Destination == "/data").Source')

if [ -z "$mount" ] || [[ "$mount" == "null" ]] || [ ! -d "/data" ]; then
echo "ERROR: You did not bind the /data folder!" && exit 18
error "You did not bind the /data folder!" && exit 18
fi

# Create directories
Expand All @@ -46,7 +58,7 @@ if [[ "$mount" == *":\\"* ]]; then
fi

if [[ "$mount" != "/"* ]]; then
echo "ERROR: Please bind the /data folder to an absolute path!" && exit 19
error "Please bind the /data folder to an absolute path!" && exit 19
fi

# Mirror external folder to local filesystem
Expand Down

0 comments on commit 09d2e07

Please sign in to comment.