Cacti: ss_fping.php is using a non-standard hashbang

Created on 28 Feb 2019  路  11Comments  路  Source: Cacti/cacti

Describe the bug
Since the change 33d99b73ffa8436c62c219e815c9f089fd4441b9 i had an problem with packaging cacti in openSUSE.

"Problem: nothing provides /bin/php"

Version 1.2.1:
scripts/ss_fping.php:

!/usr/bin/php -q

Version 1.2.2:
scripts/ss_fping.php:

!/bin/php -q

CLI bug resolved

All 11 comments

Certainly on Ubuntu/Debian it is installed to /usr/bin/php:

whereis php | sed 's/ /\n/g'
php:
/usr/bin/php7.2
/usr/bin/php
/usr/lib/php
/etc/php
/usr/include/php
/usr/share/php7.2-readline
/usr/share/php7.2-snmp
/usr/share/php7.2-bcmath
/usr/share/php7.2-common
/usr/share/php7.2-xml
/usr/share/php7.2-gd
/usr/share/php7.2-json
/usr/share/php
/usr/share/php7.2-mysql
/usr/share/php7.2-opcache
/usr/share/php7.2-mbstring
/usr/share/php7.2-ldap
/usr/share/php7.2-gmp
/usr/share/php7.2-curl
/usr/share/man/man1/php.1.gz

However, that is really only an issue if you are calling the script directly rather than prefixing it with php -q? Can you give more info on where it's causing you an issue?

Note: With the changes in 1.2.0, most commands would expect you to run them more the following style to allow logging to occur

sudo -u <website/poller user> php -q <script>

Packaging is no problem. After packaging i want to install the new RPM package. But this is not possible because i get following error:
"Problem: nothing provides /bin/php"

After creating a patch for the file "scripts/ss_fping.php" all works fine and i can install the new RPM Package.

PHP on openSUSE is also installed in /usr/bin/php:
Linux:~ # which php
/usr/bin/php

Would you be OK with removing the hashbang/shebang? None of the other scripts in that folder have one so it would make it more consistent. You could do that for now when packaging to keep it consistent too.

@DavidLiedke did that work for you? If so I'll commit it.

Everything else is pointed to /usr/bin/php. I suggest we follow suit on this one.

@DavidLiedke, fixed it.

What about FreeBSD. Default path /usr/local/bin/php.
Maybe use:
/usr/bin/env PATH=/usr/bin:/usr/local/bin php -q

Like I said earlier, I believe it better to remove the hashbangs, most of our scripts must run under the same user as the website/poller now or you'll end up with errors writing to files.

I suppose using the ENV method may work if the consensus is to leave them in

The env approach has gotten more and more popular more recently. We should target for 1.3. In the mean time, let's close this one.

Make sure to open a new issue as an enhancement for 1.3 @cigamit

Was this page helpful?
0 / 5 - 0 ratings