Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the working directory configurable for the openvpn script #8

Open
ryanniehaus opened this issue Dec 28, 2015 · 16 comments
Open

Make the working directory configurable for the openvpn script #8

ryanniehaus opened this issue Dec 28, 2015 · 16 comments
Assignees

Comments

@ryanniehaus
Copy link
Owner

Per Issue #1:

@famewolf made the following comment: "I guess the only addition I would request is a method to overwrite what directory to use as when ran from cron.daily it tries to put the zip files in the /etc/cron.daily dir.....I hardcoded the dir in the previous version."

I think this is a good idea, and should be done when I have time.

@ryanniehaus ryanniehaus self-assigned this Dec 28, 2015
ryanniehaus added a commit that referenced this issue Dec 29, 2015
Made it so the working directory (and output directory) is now
configurable
@ryanniehaus
Copy link
Owner Author

@famewolf: This is implemented now

ryanniehaus added a commit that referenced this issue Dec 29, 2015
Added script usage info to git README.md
ryanniehaus added a commit that referenced this issue Dec 29, 2015
formatting of README for Issue #8
ryanniehaus added a commit that referenced this issue Dec 29, 2015
formatting of README for Issue #8
@famewolf
Copy link

IN Readme it says if the temp dir is not specified it falls back on script dir. What if the output dir is specified? It could also be used for temp files. I would think it would fall back to output dir first and then script. Or do you have to do it as ./script /home/famewolf/vpn /home/famewolf/vpn ?

@ryanniehaus
Copy link
Owner Author

You would have to specify it as script /home/famewolf/vpn /home/famewolf/vpn
That way you could specify the output directory and it could still use the script directory as a temp directory

@famewolf
Copy link

I think I'll just stick with the hardcoded one I have. I have the script symbolically linked to /etc/cron.daily so it runs on a schedule...as far as the script would be concerned it's "working dir" would be /etc/cron.daily which is not somewhere I want it writing.

@ryanniehaus
Copy link
Owner Author

If you just repeat directories, it won't try to write in the cron folder. You'd just have to have a another script that calls this one with the arguments you'd need. Or would you rather it look for an environment variable?

@famewolf
Copy link

No..I guess I had tunnel vision...I was so focused on the symbolic link to the script it never even occurred to me to do something simple like make a one line script to do the proper call. I'm sure there's an amusing acronym for that type of user error somewhere on the 'net. ;)

I tried simplifying things by having the script run directly on my freenas server which is also where the folder is shared from via smb but was unable to get the script to run correctly from the freebsd jail even after installing bash and the required tools. I'm currently playing around with freenas's virtualbox implementation and have created a ubuntu minimal VM...seems like a whole lot of work to try and have 1 machine keep 1 script updated. Maybe I need to rethink my approach...my end desire is to have the vpn folder sync'd to cloud storage so my android devices can pull in the folder with current user/pass since they can't run the script themselves.

@famewolf
Copy link

Just tried new version...would still stick with old one. Where before each different vpn got it's own unique subfolder of www.*vpnname*.com now they all end up lumped into the same folder?

While I do like being able to specify the output folder so the script could be put into a /bin dir and the output could be kept in a vpn folder I still would want each vpn separated.

@ryanniehaus
Copy link
Owner Author

Yeah, I've started using OpenVPN on Windows, and I don't think it searches
subdirectories. Maybe I'm mistaken.

The temp folder still has the subfolders. The output directory does not.
However temp=output, you'll have both.

On Wed, Dec 30, 2015, 6:58 PM famewolf [email protected] wrote:

Just tried new version...would still stick with old one. Where before each
different vpn got it's own unique subfolder of www.*vpnname*.com now they
all end up lumped into the same folder?


Reply to this email directly or view it on GitHub
#8 (comment)
.

@ryanniehaus
Copy link
Owner Author

Do you get any errors in the script when running from Freebsd?

On Thu, Dec 31, 2015, 6:11 AM Ryan Niehaus [email protected] wrote:

Yeah, I've started using OpenVPN on Windows, and I don't think it searches
subdirectories. Maybe I'm mistaken.

The temp folder still has the subfolders. The output directory does not.
However temp=output, you'll have both.

On Wed, Dec 30, 2015, 6:58 PM famewolf [email protected] wrote:

Just tried new version...would still stick with old one. Where before
each different vpn got it's own unique subfolder of www.*vpnname*.com
now they all end up lumped into the same folder?


Reply to this email directly or view it on GitHub
#8 (comment)
.

@famewolf
Copy link

When I ran the script to test I didn't specify a path at all...I just let it default to the script dir for both temp and output and that's when it dumped everything in one dir.

