Update docker/headscale/start.sh
This commit is contained in:
parent
d956efddc7
commit
674f55950f
|
@ -1,8 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set +e
|
|
||||||
|
|
||||||
replace_config_values() {
|
replace_config_values() {
|
||||||
local config_template="/etc/headscale-example/config-example.yaml"
|
local config_template="/etc/headscale/config-example.yaml"
|
||||||
local config_output="/etc/headscale/config.yaml"
|
local config_output="/etc/headscale/config.yaml"
|
||||||
|
|
||||||
# Default values
|
# Default values
|
||||||
|
@ -38,11 +37,11 @@ replace_config_values() {
|
||||||
if [ -z "$var_value" ]; then
|
if [ -z "$var_value" ]; then
|
||||||
var_value=$default_value
|
var_value=$default_value
|
||||||
fi
|
fi
|
||||||
echo ${line/\$\{$var_name\}/$var_value}
|
echo "${line/\$\{$var_name\}/$var_value}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Read the template and replace variables with defaults if not set
|
# Read the template and replace variables with defaults if not set
|
||||||
while IFS= read -r line || [[ -n "$line" ]]; do
|
while IFS='' read -r line || [[ -n "$line" ]]; do
|
||||||
line=$(replace_or_default "SERVER_URL" "$DEFAULT_SERVER_URL" "$line")
|
line=$(replace_or_default "SERVER_URL" "$DEFAULT_SERVER_URL" "$line")
|
||||||
line=$(replace_or_default "LISTEN_ADDR" "$DEFAULT_LISTEN_ADDR" "$line")
|
line=$(replace_or_default "LISTEN_ADDR" "$DEFAULT_LISTEN_ADDR" "$line")
|
||||||
line=$(replace_or_default "METRICS_LISTEN_ADDR" "$DEFAULT_METRICS_LISTEN_ADDR" "$line")
|
line=$(replace_or_default "METRICS_LISTEN_ADDR" "$DEFAULT_METRICS_LISTEN_ADDR" "$line")
|
||||||
|
@ -56,7 +55,6 @@ replace_config_values() {
|
||||||
done < "$config_template" > "$config_output"
|
done < "$config_template" > "$config_output"
|
||||||
|
|
||||||
echo "Config file generated at $config_output"
|
echo "Config file generated at $config_output"
|
||||||
cat $config_output
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run the function to replace variables and start headscale
|
# Run the function to replace variables and start headscale
|
||||||
|
|
Loading…
Reference in New Issue