claude-memory/graph/solutions/pi-hole-v6-toml-update-approach-using-pure-shellsedawk-fae8f3.md
Cal Corum b140d4d82a migrate: 313 memories from MemoryGraph
- 313 new markdown files created
- 30 relationships embedded
- 313 entries indexed
- State initialized with usage data
2026-02-13 11:11:48 -06:00

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
pihole
v6
toml
shell
sed
awk
solution
0.6 0.8 2026-02-07T15:12:33.508157+00:00 2026-02-07T15:12:33.508157+00:00
target type direction strength
dc3ed16c-18db-4011-b866-3730316cd68d SOLVES outgoing 0.5

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

  1. Extract everything before 'hosts = [' line
  2. Write new hosts array
  3. Extract everything after matching ']'
  4. 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