Skip to content

Commit e0784e0

Browse files
committed
Swift: fix update-codeql
Also require sudo at the start of the script if updating.
1 parent 4377fb0 commit e0784e0

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

.devcontainer/swift/update-codeql.sh

+9-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@ URL=https://github.com/github/codeql-cli-binaries/releases
44
LATEST_VERSION=$(curl -L -s -H 'Accept: application/json' $URL/latest | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
55
CURRENT_VERSION=v$(codeql version 2>/dev/null | sed -ne 's/.*release \([0-9.]*\)\./\1/p')
66
if [[ $CURRENT_VERSION != $LATEST_VERSION ]]; then
7-
curl -fSqL -o /tmp/codeql.zip $URL/download/$LATEST_VERSION/codeql-linux64.zip
8-
unzip /tmp/codeql.zip -qd /opt
9-
rm /tmp/codeql.zip
7+
if [[ $UID != 0 ]]; then
8+
echo "update required, please run this script with sudo:"
9+
echo " sudo $0"
10+
exit 1
11+
fi
12+
ZIP=$(mktemp codeql.XXXX.zip)
13+
curl -fSqL -o $ZIP $URL/download/$LATEST_VERSION/codeql-linux64.zip
14+
unzip -q $ZIP -d /opt
15+
rm $ZIP
1016
ln -sf /opt/codeql/codeql /usr/local/bin/codeql
1117
echo installed version $LATEST_VERSION
1218
else

0 commit comments

Comments
 (0)