21st Jan, 2014, 09:23 PM
Pages: 1 2
22nd Jan, 2014, 03:13 AM
(21st Jan, 2014 09:23 PM)josch Wrote: [ -> ]Sorry, didn't see your post until now...
If you are still interested, here's a template: http://werxltd.com/wp/2012/01/05/simple-init-d-script-template/
Okay, thanks a lot but I don't understand the script (still A kinda a noob)
Can you help me adjust it ?
22nd Jan, 2014, 11:07 PM
Here you go, I made a small startscript extra for you that is using screen to keep voicecommand running.
You need 'screen' installed to use it. If it's not, just run:
Then, to create the script just run:
Then paste in:
(Press Ctrl+O and Ctrl+X to save and close.)
Finally run:
That's it. Reboot and voicecommand should autostart and keep running.
You need 'screen' installed to use it. If it's not, just run:
Terminal
sudo apt-get install screen
Then, to create the script just run:
Terminal
sudo nano /etc/init.d/voicecommand
Then paste in:
Code:
#!/bin/sh
### BEGIN INIT INFO
# Provides: voicecommand
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start voicecommand via screen.
# Description: Start voicecommand via screen to keep running.
### END INIT INFO
USER=xbian
APP=voicecommand
case "$1" in
start)
if ! screen -list | grep -q $APP; then
echo "Starting $APP"
screen -dmS $APP su -c $APP $USER
else
echo "$APP already running"
exit 1
fi
;;
stop)
echo "Stopping $APP"
screen -S $APP -X quit
;;
*)
echo "Usage: voicecommand {start|stop}"
exit 1
;;
esac
exit 0
Finally run:
Terminal
sudo chmod +x /etc/init.d/voicecommand
sudo update-rc.d voicecommand defaults
sudo update-rc.d voicecommand defaults
That's it. Reboot and voicecommand should autostart and keep running.
22nd Jan, 2014, 11:10 PM
(22nd Jan, 2014 11:07 PM)josch Wrote: [ -> ]Here you go, I made a small startscript extra for you that is using screen to keep voicecommand running.
You need 'screen' installed to use it. If it's not, just run:
Terminalsudo apt-get install screen
Then, to create the script just run:
Terminalsudo nano /etc/init.d/voicecommand
Then paste in:
(Press Ctrl+O and Ctrl+X to save and close.)Code:
#!/bin/sh
### BEGIN INIT INFO
# Provides: voicecommand
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start voicecommand via screen.
# Description: Start voicecommand via screen to keep running.
### END INIT INFO
USER=xbian
APP=voicecommand
case "$1" in
start)
if ! screen -list | grep -q $APP; then
echo "Starting $APP"
screen -dmS $APP su -c $APP $USER
else
echo "$APP already running"
exit 1
fi
;;
stop)
echo "Stopping $APP"
screen -S $APP -X quit
;;
*)
S=/etc/init.d/${0##*/}
echo "Usage: $S {start|stop}"
exit 1
;;
esac
exit 0
Finally run:
Terminalsudo chmod +x /etc/init.d/voicecommand
sudo update-rc.d voicecommand defaults
That's it. Reboot and voicecommand should autostart and keep running.
How do you mean keep it running, I got a system witch kills it and restart it with a drifrent flag, so it won't interrupt with that?
23rd Jan, 2014, 02:41 AM
I solely mean that it will autostart when booting. Of course you can kill it.
will do the work. This will kill the screen session via
But why there is something running that will kill and restart it with different flags?
When does this happen? Why don't just start it with the right flags?
Let me know and I can help you.
Terminal
sudo service voicecommand stop
Terminal
screen -S voicecommand -X quit
But why there is something running that will kill and restart it with different flags?
When does this happen? Why don't just start it with the right flags?
Let me know and I can help you.
23rd Jan, 2014, 02:54 AM
(23rd Jan, 2014 02:41 AM)josch Wrote: [ -> ]I solely mean that it will autostart when booting. Of course you can kill it.thanks a lot : the reson why is :
will do the work. This will kill the screen session viaTerminalsudo service voicecommand stop
Terminalscreen -S voicecommand -X quit
But why there is something running that will kill and restart it with different flags?
When does this happen? Why don't just start it with the right flags?
Let me know and I can help you.
-f means diffrent VOC (voicecommand ) config file,
so i can make a menu.
for example i need to enter an vocal authorization code for shutdown.
in the main file i put shutdown==sudo killall voicecommand && sudo voicecommand -f/root/.shutdown.conf
in the conf i put
autorization code==sudo halt
see?
23rd Jan, 2014, 05:14 AM
So instead of sudo killall voicecommand you have to run sudo screen -S voicecommand -X quit if it's running in it's own screen session. (like from my startscript)
But one question: When your script ist just calling sudo voicecommand -f/root/.shutdown.conf, will it run in the background?
If so, there is no need for screen. I used it, because you said that you have to keep the terminal open to keep it running.
Anyhow, if you want to do exactly the same what you are doing now but within screen, just do:
shutdown==sudo screen -S voicecommand -X quit && sudo screen -dmS voicecommand voicecommand -f/root/.shutdown.conf
instead of
shutdown==sudo killall voicecommand && sudo voicecommand -f/root/.shutdown.conf
But one question: When your script ist just calling sudo voicecommand -f/root/.shutdown.conf, will it run in the background?
If so, there is no need for screen. I used it, because you said that you have to keep the terminal open to keep it running.
Anyhow, if you want to do exactly the same what you are doing now but within screen, just do:
shutdown==sudo screen -S voicecommand -X quit && sudo screen -dmS voicecommand voicecommand -f/root/.shutdown.conf
instead of
shutdown==sudo killall voicecommand && sudo voicecommand -f/root/.shutdown.conf
23rd Jan, 2014, 05:34 AM
(23rd Jan, 2014 05:14 AM)josch Wrote: [ -> ]So instead of sudo killall voicecommand you have to run sudo screen -S voicecommand -X quit if it's running in it's own screen session. (like from my startscript)What is the -dmS?
But one question: When your script ist just calling sudo voicecommand -f/root/.shutdown.conf, will it run in the background?
If so, there is no need for screen. I used it, because you said that you have to keep the terminal open to keep it running.
Anyhow, if you want to do exactly the same what you are doing now but within screen, just do:
shutdown==sudo screen -S voicecommand -X quit && sudo screen -dmS voicecommand voicecommand -f/root/.shutdown.conf
instead of
shutdown==sudo killall voicecommand && sudo voicecommand -f/root/.shutdown.conf
And the sudo nohup voicecommand keeps it in background
23rd Jan, 2014, 08:33 PM
(23rd Jan, 2014 05:34 AM)lukeg01 Wrote: [ -> ]What is the -dmS?
Terminal
xbian@xbian ~ $ screen -h
Use: screen [-opts] [cmd [args]]
or: screen -r [host.tty]
Options:
[...]
-dmS name Start as daemon: Screen session in detached mode.
[...]
Use: screen [-opts] [cmd [args]]
or: screen -r [host.tty]
Options:
[...]
-dmS name Start as daemon: Screen session in detached mode.
[...]
(23rd Jan, 2014 05:34 AM)lukeg01 Wrote: [ -> ]And the sudo nohup voicecommand keeps it in background
Okay, so just use screen instead of nohup. That way you can use my startscript and you're able to get into the running session whenever you want with:
Terminal
sudo screen -r voicecommand
As it seems that you want to run voicecommand as root, remember to change the USER var in the startscript to root.
Of course, you could even just delete the USER var and replace screen -dmS $APP su -c $APP $USER with screen -dmS $APP $APP
And here again your commands to kill and start again with other configuration:
kill
Terminal
sudo screen -S voicecommand -X quit
Terminal
sudo screen -dmS voicecommand voicecommand -f /your/custom/configfile
26th Jan, 2014, 03:58 AM
(23rd Jan, 2014 08:33 PM)josch Wrote: [ -> ](23rd Jan, 2014 05:34 AM)lukeg01 Wrote: [ -> ]What is the -dmS?
sudo killall voicecommand still works, is it a problem if i keep using killall?Terminalxbian@xbian ~ $ screen -h
Use: screen [-opts] [cmd [args]]
or: screen -r [host.tty]
Options:
[...]
-dmS name Start as daemon: Screen session in detached mode.
[...]
luke
(23rd Jan, 2014 05:34 AM)lukeg01 Wrote: [ -> ]And the sudo nohup voicecommand keeps it in background
Okay, so just use screen instead of nohup. That way you can use my startscript and you're able to get into the running session whenever you want with:
To exit the session again (but keep running), press Ctrl+a and then dTerminalsudo screen -r voicecommand
As it seems that you want to run voicecommand as root, remember to change the USER var in the startscript to root.
Of course, you could even just delete the USER var and replace screen -dmS $APP su -c $APP $USER with screen -dmS $APP $APP
And here again your commands to kill and start again with other configuration:
kill
start with custom confTerminalsudo screen -S voicecommand -X quit
Terminalsudo screen -dmS voicecommand voicecommand -f /your/custom/configfile
26th Jan, 2014, 05:33 AM
The problem with killall is, that it will kill die voicecommand running in the screen session but it won't kill the screen session itself.
So better kill the whole screen session if you don't need it anymore. But yes - if you are going to start voicecommand in the same
screen session again anyway, you can use killall. But then you have to start voicecommand that way:
(not tested, just got it from: http://superuser.com/questions/116743/send-command-to-an-already-running-screen-session)
So better kill the whole screen session if you don't need it anymore. But yes - if you are going to start voicecommand in the same
screen session again anyway, you can use killall. But then you have to start voicecommand that way:
Terminal
screen -S voicecommand -X stuff 'voicecommand'`echo -ne '\015'`
26th Jan, 2014, 05:41 AM
(26th Jan, 2014 05:33 AM)josch Wrote: [ -> ]The problem with killall is, that it will kill die voicecommand running in the screen session but it won't kill the screen session itself.
So better kill the whole screen session if you don't need it anymore. But yes - if you are going to start voicecommand in the same
screen session again anyway, you can use killall. But then you have to start voicecommand that way:
(not tested, just got it from: http://superuser.com/questions/116743/send-command-to-an-already-running-screen-session)Terminalscreen -S voicecommand -X stuff 'voicecommand'`echo -ne '\015'`
Well than I'll keep it at kill all sins there is always a active instance of voicecontrol
Pages: 1 2