Skip to content
Snippets Groups Projects
Commit 030ca77c authored by Thomas Bellman's avatar Thomas Bellman
Browse files

Add class for disabling console screensaver.

By default, the console screensaver is enabled on Linux systems (at
least RedHat:ish systems).  That makes it difficult to see kernel
crash messages on the console on physical servers, as the screensaver
typically is activated, and you can't deactivate it since the kernel
is dead and does not respond to key presses...

This adds a class console::screensaver::disable which disables the
console screensaver when the machine boots.
parent 0c0e5f52
No related branches found
No related tags found
No related merge requests found
# Copyright © 2017 Thomas Bellman, Linköping, Sweden
# Licensed under the GNU LGPL v3+; see the README file for more information.
/*
* Turn off the screensaver on the VGA console.
* This is useful in case of kernel crashes; if the screensaver was activated
* at the time of the crash, you can't see the crash message, and you can't
* deactivate the screensaver, since the kernel has died...
*/
class console::screensaver::disable
{
# Need redirection to tty1 in case we have console=ttyS1
$setterm_cmd = 'TERM=linux setterm -blank 0 -powerdown 0 >/dev/tty1'
case $::initsystem
{
'sysvinit', 'upstart': {
ensure_line {
'console::screensaver::disable::setterm':
file => '/etc/rc.d/rc.local',
line => $setterm_cmd,
pattern => '(TERM=\S*\s)?(setterm.*-blank|setterm.*-powerdown).*';
}
}
'systemd': {
$lines = [
'# This file is under Puppet control',
'',
'[Unit]',
'Description=Disable screensaver on the console',
'',
'[Service]',
'Type=oneshot',
"ExecStart=/bin/sh -c '${setterm_cmd}'",
'',
'[Install]',
'WantedBy=basic.target',
]
file {
'/etc/systemd/system/screensaver-disable.service':
ensure => file,
content => inline_template('<%=@lines.join("\n")+"\n" %>'),
owner => 'root', group => 'root', mode => '0444',
before => Service['screensaver-disable'];
}
service {
'screensaver-disable':
enable => true, ensure => running;
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment