WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: hacking .X.d  (Read 9647 times)

Offline jur

  • Hero Member
  • *****
  • Posts: 863
    • cycling photo essays
Re: .X.d stuff not loaded reliably
« Reply #15 on: November 09, 2010, 10:20:17 PM »
OK, thanks for checking.

What I will do is to pare the stuff down to the barest bones that will reproduce the result. That will take a day or so.

Frank

  • Guest
Re: .X.d stuff not loaded reliably
« Reply #16 on: November 10, 2010, 02:42:44 AM »
jur, most likely danielibarnes described the solution already. "sudo basic-firewall" ends with a "Press enter" prompt (that you cannot see in your scenario). Any script that comes afterwards -- will not be executed.

To prevent the sequence of scripts from getting stuck, you may wish to try danielibarnes' suggestion: "sudo basic-firewall < /dev/null".

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11048
Re: .X.d stuff not loaded reliably
« Reply #17 on: November 10, 2010, 03:30:08 AM »
Hm, I really should add a "noprompt" option for the non-interactive starts of basic-firewall.

edit: Done.
« Last Edit: November 10, 2010, 03:38:16 AM by curaga »
The only barriers that can stop you are the ones you create yourself.

Offline jur

  • Hero Member
  • *****
  • Posts: 863
    • cycling photo essays
Re: .X.d stuff not loaded reliably
« Reply #18 on: November 10, 2010, 07:20:42 AM »
if I put
Code: [Select]
conky &
tint2 &
and
Code: [Select]
tce-load -i iptables
sudo basic-firewall
in two separate files named desktop and iptables respectively, then conky and tint2 don't load.

If I add '&' to sudo basic-firewall then they do load.

If I put all 4 statements in a single file, then they load. It works better to put conky and tint2 before iptables, but still both ways work with and without adding & to basic-firewall.

Above tried with the modded iptables.

[edit]If I add < /dev/null instead of & to basic-firewall it also works, as does noprompt.
« Last Edit: November 10, 2010, 07:40:43 AM by jur »

Offline jur

  • Hero Member
  • *****
  • Posts: 863
    • cycling photo essays
Re: .X.d stuff not loaded reliably
« Reply #19 on: November 10, 2010, 04:36:16 PM »
@roberts:

Is it required to background tasks in .X.d by appending '&' to statements?

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: .X.d stuff not loaded reliably
« Reply #20 on: November 10, 2010, 05:08:21 PM »
You do not need to background them if they background themselves,
or if you need them to exit normally before continuing to the next step.

However, If any of these scripts do not detach, or pause waiting for input,
.xsession will not finish and you will be confused because something is not going
to be running correctly.

If you have a complex startup, you can enclose the script in parenthesis and background it.
EX:

(
   step 1
   step 2
   step 3
) &

This will run the script in background, but ensure that step 3 does not run until steps 1 and 2 have
completed.

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: .X.d stuff not loaded reliably
« Reply #21 on: November 10, 2010, 07:10:45 PM »
Quote
@roberts:

Is it required to background tasks in .X.d by appending '&' to statements?

