Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standalone install script fixes #149

Merged
merged 2 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ extension.

## Running as a Systemd Service

A [install script](/standalone_ubuntu_oss_install.sh) for the gateway shows
An [install script](/standalone_ubuntu_oss_install.sh) for the gateway shows
how to install NGINX from a package repository, checkout the gateway source,
and configure it using the supplied environment variables.

Expand All @@ -115,6 +115,11 @@ variables mentioned in the [configuration section](#configuration) into memory,
and then execute the script. The script takes one optional parameter that
specifies the name of the branch to download files from.

For example:
```shell-session
sudo env $(cat settings.example) ./standalone_ubuntu_oss_install.sh
```

## Running in Containers

### Running the Public Open Source NGINX Container Image
Expand Down
21 changes: 1 addition & 20 deletions standalone_ubuntu_oss_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -256,31 +256,12 @@ auto_envsubst() {
done
}

auto_envsubst_on_include() {
local include_dir="/etc/nginx/include"
local suffix="${NGINX_ENVSUBST_TEMPLATE_SUFFIX:-.template}"
local filter="${NGINX_ENVSUBST_FILTER:-}"

local template defined_envs relative_path output_path subdir
defined_envs=$(printf '${%s} ' $(env | cut -d= -f1))
if [ ! -w "$include_dir" ]; then
echo "$ME: ERROR: $include_dir is not writable"
return 0
fi
find "$include_dir" -follow -type f -name "*$suffix" -print | while read -r template; do
output_path="${template%$suffix}"
echo "$ME: Running envsubst on $template to $output_path"
envsubst "$defined_envs" < "$template" > "$output_path"
done
}

# Attempt to read DNS Resolvers from /etc/resolv.conf
if [ -z ${DNS_RESOLVERS+x} ]; then
export DNS_RESOLVERS="$(cat /etc/resolv.conf | grep nameserver | cut -d' ' -f2 | xargs)"
fi

auto_envsubst
auto_envsubst_on_include
EOF
chmod +x /usr/local/bin/template_nginx_config.sh

Expand Down Expand Up @@ -375,7 +356,7 @@ http {
}
EOF

download "common/etc/nginx/include/listing.xsl.template" "/etc/nginx/include/listing.xsl.template"
download "common/etc/nginx/include/listing.xsl" "/etc/nginx/include/listing.xsl"
download "common/etc/nginx/include/awscredentials.js" "/etc/nginx/include/awscredentials.js"
download "common/etc/nginx/include/awssig2.js" "/etc/nginx/include/awssig2.js"
download "common/etc/nginx/include/awssig4.js" "/etc/nginx/include/awssig4.js"
Expand Down