Piki wrote:
Properly, it should be "su -", not "su" (the - instructs it to set environmental variables).
Well, "properly" depends on your needs. That attempts to match a login environment, which isn't really necessary here. Plus, switching back from root's home directory could get annoying. I agree that there are cases when you may want that behavior depending on what activities you plan on doing as root, but in this case it's just to run some scripts within a constrained environment.
Quote:
I'd agree to use root instead of sudo, however the entire path should not be needed for executing scripts (provided they have the executable permission). Since the tutorial says to cd to the same directory as the scripts, you
should be able to use:
Code:
sudo ./clean-all
with no space beween the . and /. If they are setup as proper scripts, that should work no problem.
Not quite in this case. There are environment variables used to set defaults for the various openvpn easy-rsa scripts that sudo won't maintain (without -E). That is, vars sets up a series of environment variables that later scripts depend on. Your sudo command above would run clean-all without those variables set.
That's why it's simplest to switch to a root shell (or whatever environment you can then run all commands in) before doing anything else, since then sourcing vars will properly set up the common environment for the commands to follow.
I do think it's true that vars is the only script critical to directly source in the current shell - the rest can be run as regular scripts if desired, although sourcing them (as the library article shows) should be fine too. As long as however they are run maintains the parent environment.
-- David