@@ -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`. | |||
@@ -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 %} |
@@ -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 %} |
@@ -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: |