update/software/service-files/usm-initialize-init.sh
Bin Qian f2b98a4950 Add new USM initialize service
The new service is enabled on a host that completed major release
deployment prior to host-unlock. The service runs at the early stage of
node reboot after host-unlock. It sets up the systemd preset for new
deployed major release software, removes the initial_config_complete
flag file, then disable itself.

This service replicates the operations in the kickstart during a node
installation. Other operations may be added in the future.

Test Plan
PASS: AIO-DX - run throught e2e USM major release deploy,
      verify the new systemd services added to the to-release
      are enabled

Story: 2010676
Task: 50749

Change-Id: I77e819e9767071da6cd43f581c76661ba2fc06c1
Signed-off-by: Bin Qian <Bin.Qian@windriver.com>
Co-Signed-off-by: Heitor Matsui <heitorvieira.matsui@windriver.com>
2024-08-06 12:38:53 -03:00

100 lines
2.5 KiB
Bash
Executable File

#! /bin/sh
#
# Copyright (c) 2024 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
### BEGIN INIT INFO
# Description: usm-initialize
#
# Short-Description: USM initialize service.
# Provides: usm-initialize
# Required-Start:
# Required-Stop:
# Default-Start: 3 5
# Default-Stop: 3 5
### END INIT INFO
logfile="/var/log/software.log"
INITIAL_CONFIG_COMPLETE="/etc/platform/.initial_config_complete"
SERVICE_NAME="usm-initialize.service"
log() {
echo "`date "+%FT%T.%3N"`: $0: $*" >> $logfile
}
set_presets() {
. /etc/platform/platform.conf
if [ "${system_type}" == "All-in-one" ] ; then
log "AIO System"
if [[ "${subfunction}" =~ "lowlatency" ]] ; then
log "System is lowlatency"
ln -sf /usr/share/systemd-presets/lowlatency.preset /etc/systemd/system-preset/10-aio.preset
else
ln -sf /usr/share/systemd-presets/aio.preset /etc/systemd/system-preset/10-aio.preset
fi
else
log "Standard System"
log "Setting ${nodetype} preset"
if [[ "${nodetype}" == "worker" ]] ; then
if [[ "${subfunction}" =~ "lowlatency" ]] ; then
log "System is lowlatency"
ln -sf /usr/share/systemd-presets/worker-lowlatency.preset /etc/systemd/system-preset/10-worker.preset
else
ln -sf /usr/share/systemd-presets/worker.preset /etc/systemd/system-preset/10-worker.preset
fi
elif [ "${nodetype}" == "storage" ] ; then
ln -sf /usr/share/systemd-presets/storage.preset /etc/systemd/system-preset/10-storage.preset
else
ln -sf /usr/share/systemd-presets/controller.preset /etc/systemd/system-preset/10-controller.preset
fi
fi
systemctl daemon-reload
systemctl preset-all --preset-mode=full
}
reset_initial_config_complete() {
if [[ -f ${INITIAL_CONFIG_COMPLETE} ]]; then
log "Removing ${INITIAL_CONFIG_COMPLETE}"
rm ${INITIAL_CONFIG_COMPLETE} || log "Failed to remove ${INITIAL_CONFIG_COMPLETE}"
fi
}
disable_service() {
systemctl disable $SERVICE_NAME
rc=$?
if [ $rc -ne 0 ]; then
log "Failed to disable $SERVICE_NAME"
else
log "Disabled $SERVICE_NAME"
fi
}
start() {
set_presets
reset_initial_config_complete
disable_service
}
case "$1" in
start)
start
exit 0
;;
stop)
;;
status)
;;
restart)
;;
reload)
;;
force-reload)
;;
*)
esac
exit 0