Inservice post-install script

Adding a post-install for an inservice patch to restart all services
during host install to make the changes live.
If it is the active controller, the software-controller cannot be
restarted at this time, so leaves a flag for it to be restarted during
activate step.

Test-Plan SX/DX:
PASS: Run an inservice patch with this script
      and check if the changes are applied
PASS: Apply an inservice patch pre-bootstrap

Story: 2010676
Task: 52804

Change-Id: Id5b853cea0f80af6124c45aab231c44c34d65576
Signed-off-by: Lindley Vieira <lindley.vieira@windriver.com>
This commit is contained in:
Lindley Vieira
2025-09-09 12:20:10 -04:00
parent 3f75570925
commit a555f16de5
22 changed files with 158 additions and 0 deletions

View File

@@ -0,0 +1,85 @@
#!/bin/bash
#
# Copyright (c) 2025 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# Source platform.conf, for nodetype and subfunctions
. /etc/platform/platform.conf
PATCH_STATUS_OK=0
PATCH_STATUS_FAILED=1
logfile="/var/log/software.log"
NAME=$(basename "$0")
CREDENTIAL_FILE="/opt/platform/.keyring/24.09/.CREDENTIAL"
BOOTSTRAP_COMPLETED_FLAG="/etc/platform/.bootstrap_completed"
INITIAL_CONFIG_COMPLETE_FLAG="/etc/platform/.initial_config_complete"
RESTART_SERVICES_FLAG="/run/software/.activate.restart-services.flag"
loginfo() {
echo "$(date "+%FT%T.%3N"): $NAME: $*" >> "$logfile"
}
is_active_controller() {
[[ "$nodetype" == "controller" && -f "$CREDENTIAL_FILE" ]]
}
is_standby_controller() {
[[ "$nodetype" == "controller" && ! -f "$CREDENTIAL_FILE" ]]
}
not_controller() {
[[ "$nodetype" != "controller" ]]
}
# Check if /etc is a bind mount
BIND_SOURCE=$(findmnt /etc -n -o SOURCE)
if [[ -z "$BIND_SOURCE" ]]; then
loginfo "Not an inservice patch, exiting"
exit "$PATCH_STATUS_OK"
fi
# Pre-bootstrap does not need to restart services since it will be unlocked later
if [ ! -f "$BOOTSTRAP_COMPLETED_FLAG" ] && [ ! -f "$INITIAL_CONFIG_COMPLETE_FLAG"]; then
loginfo "Pre-bootstrap, exiting"
exit "$PATCH_STATUS_OK"
fi
### Services to restart in all nodes
# Set flag to restart software-agent
touch /run/software/.restart.software-agent
### Services to restart only in the active controller
if is_active_controller; then
loginfo "Running in the active controller"
# Let a flag for vim, vim-api, and software-controller
# services to be restarted during activate
touch "$RESTART_SERVICES_FLAG"
sm-restart-safe service sysinv-conductor
exit "$PATCH_STATUS_OK"
fi
### Services to restart only in the standby controller
if is_standby_controller; then
loginfo "Running in the standby controller"
# It is safe to restart software-controller in the standby controller
pmon-restart software-controller-daemon
exit "$PATCH_STATUS_OK"
fi
### Services to restart only in non-controller nodes
if not_controller; then
loginfo "Running in non-controller node"
exit "$PATCH_STATUS_OK"
fi
exit "$PATCH_STATUS_OK"

View File

@@ -0,0 +1,73 @@
# Install Scripts Management
This repository manages **pre-install** and **post-install** shell scripts used in the patch deployment process.
They run for each patch at the beginning and at the end of `software deploy host` for both inservice and reboot required patches.
## Folder Structure
```
install-scripts/
├── boilerplate/
│ ├── pre-install.sh
│ └── post-install.sh
├── 24.09.400/
│ ├── pre-install.sh
│ └── post-install.sh
├── examples/
└── ...
```
- `boilerplate/`:
Contains the **default scripts**. These are the standard versions used for most software releases.
- `MM.mm.pp/`:
Contains **version-specific scripts**, only when changes are required that differ from the boilerplate.
- `examples/`:
Contains **previous scripts examples**. Scripts used in old releases.
---
## Usage
### Default Case
If the pre and post install steps remain unchanged:
- Use the scripts in the `boilerplate/` folder.
- No need to create a version-specific directory.
### When Customization Is Needed
If any version of the software requires changes to the install scripts:
1. **Create a version folder** (e.g., `24.09.400/`):
```bash
mkdir install-scripts/24.09.400
```
2. **Copy the boilerplate scripts**:
```bash
cp install-scripts/boilerplate/*.sh start-scripts/24.09.400/
```
3. **Edit the scripts** in `24.09.400/` as needed.
> Always start from the boilerplate to ensure consistency.
---
## Tips
- **Include comments** in versioned scripts, noting what the change is doing.
- Use previous versions as examples of what these scripts can do.
---
## License
Include the license in all scripts
```
Copyright (c) 2025 Wind River Systems, Inc.
SPDX-License-Identifier: Apache-2.0
```