The current install.php creates an empty config.php file, this fixes the logic and creates a proper configuration file
I'm going to recheck the issue+PR shortly and report back. I agree that there might be a typo in the variablename containing the file-handle. This would indeed need fixing.
Thank you very much for the quick response.
Yes I have verified that the file doesn't exist, the one that is written is empty and this is the only way I could get it write a non-empty config.php file
Oh for the ?> part, I took that from the config.php file on the VMware image
Thanks for the PR. Whilst @f0o checks it over could you sign the contributors agreement. As an example: #953
It's not too important on this one as I wrote install.php so pretty confident no copyright issues with the changes, however for other PRs it might be needed so easier to just do it now :)
On this PR, if you can push a new commit that removes ?> from the end of config.php that would be good, we've dropped this from all other places now as it can lead to issues if left in.
Ok its that filehandle variable-typo.
I'm at my family's currently so I'm bound to to phone-browser :S
@laf you can take over if you're bored :)
@laf so I just write this "I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md." ?
@mohshami You put that in the commit message and just add your details to the Contributing.md file as you see others have done :)
@f0o I'll try and get to this also soon.
Reverted the commit and created a new one with the required changes
Update install.php to prevent creating an empty config.php file
I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md.
Hi @mohshami, testing this patch for me causes a 500 error due to this line being commented out:
#$install_dir = array_pop($cur_dir);
What's the reason for this to be commented out?
I'm running the code on FreeBSD 10.1, librenms is installed in /usr/local/www/librenms
$_SERVER['DOCUMENT_ROOT'] = /usr/local/www/librenms/html
After running $install_dir = implode('/',$cur_dir); $install_dir should be /usr/local/www/librenms and not /usr/local/www, which is I why I commented out the second $install_dir = array_pop($cur_dir); line
Should $_SERVER['DOCUMENT_ROOT'] be equal to a sub folder in html? or should install_dir point to /usr/local/www/ in the end?
The implode creates the array and then pops two elements off the end, the first being blank (/usr/local/www/librenms/ ends with BLANK usr local www librenms html BLANK) the second being html so you end up with /usr/local/www/librenms when it's imploded back.
It's a hack to get the true install location, if you leave it in it should be all ok.
If I leave it the final value will be /usr/local/www, not /usr/local/www/librenms
Could this be an nginx issue?
Yup quite possibly. You'd need to code to be compatible with nginx and apache, at present apache works so I'd prefer not to merge this change and affect the majority of users :)
Of course, I'd like to give it a shot to have both versions working.
For your setup, what is the value of $_SERVER['DOCUMENT_ROOT']?
For me it's:
Awesome, thanks mate.
The issue was simpler than I expected, for you there is a "/" at the end of $_SERVER['DOCUMENT_ROOT'], but for me there wasn't. I'm not a PHP guy and this didn't register for me. When I changed the following setting in nginx
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param DOCUMENT_ROOT $document_root/;
$_SERVER['DOCUMENT_ROOT'] changed and now it ends with a "/" and removing the comment works the same way it does for you, no change needed. I will remove the commit and add the code again
No worries :)
No need to remove the commit btw, just add a new one with the changes. Before re-submitting you will need to update your local install as other PRs have been done since this one and the AUTHORS.md file is now out of sync.
$install_dir = array_pop($cur_dir);
line. Issue was happening because nginx doesn't add a trailing slash to DOCUMENT_ROOT. Simple change to nginx configuration adds that so no need to edit the code here.
Fixed conflict with AUTHORS.md
Thanks for the info mate.
Removed comment from install.php and updated AUTHORS.md
Merged changes with upstream and fixed AUTHORS.md
Merge remote-tracking branch 'upstream/master'
Nearly there :)
So now when the file creation fails the user isn't shown any errors or anything. This patch will fix that for now, needs tidying up but we can do that later:
If you apply that and commit the update it should be good to go. One comment on how you've done the PR is that you're working in your master branch which isn't really the best way. We can merge this time around but it would be worth you having a look at http://docs.librenms.org/Developing/Using-Git/ to get a better idea of how to work using git locally before submitting a PR :)
Add logic to handle the case where config.php cannot be written for s…
Forgive me for forgetting that.
So far I've only used git for personal projects where I haven't done any collaboration with other people, and this is my first PR.
I will read your document. Thanks again my friend :)
No problem at all @mohshami.
I'll retest this tomorrow and then merge all being well :)
Have a pleasant night