From b664b5d451eaf75733095016ed5dfc4fc38ff147 Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Mon, 26 Oct 2020 18:14:28 +0900 Subject: Delayed target: add delaying the start of delayed.target If /etc/systemd/delayed-target.conf exists and has DelayedTargetWait environment value, delayed.target starts after DelayedTargetWait seconds. If the /tmp/.systemd_delayed_target_wait file is created within the delayed time, delayed.target starts immediately. Change-Id: I4ad1ff6a8084ed9db7d630f533a9348b41decbf0 --- packaging/delayed-target-trigger.sh | 29 ++++++++++++++++++++++++++ packaging/systemd.spec | 3 +++ units/system-delayed-target-trigger.service.in | 2 ++ 3 files changed, 34 insertions(+) create mode 100644 packaging/delayed-target-trigger.sh diff --git a/packaging/delayed-target-trigger.sh b/packaging/delayed-target-trigger.sh new file mode 100644 index 0000000000..cbc129057d --- /dev/null +++ b/packaging/delayed-target-trigger.sh @@ -0,0 +1,29 @@ +#!/bin/bash +PATH=/bin:/usr/bin:/sbin:/usr/sbin + +# /etc/systemd/delayed-target.conf does not exist +if [ -z "$DelayedTargetWait" ] +then + echo "Start delayed.target without any delay." + exit 0; +fi + +echo "Wait $DelayedTargetWait seconds for delayed.target to start." + +index=0 +while [ $index -lt "$DelayedTargetWait" ] +do + if [ -f /tmp/.systemd_delayed_target_wait ] + then + rm -f /tmp/.systemd_delayed_target_wait + break; + fi + + ((index++)) + + sleep 1 +done + +echo "Start delayed.target after $index seconds delay." + +exit 0; diff --git a/packaging/systemd.spec b/packaging/systemd.spec index 78ee2ad00b..37101db239 100644 --- a/packaging/systemd.spec +++ b/packaging/systemd.spec @@ -64,6 +64,7 @@ Source6: org.tizen.system.conf Source7: sysctl-tizen-override.conf Source8: send-booting-done.c Source9: wait-target-done.c +Source10: delayed-target-trigger.sh Source1001: systemd.manifest BuildRequires: gperf BuildRequires: intltool >= 0.40.0 @@ -374,6 +375,7 @@ ln -sf ./libsystemd.pc %{buildroot}%{_libdir}/pkgconfig/libsystemd-login.pc install -m 0755 %{SOURCE4} %{buildroot}%{_bindir}/wait-default-target.sh install -m 0755 %{SOURCE5} %{buildroot}%{_bindir}/wait-delayed-target.sh install -m 0644 %{SOURCE6} %{buildroot}%{dbuspolicydir}/system.d/org.tizen.system.conf +install -m 0755 %{SOURCE10} %{buildroot}%{_bindir}/delayed-target-trigger.sh # Tizen sysctl values overriding default systemd values install -m 0644 %{SOURCE7} %{buildroot}%{_sysconfdir}/sysctl.d/ @@ -680,6 +682,7 @@ fi %{_bindir}/wait-default-target.sh %{_bindir}/wait-delayed-target.sh +%{_bindir}/delayed-target-trigger.sh %exclude %{_prefix}/lib/systemd/system/runlevel0.target %exclude %{_prefix}/lib/systemd/system/runlevel1.target %exclude %{_prefix}/lib/systemd/system/runlevel2.target diff --git a/units/system-delayed-target-trigger.service.in b/units/system-delayed-target-trigger.service.in index 8f3b6dd2a8..491e347405 100644 --- a/units/system-delayed-target-trigger.service.in +++ b/units/system-delayed-target-trigger.service.in @@ -12,7 +12,9 @@ RefuseManualStop=yes # At least one service must remain, and systemd will not enter the Startupfinished state. # So this unit, which is oneshot type, becomes that one service. Type=oneshot +EnvironmentFile=-/etc/systemd/delayed-target.conf ExecStart=@rootbindir@/wait-default-target.sh System +ExecStart=@rootbindir@/delayed-target-trigger.sh ExecStart=@rootbindir@/systemctl --no-block start delayed.target RemainAfterExit=yes SmackProcessLabel=System -- cgit v1.2.3