kpise
January 20, 2023, 8:23pm
#1
Hello,
I have installed php on the router for basic rest api implementation. If I fire below command from putty, my server starts and I can browse the page.
php-cli -S 192.168.1.1:8080 -t /www
Somehow If I want startup script that runs along with boot, so that page is always available, below script is not working. can you help ? This script is visible in UI as well but always marked as disabled.
#!/bin/sh /etc/rc.common
# Example script
# Copyright (C) 2007 OpenWrt.org
START=99
STOP=15
start() {
echo php started
# commands to launch application
php-cli -S 192.168.1.1:8088 -t /www &&
}
stop() {
echo stop
# commands to kill application
}
kpise:
Somehow If I want startup script that runs along with boot, so that page is always available, below script is not working. can you help ? This script is visible in UI as well but always marked as disabled.
Just enable it in the UI.
LuCI > System > Startup and select Disabled to set it to Enabled
1 Like
hnyman
January 21, 2023, 7:43am
#3
Or set to enabled (= create a symlink in /etc/rc.d/
to the init script) by running /etc/init.d/yourscriptname enable
from SSH console.
(That is the action that the LuCI button triggers.)
kpise
January 21, 2023, 12:39pm
#4
When I set this script and reboot the router.
I get following error when I enable it.. its always marked as disabled. I think there is something missing.
There is some thing wrong at the end of command where && is used. Not sure if its required or not. If I remove it works, but looks after some times php server gets killed.
This leaves me to believe you’ve derived the code from somewhere else.
Is your intent to run this in background ?
1 Like
hnyman
January 21, 2023, 4:23pm
#6
Double && means "run next the command after &&", and there should be a command on the line after &&
A single & would mean a detached process to be run on the background.
I have a hunch that you are aiming for either
php-cli -S 192.168.1.1:8088 -t /www &
or
(php-cli -S 192.168.1.1:8088 -t /www )&
which would be a detached shell.
Once of those might work for you if you want to keep the process run even after the script should complete. I would go with the latter version.
Ps. google for Linux shell detach process
, and you should get more info.
1 Like