Script to create a openVPN .conf file for OpenWRT with multiple client configuration

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I'm trying to automatically generate, from hundreds of files(ovpn client configurations), a config file for openVPN on a openWRT router.
My problem is that I have hundreds of connection and I need the ability to choose between each one every time I start. To do that I need a configuration file that points to each one of those files.
I've been trying to figure out how to generate this file for a long time but no luck from google.



Example of Configuration:



config openvpn '*filenamewithoutdots*'
option config '/etc/openvpn/*filename*'
option enabled '1'


So if I I have these files in a folder:



server1.domain.com.ovpn
server2.domain.com.ovpn
server3.domain.com.ovpn


the script should return a configuration file like this



config openvpn 'server1domaincomovpn'
option config '/etc/openvpn/server1.domain.com.ovpn'
option enabled '1'

config openvpn 'server2domaincomovpn'
option config '/etc/openvpn/server2.domain.com.ovpn'
option enabled '1'

config openvpn 'server3domaincomovpn'
option config '/etc/openvpn/server3.domain.com.ovpn'
option enabled '1'


Bonus points if it removes the extension from the first line as well. But to work it needs all symbols removed in the first line. Alternatively(if simpler) it can put in the first line just the text till the point



more info:
1. the files are openvpn configuration files, but their content is not relevant.
2. Filenames are added in the configuration files, the files then are side loaded on the router in a different folder.



Any idea?



thanks in advance







share|improve this question


























    up vote
    0
    down vote

    favorite












    I'm trying to automatically generate, from hundreds of files(ovpn client configurations), a config file for openVPN on a openWRT router.
    My problem is that I have hundreds of connection and I need the ability to choose between each one every time I start. To do that I need a configuration file that points to each one of those files.
    I've been trying to figure out how to generate this file for a long time but no luck from google.



    Example of Configuration:



    config openvpn '*filenamewithoutdots*'
    option config '/etc/openvpn/*filename*'
    option enabled '1'


    So if I I have these files in a folder:



    server1.domain.com.ovpn
    server2.domain.com.ovpn
    server3.domain.com.ovpn


    the script should return a configuration file like this



    config openvpn 'server1domaincomovpn'
    option config '/etc/openvpn/server1.domain.com.ovpn'
    option enabled '1'

    config openvpn 'server2domaincomovpn'
    option config '/etc/openvpn/server2.domain.com.ovpn'
    option enabled '1'

    config openvpn 'server3domaincomovpn'
    option config '/etc/openvpn/server3.domain.com.ovpn'
    option enabled '1'


    Bonus points if it removes the extension from the first line as well. But to work it needs all symbols removed in the first line. Alternatively(if simpler) it can put in the first line just the text till the point



    more info:
    1. the files are openvpn configuration files, but their content is not relevant.
    2. Filenames are added in the configuration files, the files then are side loaded on the router in a different folder.



    Any idea?



    thanks in advance







    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm trying to automatically generate, from hundreds of files(ovpn client configurations), a config file for openVPN on a openWRT router.
      My problem is that I have hundreds of connection and I need the ability to choose between each one every time I start. To do that I need a configuration file that points to each one of those files.
      I've been trying to figure out how to generate this file for a long time but no luck from google.



      Example of Configuration:



      config openvpn '*filenamewithoutdots*'
      option config '/etc/openvpn/*filename*'
      option enabled '1'


      So if I I have these files in a folder:



      server1.domain.com.ovpn
      server2.domain.com.ovpn
      server3.domain.com.ovpn


      the script should return a configuration file like this



      config openvpn 'server1domaincomovpn'
      option config '/etc/openvpn/server1.domain.com.ovpn'
      option enabled '1'

      config openvpn 'server2domaincomovpn'
      option config '/etc/openvpn/server2.domain.com.ovpn'
      option enabled '1'

      config openvpn 'server3domaincomovpn'
      option config '/etc/openvpn/server3.domain.com.ovpn'
      option enabled '1'


      Bonus points if it removes the extension from the first line as well. But to work it needs all symbols removed in the first line. Alternatively(if simpler) it can put in the first line just the text till the point



      more info:
      1. the files are openvpn configuration files, but their content is not relevant.
      2. Filenames are added in the configuration files, the files then are side loaded on the router in a different folder.



      Any idea?



      thanks in advance







      share|improve this question














      I'm trying to automatically generate, from hundreds of files(ovpn client configurations), a config file for openVPN on a openWRT router.
      My problem is that I have hundreds of connection and I need the ability to choose between each one every time I start. To do that I need a configuration file that points to each one of those files.
      I've been trying to figure out how to generate this file for a long time but no luck from google.



      Example of Configuration:



      config openvpn '*filenamewithoutdots*'
      option config '/etc/openvpn/*filename*'
      option enabled '1'


      So if I I have these files in a folder:



      server1.domain.com.ovpn
      server2.domain.com.ovpn
      server3.domain.com.ovpn


      the script should return a configuration file like this



      config openvpn 'server1domaincomovpn'
      option config '/etc/openvpn/server1.domain.com.ovpn'
      option enabled '1'

      config openvpn 'server2domaincomovpn'
      option config '/etc/openvpn/server2.domain.com.ovpn'
      option enabled '1'

      config openvpn 'server3domaincomovpn'
      option config '/etc/openvpn/server3.domain.com.ovpn'
      option enabled '1'


      Bonus points if it removes the extension from the first line as well. But to work it needs all symbols removed in the first line. Alternatively(if simpler) it can put in the first line just the text till the point



      more info:
      1. the files are openvpn configuration files, but their content is not relevant.
      2. Filenames are added in the configuration files, the files then are side loaded on the router in a different folder.



      Any idea?



      thanks in advance









      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 6 '17 at 15:08

























      asked Dec 6 '17 at 15:00









      Beagleboys

      13




      13

























          active

          oldest

          votes











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f409231%2fscript-to-create-a-openvpn-conf-file-for-openwrt-with-multiple-client-configura%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f409231%2fscript-to-create-a-openvpn-conf-file-for-openwrt-with-multiple-client-configura%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay