Skip to content

MrcRjs/adguardhome-scheduled-block-service

Repository files navigation

AdguardHome Scheduled Service Blocker

Adguardhome Block Services CLI demo

Pre-requirements

While this can be installed in any server with crontab, I recommend installing it in a local network server or in the same server host adguardhome due to the basic authentication security used by AdguardHome.

Installation

$ git clone https://github.com/MrcRjs/adguardhome-scheduled-block-service.git aghblock
$ cd aghblock && sudo make install

Configuration

Once installation is complete you need to set your own configuration adding the following environment variables to your .bash_profile or .profile.

export AGH_SERVER="127.0.0.1:2023" # Your adguard home server ip and port
export AGH_USER="your_agh_username"
export AGH_PASS="your_agh_password"

Confirm your configuration works by getting the current services blocked status with:

$ aghblock status

Schedule block

We'll use crontab as it is widely available for linux distributions including OpenWrt.

Edit your crontab file from a terminal in openwrt:

$ crontab -e

To block services during the weekdays Monday to Friday at 9am add:

0 09 * * 1-5 aghblock block facebook,youtube,instagram,tiktok

crontab.guru is a great resource to build / understand a cron schedule.

We add one more line to unblock services during the weekdays Monday to Friday at 5pm add:

0 17 * * 1-5 aghblock unblock facebook,youtube,instagram,tiktok

Note you can also update your crontab through the UI luci app by clicking on System -> Scheduled Tasks you can paste the same lines from the previous steps.