Advertisement
rafael_grether

unrealircd-upgrade-script - Modified 6-rc1

Nov 30th, 2021
59
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env bash
  2. #
  3. # This is stage 1 of the UnrealIRCd upgrade script
  4. # It downloads stage 2 online, verifies the integrity, and then
  5. # passes control to it to proceed with the rest of the upgrade.
  6. #
  7. # This is a bash script, so it is less cross-platform than
  8. # the rest of UnrealIRCd. We also mostly assume Linux here.
  9. #
  10.  
  11. BUILDDIR="/home/unrealircd/unrealircd-6.0.0-rc1"
  12. SCRIPTDIR="/home/unrealircd/unrealircd"
  13. DOCDIR="/home/unrealircd/unrealircd/doc"
  14. TMPDIR="/home/unrealircd/unrealircd/tmp"
  15.  
  16. function warn()
  17. {
  18. echo
  19. echo "WARNING: $*"
  20. echo "This is for your information only. It is possible to continue."
  21. echo "Press ENTER to continue, or CTRL+C to abort."
  22. echo "If in doubt, see https://www.unrealircd.org/docs/FAQ#upgrade-verify-failed"
  23. read xyz
  24. }
  25.  
  26. function bigwarn()
  27. {
  28. echo
  29. echo "[!!!] WARNING: $*"
  30. echo "Check https://www.unrealircd.org/docs/FAQ#upgrade-verify-failed !"
  31. echo "Type 'IGNORE' in uppercase to continue if you think it is safe."
  32. echo "Type anything else to abort."
  33. read answer
  34. if [ "$answer" != "IGNORE" ]; then
  35. exit 1
  36. fi
  37. }
  38.  
  39. function fail()
  40. {
  41. echo
  42. echo "ERROR: $*"
  43. echo "NOTE: Your existing UnrealIRCd is backed up to $BACKUPDIR"
  44. echo "Perhaps check out the FAQ for common problems:"
  45. echo "https://www.unrealircd.org/docs/FAQ#upgrade-failed"
  46. echo "Otherwise, follow the manual upgrade procedure from"
  47. echo "https://www.unrealircd.org/docs/Upgrading"
  48. exit 1
  49. }
  50.  
  51. if [ ! -d "$BUILDDIR" ]; then
  52. echo "UnrealIRCd source not found at $BUILDDIR."
  53. echo "Sorry, then it is not possible to know your existing settings and thus we cannot upgrade."
  54. echo "Follow the manual upgrade procedure from https://www.unrealircd.org/docs/Upgrading"
  55. exit 1
  56. fi
  57.  
  58. #FreeBSD uses fetch to retrieve a file
  59. if [[ "$OSTYPE" != "freebsd"* ]] ; then
  60. if ! wget --help 1>/dev/null 2>&1 ; then
  61. echo "The tool 'wget' is missing, which is used by this script."
  62. echo "On Linux consider running 'sudo apt install wget' or 'sudo yum install wget'"
  63. echo "and run this script again."
  64. echo "Or, don't use this script and follow the manual upgrade procedure from"
  65. echo "https://www.unrealircd.org/docs/Upgrading"
  66. exit 1
  67. fi
  68. fi
  69.  
  70. # Weird way to get version, but ok.
  71. cd "$BUILDDIR" || fail "Could not cd to builddir"
  72. UNREALVER="`./configure --version|head -n1|awk '{ print $3 }'`"
  73. cd .. || fail "Could not cd back"
  74.  
  75. # Set and export all variables with settings
  76. export UNREALVER BUILDDIR SCRIPTDIR DOCDIR TMPDIR
  77.  
  78. # Download the install script
  79. if [[ "$OSTYPE" == "freebsd"* ]] ; then
  80. fetch -o unrealircd-upgrade-script.stage2 "https://www.unrealircd.org/downloads/unrealircd-upgrade-script.stage2?from=$UNREALVER" || fail "Could not download online installer"
  81. fetch -o unrealircd-upgrade-script.stage2.asc "https://www.unrealircd.org/downloads/unrealircd-upgrade-script.stage2.asc" || fail "Could not download online installer signature"
  82. else
  83. wget -O unrealircd-upgrade-script.stage2 "https://www.unrealircd.org/downloads/unrealircd-upgrade-script.stage2?from=$UNREALVER" || fail "Could not download online installer"
  84. wget -O unrealircd-upgrade-script.stage2.asc "https://www.unrealircd.org/downloads/unrealircd-upgrade-script.stage2.asc" || fail "Could not download online installer signature"
  85. fi
  86.  
  87. # GPG verification - if available
  88. if gpg --version 1>/dev/null 2>&1; then
  89. if [ -f "$DOCDIR/KEYS" ]; then
  90. gpg --import "$DOCDIR/KEYS"
  91. echo
  92. if gpg --batch --exit-on-status-write-error --verify unrealircd-upgrade-script.stage2.asc unrealircd-upgrade-script.stage2; then
  93. echo "GPG: Verification succeeded. Download is genuine."
  94. export NOGPG=0
  95. else
  96. bigwarn "GPG/PGP verification failed. This could be a security issue."
  97. export NOGPG=1
  98. fi
  99. else
  100. warn "Unable to check download integrity with GPG/PGP. Missing $DOCDIR/KEYS file."
  101. export NOGPG=1
  102. fi
  103. else
  104. echo "WARNING: The GnuPG (GPG/PGP) verification tool 'gpg' is not installed."
  105.  
  106. if [[ "$OSTYPE" == "freebsd"* ]] ; then
  107. echo "On FreeBSD consider running 'sudo pkg install gnupg'"
  108. else
  109. echo "On Linux consider running 'sudo apt install gpg' or 'yum install gnupg2'"
  110. fi
  111. echo "When 'gpg' is installed then the UnrealIRCd upgrade script can"
  112. echo "verify the digital signature of the download file."
  113. warn "Unable to check download integrity"
  114. export NOGPG=1
  115. fi
  116.  
  117. chmod +x unrealircd-upgrade-script.stage2
  118. ./unrealircd-upgrade-script.stage2 $*
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement