I am writing a web frontend for configuring OpenWRT. I'm using PHP to execute commands and all the uci commands are executing without issues. However, OpenVPN configurations cannot be done via UCI and I have to use direct Unix commands on its config file.
These commands run fine in my terminal, but not in PHP:
shell_exec(" cd /etc/openvpn && sed -i '2s/.*/remote 5-nl.cg-dialup.net 443/' openvpn.ovpn && cd'");
shell_exec(" cd /etc/openvpn && sed -i '30s/.*/ca /etc/openvpn/Nethelands/ca.crt/' openvpn.ovpn && cd'");
shell_exec(" cd /etc/openvpn && sed -i '32s/.*/cert /etc/openvpn/Nethelands/client.crt/' openvpn.ovpn && cd'");
shell_exec(" cd /etc/openvpn && sed -i '34s/.*/key /etc/openvpn/Nethelands/client.key/' openvpn.ovpn && cd'");
How can I get the tasks above done in PHP? Do I need to write a shell script, or do I need to change the uhttpd permissions?
I am running php on top of uhttpd web server in Openwrt Chaos calmer. with raspberry pi2