jacklul / pihole-updatelists

Update Pi-hole's lists from remote sources easily
MIT License
1.42k stars 82 forks source link

Fix #67: Update README.md #68

Closed dakotahawkins closed 3 years ago

dakotahawkins commented 3 years ago

Add sed command sed -Ei '/pihole[[:space:]]+updateGravity/I,${s/^#*/#/;b};$q1' /etc/cron.d/pihole to the section on disabling the default gravity update schedule.

Fixes #67

jacklul commented 3 years ago

I'm wondering what's the story behind this long regex I've been using sed -e '/pihole updateGravity/ s/^#*/#/' -i /etc/cron.d/pihole for some time and it seems to do the job fine

dakotahawkins commented 3 years ago

There are simpler ones that do the job, this one is similar to others I've cobbled together to do the same thing.

The line match itself just allows arbitrary whitespace between pihole and updateGravity and is case insensitive.

The sed voodoo ${s/^#*/#/;b};$q1 has the following features:

I guess that's not really important unless you're putting it in another script (like I am) and want to respond to failures somehow.

I can change it to the simpler version if you prefer, let me know!

dakotahawkins commented 3 years ago

Now that I think about it, for documentation purposes the simpler one is better as long as it continues to work (which it should). I'll just change it to that. I should have considered that in the first place :)

jacklul commented 3 years ago

I'm now wondering why did I put a space between / s/... I don't think there is any reason to put it there

dakotahawkins commented 3 years ago

That's important, it's the end of the line match expression and the beginning of the replace. In other words, first it matches the line, then it attempts the replace on matching lines only I think.

Edit: in sed terminology it's the "address"

dakotahawkins commented 3 years ago

Also it just occurred to me I need to make sure running that doesn't require a sudo...

Edit: it does, whoops