I am on Debian 12 with Etckeeper and OpenVPN running as a service. If I manually start/stop openVPN, it modifies few files, including /etc/resolv.conf. I would like to run a script to automatically commit these changes. So I wrote a script (which is working on its own) and called it from the ExecStartPost/ExecStopPost of the VPN service. But the changes are never committed and I see a “Cannot Fork” error in the service logs
root@emporium:/etc# systemctl status openvpn@protonvpn.service
● openvpn@protonvpn.service - OpenVPN connection to protonvpn
Loaded: loaded (/lib/systemd/system/openvpn@.service; enabled-runtime; preset: enabled)
Drop-In: /etc/systemd/system/openvpn@protonvpn.service.d
└─override.conf
Active: active (running) since Mon 2025-08-04 20:12:59 BST; 1s ago
Docs: man:openvpn(8)
https://community.openvpn.net/openvpn/wiki/Openvpn24ManPage
https://community.openvpn.net/openvpn/wiki/HOWTO
Process: 3656008 ExecStartPost=/usr/local/sbin/commitVPNExecChanges.sh Start (code=exited, status=1/FAILURE)
Main PID: 3656004 (openvpn)
Status: "Initialization Sequence Completed"
Tasks: 1 (limit: 10)
Memory: 1.8M
CPU: 265ms
CGroup: /system.slice/system-openvpn.slice/openvpn@protonvpn.service
└─3656004 /usr/sbin/openvpn --daemon ovpn-protonvpn --status /run/openvpn/protonvpn.status 10 --cd /etc/openvpn --config /etc/openvpn/protonvpn.conf --writepid /run/openvpn/protonvpn.pid
Aug 04 20:12:55 emporium openvpn[3656034]: /sbin/resolvconf: 519: Cannot fork
Aug 04 20:12:55 emporium ovpn-protonvpn[3656004]: Initialization Sequence Completed
Aug 04 20:12:59 emporium commitVPNExecChanges.sh[3656110]: /etc/etckeeper/commit.d/20store-metadata: 17: Cannot fork
Aug 04 20:12:59 emporium commitVPNExecChanges.sh[3656115]: /etc/etckeeper/commit.d/20store-metadata: 23: Cannot fork
Aug 04 20:12:59 emporium commitVPNExecChanges.sh[3656109]: find: ‘standard output’: Broken pipe
Aug 04 20:12:59 emporium commitVPNExecChanges.sh[3656109]: find: write error
Aug 04 20:12:59 emporium commitVPNExecChanges.sh[3656158]: /etc/etckeeper/pre-commit.d/20warn-problem-files: 15: Cannot fork
Aug 04 20:12:59 emporium commitVPNExecChanges.sh[3656161]: /etc/etckeeper/pre-commit.d/20warn-problem-files: 16: Cannot fork
Aug 04 20:12:59 emporium commitVPNExecChanges.sh[3656163]: /etc/etckeeper/pre-commit.d/30store-metadata: 60: Cannot fork
Aug 04 20:12:59 emporium systemd[1]: Started openvpn@protonvpn.service - OpenVPN connection to protonvpn.
I don t understand why forking is not possible. I have tried different variations of the script without luck. The latest script version is as below
root@emporium:/etc# cat /usr/local/sbin/commitVPNExecChanges.sh
#!/bin/bash
command="$1"
is_etc_with_uncommited_changes=$(git -C /etc status --porcelain /etc 2>/dev/null | wc -l)
if [ $is_etc_with_uncommited_changes -gt 0 ]; then
etckeeper commit -m "Saving OpenVPN changes in /etc/resov.conf after $command"
fi
To modify the service, I ran systemctl edit on it, with the changes below
### Editing /etc/systemd/system/openvpn@protonvpn.service.d/override.conf
### Anything between here and the comment below will become the new contents of the file
[Service]
ExecStartPost=-/usr/local/sbin/commitVPNExecChanges.sh Start
ExecStopPost=-/usr/local/sbin/commitVPNExecChanges.sh Stop
### Lines below this comment will be discarded