Tools: setup-unit: workarounded macOS tmp file permissions.

mktemp(1) in macOS uses a weird directory where only the running user
has permissions.  If we use that for the welcome website, unitd(8) won't
be able to read the page.  Use a directory at $HOME before trying a tmpdir.

Reported-by: Liam Crilly <lcrilly@nginx.com>
Signed-off-by: Alejandro Colomar <alx@nginx.com>
This commit is contained in:
Alejandro Colomar
2022-12-16 21:39:28 +01:00
parent 6861c25e4e
commit 2435bd1c3a

View File

@@ -562,6 +562,9 @@ unit_ctl_welcome()
www='/srv/www/unit/index.html'; www='/srv/www/unit/index.html';
if test -e "$www" && ! test -v force || ! test -w /srv; then if test -e "$www" && ! test -v force || ! test -w /srv; then
www="$HOME/srv/www/unit/index.html";
fi;
if test -e "$www" && ! test -v force; then
www="$(mktemp)"; www="$(mktemp)";
mv "$www" "$www.html"; mv "$www" "$www.html";
www="$www.html" www="$www.html"
@@ -624,7 +627,7 @@ unit_ctl_welcome()
dry_run_echo 'Create a file to serve:'; dry_run_echo 'Create a file to serve:';
dry_run_eval "mkdir -p $(dirname $www);"; dry_run_eval "mkdir -p $(dirname $www);";
dry_run_eval "cat >'$www'"' <<__EOF__; dry_run_eval "tee '$www' >/dev/null"' <<__EOF__;
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>