WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [HELP] Alternative app autostart methods?  (Read 4316 times)

Offline binarydemon

  • Newbie
  • *
  • Posts: 35
[HELP] Alternative app autostart methods?
« on: January 29, 2018, 10:04:12 AM »
Hi,

Some quick background, I'm trying to create a DOSBox distro - a LIVEUSB where TinyCore starts up and loads a FullScreen DOSBox. I'm largely following the setup described here: http://forum.tinycorelinux.net/index.php?topic=17948  I'm still very new to Linux, but when I'm motivated I'm a quick learner.

Now the question, while booting directly to Full Screen DOSBox was easy enough, I became concerned there might be issues with incorrect shutdown - especially since it's a usb device.

What I want to do is:  dosbox && sudo poweroff

When I boot into X, and type this in the terminal manually it works perfectly: DosBox runs, when the user types the dos command 'exit', dosbox closes, poweroff executes, and the machine shuts down.

When I run 'dosbox && sudo poweroff &' from a file in /.X.d/ tinycore loads and immediately powers off. Amusing and frustrating. Basically both commands run concurrently there.

I attempted to put 'dosbox && sudo poweroff &' in /opt/bootsync.sh but it seemed to be ignored (not sure if thats because of my install type or a scripting error).

Is there another way to autorun this after X has loaded, or see a mistake?

-BinaryDemon




Check out DOSBox Distro - https://sites.google.com/site/dosboxdistro/

A tinycore LIVEUSB that makes playing your dos games anywhere very simple.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11641
Re: [HELP] Alternative app autostart methods?
« Reply #1 on: January 29, 2018, 10:25:15 AM »
Hi binarydemon
If it were me I'd create a file in  /home/tc/.local/bin  called  StartDosbox  containing:
Code: [Select]
dosbox
sudo poweroff
and place the command:
Code: [Select]
StartDosbox &in a file in  .X.d.

Offline binarydemon

  • Newbie
  • *
  • Posts: 35
Re: [HELP] Alternative app autostart methods?
« Reply #2 on: January 29, 2018, 11:40:16 AM »
I'll test in a few hours and report back. Thanks!
Check out DOSBox Distro - https://sites.google.com/site/dosboxdistro/

A tinycore LIVEUSB that makes playing your dos games anywhere very simple.

Offline binarydemon

  • Newbie
  • *
  • Posts: 35
Re: [HELP] Alternative app autostart methods?
« Reply #3 on: January 29, 2018, 08:22:06 PM »
Sorry to report, same behavior.

When I execute StartDosBox.sh from terminal it works perfect.  When the same script is called from .X.d. both dosbox and sudo poweroff execute at the same time.

Another thing puzzling me that is likely unrelated, any reason why the boot code 'noicons' would be ignored? Everything else on my append line is executing correctly, but the wbar stubbornly remains.

Check out DOSBox Distro - https://sites.google.com/site/dosboxdistro/

A tinycore LIVEUSB that makes playing your dos games anywhere very simple.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11641
Re: [HELP] Alternative app autostart methods?
« Reply #4 on: January 29, 2018, 08:39:08 PM »
Hi binarydemon
If it were me I'd create a file in  /home/tc/.local/bin  called  StartDosbox  containing:
Code: [Select]
dosbox
sudo poweroff
I think that should have been:
Code: [Select]
#!/bin/sh
dosbox
sudo poweroff

Offline binarydemon

  • Newbie
  • *
  • Posts: 35
Re: [HELP] Alternative app autostart methods?
« Reply #5 on: January 29, 2018, 08:45:22 PM »
Yeah I did that. And chmod +x StartDosBox.sh

I think I need another way to launch it, maybe use a scheduler like cron.
Check out DOSBox Distro - https://sites.google.com/site/dosboxdistro/

A tinycore LIVEUSB that makes playing your dos games anywhere very simple.

Offline binarydemon

  • Newbie
  • *
  • Posts: 35
Re: [HELP] Alternative app autostart methods?
« Reply #6 on: January 29, 2018, 11:44:00 PM »
I thought for sure if in .X.d. that I did something like this: 

xterm -e StartDosBox.sh

that surely it would behave normally since I'm launching a whole new instance of the terminal, BUT IT STILL started DosBox then immediately shutdown.
Check out DOSBox Distro - https://sites.google.com/site/dosboxdistro/

A tinycore LIVEUSB that makes playing your dos games anywhere very simple.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11641
Re: [HELP] Alternative app autostart methods?
« Reply #7 on: January 29, 2018, 11:49:15 PM »
Hi binarydemon
OK, one last idea:
Code: [Select]
#!/bin/sh
exec /usr/local/bin/dosbox
sudo poweroff

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11047
Re: [HELP] Alternative app autostart methods?
« Reply #8 on: January 30, 2018, 04:22:51 AM »
Please double-check that there's no stray shutdown command somewhere, the separate file should work (without exec, that replaces the script). It would be very weird behavior from dosbox to daemonize automatically.

edit: or perhaps dosbox quits for some reason? Replace shutdown with some benign command, like editor, and redirect dosbox errors to some file.
« Last Edit: January 30, 2018, 04:28:06 AM by curaga »
The only barriers that can stop you are the ones you create yourself.

Offline binarydemon

  • Newbie
  • *
  • Posts: 35
Re: [HELP] Alternative app autostart methods?
« Reply #9 on: January 30, 2018, 07:41:20 AM »
Curaga,

You are on to something. When I replace DosBox with Editor, the script behaves properly.  DosBox doesnt appear to be crashing tho -

I did:

dosbox
sleep 5
sudo poweroff

as a test, and I can see DosBox completely loads, then poweroff shuts everything down.

I guess I might have to use a script that constantly checks if DosBox process is running, it just seems like an ugly solution tho.

* On a sidenote, thank you for suggesting testing with Editor - I didnt know tinycore had that packaged with it, I was installing nano each time i needed it. :)
Check out DOSBox Distro - https://sites.google.com/site/dosboxdistro/

A tinycore LIVEUSB that makes playing your dos games anywhere very simple.

Offline binarydemon

  • Newbie
  • *
  • Posts: 35
Re: [HELP] Alternative app autostart methods?
« Reply #10 on: February 01, 2018, 11:12:45 PM »
Rich - I tried exec, and wait, but the result was the same everytime.  Crontab @reboot looked interesting but cause other issues.

Just wanted to follow up with my ugly workaround, incase anyone else is experiencing similar issues.

Now in .X.d - I start two scripts:

StartDosBox  (which is just a 5 second sleep then dosbox)

and

MonitorDosBox: (which I run with nice -n 19 since I hate having a while loop constantly running)

#!/bin/sh
# DOSBOX starts with a 5 second delay to allow alsasound to initialize
# this script needs to delay longer.
sleep 7
while :
do
   pidof dosbox >/dev/null
   if [[ $? -ne 0 ]] ; then
      sudo poweroff
      break
   else
      sleep 1
   fi
done


Check out DOSBox Distro - https://sites.google.com/site/dosboxdistro/

A tinycore LIVEUSB that makes playing your dos games anywhere very simple.