Update_RetroDriven.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/bin/bash
  2. # This program is free software: you can redistribute it and/or modify
  3. # it under the terms of the GNU General Public License as published by
  4. # the Free Software Foundation, either version 3 of the License, or
  5. # (at your option) any later version.
  6. # This program is distributed in the hope that it will be useful,
  7. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. # GNU General Public License for more details.
  10. # You should have received a copy of the GNU General Public License
  11. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  12. # Copyright 2019 Alessandro "Locutus73" Miele
  13. # You can download the latest version of this script from:
  14. # https://github.com/RetroDriven/MiSTer_UnofficialCores
  15. : '
  16. ###### Disclaimer / Legal Information ######
  17. By downloading ROM injected Core/RBF files you are agreeing to the following:
  18. * You are responsible for checking your local laws regarding the use of the ROMs associated with the injected Core/RBF files.
  19. * You are authorized/licensed to own/use the ROMs associated with the injected Core/RBF files that you download.
  20. * You will not distribute any of these files without the appropriate permissions.
  21. * You own the original Arcade PCB for each ROM injected Core/RBF file that you download.
  22. * I take no responsibility for any data loss or anything, use the script at your own risk.
  23. '
  24. # RetroDriven v1.0 - Changed Script as needed
  25. # ========= OPTIONS ==================
  26. URL="https://github.com"
  27. SCRIPT_URL="${URL}/RetroDriven/MiSTer_UnofficialCores/blob/master/Scripts/Updater_RetroDriven.sh"
  28. CURL_RETRY="--connect-timeout 15 --max-time 120 --retry 3 --retry-delay 5 --silent"
  29. # ========= ADVANCED OPTIONS =========
  30. # ALLOW_INSECURE_SSL="true" will check if SSL certificate verification (see https://curl.haxx.se/docs/sslcerts.html )
  31. # is working (CA certificates installed) and when it's working it will use this feature for safe curl HTTPS downloads,
  32. # otherwise it will use --insecure option for disabling SSL certificate verification.
  33. # If CA certificates aren't installed it's advised to install them (i.e. using security_fixes.sh).
  34. # ALLOW_INSECURE_SSL="false" will never use --insecure option and if CA certificates aren't installed
  35. # any download will fail.
  36. ALLOW_INSECURE_SSL="true"
  37. # ========= CODE STARTS HERE =========
  38. # get the name of the script, or of the parent script if called through a 'curl ... | bash -'
  39. ORIGINAL_SCRIPT_PATH="${0}"
  40. [[ "${ORIGINAL_SCRIPT_PATH}" == "bash" ]] && \
  41. ORIGINAL_SCRIPT_PATH="$(ps -o comm,pid | awk -v PPID=${PPID} '$2 == PPID {print $1}')"
  42. # ini file can contain user defined variables (as bash commands)
  43. # Load and execute the content of the ini file, if there is one
  44. INI_PATH="${ORIGINAL_SCRIPT_PATH%.*}.ini"
  45. if [[ -f "${INI_PATH}" ]] ; then
  46. TMP=$(mktemp)
  47. # preventively eliminate DOS-specific format and exit command
  48. dos2unix < "${INI_PATH}" 2> /dev/null | grep -v "^exit" > ${TMP}
  49. source ${TMP}
  50. rm -f ${TMP}
  51. fi
  52. # test network and https by pinging the target website
  53. SSL_SECURITY_OPTION=""
  54. curl ${CURL_RETRY} "${URL}" > /dev/null 2>&1
  55. case $? in
  56. 0)
  57. ;;
  58. 60)
  59. if [[ "${ALLOW_INSECURE_SSL}" == "true" ]]
  60. then
  61. SSL_SECURITY_OPTION="--insecure"
  62. else
  63. echo "CA certificates need"
  64. echo "to be fixed for"
  65. echo "using SSL certificate"
  66. echo "verification."
  67. echo "Please fix them i.e."
  68. echo "using security_fixes.sh"
  69. exit 2
  70. fi
  71. ;;
  72. *)
  73. echo "No Internet connection"
  74. exit 1
  75. ;;
  76. esac
  77. # download and execute the latest mister_updater.sh
  78. echo "Downloading and executing"
  79. echo "${SCRIPT_URL/*\//}"
  80. echo ""
  81. curl \
  82. ${CURL_RETRY} \
  83. ${SSL_SECURITY_OPTION} \
  84. --fail \
  85. --location \
  86. "${SCRIPT_URL}?raw=true" | \
  87. bash -
  88. exit 0