Forum

Full Version: alsaproblems (want it for voicecommand)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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/
(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 ?
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:
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
(Press Ctrl+O and Ctrl+X to save and close.)

Finally run:
Terminal
sudo chmod +x /etc/init.d/voicecommand
sudo update-rc.d voicecommand defaults


That's it. Reboot and voicecommand should autostart and keep running.
(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:
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
;;

*)
S=/etc/init.d/${0##*/}
echo "Usage: $S {start|stop}"
exit 1
;;
esac

exit 0
(Press Ctrl+O and Ctrl+X to save and close.)

Finally run:
Terminal
sudo 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?
I solely mean that it will autostart when booting. Of course you can kill it.

Terminal
sudo service voicecommand stop
will do the work. This will kill the screen session via
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:41 AM)josch Wrote: [ -> ]I solely mean that it will autostart when booting. Of course you can kill it.

Terminal
sudo service voicecommand stop
will do the work. This will kill the screen session via
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.
thanks a lot : the reson why is :
-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?
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
(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)

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
What is the -dmS?
And the sudo nohup voicecommand keeps it in background
(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.
[...]



(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
To exit the session again (but keep running), press Ctrl+a and then d


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
start with custom conf
Terminal
sudo screen -dmS voicecommand voicecommand -f /your/custom/configfile
(23rd Jan, 2014 08:33 PM)josch Wrote: [ -> ]
(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.
[...]
sudo killall voicecommand still works, is it a problem if i keep using killall?

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:
Terminal
sudo screen -r voicecommand
To exit the session again (but keep running), press Ctrl+a and then d


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
start with custom conf
Terminal
sudo screen -dmS voicecommand voicecommand -f /your/custom/configfile
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:

Terminal
screen -S voicecommand -X stuff 'voicecommand'`echo -ne '\015'`
(not tested, just got it from: http://superuser.com/questions/116743/send-command-to-an-already-running-screen-session)
(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:

Terminal
screen -S voicecommand -X stuff 'voicecommand'`echo -ne '\015'`
(not tested, just got it from: http://superuser.com/questions/116743/send-command-to-an-already-running-screen-session)

Well than I'll keep it at kill all sins there is always a active instance of voicecontrol
Pages: 1 2
Reference URL's