Pivpn: Installer removes .pivpn directory mid-install (octopi)

Created on 14 Jun 2019  路  6Comments  路  Source: pivpn/pivpn

In raising this issue, I confirm the following:

{please fill the checkboxes, e.g: [X]}

  • [x] I have read and understood the contributors guide.
  • [x] The issue I am reporting can be replicated.
  • [x] The issue I am reporting can be is directly related to the pivpn installer script.
  • [x] The issue I am reporting isn't a duplicate (see FAQs, closed issues, and open issues).

Issue

  1. Install octopi on RPi 3B+
  2. Follow workaround for git clone #278
  3. ls -a /etc ... .pivpn is present
  4. sudo su; curl -L https://install.pivpn.io | bash
  5. Installer opens and gets through a few steps then fails, somehow removing /etc/.pivpn and then making it known.

The user installing is a sudoer. The default user pi has been locked using sudo passwd --lock pi. I select the user to be the secondary when prompted in the installer menu. The static IP settings have already been configured.

Have you searched for similar issues and solutions?

(yes/no / which issues?)

Manual git clone, i.e. #278 . sudo su; /usr/bin/git clone https://github.com/pivpn/pivpn.git /etc/.pivpn

Console output of curl -L https://install.pivpn.io | bash

$ sudo curl -L https://install.pivpn.io | bash
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   178  100   178    0     0    393      0 --:--:-- --:--:-- --:--:--   392
100 55086  100 55086    0     0  68981      0 --:--:-- --:--:-- --:--:-- 68981
:::
::: sudo will be used for the install.
::: Verifying free disk space...
:::
::: Checking apt-get for upgraded packages.... done!
:::
::: Your system is up to date! Continuing with PiVPN installation...
::: Static IP already configured.
::: Using User: alsdkjfasldjfk
:::
::: Checking for existing base files...
:::    Checking /etc/.pivpn is a repo...:::     Updating repo in /etc/.pivpn...shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
main: line 565: cd: /etc/.pivpn: No such file or directory

Console output of pivpn add or pivpn add nopass

  Output Here

Console output of pivpn debug

-bash: pivpn: command not found
418: I'm a teapot.

Have you taken any steps towards solving your issue?

Rebuild OS, retried install process as described.
information

Most helpful comment

OK, here's a bodge workaround which seems to work properly and is least-messy. These steps are not heavily-optimised but should hopefully be helpful. This approach does not require the manual git-clone procedure - instead, we just patch the installer script so it works properly with Octopi's silly quirk.

Rather than using the standard one-liner install, download the installer script and rename it (and make it executable):

  1. wget https://install.pivpn.io (downloads the script, it ends up as a file called index.html)
  2. mv index.html pivpn-install.sh (renames that index.html to something more sensible)
  3. chmod u+x pivpn-install.sh (makes that file Executable, which we will need later)

