-
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathdevcontainer_bootstrap
More file actions
executable file
·67 lines (58 loc) · 2.74 KB
/
Copy pathdevcontainer_bootstrap
File metadata and controls
executable file
·67 lines (58 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# Bootstrap script for Home Assistant devcontainer
# Fixes Docker mount propagation issues
set -e
echo "🔧 Setting up Docker mount propagation..."
# Ensure /run/supervisor exists to prevent bind mount issues when starting Home Assistant Core container
sudo mkdir -p /run/supervisor
echo "✓ /run/supervisor folder created"
# Pre-initialize supervisor jobs config to ignore the "healthy" check since devcontainer networks trigger "unhealthy" status
sudo mkdir -p /mnt/supervisor
echo '{"ignore_conditions": ["healthy"]}' | sudo tee /mnt/supervisor/jobs.json >/dev/null
echo "✓ jobs.json pre-configured to ignore healthy checks"
# Create supervisor directories
mkdir -p /mnt/supervisor/{share,addon_configs}
echo "✓ Supervisor directories created"
# Check if /mnt/supervisor/share is already a mount point
if mountpoint -q /mnt/supervisor/share 2>/dev/null; then
echo "✓ /mnt/supervisor/share is already mounted"
# Try to make it shared if it's not already
mount --make-shared /mnt/supervisor/share 2>/dev/null || \
mount --make-rshared /mnt/supervisor/share 2>/dev/null || \
echo "⚠ Could not make /mnt/supervisor/share shared"
else
# Try to mount tmpfs if not already mounted
if mount -t tmpfs -o size=100M tmpfs /mnt/supervisor/share 2>/dev/null; then
echo "✓ tmpfs montato su /mnt/supervisor/share"
else
echo "ℹ /mnt/supervisor/share non montato (verrà creato automaticamente)"
fi
fi
# Try to make root mount shared (required for Docker-in-Docker)
# This might fail if we don't have sufficient privileges
if mount --make-shared / 2>/dev/null || mount --make-rshared / 2>/dev/null; then
echo "✓ Root mount configured as shared"
else
# Check if it's already shared
if grep -q "shared:" /proc/self/mountinfo | grep " / "; then
echo "✓ Root mount is already shared"
else
echo "⚠ Could not configure root mount as shared"
echo " This may cause issues with Docker-in-Docker"
fi
fi
echo ""
echo "🔧 Mount local apps directory..."
sudo mkdir -p /mnt/supervisor/apps/local/wireguard_client
if ! mountpoint -q /mnt/supervisor/apps/local/wireguard_client 2>/dev/null; then
if sudo mount --bind /workspaces/addon-wireguard-client/wireguard_client /mnt/supervisor/apps/local/wireguard_client 2>/dev/null; then
echo "✓ Workspace wireguard_client directory bind mounted to /mnt/supervisor/apps/local/wireguard_client"
else
echo "⚠ Errore nel montaggio bind del workspace, procedo con la sincronizzazione files"
sudo cp -rT /workspaces/addon-wireguard-client/wireguard_client /mnt/supervisor/apps/local/wireguard_client
fi
else
echo "✓ Workspace wireguard_client directory already mounted"
fi
echo ""
echo "✅ Bootstrap complete"