From 7b1f2bbb5ccf914b9d239fd034a4180041047b45 Mon Sep 17 00:00:00 2001 From: Clifton Palmer Date: Thu, 26 Oct 2023 03:26:04 -0500 Subject: [PATCH] Hotfix 1.2.3 - Updated publish.lua to display meaningful message if links are not created - If no links generated in publish.sh, return empty string instead of nonce - Updated readme with more explicit httpd auth instructions --- docker-compose.yml | 2 +- lua/publish.lua | 21 +++++++++++++-------- lua/publish.sh | 11 +++++++++-- readme.md | 12 +++--------- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 65080cd..7a29cea 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '3' services: web: build: . - image: cjpalmer/public:1.2.2 + image: cjpalmer/public:1.2.3 volumes: - ${SHARE_ROOT}:/storage - public_data:/usr/local/apache2/htdocs diff --git a/lua/publish.lua b/lua/publish.lua index b98e8f4..c0a4ff7 100644 --- a/lua/publish.lua +++ b/lua/publish.lua @@ -25,14 +25,19 @@ function handle(r) if pattern then local nonce = publish(r.context_document_root, pattern) - - -- if FQDN override is set, - -- use override instead of my own server name and port number - local fqdn = os.getenv('PUBLIC_FQDN_OVERRIDE') - fqdn = fqdn or (r.is_https and "https" or "http") .. "://" .. r.server_name .. ":" ..r.port - - local uri = ("%s/%s/"):format(fqdn, nonce) - r:puts( ([[%s]]):format(uri, uri) ) + if nonce == "" then + r:puts( "No links created" ) + else + -- if FQDN override is set, + -- use override instead of my own server name and port number + local fqdn = os.getenv('PUBLIC_FQDN_OVERRIDE') + fqdn = fqdn or + (r.is_https and "https" or "http") .. + "://" .. r.server_name .. ":" ..r.port + + local uri = ("%s/%s/"):format(fqdn, nonce) + r:puts( ([[%s]]):format(uri, uri) ) + end else local template = get_form(r.context_document_root) r:puts( template ) diff --git a/lua/publish.sh b/lua/publish.sh index bf88fbd..3371126 100755 --- a/lua/publish.sh +++ b/lua/publish.sh @@ -18,5 +18,12 @@ do ln -s $fname $symlink_dir/$(echo $fname | sed 's|^.*/||') done -# print nonce directory -echo $nonce +# if nonce directory has been created, +# print nonce +# else no links generated, print nothing +if [[ -d "$symlink_dir" ]] +then + echo -n "$nonce" +else + echo -n "" +fi diff --git a/readme.md b/readme.md index f8fb6dc..5ed18fd 100644 --- a/readme.md +++ b/readme.md @@ -9,15 +9,9 @@ docker stack deploy -c <(docker-compose config) public ### reaching the services -Must authorize self through ```$hostname```/lua/publish.lua and set up valid users on first deployment +Must authorize self through ```$hostname```/lua/publish.lua and set up valid users on first deployment. Right now you gotta ```docker exec -it``` the container to do that. + ``` -htpasswd -c passwords $username +htpasswd -c ${HTTPD_PREFIX}/auth/passwords $username ``` - -## todo - -* clean up temporary public directories - ``` - 0 * * * * find /var/www/html/public/* -depth -mtime +7 -delete - ``` -- 2.47.2