-
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 #696 from pastequo/nvidia-bootc/feat/remove-makefi…
…le-step nvidia-bootc: Duplicate common lib & ilab, to avoid an intermediate makefile target
- Loading branch information
Showing
7 changed files
with
95 additions
and
8 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
...ootc/duplicated/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
...bootc/duplicated/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/nvidia-bootc/duplicated/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/nvidia-bootc/duplicated/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 |
37 changes: 37 additions & 0 deletions
37
training/nvidia-bootc/duplicated/common/usr/libexec/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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
# Template values replaced by container build | ||
CONTAINER_DEVICE="__REPLACE_CONTAINER_DEVICE__" | ||
IMAGE_NAME="__REPLACE_IMAGE_NAME__" | ||
|
||
export ENTRYPOINT="/opt/python3.11/venv/bin/ilab" | ||
export PARAMS=("$@") | ||
|
||
for dir in "$HOME/.cache" "$HOME/.config" "$HOME/.local"; do | ||
mkdir -p "$dir" | ||
done | ||
|
||
if [[ "$1" = "shell" ]]; then | ||
export ENTRYPOINT=bash | ||
export PARAMS=() | ||
fi | ||
|
||
PODMAN_COMMAND=("podman" "run" "--rm" "-it" | ||
"--device" "${CONTAINER_DEVICE}" | ||
"--security-opt" "label=disable" "--net" "host" | ||
"-v" "$HOME:$HOME" | ||
"--env" "HOME" | ||
"--entrypoint" "$ENTRYPOINT" | ||
"--env" "HF_TOKEN" | ||
"${IMAGE_NAME}") | ||
|
||
exec "${PODMAN_COMMAND[@]}" "${PARAMS[@]}" |