Then edit the script, to change the key invocations of git to specifically use /usr/bin/git (which avoids Octopi's annoying thing) - here's hand-holding instructions for doing this with Nano:

  1. nano pivpn-install.sh (opens the downloaded script in the nano editor)
  2. Press Ctrl+W then type make_repo(), press Return (searches for that text string)
  3. Cursor-down to the line which starts $SUDO git clone ... (immediately underneath the line $SUDO rm -rf "${1}")
  4. Change it so it starts $SUDO /usr/bin/git clone ... (adding "/usr/bin/" in front of "git")
  5. Move further down the file to the function "update_repo()"
  6. Find another line in that function starting $SUDO git clone ... (again, immediately underneath the line $SUDO rm -rf "${1}")
  7. Change that line so it also starts $SUDO /usr/bin/git clone ... (adding "/usr/bin/" in front of "git")
  8. Press Ctrl+X to exit Nano, typing a y when it asks if you want to save changes.

Now, execute that locally-edited version of the installer script - sudo ./pivpn-install.sh

The script will still delete /etc/.pivpn as before - but this time it should actually succeed in re-git-cloning the repository (thus re-creating and repopulating that folder), so it should run-through and complete "like normal".

Using the above process, I have managed to get PiVPN installed and working on my OctoPi setup, so hopefully it will also work for others.

All 6 comments

I don't have a proper fix, nor even a succeeded bodge-fix at this point, but I've been running in to this same problem this evening and I do have some observations.

The installer script (the thing fetched by curl from install.pivpn.io), in its function "clone_or_update_repos", calls the other function "getGitFiles", which either calls "update_repo" or "make_repo". The function "make_repo" ALWAYS deletes the folder where it wants to re-create the git repository clone (to whit, /etc/.pivpn/) before re-cloning the git repo, the function "update_repo" can be told NOT to delete-and-reclone if the undocumented "--reconfigure" switch was passed to the install script.

(Of course, the attempt it makes to re-clone after deleting doesn't work on Octopi because that interferes with sudo git commands - net result, the folder just got baleeted.)

I have tried downloading the installer script (rather than the official "pipe it into bash" approach) after doing the manual git-clone as described on the other Issue, running it with sudo ./pivpn-installer.sh --reconfigure (which does appear to re-do the "installing things phase").

The install (done that way) appeared to work, I could get an oVPN client to reach it from the local LAN (changing the external hostname reference in the generated .ovpn config file to the relevant local IP), but it wasn't playing ball from external. So it's possible that trying to do an "install without messing up /etc/.pivpn/" by passing the --reconfigure switch in somehow-doesn't-quite-work, or it's entirely possible that there's something else non-pivpn-related in my environments which is messing things up for me. Maybe it's worth a try?

I have run out of energy to try to figure this particular stuff out this evening and I might just install it on a different rPi in my fleet of far-too-many tomorrow. The ramblings above may or may not help you bodge your way to a successful install - but I can be pretty confident in saying that the root cause of our problem here is Octopi playing mother-knows-best with sudo git.

OK, here's a bodge workaround which seems to work properly and is least-messy. These steps are not heavily-optimised but should hopefully be helpful. This approach does not require the manual git-clone procedure - instead, we just patch the installer script so it works properly with Octopi's silly quirk.

Rather than using the standard one-liner install, download the installer script and rename it (and make it executable):

  1. wget https://install.pivpn.io (downloads the script, it ends up as a file called index.html)
  2. mv index.html pivpn-install.sh (renames that index.html to something more sensible)
  3. chmod u+x pivpn-install.sh (makes that file Executable, which we will need later)

Then edit the script, to change the key invocations of git to specifically use /usr/bin/git (which avoids Octopi's annoying thing) - here's hand-holding instructions for doing this with Nano:

  1. nano pivpn-install.sh (opens the downloaded script in the nano editor)
  2. Press Ctrl+W then type make_repo(), press Return (searches for that text string)
  3. Cursor-down to the line which starts $SUDO git clone ... (immediately underneath the line $SUDO rm -rf "${1}")
  4. Change it so it starts $SUDO /usr/bin/git clone ... (adding "/usr/bin/" in front of "git")
  5. Move further down the file to the function "update_repo()"
  6. Find another line in that function starting $SUDO git clone ... (again, immediately underneath the line $SUDO rm -rf "${1}")
  7. Change that line so it also starts $SUDO /usr/bin/git clone ... (adding "/usr/bin/" in front of "git")
  8. Press Ctrl+X to exit Nano, typing a y when it asks if you want to save changes.

Now, execute that locally-edited version of the installer script - sudo ./pivpn-install.sh

The script will still delete /etc/.pivpn as before - but this time it should actually succeed in re-git-cloning the repository (thus re-creating and repopulating that folder), so it should run-through and complete "like normal".

Using the above process, I have managed to get PiVPN installed and working on my OctoPi setup, so hopefully it will also work for others.

Will try this later today and provide an update. I truly appreciate you taking the time to take a deeper look at it. From the other thread I read it seems like the octopi build is just... special.

I literally ran in to the same situation as you had, about 12-ish hours after you had opened this thread. I wasn't solving your problem for you, I was solving my problem for me! Sharing what I initially-found, and then the workaround that fixed it for me, is just being a good internet-neighbour.

My best guess on why Octopi blocks sudo git is that maybe their project has had issues with people reflexively doing sudo for everything even when it's not required or appropriate, causing needless support issues for them, so they put in a block. That works ok within their range of expected use-cases, but when trying to use a script which presumes normal Linux behaviour (where tools do exactly what they are told without so much second-guessing) then Things Don't Work Properly.

My workaround just takes the little grain of knowledge from the other Issue (that sudo /usr/bin/git is NOT blocked) and puts it into the install script.

thanks @BuxtonTheRed , your workaround did work for me. not the first time, but trying 2 or 3 consecutive times and selecting "reconfiguration" instead of "update" in the setup worked for me :D

the first time I got this error :

pi@octopi:~ $ sudo ./pivpn-install.sh
[sudo] password for pi:
:::
::: You are root.
::: Reconfigure option selected
::: Verifying free disk space...
:::
::: Checking apt-get for upgraded packages.... done!
:::
::: There are 96 updates available for your system!
::: We recommend you update your OS after installing PiVPN!
:::
::: Static IP already configured.
::: Using User: pi
:::
::: Checking for existing base files...
:::    Checking /etc/.pivpn is a repo... OK!
:::     Updating repo in /etc/.pivpn...fatal: repository '' does not exist
./pivpn-install.sh: line 565: cd: /etc/.pivpn: No such file or directory

but when I run sudo ./pivpn-install.sh for the second time it worked :D

PS : btw, for the replacing of $SUDO git to $SUDO /usr/bin/git I just opened the file with notepadd++ using filezilla and execute a search and replace and uploaded back to pi.

This is the main reason why octopi doesn't work correctly with PiVPN: https://github.com/guysoft/OctoPi/issues/373

and the main reason why we didn't bothered much to support it, however i see some changes have been made and this might fix your issues.

https://github.com/guysoft/OctoPi/pull/374

I will be adding this to our wiki for future reference.
If any of you can confirm if this solves your issue or not would be great we can close this chapter.

Edit:

Update here: https://github.com/pivpn/pivpn/wiki/FAQ#what-about-octopi
Hope it helps. and fixes your problems.. let me know if got any easier.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kimbauters picture kimbauters  路  7Comments

fortresscrasher picture fortresscrasher  路  3Comments

peterHendrickx picture peterHendrickx  路  4Comments

InnovativeInventor picture InnovativeInventor  路  6Comments

m4rtini2 picture m4rtini2  路  3Comments