Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified scripts/macos/cwdown.sh
100644 → 100755
Empty file.
53 changes: 45 additions & 8 deletions scripts/macos/cwup.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,65 @@ set -e

ensure_network() {
local name=$1
if [ "$(container network inspect "$name" 2>/dev/null)" != "[]" ]; then
echo "✓ $name"
else

local inspect_output
if ! inspect_output=$(container network inspect "$name" 2>/dev/null); then
echo "➕ Creating network $name..."
container network create "$name"
return
fi

if [ -z "$inspect_output" ] || [ "$inspect_output" = "[]" ]; then
echo "➕ Creating network $name..."
container network create "$name"
else
echo "✓ Network $name exists"
fi
}

ensure_volume() {
local name=$1
if [ "$(container volume inspect "$name" 2>/dev/null)" != "[]" ]; then
echo "✓ $name"
else

local inspect_output
if ! inspect_output=$(container volume inspect "$name" 2>/dev/null); then
echo "➕ Creating volume $name..."
container volume create "$name"
return
fi

if [ -z "$inspect_output" ] || [ "$inspect_output" = "[]" ]; then
echo "➕ Creating volume $name..."
container volume create "$name"
else
echo "✓ Volume $name exists"
fi
}

start_container() {
local name=$1
shift
if ! [ "$(container inspect "$name" 2>/dev/null)" != "[]" ]; then
echo "🚀 Starting $name..."

local inspect_output
if ! inspect_output=$(container inspect "$name" 2>/dev/null); then
echo "🚀 Creating and starting $name..."
container run -d --name "$name" "$@"
return
fi

if [ -z "$inspect_output" ] || [ "$inspect_output" = "[]" ]; then
echo "🚀 Creating and starting $name (was empty)..."
container run -d --name "$name" "$@"
return
fi

local status
status=$(echo "$inspect_output" | jq -r '.[0].status // "unknown"')

if [ "$status" != "running" ]; then
echo "▶️ Starting existing container $name..."
container start "$name"
else
echo "✅ $name is already running"
fi
}

Expand Down
Loading