Update docker/headscale/prep.sh
This commit is contained in:
		
							parent
							
								
									933b33ee15
								
							
						
					
					
						commit
						d74159a7a2
					
				| 
						 | 
				
			
			@ -36,4 +36,38 @@ download_and_process_config() {
 | 
			
		|||
    fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
insert_placeholders() {
 | 
			
		||||
    local config_file="/etc/headscale/config-example.yaml"
 | 
			
		||||
 | 
			
		||||
    if [[ ! -f "$config_file" ]]; then
 | 
			
		||||
        echo "Config file $config_file not found."
 | 
			
		||||
        return 1
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    declare -a replacements=(
 | 
			
		||||
        "server_url: .*" "server_url: \${SERVER_URL}"
 | 
			
		||||
        "listen_addr: .*" "listen_addr: \${LISTEN_ADDR}"
 | 
			
		||||
        "metrics_listen_addr: .*" "metrics_listen_addr: \${METRICS_LISTEN_ADDR}"
 | 
			
		||||
        "grpc_listen_addr: .*" "grpc_listen_addr: \${GRPC_LISTEN_ADDR}"
 | 
			
		||||
        "grpc_allow_insecure: .*" "grpc_allow_insecure: \${GRPC_ALLOW_INSECURE}"
 | 
			
		||||
        "private_key_path: .*" "private_key_path: \${NOISE_PRIVATE_KEY_PATH}"
 | 
			
		||||
        "acme_url: .*" "acme_url: \${ACME_URL}"
 | 
			
		||||
        "acme_email: .*" "acme_email: \${ACME_EMAIL}"
 | 
			
		||||
        "tls_letsencrypt_hostname: .*" "tls_letsencrypt_hostname: \${TLS_LETSENCRYPT_HOSTNAME}"
 | 
			
		||||
        "tls_letsencrypt_cache_dir: .*" "tls_letsencrypt_cache_dir: \${TLS_LETSENCRYPT_CACHE_DIR}"
 | 
			
		||||
        "db_type: .*" "db_type: \${DB_TYPE}"
 | 
			
		||||
        "db_path: .*" "db_path: \${DB_PATH}"
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    for i in "${!replacements[@]}"; do
 | 
			
		||||
        local search="${replacements[i]% *}"
 | 
			
		||||
        local replace="${replacements[i]#* }"
 | 
			
		||||
        sed -i "s|$search|$replace|" "$config_file"
 | 
			
		||||
    done
 | 
			
		||||
 | 
			
		||||
    echo "Placeholders inserted in $config_file"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
insert_placeholders
 | 
			
		||||
 | 
			
		||||
download_and_process_config
 | 
			
		||||
		Loading…
	
		Reference in New Issue