Skip to content

Commit

Permalink
Request root access only when all files are present in offline mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Howard20181 committed Sep 17, 2022
1 parent 9968805 commit 42f56d9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ if [ "$DEBUG" ]; then
set -x
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")
RELEASE_NAME=${RELEASE_NAME_MAP[$RELEASE_TYPE]} || abort

Expand All @@ -295,11 +301,10 @@ if [ "$GAPPS_BRAND" = "OpenGApps" ]; then
else
GAPPS_PATH="$DOWNLOAD_DIR"/MindTheGapps-"$ARCH".zip
fi
if [ "$(sudo whoami)" != "root" ]; then
sudo echo "sudo is required to run this script"
fi

if [ -z "${OFFLINE+x}" ]; then
trap 'rm -f -- "${DOWNLOAD_DIR:?}/${DOWNLOAD_CONF_NAME}"' EXIT
require_su
echo "Generate Download Links"
python3 generateWSALinks.py "$ARCH" "$RELEASE_TYPE" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort
if [ -z "${CUSTOM_MAGISK+x}" ]; then
Expand Down Expand Up @@ -332,6 +337,7 @@ else
echo "Offline mode: Some files are missing, please disable offline mode."
exit 1
fi
require_su
fi

echo "Extract WSA"
Expand Down

0 comments on commit 42f56d9

Please sign in to comment.