I'm building a system, using buildroot, that will have a webpage to control a raspberry's GPIO pins, using php. To do so, I'm writing (and reading) the kernel files located in /sys/class/gpio/.. the problem is that apache doesn't have permission to write or read in such directories and files. I can make it work by changing all directories permissions to:
chmod a+rx dir_name
But this has to be executed everytime the system is turned on since that the /sys/... permissions are reset to default when the system is turned off.
So I would like to know what's the easiest way to solve this problem? Not forgetting that at some point I might write into /sys/class/gpio/export a GPIO number creating a new directory (/sys/class/gpio/gpioN/ where N is the pin number) with new files wich permissions need to be changed aswell.
I'm not very skilled in this kind of stuff but the only way I can think of making it work is to run a script at boot that would export all GPIO pins (write in /sys/class/gpio/export) and then change the permissions of all directories and files. The problem is that I have no clue how to do such scripts, besides that it needs to be in /etc/init.d directory. I've looked in some of the files in this directory but can't understand them, what language is it written?
I found in a post that to find the apache user I can run the following command:
ps aux | egrep '(apache|httpd)'
Wich outputs the following:
135 root /usr/bin/httpd -k start 138 daemon /usr/bin/httpd -k start 139 daemon /usr/bin/httpd -k start 140 daemon /usr/bin/httpd -k start 1133 root egrep (apache|http)