Would be useful to include systemd scheduling information for those who wish to use the scheduler. These are the steps that I have noted after copying magichosts to /usr/local/bin and modifying as required
- cd to /etc/systemd/system
- Create the file magichosts.service as follows
[Unit]
Description=Script to swith /etc/hosts when connected to LAN at home
[Service]
Type=oneshot
ExecStart=/usr/local/bin/magichosts
- For scheduling create the file magichosts.timer with the following which will run the magichosts.service every minute.
[Unit]
Description=Check for wireless connection every minute
[Timer]
OnCalendar=*-*-* *:*:00
Persistent=Ttrue
[Install]
WantedBy=timers.target
Confirm the details of the scheduling parameters. This will show the next 5 scheduled instances according to the parameters for OnCalendar.
systemd-analyze calendar --iterations=5 '*-*-* *:*:00'
Information on systemd timers at https://wiki.archlinux.org/title/Systemd/Timers
4. Enable the systemd timer with the following
i) Reload systemd
sudo systemctl daemon-reload
ii) Enable the timer to run on boot
sudo systemctl enable magichosts
iii) Start the timer immediately
sudo systemctl start magichosts
Would be useful to include systemd scheduling information for those who wish to use the scheduler. These are the steps that I have noted after copying magichosts to /usr/local/bin and modifying as required
Confirm the details of the scheduling parameters. This will show the next 5 scheduled instances according to the parameters for OnCalendar.
Information on systemd timers at https://wiki.archlinux.org/title/Systemd/Timers
4. Enable the systemd timer with the following
i) Reload systemd
ii) Enable the timer to run on boot
iii) Start the timer immediately