gerald_clark is correct here. But typically most X programs do.
Quote
[You do not need to background them if they background themselves,
or if you need them to exit normally before continuing to the next step.

The running of non-X within .xsession .X/.d seems to be overly complicating matters.
It is like let's do away with SOP of bootlocal.sh, bootsync.sh, .profile, e.g., the typical places to start non-X programs. In fact the .info file for iptables correctly suggests to use:
Quote
From bootlocal.sh (to start on every boot):
/usr/local/sbin/basic-firewall noprompt
10+ Years Contributing to Linux Open Source Projects.

Offline jur

  • Hero Member
  • *****
  • Posts: 863
    • cycling photo essays
Re: .X.d stuff not loaded reliably
« Reply #22 on: November 10, 2010, 08:00:51 PM »
I may seem complicated but it's driven by the decision not to load extensions at boot time. I like to have the desktop up and running ASAP. So my OnBoot list only contains those extensions which are essential to get the desktop up and running, such as Xorg, the wm and so on. Those other extensions are not OnDemand either, it's just not necessary to load them immediately.

So how would you load extensions later? There is no provision - I like to keep .profile and .xsession default, because previous times when I did actually insert stuff in there, it complicated matters when switching to new releases when from time to time there are changes in those files. bootlocal.sh runs as root so is not suitable either.

So it seems to me there needs to be a startup file which is processed as user in which one can place various startup commands and scripts.

Or am I missing something?
« Last Edit: November 10, 2010, 08:05:24 PM by jur »

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: .X.d stuff not loaded reliably
« Reply #23 on: November 10, 2010, 08:45:52 PM »
So how would you load extensions later? There is no provision
On-demand does just that.

Offline jur

  • Hero Member
  • *****
  • Posts: 863
    • cycling photo essays
Re: .X.d stuff not loaded reliably
« Reply #24 on: November 10, 2010, 11:13:45 PM »
Perhaps I didn't make myself clear enough... extension I have in mind are eg hwmon-2.6.33.3-tinycore. I need that for normal running but I don't need it to get the desktop running. There are quite  few of these. Clearly they are not ondemand extensions.

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: .X.d stuff not loaded reliably
« Reply #25 on: November 10, 2010, 11:59:45 PM »
jur: I really think you are "missing something" (which has come up in this forum multiple times). The simple way for 'root' to run something as user 'tc' is via su -c COMMAND tc

As a proof of concept I've done:
Code: [Select]
tc@box:~$ echo 'su -c "tce-load -w conky && tce-load -i conky" tc' >> /opt/bootlocal.sh
tc@box:~$ echo 'su -c "tce-load -w tint2 && tce-load -i tint2" tc' >> /opt/bootlocal.sh
tc@box:~$ echo '( while [ ! $( which conky 2> /dev/null ) ] ; do sleep 1 ; done ; conky ) &' > .X.d/conky
tc@box:~$ echo '( while [ ! $( which tint2 2> /dev/null ) ] ; do sleep 1 ; done ; tint2 ) &' > .X.d/tint2
tc@box:~$ filetool.sh -b && sudo reboot

I believe that it is what you want: It starts the X server as early as possible and 'conky' and 'tint2' are showing up whenever they are available. I personally believe it's better to create in '~/.X.d' a file for each application, but I've tried to come up with a command sequence that should also work if you "squeeze" everthing into a single file.

As a side note: The test was conducted using a VM (i.e. QEMU without KQEMU). It was rather slow for 'the applications to start and I'm putting this down to being forced into loading 'wireless_tools.tcz' and the wireless kernel modules on a (virtual) system that will never have any such hardware.

Frank

  • Guest
Re: .X.d stuff not loaded reliably
« Reply #26 on: November 11, 2010, 01:57:14 AM »
Quote from: /etc/skel/.xsession
[ -d ".X.d" ] && find ".X.d" -type f -print | while read F; do . "$F"; done

The last line of .xsession runs the scripts and programs in .X.d as shown above. The most universal solution would be a minor rewrite of the line, such that it starts all scripts and programs in the background. Which, obviously, is a suggestion for roberts, not for jur.

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: .X.d stuff not loaded reliably
« Reply #27 on: November 11, 2010, 10:27:03 AM »
That would prohibit not backgrounding where a race condition may exist.

Frank

  • Guest
Re: .X.d stuff not loaded reliably
« Reply #28 on: November 11, 2010, 10:33:59 AM »
The present solution with its unpredictable order of script execution doesn't prevent race conditions either -- so we are no worse off with my suggestion.

A few posts further up in this thread someone showed the proper way of preventing race conditions. Oh, that was you ...


Offline jur

  • Hero Member
  • *****
  • Posts: 863
    • cycling photo essays
Re: hacking .X.d
« Reply #29 on: November 11, 2010, 03:36:46 PM »
OK, I have taken all the good advice in this thread on board and come up with the following. Please feel free to point out any problems, as I am really still in early learning phase:

.X.d has a single file with
Code: [Select]
conky &
tint2 &
,profile has an extra inclusion
Code: [Select]
if [ -f "$HOME/.startup" ]; then
   . "$HOME/.startup"
fi
.startup:
Code: [Select]
export GDK_NATIVE_WINDOWS=true
(
        sleep 5
loadapp iptables && sudo basic-firewall noprompt
loadapp volumeicon && volumeicon &
loadapp iptables && sudo basic-firewall noprompt
loadapp hwmon-2.6.33.3-tinycore.tcz
loadapp pci-hotplug-2.6.33.3-tinycore.tcz
loadapp hicolor-icon-theme.tcz
loadapp gtk2_prefs
loadapp zenity
        amixer sset 'Master' 64 >/dev/null
        amixer sset 'Headphone' 55 >/dev/null
        amixer sset 'Speaker' 55 >/dev/null
        loadapp wine
updates
) &

The reason I am sticking with my loadapp script is that it contains all checking; I can start a new setup from scratch, all necessary extensions will be auto-downloaded.
« Last Edit: November 11, 2010, 04:21:49 PM by jur »