- 313 new markdown files created - 30 relationships embedded - 313 entries indexed - State initialized with usage data
1.7 KiB
| id | type | title | tags | importance | confidence | created | updated | relations | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| fae8f322-d5c6-4ffb-9735-49e9f46940e8 | solution | Pi-hole v6 TOML update approach using pure shell/sed/awk |
|
0.6 | 0.8 | 2026-02-07T15:12:33.508157+00:00 | 2026-02-07T15:12:33.508157+00:00 |
|
Approach for updating Pi-hole v6 pihole.toml without python/perl
Constraint: Pi-hole container only has sh, sed, awk, grep
Method 1: Extract-Replace-Merge
- Extract everything before 'hosts = [' line
- Write new hosts array
- Extract everything after matching ']'
- Concatenate all parts
Shell commands:
Before hosts array
sed -n '1,/^:space:hosts:space:=/p' pihole.toml | head -n -1 > part1.toml
New hosts array
cat >> part1.toml <<EOF hosts = [ "10.10.0.16 domain1.com", "10.10.0.16 domain2.com" ] EOF
After hosts array (skip until first ] after hosts =)
awk '/^:space:hosts:space:=/,/]/ {found=1; next} found {print}' pihole.toml >> part1.toml
Replace original
mv part1.toml pihole.toml
Method 2: Line-by-line state machine with awk
awk '
BEGIN { in_hosts=0; done=0 }
/^:space:hosts:space:=/ && !done {
print " hosts = ["
print " "10.10.0.16 domain1.com","
print " "10.10.0.16 domain2.com""
print " ]"
in_hosts=1
done=1
next
}
in_hosts && /]/ { in_hosts=0; next }
!in_hosts { print }
' pihole.toml
Implementation in script:
- Build TOML_HOSTS variable with proper escaping
- Inject into awk/sed command
- Execute via docker exec pihole sh -c
Test first on primary, then secondary