m13253 / VxWireguard-Generator

Utility to generate VXLAN over Wireguard mesh SD-WAN configuration
MIT License
150 stars 18 forks source link

feature request - add vwgen cli option to create N number of Node configs using a basename & a number specifying how many #9

Closed bmullan closed 4 years ago

bmullan commented 4 years ago

Could you add a vwgen command line option to create a large number of Node configs.

example: _

vwgen add wg-meshvpn node1 node2 node3

_ is fine for 2,3.. maybe 10 Nodes.

But what if you needed 50 Nodes (or more)? Specifying them all this way would be alot of repetitive typing.

Could some option be created to do this for the user.

example: _

vwgen add wg-meshvpn nameroot="string" numbernodes="#"

where: nameroot would be something like "node" or "cn" or anything where: numbernodes would be the number of "namerootXX" to maximum number of Node Configs to generate _

So

vwgen add wg-meshvpn nameroot=mycn numbernodes=25

would create 25 Node Configurations and they would be named as a concatenation of the "nameroot" and the "number" so in the above it would generate:

mycn1 mycn2 mycn3 ... mycn25

The above is just my .02 cents and there may be a better way to do this but I think it would be helpful to have something like this?

m13253 commented 4 years ago

What you want might be:

vwgen add wg-meshvpn $(seq -f 'mycn%.f' 50)
bmullan commented 4 years ago

@m13253

Cool I wasn't aware vwgen could execute an external program like 'seq'.

This works for me regarding this issue but read the section titled:

The seq command to create standard bash for Loop (outdated method)

Where it says...
_

WARNING! The seq command print a sequence of numbers and it is here due to historical reasons. The following examples is only recommend for older bash version. All users (bash v3.x+) are recommended to use the above syntax.

_

URL: https://www.cyberciti.biz/faq/bash-for-loop/