-
Hello guys, is it possible to have multiple pause service blocking on different times on the same day. I have tried creating but it always overwrites. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
This is currently a feature request. At this stage from reading, it looks like the easiest way to do it would be to apply the $ctag rule to specific clients, and schedule a script that interfaces with the AdGuard Home API to run at the desired times, or by using Home Assistant. |
Beta Was this translation helpful? Give feedback.
-
Am running AdGuard Home on a college setup. I want to allow students to
browse freely at 1pm - 2pm and from 5pm to 8 am the next day. How do apply
the ctag rule for such a setup?
…On Sat, Mar 23, 2024 at 6:08 AM jslawler-gh ***@***.***> wrote:
This is currently <#1692>
a feature request.
At this stage from reading, it looks like the easiest way to do it would
be to apply the $ctag rule to specific clients, and schedule a script that
interfaces with the AdGuard Home API to run at the desired times, or by
using Home Assistant.
—
Reply to this email directly, view it on GitHub
<#6835 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVPAWFKERC6KLRZKBFJOMM3YZTW4RAVCNFSM6AAAAABE7DYQYKVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DQOBUGI2DC>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
Thanks, I'll check it out! Can I get back if i face any challenges?
…On Mon, Mar 25, 2024 at 11:14 AM jslawler-gh ***@***.***> wrote:
You can read up on how to use the ctag rule here
<https://adguard-dns.io/kb/general/dns-filtering-syntax/#ctag-modifier>.
As for the rules, you would store them in the AdGuardHome.yaml file like
the example below:
user_rules:
- '||example.com'
To do what you want to do you would need to automate the function,
something like the below would do it. I haven't tested it though.
This script will:
Stop AdGuard Home.
Rename AdGuardHome.yaml to AdGuardHome.backup safely, avoiding
overwriting if a backup already exists.
Rename AdGuardHome.backup to AdGuardHome.yaml when needed.
Start AdGuard Home again.
Please note that you’ll need to set up cron jobs to run this script at the
specified times.
#!/bin/bash
# Define the paths to the AdGuard Home binary and configuration files
ADGUARD_BINARY="/path/to/AdGuardHome"
CONFIG_FILE="/path/to/AdGuardHome.yaml"
BACKUP_FILE="/path/to/AdGuardHome.backup"
# Stop AdGuard Home service
$ADGUARD_BINARY stop
# Check the time and date to determine which action to take
HOUR=$(date +'%H')
DAY=$(date +'%u') # Day of the week (1..7); 1 is Monday
# Between 1 PM and 2 PM or 5 PM to 8 AM the next day
if { [ "$HOUR" -ge 13 ] && [ "$HOUR" -lt 14 ]; } || { [ "$HOUR" -ge 17 ] || [ "$HOUR" -lt 8 ]; }; then
# Make sure we don't overwrite the backup file
if [ -f "$BACKUP_FILE" ]; then
mv "$BACKUP_FILE" "${BACKUP_FILE}_$(date +'%Y%m%d%H%M%S')"
fi
# Rename the current config to backup
mv "$CONFIG_FILE" "$BACKUP_FILE"
else
# All other times, use the backup file
if [ -f "$CONFIG_FILE" ]; then
mv "$CONFIG_FILE" "${CONFIG_FILE}_$(date +'%Y%m%d%H%M%S')"
fi
mv "$BACKUP_FILE" "$CONFIG_FILE"
fi
# Start AdGuard Home service
$ADGUARD_BINARY start
To automate this process, you would set up two cron jobs to run this
script at the desired times. Here’s an example of what the cron entries
might look like:
# Run script at 1 PM every day
0 13 * * * /path/to/script.sh
# Run script at 2 PM every day
0 14 * * * /path/to/script.sh
# Run script at 5 PM every day
0 17 * * * /path/to/script.sh
# Run script at 8 AM every day
0 8 * * * /path/to/script.sh
Make sure to replace /path/to/AdGuardHome and /path/to/script.sh with the
actual paths on your system. Also, ensure that the script has executable
permissions by running chmod +x /path/to/script.sh.
This script assumes that the AdGuardHome binary has the capability to
start and stop the service directly. If your setup requires a different
command to control the service, such as systemctl, make sure to update
the script accordingly.
—
Reply to this email directly, view it on GitHub
<#6835 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVPAWFJ626T6PQUHGCPZLYLYZ7MF5AVCNFSM6AAAAABE7DYQYKVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DQOJZGA2DK>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
Thanks, I will.
…On Mon, Mar 25, 2024 at 2:13 PM jslawler-gh ***@***.***> wrote:
Make a backup before making changes.
—
Reply to this email directly, view it on GitHub
<#6835 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVPAWFJQFGW3GQE3DASY6LLY2ABEDAVCNFSM6AAAAABE7DYQYKVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DSMBRGA3TM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
You can read up on how to use the ctag rule here.
As for the rules, you would store them in the AdGuardHome.yaml file like the example below:
To do what you want to do you would need to automate the function, something like the below would do it. I haven't tested it though.
This script will:
Stop AdGuard Home.
Rename
AdGuardHome.yaml
toAdGuardHome.backup
safely, avoiding overwriting if a backup already exists.Rename
AdGuardHome.backup
toAdGuardHome.yaml
when needed.Start AdGuard Home again.
Please note that you’ll need to set up cron jobs to run this script at the specified times.