-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #689 from javipolo/upgrade-informer-service
RHELAI-429: Adding upgrade informer service
- Loading branch information
Showing
7 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
training/common/usr/lib/systemd/system/basic.target.wants/upgrade-informer.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../upgrade-informer.service |
1 change: 1 addition & 0 deletions
1
training/common/usr/lib/systemd/system/timers.target.wants/upgrade-informer.timer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../upgrade-informer.timer |
12 changes: 12 additions & 0 deletions
12
training/common/usr/lib/systemd/system/upgrade-informer.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[Unit] | ||
Description=Check for available RHEL AI upgrade | ||
ConditionPathExists=/run/ostree-booted | ||
After=network-online.target | ||
StartLimitIntervalSec=400 | ||
StartLimitBurst=3 | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/libexec/upgrade-informer | ||
Restart=on-failure | ||
RestartSec=90 |
11 changes: 11 additions & 0 deletions
11
training/common/usr/lib/systemd/system/upgrade-informer.timer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[Unit] | ||
Description=Runs upgrade informer periodically | ||
ConditionPathExists=/run/ostree-booted | ||
|
||
[Timer] | ||
OnBootSec=1h | ||
OnUnitInactiveSec=1day | ||
RandomizedDelaySec=2h | ||
|
||
[Install] | ||
WantedBy=timers.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
# Run the command and capture its output | ||
output=$(bootc upgrade --check | sed -e 1q) | ||
message_file="/etc/motd.d/upgrade-message" | ||
bootc_auth="/etc/ostree/auth.json" | ||
|
||
if [[ $output == Update\ available* ]]; then | ||
if [[ ! -f $message_file ]]; then | ||
echo "New version was found" | ||
bootc_image=$(awk '{print $4}' <<< "$output") | ||
# If auth file exists we should use it | ||
auth_params="" | ||
if [[ -f $bootc_auth ]]; then | ||
auth_params="--authfile $bootc_auth" | ||
fi | ||
|
||
# Get image version | ||
# shellcheck disable=SC2086 | ||
image_version_id=$(skopeo inspect --format json $auth_params "$bootc_image" | jq -r '.Labels | .["image_version_id"] // empty') | ||
|
||
# If upgrade available, write the output to the file | ||
cat > $message_file << EOF | ||
** Attention! ** | ||
** A new $image_version_id version is available ** | ||
** In order to apply it run: bootc upgrade --apply | ||
** Please note that the system will reboot after the upgrade ** | ||
EOF | ||
fi | ||
else | ||
echo "No upgrade was found" | ||
rm $message_file 2> /dev/null | ||
fi | ||
|
||
echo "Finished running upgrade informer" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters