Skip to content

Commit dcb6b56

Browse files
Add conditional output for VPN credentials based on selected packages
1 parent b281bce commit dcb6b56

1 file changed

Lines changed: 32 additions & 7 deletions

File tree

scripts/dappnode_install.sh

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,28 @@ wait_for_internal_ip() {
232232
# Works on both Linux and macOS as long as the relevant containers are running.
233233
print_vpn_access_credentials() {
234234
local localhost_flag=()
235+
local has_wireguard=false
236+
local has_vpn=false
237+
local pkg
238+
235239
if $IS_MACOS; then
236240
localhost_flag=(--localhost)
237241
fi
238242

243+
for pkg in "${PKGS[@]}"; do
244+
if [[ "$pkg" == "WIREGUARD" ]]; then
245+
has_wireguard=true
246+
elif [[ "$pkg" == "VPN" ]]; then
247+
has_vpn=true
248+
fi
249+
done
250+
251+
if [[ "$has_wireguard" != "true" && "$has_vpn" != "true" ]]; then
252+
echo ""
253+
echo "No VPN package selected (VPN/WIREGUARD). Skipping credentials output."
254+
return 0
255+
fi
256+
239257
echo ""
240258
echo "Waiting for VPN initialization..."
241259
wait_for_internal_ip "DAppNodeCore-dappmanager.dnp.dappnode.eth" 120 20
@@ -250,14 +268,21 @@ print_vpn_access_credentials() {
250268
echo "credentials below into your VPN app to access your DAppNode."
251269
echo ""
252270

253-
echo "--- Wireguard ---"
254-
docker exec -i DAppNodeCore-api.wireguard.dnp.dappnode.eth getWireguardCredentials "${localhost_flag[@]}" 2>&1 || \
255-
echo "Wireguard credentials not yet available. Try later with: dappnode_wireguard${localhost_flag:+ ${localhost_flag[*]}}"
271+
if [[ "$has_wireguard" == "true" ]]; then
272+
echo "--- Wireguard ---"
273+
docker exec -i DAppNodeCore-api.wireguard.dnp.dappnode.eth getWireguardCredentials "${localhost_flag[@]}" 2>&1 || \
274+
echo "Wireguard credentials not yet available. Try later with: dappnode_wireguard${localhost_flag:+ ${localhost_flag[*]}}"
275+
fi
256276

257-
echo ""
258-
echo "--- OpenVPN ---"
259-
docker exec -i DAppNodeCore-vpn.dnp.dappnode.eth vpncli get dappnode_admin "${localhost_flag[@]}" 2>&1 || \
260-
echo "OpenVPN credentials not yet available. Try later with: dappnode_openvpn_get dappnode_admin${localhost_flag:+ ${localhost_flag[*]}}"
277+
if [[ "$has_wireguard" == "true" && "$has_vpn" == "true" ]]; then
278+
echo ""
279+
fi
280+
281+
if [[ "$has_vpn" == "true" ]]; then
282+
echo "--- OpenVPN ---"
283+
docker exec -i DAppNodeCore-vpn.dnp.dappnode.eth vpncli get dappnode_admin "${localhost_flag[@]}" 2>&1 || \
284+
echo "OpenVPN credentials not yet available. Try later with: dappnode_openvpn_get dappnode_admin${localhost_flag:+ ${localhost_flag[*]}}"
285+
fi
261286

262287
echo ""
263288
echo "Import the configuration above into your VPN client of choice to access your DAppNode at http://my.dappnode"

0 commit comments

Comments
 (0)