1
1
#! /bin/bash
2
2
3
- if command -v rpm-ostree > /dev/null; then
3
+ if command -v ublue-update > /dev/null; then
4
4
if [ " $1 " == " check" ]; then
5
5
if [ -f ' /tmp/upgrade-installed' ]; then
6
6
exit 7 # Upgrade already installed
7
7
else
8
- # Perform connectivity check
9
- wget -q --spider https://github.com
8
+ # Check system state
9
+ ublue-update --check
10
10
if [ $? -eq 0 ]; then
11
- # Compare installation digest to latest image
12
- IMAGE=$( rpm-ostree status | grep -m1 ghcr | sed ' s/^.*ghcr/ghcr/' )
13
- CURRENT=$( rpm-ostree status | grep -m1 Digest | tr -d ' [:space:]' | sed ' s/' Digest:' //g' )
14
- LATEST=$( skopeo inspect docker://${IMAGE} | jq ' .Digest' | tr -d ' "' )
15
- if [ ${CURRENT} == ${LATEST} ]; then
16
- exit 7 # Up to date
11
+ # Perform connectivity check
12
+ wget -q --spider https://github.com
13
+ if [ $? -eq 0 ]; then
14
+ # Compare installation digest to latest image
15
+ IMAGE=$( rpm-ostree status | grep -m1 ghcr | sed ' s/^.*ghcr/ghcr/' )
16
+ CURRENT=$( rpm-ostree status | grep -m1 Digest | tr -d ' [:space:]' | sed ' s/' Digest:' //g' )
17
+ LATEST=$( skopeo inspect docker://${IMAGE} | jq ' .Digest' | tr -d ' "' )
18
+ if [ ${CURRENT} == ${LATEST} ]; then
19
+ exit 7 # Up to date
20
+ else
21
+ exit 0 # Upgrade available
22
+ fi
17
23
else
18
- exit 0 # Upgrade available
24
+ exit 7 # Connectivity check failed
19
25
fi
20
26
else
21
- exit 7 # Connectivity check failed
27
+ exit 7 # System in use
22
28
fi
23
29
fi
24
30
elif [ " $1 " == " --supports-duplicate-detection" ]; then
@@ -36,20 +42,20 @@ if command -v rpm-ostree > /dev/null; then
36
42
echo 100%
37
43
}
38
44
upgrade () {
39
- # Pull exit code from rpm-ostree
40
- rpm-ostree upgrade --unchanged-exit-77
45
+ # Pull exit code from ublue-update
46
+ ublue-update
41
47
echo $? > /tmp/upgrade-check
42
48
}
43
49
upgrade | fake_progress
44
50
# Check if upgrade failed
45
51
UPGRADE_CHECK=/tmp/upgrade-check
46
52
rm /tmp/upgrade-check
47
- if [ ${UPGRADE_CHECK} -eq 77 ]; then
48
- exit 0 # Upgrade failed
49
- else
53
+ if [ ${UPGRADE_CHECK} -eq 0 ]; then
50
54
touch /tmp/upgrade-installed
55
+ else
56
+ exit 0 # Upgrade failed
51
57
fi
52
58
fi
53
59
else
54
- exit 7 # rpm-ostree not installed
60
+ exit 7 # ublue-update not installed
55
61
fi
0 commit comments