osuboot/osuboot.sh
2024-03-14 21:08:16 +01:00

80 lines
2.2 KiB
Bash
Executable file

#!/usr/sbin/env bash
##########################
## osu!boot ##
## Made by JeremyStarTM ##
## Licensed under the ##
## GNU GPL v3 ##
##########################
export "OSUBOOT_NETCONNECT=false"
function prepare(){
echo "Preparing osu!boot"
if [ -d "/tmp/osuboot/" ]; then
rm -rf "/tmp/osuboot/" &> /tmp/osuboot_rm.log
fi
mkdir "/tmp/osuboot" -p
if [ -f "/tmp/osuboot_rm.log" ]; then
mv "/tmp/osuboot_rm.log" "/tmp/osuboot/rm.log"
fi
sleep 1s
}
function checkInternet() {
ping 1.1.1.1 -c 1 &> /dev/null
if [ ! "$?" == "0" ]; then
echo "Checking internet connectivity: No internet (IPv4)"
return
fi
ping one.one.one.one -c 1 &> /dev/null
if [ ! "$?" == "0" ]; then
echo "Checking internet connectivity: No internet (DNS)"
return
fi
echo "Checking internet connectivity"
export "OSUBOOT_NETCONNECT=true"
}
function downloadGame(){
if [ "$OSUBOOT_NETCONNECT" == "false" ]; then
echo "Downloading osu!lazer: Skipping, no internet available"
return
fi
echo "Downloading osu!lazer"
if [ ! -f "$HOME/.cache/osu.AppImage" ] || [[ $(find "$HOME/.cache/osu.AppImage" -mtime +1 -print) ]]; then
wget "https://github.com/ppy/osu/releases/latest/download/osu.AppImage" -O "$HOME/.cache/osu.AppImage" &> /tmp/osuboot/download.log
else
echo "Downloading osu!lazer: Skipping, download is not yet a day old"
fi
chmod +x "$HOME/.cache/osu.AppImage"
}
function runGame(){
if [ ! -f "$HOME/.cache/osu.AppImage" ]; then
echo "Launching osu!lazer: osu!lazer is missing and can't be launched."
return
fi
echo "Launching osu!lazer"
"$HOME"/.cache/osu.AppImage &> /tmp/osuboot/osu.proclog
}
function notice(){
if [ "$1" == "startup" ]; then
echo " _ _ _ "
echo " ___ ___ _ _| | |__ ___ ___ | |_ "
echo " / _ \/ __| | | | | '_ \ / _ \ / _ \| __|"
echo "| (_) \__ \ |_| |_| |_) | (_) | (_) | |_ "
echo " \___/|___/\__,_(_)_.__/ \___/ \___/ \__|"
echo ""
elif [ "$1" == "exit" ]; then
echo ""
echo "osu!boot is being developed by the StarOpenSource Project, is designed"
echo "to be used with osu!launcher and is maintained by JeremyStarTM."
else
echo "Invalid notice."
return
fi
}
function run() {
notice "startup"
prepare
checkInternet
downloadGame
runGame
notice "exit"
}
run