Multiple Clients Configurations and Open VPN

So, I have been scouring the internet all over for months and I can't find an easy way to do this. So, here we go:

Nowadays any VPN provider has thousands of server configurations and being able to switch trough them(using the less loaded one etc...) is somewhat necessary. But, while on a pc/Mac they will have their own app to easily switch to trough them on router that not usually possible.

What I'm trying to do is:

  • load all the .ovpn configuration files on the router(done),
  • making sure that all the .ovpn config points to an external password file(so I can change it if I need to change the password without having to go trough all the files) (done)
    I did that trough terminal before uploading using:
perl -pi -w -e 's/auth-user-pass/auth-user-pass secret.txt/g;' /path/*.ovpn
  • add automatically all those configurations files to the openvpn.conf (can't find an easy way to do it)

So, this is the openvpn.conf file:

config openvpn 'filename'
	option config '/etc/openvpn/filename.ovpn'

basically what I'm trying to figure out how to do is how to generate a new line from every single .ovpn file(1827 of them) using the filename(without symbols) in the first line and all the filenames and path in the second line.

what I would have once this is completed is a list, in the LUCI interface for ovpn, of all available servers to easily choose from.

Hopefully all of this is clear.
Thanks in advance

A little sh script might help, along the lines of

for c in $( ls /some/path/to/*.ovpn ) ; do $c

or, if there are too many arguments

find /some/path/to -name '*.ovpn' -exec {} \;
1 Like