Page MenuHomeVyOS Platform

Restore pre/postconfig scripts if user deleted them
Closed, ResolvedPublicBUG

Description

If user deletes pre/postconfig scripts from directory /config/scripts then its not obvious how to restore the empty editions since they will only show up on a fresh install.

Bugfix is to adjust /usr/libexec/vyos/init/vyos-router so except for copying the empty scripts (if scripts are missing in /config/scripts) it will also set proper group and permission.

This will also fix the issue where preconfig script doesnt show up after an upgrade (add system image) as described in: https://vyos.dev/T5436

Details

Difficulty level
Unknown (require assessment)
Version
VyOS 1.4-rolling-202308050917
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Improvement (missing useful functionality)

Event Timeline

Verified in VyOS 1.4-rolling-202308140557:

1: Delete the scripts (vyos-preconfig-bootup.script and vyos-postconfig-bootup.script) in /config/scripts and reboot.

2: The scripts have been restored after reboot:

vyos@vyos:~$ sudo ls -la /config/scripts
total 16
drwxrwsr-x 2 root vyattacfg 4096 Aug 14 23:49 .
drwxrwxr-x 9 root vyattacfg 4096 Aug 14 23:49 ..
-rwxr-x--- 1 root vyattacfg  230 Aug 14 23:49 vyos-postconfig-bootup.script
-rwxr-x--- 1 root vyattacfg  225 Aug 14 23:49 vyos-preconfig-bootup.script

I have two scripts
Is it ok?

vyos@r14:~$ sudo ls -la /config/scripts/vyos-postconfig-boot*
-rwxrwxr-x 1 root vyattacfg 413 Sep  6 15:04 /config/scripts/vyos-postconfig-boot.script
-rwxrwxr-x 1 root vyattacfg 230 Jun 27 06:17 /config/scripts/vyos-postconfig-bootup.script
vyos@r14:~$

According to https://github.com/vyos/vyos-1x/blob/current/src/init/vyos-router it should be named:

/config/scripts/vyos-preconfig-bootup.script
/config/scripts/vyos-postconfig-bootup.script

Which also matches the content of the manual:

https://docs.vyos.io/en/latest/automation/command-scripting.html?highlight=preconfig#preconfig-on-boot

Whats the content of that /config/scripts/vyos-postconfig-boot.script ?

Could it be some leftover from previous install that is the timetag of "Sep 6 15:04" is when you did a add system image?

Anyhow unless you call that *boot.script from elsewhere it doesnt seem to be called by VyOS itself (which according to above source link is calling *bootup.script) so if you have a backup of that file it should be safe to delete it (again depending on its content, move the content to the *bootup.script file).