mirror of
				https://github.com/casjaysdevdocker/tor
				synced 2025-10-30 20:02:25 -04:00 
			
		
		
		
	🗃️ Update codebase 🗃️
rootfs/root/docker/setup/06-post.sh rootfs/usr/local/etc/docker/init.d/zz-nginx.sh
This commit is contained in:
		| @@ -45,24 +45,20 @@ EOF | |||||||
| 	# AWK Markdown -> HTML (body only). Designed to handle the README’s structure. | 	# AWK Markdown -> HTML (body only). Designed to handle the README’s structure. | ||||||
| 	awk_prog=' | 	awk_prog=' | ||||||
| BEGIN{ | BEGIN{ | ||||||
|   in_code=0; code_fence=""; in_ul=0; in_ol=0; in_blockquote=0; |   in_code=0; in_ul=0; in_ol=0; in_blockquote=0; in_table=0; table_open=0; | ||||||
|   in_table=0; table_open=0; last_nonblank=""; |   last_nonblank=""; | ||||||
|   FS=""; |   FS=""; | ||||||
| } | } | ||||||
|  | function htmlesc(s){ gsub(/&/,"&",s); gsub(/</,"<",s); gsub(/>/,">",s); return s } | ||||||
|  |  | ||||||
| function htmlesc(s,   t){ | function linkify(s){ | ||||||
|   gsub(/&/,"&",s); gsub(/</,"<",s); gsub(/>/,">",s); return s |  | ||||||
| } |  | ||||||
|  |  | ||||||
| # Inline transforms: minimal but safe |  | ||||||
| function linkify(s,   before,after){ |  | ||||||
|   # Images:  |   # Images:  | ||||||
|   s = gensub(/!\[([^[\]]+)\]\(([^) \t]+)\)/, "<img alt=\"\\1\" src=\"\\2\" />", "g", s) |   s = gensub(/!\[([^[\]]+)\]\(([^) \t]+)\)/, "<img alt=\"\\1\" src=\"\\2\" />", "g", s) | ||||||
|   # Links: [text](url) |   # Links: [text](url) | ||||||
|   s = gensub(/\[([^[\]]+)\]\(([^) \t]+)\)/, "<a href=\"\\2\" rel=\"noopener noreferrer\">\\1<\\/a>", "g", s) |   s = gensub(/\[([^[\]]+)\]\(([^) \t]+)\)/, "<a href=\"\\2\" rel=\"noopener noreferrer\">\\1<\\/a>", "g", s) | ||||||
|   # Inline code: `code` |   # Inline code | ||||||
|   s = gensub(/`([^`]+)`/, "<code>\\1<\\/code>", "g", s) |   s = gensub(/`([^`]+)`/, "<code>\\1<\\/code>", "g", s) | ||||||
|   # Bold/italic (simple, non-nested) |   # Bold / italic (simple) | ||||||
|   s = gensub(/\*\*([^*]+)\*\*/, "<strong>\\1<\\/strong>", "g", s) |   s = gensub(/\*\*([^*]+)\*\*/, "<strong>\\1<\\/strong>", "g", s) | ||||||
|   s = gensub(/\*([^*]+)\*/, "<em>\\1<\\/em>", "g", s) |   s = gensub(/\*([^*]+)\*/, "<em>\\1<\\/em>", "g", s) | ||||||
|   # Autolink http(s) |   # Autolink http(s) | ||||||
| @@ -72,139 +68,82 @@ function linkify(s,   before,after){ | |||||||
|   return s |   return s | ||||||
| } | } | ||||||
|  |  | ||||||
| # Emit paragraph buffer if needed | function flush_p(){ if(pbuf!=""){ printf("<p>%s</p>\n", pbuf); pbuf="" } } | ||||||
| function flush_p(){ | function close_lists(){ if(in_ul){ print "</ul>"; in_ul=0 } if(in_ol){ print "</ol>"; in_ol=0 } } | ||||||
|   if(pbuf!=""){ | function close_blockquote(){ if(in_blockquote){ print "</blockquote>"; in_blockquote=0 } } | ||||||
|     printf("<p>%s</p>\n", pbuf); |  | ||||||
|     pbuf=""; |  | ||||||
|   } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| # Close list/blockquote contexts | function table_close_fn(){ if(table_open){ print "</tbody></table>"; table_open=0 } in_table=0 } | ||||||
| function close_lists(){ | function split_cells(line,  n,i){ | ||||||
|   if(in_ul){ print "</ul>"; in_ul=0 } |  | ||||||
|   if(in_ol){ print "</ol>"; in_ol=0 } |  | ||||||
| } |  | ||||||
| function close_blockquote(){ |  | ||||||
|   if(in_blockquote){ print "</blockquote>"; in_blockquote=0 } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| # Table helpers |  | ||||||
| function table_open_fn(){ |  | ||||||
|   if(!table_open){ print "<table>"; table_open=1 } |  | ||||||
| } |  | ||||||
| function table_close_fn(){ |  | ||||||
|   if(table_open){ print "</tbody></table>"; table_open=0 } |  | ||||||
|   in_table=0 |  | ||||||
| } |  | ||||||
| function split_cells(line,  arr,n,i,cell){ |  | ||||||
|   # strip leading/trailing | |  | ||||||
|   sub(/^ *\|/,"",line); sub(/\| *$/,"",line); |   sub(/^ *\|/,"",line); sub(/\| *$/,"",line); | ||||||
|   n=split(line, arr, /\|/); |   n=split(line, C, /\|/); | ||||||
|   for(i=1;i<=n;i++){ |   for(i=1;i<=n;i++){ gsub(/^ +| +$/,"",C[i]) } | ||||||
|     gsub(/^ +| +$/,"",arr[i]); # trim |  | ||||||
|     arr[i]=arr[i]; |  | ||||||
|   } |  | ||||||
|   return n |   return n | ||||||
| } | } | ||||||
|  |  | ||||||
| { | { | ||||||
|   raw=$0 |   raw=$0 | ||||||
|   # Track last nonblank for table header detection |  | ||||||
|   if(raw ~ /[^[:space:]]/){ last_nonblank=raw } |   if(raw ~ /[^[:space:]]/){ last_nonblank=raw } | ||||||
|  |  | ||||||
|   # Handle fenced code |   # Fenced code | ||||||
|   if(!in_code && raw ~ /^```/){ |   if(!in_code && raw ~ /^```/){ flush_p(); close_lists(); close_blockquote(); print "<pre><code>"; in_code=1; next } | ||||||
|     flush_p(); close_lists(); close_blockquote(); |  | ||||||
|     print "<pre><code>"; in_code=1; next |  | ||||||
|   } |  | ||||||
|   if(in_code){ |   if(in_code){ | ||||||
|     if(raw ~ /^```/){ print "</code></pre>"; in_code=0; next } |     if(raw ~ /^```/){ print "</code></pre>"; in_code=0; next } | ||||||
|     print htmlesc(raw); next |     print htmlesc(raw); next | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   # Blank line: end paragraphs/lists/quotes; not tables |   # Blank line | ||||||
|   if(raw ~ /^[[:space:]]*$/){ |   if(raw ~ /^[[:space:]]*$/){ | ||||||
|     if(in_table==0){ flush_p(); close_lists(); close_blockquote() } |     if(in_table==0){ flush_p(); close_lists(); close_blockquote() } | ||||||
|     next |     next | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   # Horizontal rule |   # HR | ||||||
|   if(raw ~ /^ *(-{3,}|\*{3,}|_{3,}) *$/){ |   if(raw ~ /^ *(-{3,}|\*{3,}|_{3,}) *$/){ flush_p(); close_lists(); close_blockquote(); print "<hr />"; next } | ||||||
|     flush_p(); close_lists(); close_blockquote(); |  | ||||||
|     print "<hr />"; next |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   # Table separator row => open table, emit header from last_nonblank |   # Table separator row -> open table with the previous header line | ||||||
|   if(raw ~ /^ *\|? *:?-{3,}:? *(?:\| *:?-{3,}:? *)+\|? *$/){ |   if(raw ~ /^ *\|? *:?-{3,}:? *(?:\| *:?-{3,}:? *)+\|? *$/){ | ||||||
|     # last_nonblank is header |  | ||||||
|     hdr=last_nonblank |     hdr=last_nonblank | ||||||
|     # Parse header into <thead> |     split_cells(hdr); print "<table><thead><tr>"; | ||||||
|     split_cells(hdr, H, nH) |     for(i=1;i in C;i++){ printf("<th>%s</th>", linkify(htmlesc(C[i]))) } | ||||||
|     print "<table><thead><tr>" |     print "</tr></thead><tbody>"; in_table=1; table_open=1; next | ||||||
|     for(i=1;i<=nH;i++){ printf("<th>%s</th>", linkify(htmlesc(H[i]))) } |  | ||||||
|     print "</tr></thead><tbody>" |  | ||||||
|     in_table=1; table_open=1 |  | ||||||
|     next |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   # Inside table: any row with at least one pipe (and not a fence) |  | ||||||
|   if(in_table && raw ~ /\|/){ |   if(in_table && raw ~ /\|/){ | ||||||
|     split_cells(raw, C, nC) |     split_cells(raw); printf("<tr>"); | ||||||
|     printf("<tr>") |     for(i=1;i in C;i++){ printf("<td>%s</td>", linkify(htmlesc(C[i]))) } | ||||||
|     for(i=1;i<=nC;i++){ printf("<td>%s</td>", linkify(htmlesc(C[i]))) } |     print "</tr>"; next | ||||||
|     print "</tr>" |  | ||||||
|     next |  | ||||||
|   } |  | ||||||
|   # Exiting table block if we hit a non-pipe line |  | ||||||
|   if(in_table){ |  | ||||||
|     table_close_fn() |  | ||||||
|   } |   } | ||||||
|  |   if(in_table){ table_close_fn() } | ||||||
|  |  | ||||||
|   # Blockquotes |   # Blockquotes | ||||||
|   if(raw ~ /^ *> */){ |   if(raw ~ /^ *> */){ | ||||||
|     flush_p(); close_lists(); |     flush_p(); close_lists(); | ||||||
|     if(!in_blockquote){ print "<blockquote>"; in_blockquote=1 } |     if(!in_blockquote){ print "<blockquote>"; in_blockquote=1 } | ||||||
|     gsub(/^ *> */,"",raw) |     gsub(/^ *> */,"",raw); print "<p>" linkify(htmlesc(raw)) "</p>"; next | ||||||
|     print "<p>" linkify(htmlesc(raw)) "</p>" |   } else if(in_blockquote){ close_blockquote() } | ||||||
|     next |  | ||||||
|   }else{ |  | ||||||
|     if(in_blockquote && raw !~ /^ *> */){ close_blockquote() } |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   # Headings |   # Headings | ||||||
|   if(raw ~ /^#{1,6} /){ |   if(raw ~ /^#{1,6} /){ | ||||||
|     flush_p(); close_lists(); close_blockquote(); |     flush_p(); close_lists(); close_blockquote(); | ||||||
|     m=match(raw,/^#{1,6}/); level=RLENGTH |     m=match(raw,/^#{1,6}/); level=RLENGTH; text=substr(raw, level+2); | ||||||
|     text=substr(raw, level+2) |     printf("<h%d>%s</h%d>\n", level, linkify(htmlesc(text)), level); next | ||||||
|     printf("<h%d>%s</h%d>\n", level, linkify(htmlesc(text)), level) |  | ||||||
|     next |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   # Lists |   # Lists | ||||||
|   if(raw ~ /^ *([-*]) +/){ |   if(raw ~ /^ *([-*]) +/){ | ||||||
|     flush_p() |     flush_p(); if(!in_ul){ print "<ul>"; in_ul=1 } | ||||||
|     if(!in_ul){ print "<ul>"; in_ul=1 } |     item=raw; sub(/^ *[-*] +/,"",item); print "<li>" linkify(htmlesc(item)) "</li>"; next | ||||||
|     item=raw; sub(/^ *[-*] +/,"",item) |  | ||||||
|     print "<li>" linkify(htmlesc(item)) "</li>" |  | ||||||
|     next |  | ||||||
|   } |   } | ||||||
|   if(raw ~ /^ *[0-9]+\. +/){ |   if(raw ~ /^ *[0-9]+\. +/){ | ||||||
|     flush_p() |     flush_p(); if(!in_ol){ print "<ol>"; in_ol=1 } | ||||||
|     if(!in_ol){ print "<ol>"; in_ol=1 } |     item=raw; sub(/^ *[0-9]+\. +/,"",item); print "<li>" linkify(htmlesc(item)) "</li>"; next | ||||||
|     item=raw; sub(/^ *[0-9]+\. +/,"",item) |  | ||||||
|     print "<li>" linkify(htmlesc(item)) "</li>" |  | ||||||
|     next |  | ||||||
|   } |   } | ||||||
|   # If we switch list types or leave lists |  | ||||||
|   if(in_ul && raw !~ /^ *([-*]) +/ && raw !~ /^[[:space:]]*$/){ close_lists() } |   if(in_ul && raw !~ /^ *([-*]) +/ && raw !~ /^[[:space:]]*$/){ close_lists() } | ||||||
|   if(in_ol && raw !~ /^ *[0-9]+\. +/ && raw !~ /^[[:space:]]*$/){ close_lists() } |   if(in_ol && raw !~ /^ *[0-9]+\. +/ && raw !~ /^[[:space:]]*$/){ close_lists() } | ||||||
|  |  | ||||||
|   # Default: paragraph (accumulate soft-wrap into one <p>) |   # Paragraph accumulation (soft-wrap) | ||||||
|   line = linkify(htmlesc(raw)) |   line = linkify(htmlesc(raw)) | ||||||
|   if(pbuf==""){ pbuf=line } else { pbuf=pbuf " " line } |   if(pbuf==""){ pbuf=line } else { pbuf=pbuf " " line } | ||||||
| } | } | ||||||
|  |  | ||||||
| END{ | END{ | ||||||
|   if(in_code){ print "</code></pre>" } |   if(in_code){ print "</code></pre>" } | ||||||
|   if(in_table){ table_close_fn() } |   if(in_table){ table_close_fn() } | ||||||
|   | |||||||
| @@ -275,14 +275,7 @@ __update_conf_files() { | |||||||
| 	# __replace "" "" "$CONF_DIR/nginx.conf" | 	# __replace "" "" "$CONF_DIR/nginx.conf" | ||||||
| 	# replace variables recursively | 	# replace variables recursively | ||||||
| 	# __find_replace "" "" "$CONF_DIR" | 	# __find_replace "" "" "$CONF_DIR" | ||||||
| 	if [ -f "$WWW_ROOT_DIR/index.html" ]; then |  | ||||||
| 		sed -i 's|REPLACE_ONION_WWW_DIR|'$WWW_ROOT_DIR'|g' "/data/htdocs/www/index.html" |  | ||||||
| 		[ -n "$default_host" ] && sed -i 's|REPLACE_DEFAULT_TOR_ADDRESS|'$default_host.onion'|g' "$WWW_ROOT_DIR/index.html" || sed -i '/REPLACE_DEFAULT_TOR_ADDRESS/d' "$WWW_ROOT_DIR/index.html" |  | ||||||
| 	fi |  | ||||||
| 	if [ -f "/data/htdocs/www/index.html" ]; then |  | ||||||
| 		sed -i 's|REPLACE_ONION_WWW_DIR|/data/htdocs/www|g' "/data/htdocs/www/index.html" |  | ||||||
| 		[ -n "$default_host" ] && sed -i 's|REPLACE_DEFAULT_TOR_ADDRESS|'$default_host.onion'|g' "/data/htdocs/www/index.html" || sed -i '/REPLACE_DEFAULT_TOR_ADDRESS/d' "/data/htdocs/www/index.html" |  | ||||||
| 	fi |  | ||||||
| 	# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 	# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||
| 	# define actions | 	# define actions | ||||||
| 	while :; do | 	while :; do | ||||||
| @@ -326,6 +319,14 @@ __update_conf_files() { | |||||||
| 			echo "Created $onion_site.onion in /data/htdocs/onions/$onion_site" | 			echo "Created $onion_site.onion in /data/htdocs/onions/$onion_site" | ||||||
| 		done | 		done | ||||||
| 	fi | 	fi | ||||||
|  | 	if [ -f "$WWW_ROOT_DIR/index.html" ]; then | ||||||
|  | 		sed -i 's|REPLACE_ONION_WWW_DIR|'$WWW_ROOT_DIR'|g' "/data/htdocs/www/index.html" | ||||||
|  | 		[ -n "$default_host" ] && sed -i 's|REPLACE_DEFAULT_TOR_ADDRESS|'$default_host.onion'|g' "$WWW_ROOT_DIR/index.html" || sed -i '/REPLACE_DEFAULT_TOR_ADDRESS/d' "$WWW_ROOT_DIR/index.html" | ||||||
|  | 	fi | ||||||
|  | 	if [ -f "/data/htdocs/www/index.html" ]; then | ||||||
|  | 		sed -i 's|REPLACE_ONION_WWW_DIR|/data/htdocs/www|g' "/data/htdocs/www/index.html" | ||||||
|  | 		[ -n "$default_host" ] && sed -i 's|REPLACE_DEFAULT_TOR_ADDRESS|'$default_host.onion'|g' "/data/htdocs/www/index.html" || sed -i '/REPLACE_DEFAULT_TOR_ADDRESS/d' "/data/htdocs/www/index.html" | ||||||
|  | 	fi | ||||||
| 	# allow custom functions | 	# allow custom functions | ||||||
| 	if builtin type -t __update_conf_files_local | grep -q 'function'; then __update_conf_files_local; fi | 	if builtin type -t __update_conf_files_local | grep -q 'function'; then __update_conf_files_local; fi | ||||||
| 	# exit function | 	# exit function | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user