Yeah when I ran it, it had some errors I corrected...for instance it wanted "iconv -c -s -f" as opposed to "iconv -csf " but even after fixing obvious errors it still was going wrong....on the old version that did create subdir's it was still writing everything to the script dir so something was failing with the "domain_url" part (going from memory).

@ryanniehaus
Copy link
Owner Author

Have you tried the latest version? The iconv -c -s -f change I made because cygwin iconv didn't like the iconv -csf simplification.

I'm wondering if you still have issues on freebsd with it. (I'd like to make my script compatible with as many platforms as possible)

@famewolf
Copy link

famewolf commented Jan 2, 2016

I'll see about rebuilding the freebsd jail and try it again. I did finally get it working in a ubuntu minimal vm but the freebsd one would use far less resources. I wonder if freebsd has live usb images with persistence so you could install the necessary packages..would make testing easier.

@famewolf
Copy link

famewolf commented Jan 2, 2016

One change would be changing the first line to " #!/usr/bin/env bash" as bash is in /bin for linux and /usr/local/bin for freebsd. Using the env version makes it work in both places as documented here: https://news.ycombinator.com/item?id=7596191 or use #!/bin/sh which is universal if bash is not specifically needed.

@famewolf
Copy link

famewolf commented Jan 2, 2016

I've installed nano, bash, wget, and unix2dos to the shell...here is the output and it obviously goes south right from the beginning.

[root@FBSD /media/work]# ./vpnwork Using OUTPUT_DIR=/media/work Using TEMPORARY_DIR=/media/work Processing http://www.vpnbook.com/freevpn Domain http://www.vpnbook.com/freevpn mkdir: http://www.vpnbook.com: No such file or directory ./vpnwork: line 73: pushd: http://www.vpnbook.com/freevpn: No such file or directory --2016-01-01 20:19:29-- http://www.vpnbook.com/freevpn Resolving www.vpnbook.com (www.vpnbook.com)... 176.126.252.71 Connecting to www.vpnbook.com (www.vpnbook.com)|176.126.252.71|:80... connected. HTTP request sent, awaiting response... 200 OK Length: unspecified [text/html] Saving to: 'index.html'

index.html [ <=> ] 11.22K --.-KB/s in 0.1s

2016-01-01 20:19:30 (79.0 KB/s) - 'index.html' saved [11491]

