bazzite/system_files/deck/shared/usr/bin/steamos-update

55 lines
1.3 KiB
Bash
Executable File

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