Run a script automatically in the console after booting - Linux

This is a discussion on Run a script automatically in the console after booting - Linux ; Hi On a machine without X, i want an interactive script to be automatically started in the first virtual console after the machine has booted. * The script is an info-kiosk like application, allowing users to view a few pages ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Run a script automatically in the console after booting

  1. Run a script automatically in the console after booting

    Hi

    On a machine without X, i want an interactive script to be automatically
    started in the first virtual console after the machine has booted.

    * The script is an info-kiosk like application, allowing users to view a few
    pages of information, and to switch between the pages using a few keys. It
    will be set up in a store to allow customers to view information about the
    store and its products.

    * When the machine is turned on it should boot as usual, and after booting
    the application should start on the screen (no X, just the console in
    character mode), and accept input from the keyboard.

    * The application is currently a prototype written in bash, using various
    utils (such as wget) to fetch product information from servers and format
    pages to be displayed.

    * For maintenance and support it should be possible to access the machine
    over the network via ssh.

    * The application should, of course, not run as root, but as a dedicated
    "infokiosk" user.


    So how do i get this application automatically started after booting?

    I tried messing around with the /etc/inittab, replacing getty with my
    application in various ways, eg:

    1:2345:respawn:/bin/bash /home/infokiosk/bin/kiosk-app-wrapper.sh

    but it seems like the application does not get access to the tty.

    I also considered using the init= kernel boot time parameter, but this is a
    bad idea because i need the machine booted "as usual", ie. i need services
    started and stuff initialized.


    Can anyone point me in the right direction?

    Jens

    --
    For email Remove These Characters From Mail Address (r, t, c, f, m and a)

  2. Re: Run a script automatically in the console after booting

    As far as I can tell, what you have _should_ work, so I can't help you
    with that.

    What I would recommend though, is something more like this:

    1:2345:respawn:/bin/chroot /home/infokiosk kiosk

    Set kiost to chmod 0755, and add a bash line to it.

    Then you'll need to create a /bin dir in the infokiosk home directory
    and all the necessary libs, etc. That should keep it reasonably secure.
    Also, perhaps run it as an unprivileged user in case they manage to get
    out of the chrooted dir.

    Hope this helps a bit :-)

    Cheers
    --Colin


  3. Re: Run a script automatically in the console after booting

    Colin Horne wrote:

    > As far as I can tell, what you have _should_ work, so I can't help you
    > with that.


    Tried it again, on tty1, and yes, it works!

    But with a few anomalies:

    * When i first tried it i tried on tty2 instead of tty1, and here it worked
    a little strange - i could see the application output, but when pressing
    the keyboard, the characters were not echoed.

    * If i escape to a shell, start emacs and quit it again, something is
    screwed up, because characters typed are no longer echoed, and i have to
    exit the app and have init respawn it before getting my echo back.

    * The gettys on tty2 and tty3 dont work (ie. if i swicth to tty2 or tty3, i
    see no login prompt, and the keyboard seems unrersponsive), until after a
    period of time (a few minutes) has elapsed, then the gettys on tty2 and
    tty3 come alive. The gettys on ttys 4, 5 and 6 work as usual. Im not sure
    if this has anything to do with my application.

    * I cannot use control-C to stop the application, control-C seems
    unresponsive.

    I dont know if these "anomalies" are because i am missing something or what,
    but for the purpose i need it for, it works fine now.

    >
    > What I would recommend though, is something more like this:
    >
    > 1:2345:respawn:/bin/chroot /home/infokiosk kiosk
    >
    > Set kiost to chmod 0755, and add a bash line to it.
    >
    > Then you'll need to create a /bin dir in the infokiosk home directory
    > and all the necessary libs, etc. That should keep it reasonably secure.
    > Also, perhaps run it as an unprivileged user in case they manage to get
    > out of the chrooted dir.


    I intend to run it as an unprivileged user, but without the chroot jail, ie.
    like

    1:12345:respawn:su - -c "/home/kiosk/kiosk-app.sh" kiosk

    the security is not critical, so i dont think it is worth the effort to
    chroot. If a user is somehow able to break out of the application and
    escape to a shell or something similar, they will only be able to mess up
    the kiosk user, unless they can exploit some vulnerability to gain root
    privileges. But even in this unlikely event, the way the kiosk is to be
    physically designed, makes it very onlikely that they will be able to do
    much damage.

    >
    > Hope this helps a bit :-)


    Yes, it helped ;-) Thanks!

    Jens

    --
    For email Remove These Characters From Mail Address (r, t, c, f, m and a)

+ Reply to Thread