./vpnwork: line 85: http://www.vpnbook.com/freevpn_username_password.txt: No such file or directory
./vpnwork: line 86: http://www.vpnbook.com/freevpn_username_password.txt: No such file or directory
cat: http://www.vpnbook.com/freevpn_username_password.txt: No such file or directory
rm: http://www.vpnbook.com/freevpn_username_password.txt: No such file or directory
head: illegal line count -- -1
./vpnwork: line 104: _http://www.vpnbook.com/freevpn_username_password.txt: No such file or directory
./vpnwork: line 105: _http://www.vpnbook.com/freevpn_username_password.txt: No such file or directory
_http://www.vpnbook.com/freevpn_username_password.txt: No such file or directory
./vpnwork: line 104: _http://www.vpnbook.com/freevpn_username_password.txt: No such file or directory
./vpnwork: line 105: _http://www.vpnbook.com/freevpn_username_password.txt: No such file or directory
_http://www.vpnbook.com/freevpn_username_password.txt: No such file or directory
--2016-01-01 20:19:33-- http://%3Cli%3E%3Ca/
Resolving

  • <a (
  • <a)... failed: hostname nor servname provided, or not known.
    wget: unable to resolve host address '
  • <a'
    --2016-01-01 20:19:35-- http://href=%22/free-openvpn-account/VPNBook.com-OpenVPN-Euro1.zip%22%3EEuro1
    Resolving href=" (href=")... failed: hostname nor servname provided, or not known.
    wget: unable to resolve host address 'href="'
    --2016-01-01 20:19:36-- http://openvpn/
    Resolving openvpn (openvpn)... failed: hostname nor servname provided, or not known.
    wget: unable to resolve host address 'openvpn'
    --2016-01-01 20:19:36-- http://certificate/
    Resolving certificate (certificate)... failed: hostname nor servname provided, or not known.
    wget: unable to resolve host address 'certificate'
    --2016-01-01 20:19:37-- http://bundle%3C/a%3E
    Resolving bundle< (bundle<)... failed: hostname nor servname provided, or not known.
    wget: unable to resolve host address 'bundle<'
    --2016-01-01 20:19:39-- http://%3C/li%3E%0D
    Resolving < (<)... failed: hostname nor servname provided, or not known.
    wget: unable to resolve host address '<'
    --2016-01-01 20:19:40-- http://%3Cli%3E%3Ca/
    Resolving
  • <a (
  • <a)... failed: hostname nor servname provided, or not known.
    wget: unable to resolve host address '
  • <a'
    --2016-01-01 20:19:40-- http://href=%22/free-openvpn-account/VPNBook.com-OpenVPN-Euro2.zip%22%3EEuro2
    Resolving href=" (href=")... failed: hostname nor servname provided, or not known.
    wget: unable to resolve host address 'href="'
    --2016-01-01 20:19:40-- http://openvpn/
    Resolving openvpn (openvpn)... failed: hostname nor servname provided, or not known.
    wget: unable to resolve host address 'openvpn'
    --2016-01-01 20:19:40-- http://certificate/
    Resolving certificate (certificate)... failed: hostname nor servname provided, or not known.
    wget: unable to resolve host address 'certificate'
    --2016-01-01 20:19:40-- http://bundle%3C/a%3E
    Resolving bundle< (bundle<)... failed: hostname nor servname provided, or not known.
    wget: unable to resolve host address 'bundle<'
    --2016-01-01 20:19:40-- http://%3C/li%3E%0D
    Resolving < (<)... failed: hostname nor servname provided, or not known.
    wget: unable to resolve host address '<'
    --2016-01-01 20:19:40-- http://%3Cli%3E%3Ca/
    Resolving
  • <a (
  • <a)... failed: hostname nor servname provided, or not known.
    wget: unable to resolve host address '
  • <a'
    --2016-01-01 20:19:40-- http://href=%22/free-openvpn-account/VPNBook.com-OpenVPN-US1.zip%22%3EUS1
    Resolving href=" (href=")... failed: hostname nor servname provided, or not known.
    wget: unable to resolve host address 'href="'
    --2016-01-01 20:19:40-- http://openvpn/
    Resolving openvpn (openvpn)... failed: hostname nor servname provided, or not known.
    wget: unable to resolve host address 'openvpn'
    --2016-01-01 20:19:40-- http://certificate/
    Resolving certificate (certificate)... failed: hostname nor servname provided, or not known.
    wget: unable to resolve host address 'certificate'
    --2016-01-01 20:19:40-- http://bundle%3C/a%3E
    Resolving bundle< (bundle<)... failed: hostname nor servname provided, or not known.
    wget: unable to resolve host address 'bundle<'
    --2016-01-01 20:19:40-- http://%3Cspan/
    Resolving <span (<span)... failed: hostname nor servname provided, or not known.
    wget: unable to resolve host address '<span'
    --2016-01-01 20:19:41-- http://class=%22red%22%3E(optimized/
    Resolving class="red">(optimized (class="red">(optimized)... failed: hostname nor servname provided, or not known.
    wget: unable to resolve host address 'class="red">(optimized'
    --2016-01-01 20:19:42-- http://for/
    Resolving for (for)... failed: hostname nor servname provided, or not known.
    wget: unable to resolve host address 'for'
    --2016-01-01 20:19:42-- http://fast/
    Resolving fast (fast)... 127.0.53.53
    Connecting to fast (fast)|127.0.53.53|:80... failed: Can't assign requested address.
    Retrying.

    --2016-01-01 20:19:44-- (try: 2) http://fast/
    Connecting to fast (fast)|127.0.53.53|:80... failed: Can't assign requested address.
    Retrying.

    --2016-01-01 20:19:46-- (try: 3) http://fast/
    Connecting to fast (fast)|127.0.53.53|:80... failed: Can't assign requested address.
    Retrying.

    --2016-01-01 20:19:49-- (try: 4) http://fast/
    Connecting to fast (fast)|127.0.53.53|:80... failed: Can't assign requested address.
    Retrying.

    --2016-01-01 20:19:53-- (try: 5) http://fast/
    Connecting to fast (fast)|127.0.53.53|:80... failed: Can't assign requested address.
    Retrying.

    --2016-01-01 20:19:58-- (try: 6) http://fast/
    Connecting to fast (fast)|127.0.53.53|:80... failed: Can't assign requested address.
    Retrying.

    --2016-01-01 20:20:04-- (try: 7) http://fast/
    Connecting to fast (fast)|127.0.53.53|:80... failed: Can't assign requested address.
    Retrying.

    ^C
    [root@FBSD /media/work]#

  • @ryanniehaus
    Copy link
    Owner Author

    @famewolf: Some reason your version of sed doesn't find a match with my sed expression.
    I've broken it up into three separate sed commands to simplify the expression and still accomplish the same goal. Hopefully this just works. I'm not sure why your sed works so differently from mine.

    @ryanniehaus
    Copy link
    Owner Author

    Oh... it looks like there are still going to be issues with the zip file downloads. I see the zip file parsing isn't working either

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants