2023-06-19 22:59:57 +00:00
|
|
|
#!/bin/bash
|
2023-02-09 11:08:39 -08:00
|
|
|
|
2023-07-02 19:11:15 -06:00
|
|
|
if command -v ublue-update > /dev/null; then
|
2023-06-19 22:59:57 +00:00
|
|
|
if [ "$1" == "check" ]; then
|
|
|
|
if [ -f '/tmp/upgrade-installed' ]; then
|
|
|
|
exit 7 # Upgrade already installed
|
|
|
|
else
|
2023-07-03 17:43:50 -06:00
|
|
|
# Perform connectivity check
|
|
|
|
wget -q --spider https://github.com
|
2023-06-19 22:59:57 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
2023-07-03 17:43:50 -06:00
|
|
|
# Check system state
|
2023-07-09 16:53:02 -06:00
|
|
|
ublue-update --check --updatecheck
|
2023-07-02 19:11:15 -06:00
|
|
|
if [ $? -eq 0 ]; then
|
2023-07-03 17:43:50 -06:00
|
|
|
exit 0 # Upgrade available
|
2023-06-19 22:59:57 +00:00
|
|
|
else
|
2023-07-03 17:43:50 -06:00
|
|
|
exit 7 # Checks failed
|
2023-06-19 22:59:57 +00:00
|
|
|
fi
|
|
|
|
else
|
2023-07-03 17:43:50 -06:00
|
|
|
exit 7 # Connectivity check failed
|
2023-06-19 22:59:57 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
elif [ "$1" == "--supports-duplicate-detection" ]; then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
# Fake upgrade progress bar
|
|
|
|
fake_progress() {
|
|
|
|
local value=0
|
2023-07-18 09:05:39 -06:00
|
|
|
while [ ! -f '/tmp/upgrade-check' ]; do
|
|
|
|
sleep 5
|
2023-06-19 22:59:57 +00:00
|
|
|
if [ ${value} -lt '100' ]; then
|
|
|
|
echo ${value}'%'
|
|
|
|
value=$(( value + 3 ))
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
echo 100%
|
|
|
|
}
|
|
|
|
upgrade() {
|
2023-07-02 19:11:15 -06:00
|
|
|
# Pull exit code from ublue-update
|
2023-07-18 09:05:39 -06:00
|
|
|
ublue-update --force > /dev/null 2>&1
|
2023-06-19 22:59:57 +00:00
|
|
|
echo $? > /tmp/upgrade-check
|
|
|
|
}
|
|
|
|
upgrade | fake_progress
|
|
|
|
# Check if upgrade failed
|
|
|
|
UPGRADE_CHECK=/tmp/upgrade-check
|
|
|
|
rm /tmp/upgrade-check
|
2023-07-02 19:11:15 -06:00
|
|
|
if [ ${UPGRADE_CHECK} -eq 0 ]; then
|
2023-06-19 22:59:57 +00:00
|
|
|
touch /tmp/upgrade-installed
|
2023-07-02 19:11:15 -06:00
|
|
|
else
|
|
|
|
exit 0 # Upgrade failed
|
2023-06-19 22:59:57 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
2023-07-02 19:11:15 -06:00
|
|
|
exit 7 # ublue-update not installed
|
2023-06-19 22:59:57 +00:00
|
|
|
fi
|