-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-privileged.sh
More file actions
69 lines (56 loc) · 2.14 KB
/
run-privileged.sh
File metadata and controls
69 lines (56 loc) · 2.14 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
68
69
#!/bin/bash
# Quick Privileged Test for HAOS Swap Enabler
# This runs the addon directly in a privileged Alpine container with host access
set -e
echo "🚀 Running HAOS Swap Enabler in privileged mode..."
echo
# Build and run the addon container with full host access
docker run --rm -it \
--privileged \
--pid=host \
--network=host \
-v /dev:/dev:rw \
-v /proc:/proc:rw \
-v /sys:/sys:rw \
-v "$(pwd)":/addon:ro \
alpine:latest \
sh -c '
# Install required tools
apk add --no-cache util-linux e2fsprogs parted lsblk blkid jq
# Enter host namespace for full system access
nsenter --target 1 --mount --uts --net --ipc sh -xec "
echo \"=== Host System Access Established ====\"
echo \"Current working directory: \$(pwd)\"
echo
# Show current system state
echo \"=== Current Block Devices ====\"
lsblk
echo
echo \"=== Current Swap Status ====\"
swapon -s 2>/dev/null || echo \"No swap currently active\"
echo
echo \"=== Available Swap Partitions ====\"
blkid -t TYPE=swap -o device 2>/dev/null || echo \"No swap partitions found\"
echo
# Mock bashio functions for testing
bashio_config() {
case \"\$1\" in
device) echo \"/dev/sdb\" ;;
auto_discover) echo \"true\" ;;
create_partition) echo \"false\" ;;
priority) echo \"10\" ;;
*) echo \"\${2:-}\" ;;
esac
}
# Source the addon script with modifications
echo \"=== Running Addon Script ====\"
cd /addon
# Replace bashio::config calls with our mock function
sed 's/bashio::config/bashio_config/g' run.sh > /tmp/run_modified.sh
chmod +x /tmp/run_modified.sh
# Run the modified script
/tmp/run_modified.sh
"
'
echo
echo "✅ Test completed!"