This hook should echo some text and create a new file with the current unix timestamp on every commit (this is just an example), but in actuality the commit proceeds normally as if there’s no hook.
PS C:\Users\brire> ssh vyos@172.20.48.130 -oidentitiesonly=true
vyos@172.20.48.130's password:
Welcome to VyOS!
Check out project news at https://blog.vyos.io
and feel free to report bugs at https://phabricator.vyos.net
You can change this banner using "set system login banner post-login" command.
VyOS is a free software distribution that includes multiple components,
you can check individual component licenses under /usr/share/doc/\*/copyright
Last login: Sun Jan 1 01:07:52 2023 from 172.20.48.1
vyos@vyos:~$ show conf
interfaces {
ethernet eth0 {
address dhcp
hw-id 00:15:5d:0c:7a:00
}
}
service {
ssh {
listen-address 0.0.0.0
}
}
vyos@vyos:~$ conf
[edit]
vyos@vyos# comment interfaces ethernet eth0 "just making a change so I can commit"
[edit]
vyos@vyos# commit
[edit]
vyos@vyos# ### Something should have happened.
[edit]
vyos@vyos# ls -l ~
total 0
[edit]
vyos@vyos# ### ...but nothing happened!!!
vyos@vyos# show
interfaces {
/* just making a change so I can commit */
ethernet eth0 {
address dhcp
hw-id 00:15:5d:0c:7a:00
}
}
service {
ssh {
listen-address 0.0.0.0
}
}
[edit]
vyos@vyos# ###So the commit did succeed! But the hooks were not run.
[edit]
vyos@vyos# ### Let's set this back and try again.
[edit]
vyos@vyos# comment interfaces ethernet eth0 ""
vyos@vyos# show
interfaces {
- /* just making a change so I can commit */
ethernet eth0 {
address dhcp
hw-id 00:15:5d:0c:7a:00
}
}
service {
ssh {
listen-address 0.0.0.0
}
}
[edit]
vyos@vyos# commit
[edit]
vyos@vyos# ### Still nothing!
Running on Hyper-V on Windows 11 and Windows Server 2022, if that matters.
I just tested this on 1.4-202212280917 and it works.
There is one little caveat though, the docs state:
Their names must consist entirely of ASCII upper- and lower-case letters,ASCII digits, ASCII underscores, and ASCII minus-hyphens.No other characters are allowed.
which I didn’t read, so my test.sh script didn’t run. Changing it to just test made it work. Could it be your script has a character in it that is not allowed?
I just tried putting your script in just in case something somehow was wrong with mine, and it still doesn’t work. I also tried with a fresh install of 1.4-202212280917 as you used, and oddly enough it worked once or twice but then stopped working. I cannot figure out what I did that broke it, but it definitely wasn’t anything too crazy.
Is it possible that adding a new system image and doing the config migration breaks the hook scripts? This is just a hunch, because the following caused the scripts to stop running:
but then rebooting back into the stock 1.4-202212280917 didn’t cause the script to start working again, so maybe it’s something to do with when the machine boots?
I’m really grasping at straws here I can’t seem to figure out what I could possibly be doing wrong myself, but then that means this is one of those weird bugs that just doesn’t always bug?
I have no idea how to debug this, because when I tried running set -x before committing the config I didn’t see the shell attempt to run the scripts amongst all the output, but looking in the vyos repo it seems that /opt/vyatta/sbin/my_commit (which is itself a symlink to /opt/vyatta/sbin/my_cli_bin) is responsible for running the hooks so I wouldn’t expect to see what’s wrong in the shell debug output.
I’ve tried using 755 and 775 permissions, and I’ve tried with /config/scripts/commit recursively chown’d to vyos:vyattacfg so I don’t think it’s permissions either