10
#-----------------------------------------------------------------------------#
12
#-----------------------------------------------------------------------------#
14
open INITTAB, "/etc/inittab"
15
or die "Unable to open /etc/inittab: $!";
24
my ($id, $rlevel, $action, $process) = split /:/, $_, 4;
26
warn "missing id field" and next
27
unless defined $id and length $id;
28
warn "missing runlevel field" and next
29
unless defined $rlevel;
30
warn "missing action field" and next
31
unless defined $action and length $action;
32
warn "missing process field" and next
33
unless defined $process;
36
$have_cad = 1 if $action eq "ctrlaltdel";
37
$gettys{$1} = [ $rlevel, $process ] if $process =~ /getty.*\b(tty\w+)/;
41
or warn "Error while closing /etc/inittab: $!";
44
#-----------------------------------------------------------------------------#
46
#-----------------------------------------------------------------------------#
48
unlink "/etc/init/control-alt-delete.conf"
51
foreach (qw/tty1 tty2 tty3 tty4 tty5 tty6/) {
52
unlink "/etc/init/$_.conf"
53
unless exists $gettys{$_};
56
foreach (sort keys %gettys) {
57
my ($rlevel, $process) = @{$gettys{$_}};
60
if (-f "/etc/event.d/$_") {
61
open JOB, "/etc/event.d/$_"
62
or warn "Unable to open /etc/event.d/$_: $!" and next;
66
or warn "Error while closing /etc/event,d/$_: $!" and next;
68
foreach my $rl (qw/2 3 4 5/) {
70
for ($idx = 0; $idx < @job; $idx++) {
71
last if $job[$idx] =~ /^\s*(start|stop)\s+on\s+runlevel\s+$rl\b/;
75
if ($rlevel =~ /$rl/) {
76
$job[$idx] =~ s/^(\s*)stop(\s+)/$1start$2/;
78
$job[$idx] =~ s/^(\s*)start(\s+)/$1stop$2/;
81
if ($rlevel =~ /$rl/) {
82
push @job, "start on runlevel $rl";
84
push @job, "stop on runlevel $rl";
90
for ($idx = 0; $idx < @job; $idx++) {
91
last if $job[$idx] =~ /^\s*respawn\s*/; # match bare 'respawn' too
95
# only match old-style 'respawn process', not bare 'respawn'
96
$job[$idx] =~ s/^(\s*respawn\s+).*/$1$process/;
99
push @job, "exec $process";
102
# Try to fix up effects of previous broken migrations
103
if (@job and $job[$#job] =~ /.*(.+?)exec (\1)$/) {
104
$job[$#job] = "exec $1";
108
push @job, "# $_ - getty";
110
push @job, "# Converted from /etc/inittab entry";
113
foreach my $rl (qw/2 3 4 5/) {
114
if ($rlevel =~ /$rl/) {
115
push @job, "start on runlevel $rl";
117
push @job, "stop on runlevel $rl";
122
push @job, "stop on shutdown";
125
push @job, "respawn";
126
push @job, "exec $process";
129
open JOB, ">/etc/event.d/.$_"
130
or warn "Unable to write to /etc/event.d/.$_: $!" and next;
131
print JOB map { "$_\n" } @job;
133
warn "Error while closing /etc/event.d/.$_: $!";
134
unlink "/etc/event.d/.$_";
138
unless (rename "/etc/event.d/.$_", "/etc/event.d/$_") {
139
warn "Unable to replace /etc/event.d/$_: $!";
140
unlink "/etc/event.d/.$_";