From 147b4caf3352ae985749b2e7d728abc7d97ce258 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Tue, 5 Jan 2016 12:05:43 +0100 Subject: [PATCH 1/5] fix startup/shutdown order of nis and mxstartup After 4ee8fedc systems hang on shtudown until systemd times out. Do not wait for NIS on shutdown. Tell systemd to order nis and mxstartup in startup and shutdown --- mxstartup-classic.service | 2 +- mxstartupctl | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mxstartup-classic.service b/mxstartup-classic.service index b2ba5ca..827854d 100644 --- a/mxstartup-classic.service +++ b/mxstartup-classic.service @@ -1,6 +1,6 @@ [Unit] Description=Mariux mxstartup classic -After=mxstartup-mxvip.service mxmount.service +After=mxstartup-mxvip.service mxmount.service nis.service Requires=mxstartup-mxvip.service mxmount.service [Service] diff --git a/mxstartupctl b/mxstartupctl index 0b52f0a..8dbaf94 100755 --- a/mxstartupctl +++ b/mxstartupctl @@ -2,13 +2,13 @@ remoteuser=molgen -while ! id ${remoteuser} >/dev/null 2>&1 ; do - echo >&2 "WARNING: Waiting for NIS (failed to resolve remote user ${remoteuser})" - sleep 1 -done case "${1}" in start) + while ! id ${remoteuser} >/dev/null 2>&1 ; do + echo >&2 "WARNING: Waiting for NIS (failed to resolve remote user ${remoteuser})" + sleep 1 + done mxvipctl start $2 mxservicectl start $2 ;; From 6fa05102ab3006192b789372d77262d0bb384905 Mon Sep 17 00:00:00 2001 From: Peter Marquardt Date: Mon, 13 Jun 2016 09:05:22 +0200 Subject: [PATCH 2/5] remove NIS netgroup handling --- mxstartup2mxconfig | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/mxstartup2mxconfig b/mxstartup2mxconfig index 021f915..28c1505 100755 --- a/mxstartup2mxconfig +++ b/mxstartup2mxconfig @@ -248,28 +248,6 @@ sub print_ips_cfg { ############################################################################## -sub walknetgroup { - my @ng; - - &y(\@ng,@_); - - sub y { - my ($ary,$m)=@_; - $_=`ypmatch $m netgroup 2>/dev/null`; - foreach ( split ) { - if (/\(/) { - s/[\(\),]//g; - push @$ary, $_; - } else { - foreach ( split ) { - &y($ary,$_); - } - } - } - } - - return @ng; -} sub expand_hosts { @@ -278,9 +256,7 @@ sub expand_hosts { foreach my $host (@oh) { - if($host =~ /^\@(\S+)/) { - push @hosts, walknetgroup($1); - } elsif($host =~ /^(\/\S+)/) { + if ($host =~ /^(\/\S+)/) { next unless(-r $1); push @hosts, expand_hosts(read_file($1)); } else { From 3e163e506ac3a248d9b44b6c1503542c69e5da13 Mon Sep 17 00:00:00 2001 From: Peter Marquardt Date: Mon, 13 Jun 2016 09:34:45 +0200 Subject: [PATCH 3/5] allow @tag for hostconfig selection --- mxstartup2mxconfig | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mxstartup2mxconfig b/mxstartup2mxconfig index 28c1505..b1b2010 100755 --- a/mxstartup2mxconfig +++ b/mxstartup2mxconfig @@ -248,6 +248,11 @@ sub print_ips_cfg { ############################################################################## +sub hostconfig_list { + my $tag = shift; + $_=`/usr/sbin/hostconfig --list $tag 2>/dev/null`; + return ( split ); +} sub expand_hosts { @@ -256,7 +261,10 @@ sub expand_hosts { foreach my $host (@oh) { - if ($host =~ /^(\/\S+)/) { + if($host =~ /^\@(\S+)/) { + push @hosts, hostconfig_list($1); + } + elsif ($host =~ /^(\/\S+)/) { next unless(-r $1); push @hosts, expand_hosts(read_file($1)); } else { From 2159300616cb42ff02e5cd67e576139ee1d8edb2 Mon Sep 17 00:00:00 2001 From: Peter Marquardt Date: Tue, 21 Jun 2016 16:51:16 +0200 Subject: [PATCH 4/5] Restart not needed --- mxstartup-mxvip.service | 1 - 1 file changed, 1 deletion(-) diff --git a/mxstartup-mxvip.service b/mxstartup-mxvip.service index 80d0446..0ccd23e 100644 --- a/mxstartup-mxvip.service +++ b/mxstartup-mxvip.service @@ -10,7 +10,6 @@ ExecStart=/usr/sbin/mxvipctl start ExecStop=/usr/sbin/mxvipctl stop RemainAfterExit=yes StandardOutput=syslog -Restart=always [Install] WantedBy=multi-user.target From 6f0dd5f7a21b3edb5011fe07edc1c29226eaffed Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Thu, 12 Apr 2018 14:34:28 +0200 Subject: [PATCH 5/5] mxservicectl: Accept service unit name in mxstartups Regard the 4th column of /etc/mxstartups as the name of a systemd service unit if it ends in ".service". In that case, ignore the username and use systemctl to start/stop that unit. The idea is to use /etc/mxstartups for services, which we want to run as a systems service, e.g. to use the features of systemd. Currently there is an option to use unit files with an encoded hostname but we prefer to have the information of which hosts starts which service in /etc/mxstartups. --- mxservicectl | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/mxservicectl b/mxservicectl index 5541f25..49dacd9 100755 --- a/mxservicectl +++ b/mxservicectl @@ -19,7 +19,14 @@ function mxsrv_start_one() { . ${cfg} - su - ${MX_SRV_USER} -c "${MX_SRV_SCRIPT} start" & + case "${MX_SRV_SCRIPT}" in + *.service) + systemctl start "${MX_SRV_SCRIPT}" + ;; + *) + su - ${MX_SRV_USER} -c "${MX_SRV_SCRIPT} start" & + ;; + esac mv ${cfg}{,.r} @@ -34,7 +41,14 @@ function mxsrv_stop_one() { . ${cfg} - su - ${MX_SRV_USER} -c "${MX_SRV_SCRIPT} stop" & + case "${MX_SRV_SCRIPT}" in + *.service) + systemctl stop "${MX_SRV_SCRIPT}" + ;; + *) + su - ${MX_SRV_USER} -c "${MX_SRV_SCRIPT} stop" & + ;; + esac rm ${cfg}