From 0e125abc36fcb664131abaa5d5765fdbbd466f61 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Sun, 10 Jan 2021 16:22:33 +0100 Subject: [PATCH] New: "./unrealircd upgrade" to upgrade to latest UnrealIRCd release. --- Makefile.in | 3 +- configure | 3 +- configure.ac | 1 + extras/unrealircd-upgrade-script.in | 90 +++++++++++++++++++++++++++++ unrealircd.in | 9 ++- 5 files changed, 101 insertions(+), 5 deletions(-) create mode 100644 extras/unrealircd-upgrade-script.in diff --git a/Makefile.in b/Makefile.in index 71a104dd9..10a56786c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -166,8 +166,9 @@ depend: install: all $(INSTALL) -m 0700 -d $(DESTDIR)@BINDIR@ $(INSTALL) -m 0700 src/ircd $(DESTDIR)@BINDIR@/unrealircd + $(INSTALL) -m 0700 extras/unrealircd-upgrade-script $(DESTDIR)@BINDIR@/unrealircd-upgrade-script $(INSTALL) -m 0700 -d $(DESTDIR)@DOCDIR@ - $(INSTALL) -m 0600 doc/Authors doc/coding-guidelines doc/tao.of.irc $(DESTDIR)@DOCDIR@ + $(INSTALL) -m 0600 doc/Authors doc/coding-guidelines doc/tao.of.irc doc/KEYS doc/RELEASE-NOTES.md $(DESTDIR)@DOCDIR@ $(INSTALL) -m 0700 -d $(DESTDIR)@CONFDIR@ $(INSTALL) -m 0600 doc/conf/*.default.conf $(DESTDIR)@CONFDIR@ $(INSTALL) -m 0600 doc/conf/*.optional.conf $(DESTDIR)@CONFDIR@ diff --git a/configure b/configure index 17d59631b..08ef23671 100755 --- a/configure +++ b/configure @@ -7984,7 +7984,7 @@ fi -ac_config_files="$ac_config_files Makefile src/Makefile src/modules/Makefile src/modules/chanmodes/Makefile src/modules/usermodes/Makefile src/modules/snomasks/Makefile src/modules/extbans/Makefile src/modules/third/Makefile unrealircd" +ac_config_files="$ac_config_files Makefile src/Makefile src/modules/Makefile src/modules/chanmodes/Makefile src/modules/usermodes/Makefile src/modules/snomasks/Makefile src/modules/extbans/Makefile src/modules/third/Makefile extras/unrealircd-upgrade-script unrealircd" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -8685,6 +8685,7 @@ do "src/modules/snomasks/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/snomasks/Makefile" ;; "src/modules/extbans/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/extbans/Makefile" ;; "src/modules/third/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/third/Makefile" ;; + "extras/unrealircd-upgrade-script") CONFIG_FILES="$CONFIG_FILES extras/unrealircd-upgrade-script" ;; "unrealircd") CONFIG_FILES="$CONFIG_FILES unrealircd" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; diff --git a/configure.ac b/configure.ac index 10b76863c..af051c980 100644 --- a/configure.ac +++ b/configure.ac @@ -730,6 +730,7 @@ AC_CONFIG_FILES([Makefile src/modules/snomasks/Makefile src/modules/extbans/Makefile src/modules/third/Makefile + extras/unrealircd-upgrade-script unrealircd]) AC_OUTPUT chmod 0700 unrealircd diff --git a/extras/unrealircd-upgrade-script.in b/extras/unrealircd-upgrade-script.in new file mode 100644 index 000000000..c90fc9f18 --- /dev/null +++ b/extras/unrealircd-upgrade-script.in @@ -0,0 +1,90 @@ +#!/bin/bash +# +# 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. +# +# This is a bash script, so it is less cross-platform than +# the rest of UnrealIRCd. We also mostly assume Linux here. +# + +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 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 + +if ! wget --help 1>/dev/null 2>&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 + +# 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 +export UNREALVER BUILDDIR SCRIPTDIR DOCDIR TMPDIR + +# Download the install script +wget -O unrealircd-upgrade-script.stage2 "https://www.unrealircd.org/downloads/unrealircd-upgrade-script.stage2" || 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" + +# GPG verification - if available +if gpgv --version 1>/dev/null 2>&1; then + if [ -f "$DOCDIR/KEYS" ]; then + if gpgv --keyring $DOCDIR/KEYS unrealircd-latest.tar.gz.asc unrealircd-latest.tar.gz; then + echo "GPG: Verification succeeded. Download is genuine." + export NOGPG=0 + else + warn "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 'gpgv' is not installed." + echo "Consider running 'sudo apt install gpgv' or 'yum install gnupg2'" + echo "When 'gpgv' 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 $* diff --git a/unrealircd.in b/unrealircd.in index 73dcaea12..b83d3d48b 100644 --- a/unrealircd.in +++ b/unrealircd.in @@ -286,6 +286,8 @@ elif [ "$1" = "hot-patch" -o "$1" = "cold-patch" ] ; then else echo "Patch applied successfully. You must now restart your IRC server." fi +elif [ "$1" = "upgrade" ] ; then + @BINDIR@/unrealircd-upgrade-script $* elif [ "$1" = "genlinkblock" ] ; then @BINDIR@/unrealircd -L else @@ -298,8 +300,11 @@ else echo "unrealircd start Start the IRC Server" echo "unrealircd stop Stop (kill) the IRC Server" echo "unrealircd rehash Reload the configuration file" - echo "unrealircd reloadtls Reload the SSL/TLS certificate and settings" + echo "unrealircd reloadtls Reload the SSL/TLS certificates" echo "unrealircd restart Restart the IRC Server (stop+start)" + echo "unrealircd upgrade Upgrade UnrealIRCd to the latest version" + echo "unrealircd upgrade-conf Upgrade the configuration file from UnrealIRCd" + echo " 3.2.x/4.x to 5.x format" echo "unrealircd mkpasswd Hash a password" echo "unrealircd version Display the UnrealIRCd version" echo "unrealircd module Install and uninstall 3rd party modules" @@ -307,6 +312,4 @@ else echo " is running. If not, the server is started." echo "unrealircd gencloak Display 3 random cloak keys" echo "unrealircd spkifp Display SPKI Fingerprint" - echo "unrealircd upgrade-conf Upgrade the configuration file from UnrealIRCd" - echo " 3.2.x/4.x to 5.x format" fi