4
mirror of git://git.acid.vegas/unrealircd.git synced 2024-11-30 11:56:40 +00:00
unrealircd/extras/unrealircd-upgrade-script.in

124 lines
4.3 KiB
Plaintext
Raw Normal View History

2022-01-15 05:16:34 +00:00
#!/usr/bin/env bash
2021-03-21 17:05:35 +00:00
#
# This is stage 1 of the UnrealIRCd upgrade script
# It downloads stage 2 online, verifies the integrity, and then
# passes control to it to proceed with the rest of the upgrade.
#
2022-01-15 05:16:34 +00:00
# This is a bash script, so it is less cross-platform than the
# rest of UnrealIRCd. We also mostly assume Linux/FreeBSD here.
2021-03-21 17:05:35 +00:00
#
BUILDDIR="@BUILDDIR@"
SCRIPTDIR="@SCRIPTDIR@"
DOCDIR="@DOCDIR@"
TMPDIR="@TMPDIR@"
function warn()
{
echo
echo "WARNING: $*"
echo "This is for your information only. It is possible to continue."
echo "Press ENTER to continue, or CTRL+C to abort."
echo "If in doubt, see https://www.unrealircd.org/docs/FAQ#upgrade-verify-failed"
read xyz
}
function bigwarn()
{
echo
echo "[!!!] WARNING: $*"
echo "Check https://www.unrealircd.org/docs/FAQ#upgrade-verify-failed !"
echo "Type 'IGNORE' in uppercase to continue if you think it is safe."
echo "Type anything else to abort."
read answer
if [ "$answer" != "IGNORE" ]; then
exit 1
fi
}
function fail()
{
echo
echo "ERROR: $*"
echo "NOTE: Your existing UnrealIRCd is backed up to $BACKUPDIR"
echo "Perhaps check out the FAQ for common problems:"
echo "https://www.unrealircd.org/docs/FAQ#upgrade-failed"
echo "Otherwise, follow the manual upgrade procedure from"
echo "https://www.unrealircd.org/docs/Upgrading"
exit 1
}
if [ ! -d "$BUILDDIR" ]; then
echo "UnrealIRCd source not found at $BUILDDIR."
echo "Sorry, then it is not possible to know your existing settings and thus we cannot upgrade."
echo "Follow the manual upgrade procedure from https://www.unrealircd.org/docs/Upgrading"
exit 1
fi
2022-01-15 05:16:34 +00:00
FETCHER="wget"
2021-03-21 17:05:35 +00:00
if ! wget --help 1>/dev/null 2>&1; then
2022-01-15 05:16:34 +00:00
# fetch is a pain: it always returns 1 (false) even for usage info and has no --version
fetch 1>/dev/null 2>&1
if [ "$?" -ne 1 ]; then
echo "The tool 'wget' is missing, which is used by this script."
echo "On Linux consider running 'sudo apt install wget' or 'sudo yum install wget'"
echo "and run this script again."
echo "Or, don't use this script and follow the manual upgrade procedure from"
echo "https://www.unrealircd.org/docs/Upgrading"
exit 1
fi
FETCHER="fetch"
2021-03-21 17:05:35 +00:00
fi
# Weird way to get version, but ok.
cd "$BUILDDIR" || fail "Could not cd to builddir"
UNREALVER="`./configure --version|head -n1|awk '{ print $3 }'`"
cd .. || fail "Could not cd back"
# Set and export all variables with settings
2022-01-15 05:16:34 +00:00
export UNREALVER BUILDDIR SCRIPTDIR DOCDIR TMPDIR FETCHER
2021-03-21 17:05:35 +00:00
# Download the install script
2022-01-15 05:16:34 +00:00
if [ "$FETCHER" = "wget" ]; then
wget -O unrealircd-upgrade-script.stage2 "https://www.unrealircd.org/downloads/unrealircd-upgrade-script.stage2?from=$UNREALVER" || fail "Could not download online installer"
wget -O unrealircd-upgrade-script.stage2.asc "https://www.unrealircd.org/downloads/unrealircd-upgrade-script.stage2.asc" || fail "Could not download online installer signature"
else
fetch -o unrealircd-upgrade-script.stage2 "https://www.unrealircd.org/downloads/unrealircd-upgrade-script.stage2?from=$UNREALVER" || fail "Could not download online installer"
fetch -o unrealircd-upgrade-script.stage2.asc "https://www.unrealircd.org/downloads/unrealircd-upgrade-script.stage2.asc" || fail "Could not download online installer signature"
fi
2021-03-21 17:05:35 +00:00
# GPG verification - if available
if gpg --version 1>/dev/null 2>&1; then
if [ -f "$DOCDIR/KEYS" ]; then
gpg --import "$DOCDIR/KEYS"
echo
if gpg --batch --exit-on-status-write-error --verify unrealircd-upgrade-script.stage2.asc unrealircd-upgrade-script.stage2; then
echo "GPG: Verification succeeded. Download is genuine."
export NOGPG=0
else
bigwarn "GPG/PGP verification failed. This could be a security issue."
export NOGPG=1
fi
else
warn "Unable to check download integrity with GPG/PGP. Missing $DOCDIR/KEYS file."
export NOGPG=1
fi
else
echo "WARNING: The GnuPG (GPG/PGP) verification tool 'gpg' is not installed."
2022-01-15 05:16:34 +00:00
if [[ "$OSTYPE" == "freebsd"* ]] ; then
echo "Consider running 'sudo pkg install gnupg'"
else
echo "Consider running 'sudo apt install gpg' or 'yum install gnupg2'"
fi
2021-03-21 17:05:35 +00:00
echo "When 'gpg' is installed then the UnrealIRCd upgrade script can"
echo "verify the digital signature of the download file."
warn "Unable to check download integrity"
export NOGPG=1
fi
chmod +x unrealircd-upgrade-script.stage2
./unrealircd-upgrade-script.stage2 $*
2022-01-15 05:16:34 +00:00
SAVERET="$?"
2022-11-20 04:12:40 +00:00
rm -f unrealircd-upgrade-script.stage2 unrealircd-upgrade-script.stage2.asc
2022-01-15 05:16:34 +00:00
exit $SAVERET