Bläddra i källkod

More options for consoles

tags/2016.12
Filip Pytloun 9 år sedan
förälder
incheckning
281d020aad
4 ändrade filer med 40 tillägg och 11 borttagningar
  1. +5
    -0
      README.rst
  2. +14
    -0
      linux/files/tty.upstart
  3. +16
    -10
      linux/system/console.sls
  4. +5
    -1
      tests/pillar/system.sls

+ 5
- 0
README.rst Visa fil

@@ -131,6 +131,11 @@ Enable autologin on tty1 (may work only for Ubuntu 14.04):
console:
tty1:
autologin: root
# Enable serial console
ttyS0:
autologin: root
rate: 115200
term: xterm

To disable set autologin to `false`.


+ 14
- 0
linux/files/tty.upstart Visa fil

@@ -0,0 +1,14 @@
# {{ name }} - getty
#
# This service maintains a getty on tty1 from the point the system is
# started until it is shut down again.

start on stopped rc RUNLEVEL=[2345] and (
not-container or
container CONTAINER=lxc or
container CONTAINER=lxc-libvirt)

stop on runlevel [!2345]

respawn
exec /sbin/getty{% if tty.get('autologin', False) %} --autologin {{ tty.autologin }}{% endif %} -8 {{ tty.get('rate', 38400) }} {{ name }}{% if tty.term is defined %} {{ tty.term }}{% endif %}

+ 16
- 10
linux/system/console.sls Visa fil

@@ -5,18 +5,24 @@

{%- for tty_name, console in system.console.iteritems() %}

{%- if console.autologin %}
autologin_{{ tty_name }}_enable:
cmd.run:
- name: "sed -i 's|/sbin/getty|/sbin/getty --autologin {{ console.autologin }}|g' /etc/init/{{ tty_name }}.conf"
- unless: "grep 'autologin' /etc/init/{{ tty_name }}.conf"
{%- else %}
autologin_{{ tty_name }}_disable:
cmd.run:
- name: "sed -i 's| \-\-autologin [a-zA-Z0-9]*||g' /etc/init/{{ tty_name }}.conf"
- onlyif: "grep 'autologin' /etc/init/{{ tty_name }}.conf"
{%- if grains['init'] == 'upstart' %}
{{ tty_name }}_service_file:
file.managed:
- name: /etc/init/{{ tty_name }}.conf
- source: salt://linux/files/tty.upstart
- template: jinja
- defaults:
name: {{ tty_name }}
tty: {{ console }}
{%- endif %}

{{ tty_name }}_service:
service.running:
- enable: true
- name: {{ tty_name }}
- watch:
- file: {{ tty_name }}_service_file

{%- endfor %}

{%- endif %}

+ 5
- 1
tests/pillar/system.sls Visa fil

@@ -10,7 +10,11 @@ linux:
enabled: false
console:
tty0:
autologin: true
autologin: root
ttyS0:
autologin: root
rate: 115200
term: xterm
prompt:
default: "test01.local$"
motd:

Laddar…
Avbryt
Spara