Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Run a script upon entering runlevel 2

  1. #11
    Junior Member
    Join Date
    Jul 2012
    Posts
    20
    Hi Capricorny!

    Interesting points. Is what you call the main filesystem the large KNOPPIX file? This appears to be the first thing that the init script mounts, hence Bash ought to be available prior to knoppix.sh execution, if what you think is correct.

    I retrieved one of my original attempts, upon which I made the claim that some code worked in Bash but not at boot, and tested it again; it works correctly in a Bash terminal, likewise in root console post-boot (that is to say, after INIT enters runlevel 2), but is improperly implemented at boottime execution of knoppix.sh. Quite peculiar. If you are interested let me know and I'll post it.

    Running /bin/busybox will list the functions defined in the BusyBox version installed on that workstation. As you say, these functions might not be shared by all versions of that program, and this is especially the case given the openness of GNU/Linux and associated software. Best practice entails specifying versions!

    Now, a related question has emerged, and I'll post it next.
    Last edited by lapidu; 07-19-2012 at 12:59 PM.

  2. #12
    Senior Member registered user
    Join Date
    Sep 2006
    Posts
    802
    Quote Originally Posted by lapidu View Post
    Is what you call the main filesystem the large KNOPPIX file? This appears to be the first thing that the init script mounts, hence Bash ought to be available prior to knoppix.sh execution, if what you think is correct.
    You may unzip and look at the minirt.gz init script to see what is going on at the initial stages of booting.

    The KNOPPIX image is cloop-mounted (or squashfs-mounted if it has been compressed that way, other schemes are also possible), and there may be several overlays mounted the same way, to be unionfs-mounted with persistent store(s). If you have updated any system programs, the new versions will reside in the persistent store (or overlays, if you compress stuff iteratively).

    The knoppix-autoconfig script uses several system programs, so I would think they are all accessible, and the invocation of knoppix.sh is at the end of this script. Maybe there is some kind of "call frame"
    here, making that run under busybox if the calling script does? I don't know much about this, you see .

    As for busybox components, you may roll your own. For example, you may need more commands during minirt init, or you come across some incompatibility. Important uses of busybox are in phones and embedded devices, where there may never be full version core utilities available.

    PS:
    Code:
     grep -s -w -i "no_script" /proc/cmdline && exit
    might be an even shorter way to implement that cheatcode? (Haven't tried, may also be busybox limitations for grep.)
    Last edited by Capricorny; 07-19-2012 at 01:22 PM.

  3. #13
    Junior Member
    Join Date
    Jul 2012
    Posts
    20

    Loading graphical applications with knoppix.sh

    Challenge: A user wants knoppix.sh to launch, or cause to be launched, a Leafpad window on his display. The window should be waiting for him once his graphical desktop loads. What code will allow him to do so?

    Trying to run Leafpad, or any graphical program, from the root console results, of course, in a "Cannot open display" warning. I thought this challenge should have an obvious solution - the consoles and x-server are not totally insulated from one another, since they can all access the same filesystem, so there must be a simple command that can tell the console to make the x-server perform a job (e.g. launch a window) remotely, as it were. But so far my research and attempts have not found this 'simple command', if it even exists.

    What do you think about the possibility of this challenge?

  4. #14
    Junior Member
    Join Date
    Jul 2012
    Posts
    20
    Quote Originally Posted by Capricorny View Post
    ...might be an even shorter way to implement that cheatcode? (Haven't tried, may also be busybox limitations for grep.)...
    That works, and the grep -w switch is especially recommended to anyone using a non-distinct assigned keyword that could be unintentionally matched by parts of other boot option words/phrases.

  5. #15
    Senior Member registered user
    Join Date
    Sep 2006
    Posts
    802
    Quote Originally Posted by lapidu View Post
    Challenge: A user wants knoppix.sh to launch, or cause to be launched, a Leafpad window on his display. The window should be waiting for him once his graphical desktop loads. What code will allow him to do so?

    Trying to run Leafpad, or any graphical program, from the root console results, of course, in a "Cannot open display" warning. I thought this challenge should have an obvious solution - the consoles and x-server are not totally insulated from one another, since they can all access the same filesystem, so there must be a simple command that can tell the console to make the x-server perform a job (e.g. launch a window) remotely, as it were. But so far my research and attempts have not found this 'simple command', if it even exists.

    What do you think about the possibility of this challenge?
    Some 15 years ago, I could just have the script append the commands to my startx script, but since then X has developed from hack to complete kludge, and there is still some time before Wayland resques us from that. I tried with a local .xinitrc file - X initialized, but wouldn't stay up. So there are probably very good reasons for .xinitrc missing... I don't even remember when, along the way, I gave up on such things - but it seems to be a challenge today, and that tells us that something is basucally flawed.

  6. #16
    Senior Member registered user
    Join Date
    Sep 2006
    Posts
    802

    Relatively inelegant and hard-wired, but it works

    I have found no universal way to do it, and several of the solutions on the net don't work with Knoppix/LXDE.

    But, if you run LXDE, there is a relatively inelegant&hard-wired solution, documented on the LXDE Wiki: http://wiki.lxde.org/en/Autostart

    Edit the file /etc/xdg/lxsession/LXDE/autostart and add the things you want to have run, prepended with an "@", like @leafpad, and add parameters as needed.
    Then it worked for me, at least. Attempts at using only the user's .desktop file didn't succeed for me.

    Thank you for the question, I'll need this myself to get virtualization set up automatically.
    Last edited by Capricorny; 07-19-2012 at 08:12 PM.

  7. #17
    Junior Member
    Join Date
    Jul 2012
    Posts
    20
    Glad I asked, thanks for the response. Your solution does the job. Good idea looking up LXDE specifically.

    The challenge remains open to a direct, universal solution.

    The following command will enable any command-line console to launch graphical programs by allowing them to access the appropriate display via x, but the catch is that it must be executed within the graphical environment first; attempting to do so in a console gives a variant 'unable to open display' error. Hence it cannot be usefully included in knoppix.sh.

    Code:
    xhost +local:
    Once this is done, you can launch a graphical application from console by specifying the target display. For example, launch an instance of leafpad in default display :0 :

    Code:
    DISPLAY=:0 leafpad
    When you switch back to the desktop leafpad will open.
    Last edited by lapidu; 07-20-2012 at 10:36 AM.

  8. #18
    Senior Member registered user
    Join Date
    Sep 2006
    Posts
    802
    I'm afraid there is no universal solution at this time.
    The main problem is that you may open displays as much as you like, but they are killed when X starts.

    Therefore, the most universal solution tight now might be to setup LXDE to run something like "knoppix-x.sh" at start.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Dell PowerEdge C6320 82F9M Server Blade Module 10gb SFP+ 082F9M picture

Dell PowerEdge C6320 82F9M Server Blade Module 10gb SFP+ 082F9M

$79.99



Dell PowerEdge M620 Blade Server 2x 10C E5-2690v2 64GB Ram 2x 600GB 10k HDD picture

Dell PowerEdge M620 Blade Server 2x 10C E5-2690v2 64GB Ram 2x 600GB 10k HDD

$125.00



Dell PowerEdge M620  Blade Server 2 x Xeon e5 2665 8 x 16 GB(128) RAM - No HD picture

Dell PowerEdge M620 Blade Server 2 x Xeon e5 2665 8 x 16 GB(128) RAM - No HD

$44.99



Dell PowerEdge M610 Blade Server E5620@2.2GHZ (6x)8GB RAM (2x)146GB 15K SAS HDD picture

Dell PowerEdge M610 Blade Server E5620@2.2GHZ (6x)8GB RAM (2x)146GB 15K SAS HDD

$79.00



Dell PowerEdge FX2s CTO Blade 4 Slot 2U Chassis 2x 2000W picture

Dell PowerEdge FX2s CTO Blade 4 Slot 2U Chassis 2x 2000W

$399.00



Dell PowerEdge M520 Blade Server Xeon E5-2403 NO HDD NO RAM picture

Dell PowerEdge M520 Blade Server Xeon E5-2403 NO HDD NO RAM

$40.00



Cisco UCSB-B200-M5 V05 Blade Server with 2x GOLD 6146, 3.2GHZ 64GB RAM, NO SSD picture

Cisco UCSB-B200-M5 V05 Blade Server with 2x GOLD 6146, 3.2GHZ 64GB RAM, NO SSD

$649.00



Google Search Appliance - Dell PowerEdge R710 x2 Xeon X5690 192GB Memory 6TB HDD picture

Google Search Appliance - Dell PowerEdge R710 x2 Xeon X5690 192GB Memory 6TB HDD

$529.99



HP ProLiant BL460c Gen9 Blade 2x E5-2690v4 2.6GHz =28 Cores 32GB P246 650FLB picture

HP ProLiant BL460c Gen9 Blade 2x E5-2690v4 2.6GHz =28 Cores 32GB P246 650FLB

$223.00



HP ProLiant BL460c Gen9 Blade 2x E5-2697v3 2.6GHz =28 Cores 32GB P246 650FLB picture

HP ProLiant BL460c Gen9 Blade 2x E5-2697v3 2.6GHz =28 Cores 32GB P246 650FLB

$173.00