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

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

Closed
anonymous-matomo-user opened this issue Sep 13, 2010 · 8 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc. Critical Indicates the severity of an issue is very critical and the issue has a very high priority.
Milestone

Comments

@anonymous-matomo-user
Copy link

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

@robocoder
Copy link
Contributor

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.

@hansfn
Copy link

hansfn commented Jan 4, 2011

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 ;-)

@hansfn
Copy link

hansfn commented Jan 4, 2011

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.

@mattab
Copy link
Member

mattab commented Jan 4, 2011

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

@hansfn
Copy link

hansfn commented Jan 5, 2011

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.

@mattab
Copy link
Member

mattab commented Jan 5, 2011

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

@hansfn
Copy link

hansfn commented Jan 5, 2011

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

Thx!

@anonymous-matomo-user
Copy link
Author

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

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. Critical Indicates the severity of an issue is very critical and the issue has a very high priority.
Projects
None yet
Development

No branches or pull requests

4 participants