-
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathdevcontainer_bootstrap
More file actions
executable file
·58 lines (51 loc) · 2.21 KB
/
devcontainer_bootstrap
File metadata and controls
executable file
·58 lines (51 loc) · 2.21 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
#!/bin/bash
# Bootstrap script for Home Assistant devcontainer
# Fixes Docker mount propagation issues
set -e
echo "🔧 Setting up Docker mount propagation..."
# 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 addons directory..."
sudo mkdir -p /mnt/supervisor/addons/local/addon-wireguard
if ! mountpoint -q /mnt/supervisor/addons/local/addon-wireguard 2>/dev/null; then
if sudo mount --bind /workspaces/addon-wireguard-client /mnt/supervisor/addons/local/addon-wireguard 2>/dev/null; then
echo "✓ Workspace directory bind mounted a /mnt/supervisor/addons/local/addon-wireguard"
else
echo "⚠ Errore nel montaggio bind del workspace, procedo con la sincronizzazione files"
sudo cp -rT /workspaces/addon-wireguard-client /mnt/supervisor/addons/local/addon-wireguard
fi
else
echo "✓ Workspace directory already mounted"
fi
echo ""
echo "✅ Bootstrap complete"