|
@@ -0,0 +1,419 @@
|
|
|
|
|
+#!/bin/bash
|
|
|
|
|
+
|
|
|
|
|
+# This program is free software: you can redistribute it and/or modify
|
|
|
|
|
+# it under the terms of the GNU General Public License as published by
|
|
|
|
|
+# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
+# (at your option) any later version.
|
|
|
|
|
+
|
|
|
|
|
+# This program is distributed in the hope that it will be useful,
|
|
|
|
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
+# GNU General Public License for more details.
|
|
|
|
|
+
|
|
|
|
|
+# You should have received a copy of the GNU General Public License
|
|
|
|
|
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
+
|
|
|
|
|
+# Copyright 2018-2019 Alessandro "Locutus73" Miele
|
|
|
|
|
+
|
|
|
|
|
+# You can download the latest version of this script from:
|
|
|
|
|
+# https://github.com/MiSTer-devel/Updater_script_MiSTer
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+# RetroDriven v1.0 - Changed Script as needed
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+#========= USER OPTIONS =========
|
|
|
|
|
+#Base directory for all script’s tasks, "/media/fat" for SD root, "/media/usb0" for USB drive root.
|
|
|
|
|
+BASE_PATH="/home/jeebs/Desktop"
|
|
|
|
|
+
|
|
|
|
|
+#Directories where all core categories will be downloaded.
|
|
|
|
|
+declare -A CORE_CATEGORY_PATHS
|
|
|
|
|
+CORE_CATEGORY_PATHS["arcade-cores"]="$BASE_PATH/_RetroDriven"
|
|
|
|
|
+
|
|
|
|
|
+#Specifies if old files (cores, main MiSTer executable, menu, SD-Installer, etc.) will be deleted as part of an update.
|
|
|
|
|
+DELETE_OLD_FILES="true"
|
|
|
|
|
+
|
|
|
|
|
+#Specifies what to do with new cores not installed locally:
|
|
|
|
|
+#true for downloading new cores in the standard directories (see CORE_CATEGORY_PATHS),
|
|
|
|
|
+#false for not downloading new cores at all,
|
|
|
|
|
+#a string value, i.e. "NewCores", for downloading new cores in the "NewCores" subdirectory.
|
|
|
|
|
+DOWNLOAD_NEW_CORES="true"
|
|
|
|
|
+
|
|
|
|
|
+#Specifies if the "Arcade-" prefix will be removed in local arcade cores.
|
|
|
|
|
+REMOVE_ARCADE_PREFIX="true"
|
|
|
|
|
+
|
|
|
|
|
+#A space separated list of filters for the online repositories;
|
|
|
|
|
+#each filter can be part of the repository name or a whole core category,
|
|
|
|
|
+#i.e. “C64 Minimig NES SNES arcade-cores” if you want the script to check only
|
|
|
|
|
+#for C64, Minimig, NES, SNES, and all arcade cores repositories making the whole
|
|
|
|
|
+#update process quicker;
|
|
|
|
|
+#if you use this option probably you want DOWNLOAD_NEW_CORES="true" so that you
|
|
|
|
|
+#can use this filter in order to setup a brand new empty SD with only the cores
|
|
|
|
|
+#you need, otherwise cores in the filter, but not on the SD won't be downloaded.
|
|
|
|
|
+REPOSITORIES_FILTER=""
|
|
|
|
|
+
|
|
|
|
|
+#Specifies if the cheats will be downloaded/updated from https://gamehacking.org/
|
|
|
|
|
+#"true" for checking for updates each time, "false" for disabling the function,
|
|
|
|
|
+#"once" for downloading cheats just once if not on the SD card (no further updating).
|
|
|
|
|
+UPDATE_CHEATS="false"
|
|
|
|
|
+
|
|
|
|
|
+#EXPERIMENTAL: specifies if the Kernel, the Linux filesystem and the bootloader will be updated; use it at your own risk!
|
|
|
|
|
+UPDATE_LINUX="false"
|
|
|
|
|
+
|
|
|
|
|
+#EXPERIMENTAL: specifies if the update process must be done with parallel processing; use it at your own risk!
|
|
|
|
|
+PARALLEL_UPDATE="false"
|
|
|
|
|
+
|
|
|
|
|
+#Specifies an optional URL with a text file containing a curated list of "good" cores.
|
|
|
|
|
+#If a core is specified there, it will be preferred over the latest "bleeding edge" core in its repository.
|
|
|
|
|
+#The text file can be something simple as "Genesis_20190712.rbf SNES_20190703.rbf".
|
|
|
|
|
+GOOD_CORES_URL=""
|
|
|
|
|
+
|
|
|
|
|
+#Specifies if the core directory (i.e. /media/fat/Amiga for Minimig core, /media/fat/SNES for SNES core) has to be created
|
|
|
|
|
+#the first time the core is downloaded.
|
|
|
|
|
+CREATE_CORES_DIRECTORIES="false"
|
|
|
|
|
+
|
|
|
|
|
+#========= ADVANCED OPTIONS =========
|
|
|
|
|
+#ALLOW_INSECURE_SSL="true" will check if SSL certificate verification (see https://curl.haxx.se/docs/sslcerts.html )
|
|
|
|
|
+#is working (CA certificates installed) and when it's working it will use this feature for safe curl HTTPS downloads,
|
|
|
|
|
+#otherwise it will use --insecure option for disabling SSL certificate verification.
|
|
|
|
|
+#If CA certificates aren't installed it's advised to install them (i.e. using security_fixes.sh).
|
|
|
|
|
+#ALLOW_INSECURE_SSL="false" will never use --insecure option and if CA certificates aren't installed
|
|
|
|
|
+#any download will fail.
|
|
|
|
|
+ALLOW_INSECURE_SSL="true"
|
|
|
|
|
+CURL_RETRY="--connect-timeout 15 --max-time 120 --retry 3 --retry-delay 5"
|
|
|
|
|
+SCRIPTS_PATH="Scripts"
|
|
|
|
|
+OLD_SCRIPTS_PATH="#Scripts"
|
|
|
|
|
+WORK_PATH="/media/fat/$SCRIPTS_PATH/.mister_updater"
|
|
|
|
|
+#Uncomment this if you want the script to sync the system date and time with a NTP server
|
|
|
|
|
+#NTP_SERVER="0.pool.ntp.org"
|
|
|
|
|
+AUTOREBOOT="false"
|
|
|
|
|
+REBOOT_PAUSE=0
|
|
|
|
|
+TEMP_PATH="/tmp"
|
|
|
|
|
+TO_BE_DELETED_EXTENSION="to_be_deleted"
|
|
|
|
|
+
|
|
|
|
|
+sleep 2
|
|
|
|
|
+echo
|
|
|
|
|
+echo "RetroDriven Core Updater - A Festivus for the rest of us!"
|
|
|
|
|
+echo
|
|
|
|
|
+
|
|
|
|
|
+#========= CODE STARTS HERE =========
|
|
|
|
|
+
|
|
|
|
|
+ORIGINAL_SCRIPT_PATH="$0"
|
|
|
|
|
+if [ "$ORIGINAL_SCRIPT_PATH" == "bash" ]
|
|
|
|
|
+then
|
|
|
|
|
+ ORIGINAL_SCRIPT_PATH=$(ps | grep "^ *$PPID " | grep -o "[^ ]*$")
|
|
|
|
|
+fi
|
|
|
|
|
+INI_PATH=${ORIGINAL_SCRIPT_PATH%.*}.ini
|
|
|
|
|
+if [ -f $INI_PATH ]
|
|
|
|
|
+then
|
|
|
|
|
+ eval "$(cat $INI_PATH | tr -d '\r')"
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+if [ -d "${BASE_PATH}/${OLD_SCRIPTS_PATH}" ] && [ ! -d "${BASE_PATH}/${SCRIPTS_PATH}" ]
|
|
|
|
|
+then
|
|
|
|
|
+ mv "${BASE_PATH}/${OLD_SCRIPTS_PATH}" "${BASE_PATH}/${SCRIPTS_PATH}"
|
|
|
|
|
+ echo "Moved"
|
|
|
|
|
+ echo "${BASE_PATH}/${OLD_SCRIPTS_PATH}"
|
|
|
|
|
+ echo "to"
|
|
|
|
|
+ echo "${BASE_PATH}/${SCRIPTS_PATH}"
|
|
|
|
|
+ echo "please relaunch the script."
|
|
|
|
|
+ exit 3
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+SSL_SECURITY_OPTION=""
|
|
|
|
|
+curl $CURL_RETRY -q https://github.com &>/dev/null
|
|
|
|
|
+case $? in
|
|
|
|
|
+ 0)
|
|
|
|
|
+ ;;
|
|
|
|
|
+ 60)
|
|
|
|
|
+ if [ "$ALLOW_INSECURE_SSL" == "true" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ SSL_SECURITY_OPTION="--insecure"
|
|
|
|
|
+ else
|
|
|
|
|
+ echo "CA certificates need"
|
|
|
|
|
+ echo "to be fixed for"
|
|
|
|
|
+ echo "using SSL certificate"
|
|
|
|
|
+ echo "verification."
|
|
|
|
|
+ echo "Please fix them i.e."
|
|
|
|
|
+ echo "using security_fixes.sh"
|
|
|
|
|
+ exit 2
|
|
|
|
|
+ fi
|
|
|
|
|
+ ;;
|
|
|
|
|
+ *)
|
|
|
|
|
+ echo "No Internet connection"
|
|
|
|
|
+ exit 1
|
|
|
|
|
+ ;;
|
|
|
|
|
+esac
|
|
|
|
|
+
|
|
|
|
|
+## sync with a public time server
|
|
|
|
|
+if [[ -n "${NTP_SERVER}" ]] ; then
|
|
|
|
|
+ echo "Syncing date and time with"
|
|
|
|
|
+ echo "${NTP_SERVER}"
|
|
|
|
|
+ # (-b) force time reset, (-s) write output to syslog, (-u) use
|
|
|
|
|
+ # unprivileged port for outgoing packets to workaround firewalls
|
|
|
|
|
+ ntpdate -b -s -u "${NTP_SERVER}"
|
|
|
|
|
+ echo
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+mkdir -p "${CORE_CATEGORY_PATHS[@]}"
|
|
|
|
|
+
|
|
|
|
|
+declare -A NEW_CORE_CATEGORY_PATHS
|
|
|
|
|
+if [ "$DOWNLOAD_NEW_CORES" != "true" ] && [ "$DOWNLOAD_NEW_CORES" != "false" ] && [ "$DOWNLOAD_NEW_CORES" != "" ]
|
|
|
|
|
+then
|
|
|
|
|
+ for idx in "${!CORE_CATEGORY_PATHS[@]}"; do
|
|
|
|
|
+ NEW_CORE_CATEGORY_PATHS[$idx]=$(echo ${CORE_CATEGORY_PATHS[$idx]} | sed "s/$(echo $BASE_PATH | sed 's/\//\\\//g')/$(echo $BASE_PATH | sed 's/\//\\\//g')\/$DOWNLOAD_NEW_CORES/g")
|
|
|
|
|
+ done
|
|
|
|
|
+ mkdir -p "${NEW_CORE_CATEGORY_PATHS[@]}"
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+CORE_URLS=$(curl $CURL_RETRY $SSL_SECURITY_OPTION -sLf "https://github.com/RetroDriven/Mister/wiki" | grep -io '\(https://github.com/RetroDriven/Mister/tree/master/ArcadeCores/[a-zA-Z0-9./_-]*\)\|\(user-content-[a-z-]*\)')
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+CORE_CATEGORY="-"
|
|
|
|
|
+SD_INSTALLER_PATH=""
|
|
|
|
|
+REBOOT_NEEDED="false"
|
|
|
|
|
+CORE_CATEGORIES_FILTER=""
|
|
|
|
|
+
|
|
|
|
|
+GOOD_CORES=""
|
|
|
|
|
+if [ "$GOOD_CORES_URL" != "" ]
|
|
|
|
|
+then
|
|
|
|
|
+ GOOD_CORES=$(curl $CURL_RETRY $SSL_SECURITY_OPTION -sLf "$GOOD_CORES_URL")
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+function checkCoreURL {
|
|
|
|
|
+
|
|
|
|
|
+ echo "Checking $(echo $CORE_URL | sed 's/.*\///g' | sed 's/_MiSTer//gI')"
|
|
|
|
|
+ [ "${SSH_CLIENT}" != "" ] && echo "URL: $CORE_URL"
|
|
|
|
|
+ if echo "$CORE_URL" | grep -q "SD-Installer"
|
|
|
|
|
+ then
|
|
|
|
|
+ RELEASES_URL="$CORE_URL"
|
|
|
|
|
+ else
|
|
|
|
|
+ RELEASES_URL=https://github.com$(curl $CURL_RETRY $SSL_SECURITY_OPTION -sLf "$CORE_URL" | grep -o '/RetroDriven/[a-zA-Z0-9./_-]*/tree/master/[a-zA-Z0-9./_-]*' | head -n1)
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ RELEASE_URLS=$(curl $CURL_RETRY $SSL_SECURITY_OPTION -sLf "$RELEASES_URL" | grep -o '/RetroDriven/[a-zA-Z0-9./_-]*_[0-9]\{8\}[a-zA-Z]\?\(\.rbf\)\?')
|
|
|
|
|
+
|
|
|
|
|
+ MAX_VERSION=""
|
|
|
|
|
+ MAX_RELEASE_URL=""
|
|
|
|
|
+ GOOD_CORE_VERSION=""
|
|
|
|
|
+ for RELEASE_URL in $RELEASE_URLS; do
|
|
|
|
|
+ if echo "$RELEASE_URL" | grep -q "SharpMZ"
|
|
|
|
|
+ then
|
|
|
|
|
+ RELEASE_URL=$(echo "$RELEASE_URL" | grep '\.rbf$')
|
|
|
|
|
+ fi
|
|
|
|
|
+ if echo "$RELEASE_URL" | grep -q "Atari800"
|
|
|
|
|
+ then
|
|
|
|
|
+ if [ "$CORE_CATEGORY" == "cores" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ RELEASE_URL=$(echo "$RELEASE_URL" | grep '800_[0-9]\{8\}[a-zA-Z]\?\.rbf$')
|
|
|
|
|
+ else
|
|
|
|
|
+ RELEASE_URL=$(echo "$RELEASE_URL" | grep '5200_[0-9]\{8\}[a-zA-Z]\?\.rbf$')
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+ CURRENT_VERSION=$(echo "$RELEASE_URL" | grep -o '[0-9]\{8\}[a-zA-Z]\?')
|
|
|
|
|
+
|
|
|
|
|
+ if [ "$GOOD_CORES" != "" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ GOOD_CORE_VERSION=$(echo "$GOOD_CORES" | grep -wo "$(echo "$RELEASE_URL" | sed 's/.*\///g')" | grep -o '[0-9]\{8\}[a-zA-Z]\?')
|
|
|
|
|
+ if [ "$GOOD_CORE_VERSION" != "" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ MAX_VERSION=$CURRENT_VERSION
|
|
|
|
|
+ MAX_RELEASE_URL=$RELEASE_URL
|
|
|
|
|
+ break
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ if [[ "$CURRENT_VERSION" > "$MAX_VERSION" ]]
|
|
|
|
|
+ then
|
|
|
|
|
+ MAX_VERSION=$CURRENT_VERSION
|
|
|
|
|
+ MAX_RELEASE_URL=$RELEASE_URL
|
|
|
|
|
+ fi
|
|
|
|
|
+ done
|
|
|
|
|
+
|
|
|
|
|
+ FILE_NAME=$(echo "$MAX_RELEASE_URL" | sed 's/.*\///g')
|
|
|
|
|
+ if [ "$CORE_CATEGORY" == "arcade-cores" ] && [ $REMOVE_ARCADE_PREFIX == "true" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ FILE_NAME=$(echo "$FILE_NAME" | sed 's/Arcade-//gI')
|
|
|
|
|
+ fi
|
|
|
|
|
+ BASE_FILE_NAME=$(echo "$FILE_NAME" | sed 's/_[0-9]\{8\}.*//g')
|
|
|
|
|
+
|
|
|
|
|
+ CURRENT_DIRS="${CORE_CATEGORY_PATHS[$CORE_CATEGORY]}"
|
|
|
|
|
+ if [ "${NEW_CORE_CATEGORY_PATHS[$CORE_CATEGORY]}" != "" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ CURRENT_DIRS=("$CURRENT_DIRS" "${NEW_CORE_CATEGORY_PATHS[$CORE_CATEGORY]}")
|
|
|
|
|
+ fi
|
|
|
|
|
+ if [ "$CURRENT_DIRS" == "" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ CURRENT_DIRS=("$BASE_PATH")
|
|
|
|
|
+ fi
|
|
|
|
|
+ if [ "$BASE_FILE_NAME" == "MiSTer" ] || [ "$BASE_FILE_NAME" == "menu" ] || { echo "$CORE_URL" | grep -q "SD-Installer"; }
|
|
|
|
|
+ then
|
|
|
|
|
+ mkdir -p "$WORK_PATH"
|
|
|
|
|
+ CURRENT_DIRS=("$WORK_PATH")
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ CURRENT_LOCAL_VERSION=""
|
|
|
|
|
+ MAX_LOCAL_VERSION=""
|
|
|
|
|
+ for CURRENT_DIR in "${CURRENT_DIRS[@]}"
|
|
|
|
|
+ do
|
|
|
|
|
+ for CURRENT_FILE in "$CURRENT_DIR/$BASE_FILE_NAME"*
|
|
|
|
|
+ do
|
|
|
|
|
+ if [ -f "$CURRENT_FILE" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ if echo "$CURRENT_FILE" | grep -q "$BASE_FILE_NAME\_[0-9]\{8\}[a-zA-Z]\?\(\.rbf\|\.rar\)\?$"
|
|
|
|
|
+ then
|
|
|
|
|
+ CURRENT_LOCAL_VERSION=$(echo "$CURRENT_FILE" | grep -o '[0-9]\{8\}[a-zA-Z]\?')
|
|
|
|
|
+ if [ "$GOOD_CORE_VERSION" != "" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ if [ "$CURRENT_LOCAL_VERSION" == "$GOOD_CORE_VERSION" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ MAX_LOCAL_VERSION=$CURRENT_LOCAL_VERSION
|
|
|
|
|
+ else
|
|
|
|
|
+ if [ "$MAX_LOCAL_VERSION" == "" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ MAX_LOCAL_VERSION="00000000"
|
|
|
|
|
+ fi
|
|
|
|
|
+ if [ $DELETE_OLD_FILES == "true" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ mv "${CURRENT_FILE}" "${CURRENT_FILE}.${TO_BE_DELETED_EXTENSION}" > /dev/null 2>&1
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+ else
|
|
|
|
|
+ if [[ "$CURRENT_LOCAL_VERSION" > "$MAX_LOCAL_VERSION" ]]
|
|
|
|
|
+ then
|
|
|
|
|
+ MAX_LOCAL_VERSION=$CURRENT_LOCAL_VERSION
|
|
|
|
|
+ fi
|
|
|
|
|
+ if [[ "$MAX_VERSION" > "$CURRENT_LOCAL_VERSION" ]] && [ $DELETE_OLD_FILES == "true" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ # echo "Moving $(echo ${CURRENT_FILE} | sed 's/.*\///g')"
|
|
|
|
|
+ mv "${CURRENT_FILE}" "${CURRENT_FILE}.${TO_BE_DELETED_EXTENSION}" > /dev/null 2>&1
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+ done
|
|
|
|
|
+ if [ "$MAX_LOCAL_VERSION" != "" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ break
|
|
|
|
|
+ fi
|
|
|
|
|
+ done
|
|
|
|
|
+
|
|
|
|
|
+ if [[ "$MAX_VERSION" > "$MAX_LOCAL_VERSION" ]]
|
|
|
|
|
+ then
|
|
|
|
|
+ if [ "$DOWNLOAD_NEW_CORES" != "false" ] || [ "$MAX_LOCAL_VERSION" != "" ] || [ "$BASE_FILE_NAME" == "MiSTer" ] || [ "$BASE_FILE_NAME" == "menu" ] || { echo "$CORE_URL" | grep -q "SD-Installer"; }
|
|
|
|
|
+ then
|
|
|
|
|
+ echo "Downloading $FILE_NAME"
|
|
|
|
|
+ [ "${SSH_CLIENT}" != "" ] && echo "URL: https://github.com$MAX_RELEASE_URL?raw=true"
|
|
|
|
|
+ if curl $CURL_RETRY $SSL_SECURITY_OPTION -L "https://github.com$MAX_RELEASE_URL?raw=true" -o "$CURRENT_DIR/$FILE_NAME"
|
|
|
|
|
+ then
|
|
|
|
|
+ if [ ${DELETE_OLD_FILES} == "true" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ echo "Deleting old ${BASE_FILE_NAME} files"
|
|
|
|
|
+ rm "${CURRENT_DIR}/${BASE_FILE_NAME}"*.${TO_BE_DELETED_EXTENSION} > /dev/null 2>&1
|
|
|
|
|
+ fi
|
|
|
|
|
+ if [ $BASE_FILE_NAME == "MiSTer" ] || [ $BASE_FILE_NAME == "menu" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ DESTINATION_FILE=$(echo "$MAX_RELEASE_URL" | sed 's/.*\///g' | sed 's/_[0-9]\{8\}[a-zA-Z]\{0,1\}//g')
|
|
|
|
|
+ echo "Moving $DESTINATION_FILE"
|
|
|
|
|
+ rm "/media/fat/$DESTINATION_FILE" > /dev/null 2>&1
|
|
|
|
|
+ mv "$CURRENT_DIR/$FILE_NAME" "/media/fat/$DESTINATION_FILE"
|
|
|
|
|
+ touch "$CURRENT_DIR/$FILE_NAME"
|
|
|
|
|
+ REBOOT_NEEDED="true"
|
|
|
|
|
+ fi
|
|
|
|
|
+ if echo "$CORE_URL" | grep -q "SD-Installer"
|
|
|
|
|
+ then
|
|
|
|
|
+ SD_INSTALLER_PATH="$CURRENT_DIR/$FILE_NAME"
|
|
|
|
|
+ fi
|
|
|
|
|
+ if [ "$CORE_CATEGORY" == "arcade-cores" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ OLD_IFS="$IFS"
|
|
|
|
|
+ IFS="|"
|
|
|
|
|
+ for ARCADE_ALT_PATH in $ARCADE_ALT_PATHS
|
|
|
|
|
+ do
|
|
|
|
|
+ for ARCADE_ALT_DIR in "$ARCADE_ALT_PATH/_$BASE_FILE_NAME"*
|
|
|
|
|
+ do
|
|
|
|
|
+ if [ -d "$ARCADE_ALT_DIR" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ echo "Updating $(echo $ARCADE_ALT_DIR | sed 's/.*\///g')"
|
|
|
|
|
+ if [ $DELETE_OLD_FILES == "true" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ for ARCADE_HACK_CORE in "$ARCADE_ALT_DIR/"*.rbf
|
|
|
|
|
+ do
|
|
|
|
|
+ if [ -f "$ARCADE_HACK_CORE" ] && { echo "$ARCADE_HACK_CORE" | grep -q "$BASE_FILE_NAME\_[0-9]\{8\}[a-zA-Z]\?\.rbf$"; }
|
|
|
|
|
+ then
|
|
|
|
|
+ rm "$ARCADE_HACK_CORE" > /dev/null 2>&1
|
|
|
|
|
+ fi
|
|
|
|
|
+ done
|
|
|
|
|
+ fi
|
|
|
|
|
+ cp "$CURRENT_DIR/$FILE_NAME" "$ARCADE_ALT_DIR/"
|
|
|
|
|
+ fi
|
|
|
|
|
+ done
|
|
|
|
|
+ done
|
|
|
|
|
+ IFS="$OLD_IFS"
|
|
|
|
|
+ fi
|
|
|
|
|
+ else
|
|
|
|
|
+ echo "${FILE_NAME} download failed"
|
|
|
|
|
+ rm "${CURRENT_DIR}/${FILE_NAME}" > /dev/null 2>&1
|
|
|
|
|
+ if [ ${DELETE_OLD_FILES} == "true" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ echo "Restoring old ${BASE_FILE_NAME} files"
|
|
|
|
|
+ for FILE_TO_BE_RESTORED in "${CURRENT_DIR}/${BASE_FILE_NAME}"*.${TO_BE_DELETED_EXTENSION}
|
|
|
|
|
+ do
|
|
|
|
|
+ mv "${FILE_TO_BE_RESTORED}" "${FILE_TO_BE_RESTORED%.${TO_BE_DELETED_EXTENSION}}" > /dev/null 2>&1
|
|
|
|
|
+ done
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+ sync
|
|
|
|
|
+ else
|
|
|
|
|
+ echo "New core: $FILE_NAME"
|
|
|
|
|
+ fi
|
|
|
|
|
+ else
|
|
|
|
|
+ echo "Nothing to update"
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ echo ""
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+for CORE_URL in $CORE_URLS; do
|
|
|
|
|
+
|
|
|
|
|
+ if [[ $CORE_URL == https://* ]]
|
|
|
|
|
+ then
|
|
|
|
|
+ if [ "$REPOSITORIES_FILTER" == "" ] || { echo "$CORE_URL" | grep -qi "$REPOSITORIES_FILTER"; } || { echo "$CORE_CATEGORY" | grep -qi "$CORE_CATEGORIES_FILTER"; }
|
|
|
|
|
+ then
|
|
|
|
|
+ if echo "$CORE_URL" | grep -qE "(SD-Installer)|(/Main_MiSTer$)|(/Menu_MiSTer$)"
|
|
|
|
|
+ then
|
|
|
|
|
+ checkCoreURL
|
|
|
|
|
+ else
|
|
|
|
|
+ [ "$PARALLEL_UPDATE" == "true" ] && { echo "$(checkCoreURL)"$'\n' & } || checkCoreURL
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+ else
|
|
|
|
|
+ CORE_CATEGORY=$(echo "$CORE_URL" | sed 's/user-content-//g')
|
|
|
|
|
+ if [ "$CORE_CATEGORY" == "" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ CORE_CATEGORY="-"
|
|
|
|
|
+ fi
|
|
|
|
|
+ if [ "$CORE_CATEGORY" == "computer-cores" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ CORE_CATEGORY="cores"
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+done
|
|
|
|
|
+wait
|
|
|
|
|
+
|
|
|
|
|
+echo "Done!"
|
|
|
|
|
+if [ $REBOOT_NEEDED == "true" ]
|
|
|
|
|
+then
|
|
|
|
|
+ if [ $AUTOREBOOT == "true" ]
|
|
|
|
|
+ then
|
|
|
|
|
+ echo "Rebooting in $REBOOT_PAUSE seconds"
|
|
|
|
|
+ sleep $REBOOT_PAUSE
|
|
|
|
|
+ reboot now
|
|
|
|
|
+ else
|
|
|
|
|
+ echo "You should reboot"
|
|
|
|
|
+ fi
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+exit 0
|