From 0bd8f286c05544f4646b41b14bb118f9c8634ba3 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Tue, 23 Mar 2021 17:25:16 +0900 Subject: [PATCH] haltest: Add haltest.target to support HAL TEST mode In order to support HAL TEST Mode, add haltest.target which requires the least running processes for only haltest such as sdbd service. So that haltest.target is based on getty.target to support the console and then add deviced.service/ac.service for supporting sdbd service. And reboot-haltest/reboot-normal scripts are for switching between normal mode and HALTEST mode. [Essential service list in haltest.target] - dbus.service for /usr/bin/dbus-daemon - serial-getty@.service for console - dlog_logger.service for /usr/bin/dlog_logger - systemd-udevd.service for /usr/lib/sytemd/sytemd-udevd - systemd-journald.service for /usr/bin/systemd/systemd-journald - ac.service for /usr/bin/amd is requied for deviced.service - deviced.service for /usr/bin/deviced is required for sdbd.service - sdbd.service for /usr/sbin/sdbd [Script commands to switch between Normal and HALTEST mode] - reboot-haltest switches from Normal to HALTEST mode. - reboot-normal switches from HALTEST to Normal mode. Change-Id: If8fdd240003cf3509cec5f83bf8aacb3bc1a5ec6 Signed-off-by: Chanwoo Choi --- packaging/hal-api-common.spec | 9 +++++++++ packaging/haltest.target | 6 ++++++ packaging/reboot-haltest | 41 +++++++++++++++++++++++++++++++++++++++++ packaging/reboot-normal | 26 ++++++++++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 packaging/haltest.target create mode 100644 packaging/reboot-haltest create mode 100644 packaging/reboot-normal diff --git a/packaging/hal-api-common.spec b/packaging/hal-api-common.spec index 223887f..1844696 100644 --- a/packaging/hal-api-common.spec +++ b/packaging/hal-api-common.spec @@ -14,6 +14,9 @@ Source1: %{name}.manifest Source2: libhal-api.conf Source3: systemd-hal-firmware-generator Source4: macros.hal-api +Source5: haltest.target +Source6: reboot-haltest +Source7: reboot-normal Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig @@ -67,6 +70,9 @@ mkdir -p %{buildroot}/hal install -D -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/ld.so.conf.d/libhal-api.conf install -D -m 0755 %{SOURCE3} %{buildroot}%{_systemdgeneratordir}/systemd-hal-firmware-generator install -D -m 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/rpm/macros.hal-api +install -D -m 0644 %{SOURCE5} %{buildroot}%{_unitdir}/haltest.target +install -D -m 0755 %{SOURCE6} %{buildroot}%{_bindir}/reboot-haltest +install -D -m 0755 %{SOURCE7} %{buildroot}%{_bindir}/reboot-normal %clean rm -rf %{buildroot} @@ -101,3 +107,6 @@ fi %files -n %{test_name} %{_bindir}/hal/common-haltests +%{_unitdir}/haltest.target +%{_bindir}/reboot-haltest +%{_bindir}/reboot-normal diff --git a/packaging/haltest.target b/packaging/haltest.target new file mode 100644 index 0000000..0b35a53 --- /dev/null +++ b/packaging/haltest.target @@ -0,0 +1,6 @@ +[Unit] +Description=HALTEST Mode +Requires=basic.target ac.service deviced.service getty.target +Conflicts=rescue.service rescue.target +After=basic.target rescue.service rescue.target ac.service deviced.service getty.target +AllowIsolate=yes diff --git a/packaging/reboot-haltest b/packaging/reboot-haltest new file mode 100644 index 0000000..622939c --- /dev/null +++ b/packaging/reboot-haltest @@ -0,0 +1,41 @@ +#!/bin/bash +PATH=/bin:/usr/bin:/sbin:/usr/sbin + +user=`whoami` +default=`systemctl get-default` +dmverity_path="/usr/bin/verityctl" +dmverity_cmd=`verityctl get-mode root` +dmverity_log="dm-verity is disabled (Normal boot)" + +if ! [ "$user" = "root" ] +then + echo "HALTEST: Need 'root' permission for switching mode" + exit +fi + +if [ -f $dmverity_path ] +then + if ! [ "$dmverity_cmd" = "$dmverity_log" ] + then + echo "HALTEST: Need to disable DM-VERITY to use HALTEST Mode " + echo "HALTEST: Disable DM-VERITY and reboot target " + echo "HALTEST: After rebooting, need to execure reboot-haltest again " + verityctl disable + echo "HALTEST: Rebooting ..." + reboot -f + fi +fi + +if ! [ "$default" = "haltest.target" ] +then + echo "HALTEST: Switch to HALTEST Mode from Normal Mode" + echo "HALTEST: Change default.target from $default to haltest.target" + mount -o remount,rw / + systemctl set-default haltest.target + sync + echo "HALTEST: Rebooting ..." + reboot -f +else + echo "HALTEST: HALTEST Mode is already enabled (default: $default)" +fi + diff --git a/packaging/reboot-normal b/packaging/reboot-normal new file mode 100644 index 0000000..09fafa9 --- /dev/null +++ b/packaging/reboot-normal @@ -0,0 +1,26 @@ +#!/bin/bash + +PATH=/bin:/usr/bin:/sbin:/usr/sbin + +user=`whoami` +default=`systemctl get-default` + +if ! [ "$user" = "root" ] +then + echo "HALTEST: Need 'root' permission for switching mode" + exit +fi + +if ! [ "$default" = "graphical.target" ] +then + echo "HALTEST: Switch to Normal Mode from HALTEST Mode" + echo "HALTEST: Change default.target from $default to graphical.target" + mount -o remount,rw / + systemctl set-default graphical.target + sync + echo "HALTEST: Rebooting ..." + reboot -f +else + echo "HALTEST: Normal Mode is already enabled (default: $default)" +fi + -- 2.7.4