forked from aeharding/voyager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
210 additions
and
437 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Function to sanitize input | ||
sanitize_input() { | ||
# Remove leading and trailing whitespaces | ||
local sanitized_input | ||
sanitized_input=$(echo "$1" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') | ||
echo "$sanitized_input" | ||
} | ||
|
||
# Get comma-separated list from the environment variable and sanitize it | ||
servers=$(sanitize_input "$CUSTOM_LEMMY_SERVERS") | ||
|
||
# Split comma-separated list into an array | ||
IFS=',' read -ra server_array <<< "$servers" | ||
|
||
# Convert array to JSON format | ||
json="{ \"customServers\": [" | ||
|
||
for server in "${server_array[@]}"; do | ||
# Sanitize each server name | ||
sanitized_server=$(sanitize_input "$server") | ||
if [ -n "$sanitized_server" ]; then | ||
json+="\"$sanitized_server\", " | ||
fi | ||
done | ||
|
||
# Remove trailing comma and add closing bracket | ||
json="${json%, } ] }" | ||
|
||
# Write JSON to a file | ||
echo "$json" > /var/www/config.json | ||
|
||
echo "JSON file generated: config.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
server { | ||
listen ${NGINX_PORT}; | ||
|
||
gzip on; | ||
gzip_types text/css application/javascript application/json image/svg+xml; | ||
gzip_comp_level 9; | ||
|
||
root /var/www/; | ||
|
||
location / { | ||
try_files $uri /index.html; | ||
add_header Cache-Control no-cache; | ||
} | ||
|
||
location /assets/ { | ||
add_header Cache-Control max-age=31536000; | ||
} | ||
|
||
location /_config { | ||
alias /var/www/config.json; | ||
add_header Cache-Control no-cache; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.