diff -Nur e-smith-base-5.8.0.old/createlinks e-smith-base-5.8.0/createlinks --- e-smith-base-5.8.0.old/createlinks 2016-04-11 22:14:33.297000000 -0400 +++ e-smith-base-5.8.0/createlinks 2016-04-11 22:47:13.131000000 -0400 @@ -375,6 +375,7 @@ $event = "post-install"; +event_link("fix-startup", $event, "05"); event_link("rotate_timestamped_logfiles", $event, "05"); event_link("init-accounts", $event, "05"); event_link("init-passwords", $event, "10"); @@ -388,6 +389,7 @@ $event = "post-upgrade"; +event_link("fix-startup", $event, "05"); event_link("rotate_timestamped_logfiles", $event, "05"); event_link("init-accounts", $event, "05"); event_link("conf-startup", $event, "10"); @@ -538,15 +540,8 @@ my %service2order = ( # Start rsyslog up before network! - rsyslog => "05", - #klogd => "06", - 'bootstrap-console' => "10", raidmonitor => "15", network => "37", - irqbalance => "39", - crond => "40", - smartd => "40", - acpid => "44", dhcpd => "65", 'local' => "99", ); @@ -581,3 +576,10 @@ # no template headers for /etc/pam_ldap.secret safe_touch("root/etc/e-smith/templates/etc/pam_ldap.secret/template-begin"); + + +system('mkdir -p root/usr/lib/systemd/system/multi-user.target.wants/'); + unlink "root/usr/lib/systemd/system/multi-user.target.wants/bootstrap-console.service"; +symlink("/usr/lib/systemd/system/bootstrap-console.service", + "root/usr/lib/systemd/system/multi-user.target.wants/bootstrap-console.service") + or die "Can't symlink to root/usr/lib/systemd/system/multi-user.target.wants/bootstrap-console.service: $!"; diff -Nur e-smith-base-5.8.0.old/root/etc/e-smith/events/actions/fix-startup e-smith-base-5.8.0/root/etc/e-smith/events/actions/fix-startup --- e-smith-base-5.8.0.old/root/etc/e-smith/events/actions/fix-startup 1969-12-31 19:00:00.000000000 -0500 +++ e-smith-base-5.8.0/root/etc/e-smith/events/actions/fix-startup 2016-04-11 22:48:23.867000000 -0400 @@ -0,0 +1,42 @@ +#! /usr/bin/perl + +use strict; +use warnings; +use DirHandle; +my $d = DirHandle->new("/etc/rc7.d"); + +my @d = + sort { $a->{order} cmp $b->{order} } + map { /^S(\d+)([\w\-.]+)/ ; { name => $2 , order => $1 } } + grep { /^S/ } $d->read; + +my $equivalent = {'oidentd'=> 'identd', + 'nut'=> 'ups', + 'raidmonitor' => 'mdmonitor' + }; + + +foreach my $service (@d) +{ +my $sv=$service->{'name'}; +next if $sv eq 'bootstrap-console'; +$sv= $equivalent->{$sv} || $sv; +#print "$sv: "; + if (-e "/lib/systemd/system/multi-user.target.wants/$sv.service") + { + #print "systemd (lib) "; + system(qw(systemctl disable), $sv); + } + elsif (-e "/etc/systemd/system/multi-user.target.wants/$sv.service") + { + #print "systemd (etc)"; + system(qw(systemctl disable), $sv); + } + elsif (-e "/etc/init.d/$sv") + { + #print "chkconfig $sv off "; + system("chkconfig", $sv, "off"); + #print "\n"; + } + #else {print "\n";} +} diff -Nur e-smith-base-5.8.0.old/root/sbin/e-smith/bootstrap-console e-smith-base-5.8.0/root/sbin/e-smith/bootstrap-console --- e-smith-base-5.8.0.old/root/sbin/e-smith/bootstrap-console 2014-03-23 22:47:25.000000000 -0400 +++ e-smith-base-5.8.0/root/sbin/e-smith/bootstrap-console 2016-04-11 22:42:48.072000000 -0400 @@ -48,6 +48,11 @@ use esmith::console::save_config; esmith::console::save_config->new->doit($console, $db); +$ARGV[0] = 'tty'; +$console = esmith::console->new(); +use esmith::console::startup; +esmith::console::startup->new->doit($console,$db); + system("/usr/bin/tput", "clear"); exit (0); diff -Nur e-smith-base-5.8.0.old/root/usr/lib/systemd/system/bootstrap-console.service e-smith-base-5.8.0/root/usr/lib/systemd/system/boostrap-console.service --- e-smith-base-5.8.0.old/root/usr/lib/systemd/system/bootstrap-console.service 1969-12-31 19:00:00.000000000 -0500 +++ e-smith-base-5.8.0/root/usr/lib/systemd/system/bootstrap-console.service 2016-04-11 22:23:50.332000000 -0400 @@ -0,0 +1,27 @@ +[Unit] +Description=SME server bootstrap-console +DefaultDependencies=no +Conflicts=shutdown.target +After=livesys.service plymouth-quit-wait.service +After=systemd-vconsole-setup.service +Before=getty@tty1.service +Before=shutdown.target + +[Service] +Environment=HOME=/root +WorkingDirectory=/root +ExecStartPre=-/bin/plymouth quit +ExecStart=/sbin/e-smith/bootstrap-console +Type=oneshot +Restart=no +TimeoutSec=0 +StandardInput=tty +StandardOutput=tty +StandardError=tty +KillMode=process +IgnoreSIGPIPE=no +SendSIGHUP=yes + +[Install] +WantedBy=multi-user.target + diff -Nur e-smith-base-5.8.0.old/root/usr/share/perl5/vendor_perl/esmith/console/startup.pm e-smith-base-5.8.0/root/usr/share/perl5/vendor_perl/esmith/console/startup.pm --- e-smith-base-5.8.0.old/root/usr/share/perl5/vendor_perl/esmith/console/startup.pm 1969-12-31 19:00:00.000000000 -0500 +++ e-smith-base-5.8.0/root/usr/share/perl5/vendor_perl/esmith/console/startup.pm 2016-04-11 22:36:08.133000000 -0400 @@ -0,0 +1,132 @@ +package esmith::console::startup; +use Locale::gettext; +use esmith::console; +use esmith::ConfigDB; +use strict; +use warnings; + +sub new +{ + my $class = shift; + my $self = { + @_, + }; + bless $self, $class; + return $self; +} + +sub startup_callback { + my $fd = shift; + my @out = (); + my $done = 0; + + use DirHandle; + my $d = DirHandle->new("/etc/rc7.d"); + my @services = sort + { + $a =~ /^S(\d+)/; my $A = $1; + $b =~ /^S(\d+)/; my $B = $1; + $A <=> $B + } grep { /^S/ } $d->read; + my $rows = 12; + my $status_col = 65; + + my $db = esmith::ConfigDB->open_ro; + my $rec = $db->get('smb'); + my $i=0; + foreach (@services) { + $i=$i+1; + next unless /^S(\d+)([^\.][\.\w\-]+)$/; + next unless $2 eq "smb"; + splice @services,$i-1 , 1, "S${1}4smbd", "S${1}5nmbd" unless ($rec and $rec->prop('status') eq 'disabled'); + last; + } + + + open(STDOUT, ">&STDERR"); + foreach (@services) + { + sleep 1; + my $percent = int(($done * 100) / ($#services + 1)); + $done += 1; + my $link = $_; + #warn "Looking at symlink $_\n"; + next unless /^S\d+([^\.][\.\w\-]+)$/; # Untaint service name + my $service = $1; + #my $db = esmith::ConfigDB->open_ro; + $rec = $db->get($service); + do + { + warn "not starting disabled service $service\n"; + next; + } unless ($rec and $rec->prop('status') eq 'enabled'); + my $prompt = "starting "; + my $supervised = -x "/service/$service/run"; + my @cmd; + if (-x "/service/$service/run") + { + $prompt .= " supervised service $service"; + warn "starting supervised service $service\n"; + @cmd = ("sv", "up", "/service/$service"); + } + elsif (-x "/etc/init.d/$service") + { + $prompt .= " unsupervised service $service"; + warn "starting unsupervised service $service\n"; + @cmd = ("/etc/init.d/$service", "start"); + } + else + { + warn "ignoring unknown service $service: bogus start symlink $link\n"; + next; + } + + push @out, "$prompt\n"; + print $fd "XXX\n"; + print $fd "$percent\n"; + my @show = $#out > $rows ? @out[$#out - $rows .. $#out] : @out; + do { print $fd $_ } foreach @show; + print $fd "XXX\n"; + $prompt .= " " x ($status_col - length($prompt)); + $prompt .= system(@cmd) ? "\\Z1FAILED\\Zn" : "\\Z2OK\\Zn"; + $out[-1] = "$prompt\n"; + @show = $#out > $rows ? @out[$#out - $rows .. $#out] : @out; + print $fd "XXX\n"; + print $fd "$percent\n"; + do { print $fd $_ } foreach @show; + print $fd "XXX\n"; + } + print $fd "100\n"; + sleep 2; + return undef; +}; + +my $console = esmith::console->new; + +sub doit +{ + my ($self, $console, $db) = @_; + + $console->infobox + ( + title => gettext("Starting system services"), + text => "\n" . + gettext("Please standby while system services are started ..." +), + ); + + system(qw(touch /var/lock/subsys/backup-running)); + system(qw(chown admin /var/lock/subsys/backup-running)); + sleep(6); # Wait to be certain that all runsv services have been started. + $console->gauge(\&startup_callback, + text => '', + title => 'Starting system services', + colors => 1, + no_collapse => 1); +} + +#use esmith::console; +#use esmith::ConfigDB; +#esmith::console::startup->new->doit(esmith::console->new(), +# esmith::ConfigDB->open); +1;