2

I have a script at /etc/init/ttyS0.conf. I'm configuring a KVM guest for Serial Console access so even if the network interface is broken, I can still access it via the serial connection.

I can start the ttyS0 by running sudo start ttyS0 and it works just fine until I reboot. Upon rebooting the system, the ttyS0 isn't running anymore.

How can I get this script to to tun automatically at startup?

Thanks


Here's what my script looks like:

# ttyS0 - getty
#
# This service maintains a getty on ttyS0 from the point the system is
# started until it is shut down again.

start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]

respawn
exec /sbin/getty -L 115200 ttyS0 xterm

3 Answers 3

1

From here

respawn
console none

start on (local-filesystems)
stop on [!12345]

script

exec start ttyS0
end script

Should work i suspect. else, replace start tty0 with a script that starts what you want to start

0

There are several ways to do this.

If the script invokes a process you can use /etc/init.d.

Put the script into /etc/init.d, you will need then to change the permissions on the file using chmod a+x "script". Then run update-rc.d "script" defaults, which kicks everything into gear. The script should start on boot now.

Here are some other examples:

Example 1

Example 2

0

Ubuntu uses SYSV startup (same as Debian) based on runlevels.

You have to add the script to the runlevel you're currently using. For Ubuntu the runlevel used by the init process is 2 by default. Thus you have to add ttyS0.conf to rC2.d directory and stating you want to start it (not stopping). You can do so by adding a soft link to the script like this:

ln -s /etc/init/ttyS0.conf /etc/rc2.d/S99ttyS0.conf

The S99 prefix indicates "S" -> start the script and "99" order in which the script has to be launched (lower this number if other scripts needs to run after this one).

Then you need to stop it when rebooting (runlevel 6) or shutting down (runlevel 0):

ln -s /etc/init/ttyS0.conf /etc/rc0.d/S99ttyS0.conf
ln -s /etc/init/ttyS0.conf /etc/rc6.d/S99ttyS0.conf

Prefix is similar except that "S" -> stop script (only for runlevels 0 and 6).

Hope this helps. More info here

2
  • 3
    actually, it uses upstart now, but old style init scripts ought to work
    – Journeyman Geek
    Aug 22, 2011 at 11:28
  • Hi Journeyman, I read up upstart and it seems to be the right way to do this evn though my script is in sync with the upstart specs, it doesn't start when the system boots/restarts. Any ideas? Please have a look at my edit. I've added my script there. Aug 22, 2011 at 11:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .