Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

archive.sh compatible with Freebsd (using /bin/sh instead of /bin/bash) #1698

Closed
anonymous-piwik-user opened this Issue · 8 comments

4 participants

Anonymous Piwik user Anthon Pang Hans Fredrik Nordhaug Matthieu Aubry
Anonymous Piwik user

The archive.sh script is either broken or simply incompatible with Freebsd servers.

Attempting to run it as the root user as 'sh archive.sh' leads to:

Starting Piwik reports archiving...

Reports archiving finished.
Starting Scheduled tasks...

Error: You can't access this resource as it requires a 'superuser' access.Finished Scheduled tasks.

Running it via cron according to the directions listed at the setup-auto-archiving/ page leads to the following.

/usr/local/www/piwik/misc/cron/archive.sh: not found

That happens because bash is not installed by default on Freebsd servers. Further more the script references a non standard location of bash if it is installed. It should reference /usr/local/bin/bash. Installing and fixing the bash path and running it via cron leads to the following error:

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied

I figured I'd try here first in the hope that I'm making a mistake or missing something before I start tearing it apart in a attempt to make it work.

There is also a forum reference to the issue. I'll link to it once the forum's are back on line. They appear to be down right now.
Keywords: freebsd

Anthon Pang
Collaborator

Using #!/bin/bash in the script is a best guess. Loading up the shell depends on the scripting environment -- it happens before script execution, so there's nothing we can do. You can use:

/usr/local/bin/bash /path/to/script

The shell-init error means the cron job is running as a user who doesn't have read access to the shell script.

Hans Fredrik Nordhaug

Hi, sorry for re-opening this issue, but since the fix is so easy I hope that you can reconsider and make archive.sh use /bin/sh in stead of /bin/bash.

The point is that archive.sh doesn't use any bash specific features, and requiring people to install bash when sh will do is kind of, well, unnecessary.

Thx for listening. Now I'll go and update the Norwegian Bokml translation ;-)

Hans Fredrik Nordhaug

PS! I wasn't allowed to reopen it (no permission to change fields), so I had to leave it closed. Hopefully you'll notice it anyway.

Matthieu Aubry
Owner

if we change to bin/sh maybe it will break for some existing users?

Hans Fredrik Nordhaug

No, it won't break. /bin/sh is actually a standard (POSIX) for all Unix/Linux OS-es - quote from http://en.wikipedia.org/wiki/Shebang_(Unix):

"POSIX requires that /bin/sh is a shell capable of a syntax similar to the Bourne shell."

I would have pointed to the actual POSIX standard itself, but it's behind a pay wall.

Matthieu Aubry
Owner

(In [3639]) Fixes #1698 - I assume the -e parameter is still valid?

Hans Fredrik Nordhaug

Yes, the -e parameter means the same for sh and bash. (And to be sure I have tested ;-)

Thx!

Anonymous Piwik user

note on this:
the issue is not only in referencing sh or bash, but more importantly to avoid using special bash features that will not work in sh

Anonymous Piwik user anonymous-piwik-user added this to the Piwik 1.1 milestone
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.