Improve RELEASE_COOKIE handling on read-only fs (#1919)

This commit is contained in:
Jonatan Kłosko 2023-05-23 15:23:02 +02:00 committed by GitHub
parent 8e4f3067da
commit 01bf6cd27d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View file

@ -5,6 +5,8 @@ set RELEASE_MODE=interactive
set cookie_path="!RELEASE_ROOT!\releases\COOKIE"
if not exist %cookie_path% (
for /f "skip=1" %%X in ('wmic os get localdatetime') do if not defined TIMESTAMP set TIMESTAMP=%%X
echo cookie-!TIMESTAMP:~0,11!-!RANDOM! > %cookie_path%
if not defined RELEASE_COOKIE (
for /f "skip=1" %%X in ('wmic os get localdatetime') do if not defined TIMESTAMP set TIMESTAMP=%%X
echo cookie-!TIMESTAMP:~0,11!-!RANDOM! > %cookie_path%
)
)

View file

@ -3,8 +3,7 @@ export RELEASE_DISTRIBUTION=${LIVEBOOK_DISTRIBUTION:-${RELEASE_DISTRIBUTION:-sna
export RELEASE_MODE=interactive
cookie_path="${RELEASE_ROOT}/releases/COOKIE"
if [ ! -f $cookie_path ]; then
if [ ! -f $cookie_path ] && [ -z "$RELEASE_COOKIE" ]; then
RELEASE_COOKIE=$(cat /dev/urandom | env LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
echo "$RELEASE_COOKIE" > "$cookie_path"
[ $? -eq 0 ] || export RELEASE_COOKIE
echo "$RELEASE_COOKIE" > "$cookie_path" || export RELEASE_COOKIE
fi