Skip to content
Snippets Groups Projects
Commit 25cb32db authored by Thomas Bellman's avatar Thomas Bellman Committed by Thomas Bellman
Browse files

Add support for EL-6 in console::serial::login.

parent bee2f269
No related branches found
No related tags found
No related merge requests found
......@@ -13,8 +13,6 @@
* - rootlogin To 'allow' or 'forbid' root to login on the port.
* Default is to make no changes to /etc/securetty.
*/
# FIXME: Currently only supports systemd
define console::serial::login(
$ensure='enabled',
$speeds=[115200,38400,9600],
......@@ -40,6 +38,14 @@ define console::serial::login(
}
}
/^upstart::(CentOS|Redhat|Scientific)-6(\.|$)/: {
console::serial::login::rhel_6 {
$name:
ensure => $ensure,
speeds => $speeds, termtype => $termtype;
}
}
default: {
fail("Console::Serial::Login[${title}]: ",
"Unsupported operating system/init system")
......@@ -97,3 +103,90 @@ define console::serial::login::systemd(
;
}
}
# Internal helper definition
#
define console::serial::login::rhel_6(
$ensure,
$speeds,
$termtype
)
{
$svcname = "serial-${name}"
$xspeeds = inline_template('<%= [@speeds].flatten.join(",") %>')
if ($ensure == 'enabled')
{
include console::serial::login::rhel_6::disable_auto_serial
$lines = [
'start on stopped rc RUNLEVEL=[2345]',
'stop on starting runlevel [016]',
'respawn',
"exec /sbin/agetty /dev/${name} ${xspeeds} ${termtype}",
]
file {
"/etc/init/${svcname}.conf":
ensure => file,
owner => 'root', group => 'root', mode => 0444,
content => inline_template(
'<%= @lines.join("\n") + "\n" -%>'),
notify => Exec["console::serial::login::rhel_6::${name}"];
}
exec {
"console::serial::login::rhel_6::autoserial-stop::${name}":
command => shellquote(
'/sbin/initctl', 'stop', 'serial', "DEV=${name}"),
onlyif => sprintf(
'%s | /bin/grep -q "start/running"',
shellquote('/sbin/initctl', 'status', 'serial',
"DEV=${name}")),
path => '/sbin:/usr/sbin:/bin:/usr/bin',
before => Class[
'console::serial::login::rhel_6::disable_auto_serial'];
"console::serial::login::rhel_6::${name}":
command => shellquote('/sbin/initctl', 'start', $svcname),
unless => sprintf(
'%s | /bin/grep -q "start/running"',
shellquote('/sbin/initctl', 'status', $svcname)
),
path => '/sbin:/usr/sbin:/bin:/usr/bin',
refreshonly => true;
}
}
elsif ($ensure == 'disabled')
{
file {
"/etc/init/${svcname}.conf":
ensure => absent,
require => Exec["console::serial::login::rhel_6::${name}"];
}
exec {
"console::serial::login::rhel_6::${name}":
command => shellquote(
'/sbin/initctl', 'stop', $svcname),
onlyif => sprintf(
'%s | /bin/grep -q "start/running"',
shellquote('/sbin/initctl', 'status', $svcname)),
path => '/sbin:/usr/sbin:/bin:/usr/bin';
}
}
}
# Internal helper class
# The default /etc/init/serial.conf upstart job runs an agetty process on the
# primary console, if it is a serial port. That clashes with an agetty job
# configured explicitly on that port. Disable this automatic running of
# agetty, to avoid this.
#
class console::serial::login::rhel_6::disable_auto_serial
{
disable_file {
'/etc/init/serial.conf':
renameto => '%D/%F.DISABLED';
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment