Request root access only when all files are present in offline mode

This commit is contained in:
Howard Wu 2022-09-17 21:23:18 +08:00
parent 9968805324
commit 42f56d9af4

View File

@ -275,6 +275,12 @@ if [ "$DEBUG" ]; then
set -x set -x
fi fi
require_su() {
if [ "$(sudo whoami)" != "root" ]; then
sudo echo "sudo is required to run this script"
fi
}
declare -A RELEASE_NAME_MAP=(["retail"]="Retail" ["RP"]="Release Preview" ["WIS"]="Insider Slow" ["WIF"]="Insider Fast") declare -A RELEASE_NAME_MAP=(["retail"]="Retail" ["RP"]="Release Preview" ["WIS"]="Insider Slow" ["WIF"]="Insider Fast")
RELEASE_NAME=${RELEASE_NAME_MAP[$RELEASE_TYPE]} || abort RELEASE_NAME=${RELEASE_NAME_MAP[$RELEASE_TYPE]} || abort
@ -295,11 +301,10 @@ if [ "$GAPPS_BRAND" = "OpenGApps" ]; then
else else
GAPPS_PATH="$DOWNLOAD_DIR"/MindTheGapps-"$ARCH".zip GAPPS_PATH="$DOWNLOAD_DIR"/MindTheGapps-"$ARCH".zip
fi fi
if [ "$(sudo whoami)" != "root" ]; then
sudo echo "sudo is required to run this script"
fi
if [ -z "${OFFLINE+x}" ]; then if [ -z "${OFFLINE+x}" ]; then
trap 'rm -f -- "${DOWNLOAD_DIR:?}/${DOWNLOAD_CONF_NAME}"' EXIT trap 'rm -f -- "${DOWNLOAD_DIR:?}/${DOWNLOAD_CONF_NAME}"' EXIT
require_su
echo "Generate Download Links" echo "Generate Download Links"
python3 generateWSALinks.py "$ARCH" "$RELEASE_TYPE" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort python3 generateWSALinks.py "$ARCH" "$RELEASE_TYPE" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort
if [ -z "${CUSTOM_MAGISK+x}" ]; then if [ -z "${CUSTOM_MAGISK+x}" ]; then
@ -332,6 +337,7 @@ else
echo "Offline mode: Some files are missing, please disable offline mode." echo "Offline mode: Some files are missing, please disable offline mode."
exit 1 exit 1
fi fi
require_su
fi fi
echo "Extract WSA" echo "Extract WSA"