forked from mirrors_public/oddlama_nix-config
feat(wireguard): support printing multiple configs at once
This commit is contained in:
parent
1630e37afd
commit
2e45d3f423
1 changed files with 9 additions and 10 deletions
|
@ -30,15 +30,14 @@ in
|
|||
| ${pkgs.coreutils}/bin/cut -d$'\t' -f1)
|
||||
[[ -n "$json_sel" ]] || exit 1
|
||||
|
||||
# TODO for each output line
|
||||
# TODO maybe just call a json -> make script that gives wireguard config to make this easier
|
||||
while IFS= read -r line; do
|
||||
wgName=$(${pkgs.jq}/bin/jq -r .wgName <<< "$line")
|
||||
serverNode=$(${pkgs.jq}/bin/jq -r .serverNode <<< "$line")
|
||||
peer=$(${pkgs.jq}/bin/jq -r .peer <<< "$line")
|
||||
echo "======== $wgName.$serverNode.$peer ========"
|
||||
|
||||
wgName=$(${pkgs.jq}/bin/jq -r .wgName <<< "$json_sel")
|
||||
serverNode=$(${pkgs.jq}/bin/jq -r .serverNode <<< "$json_sel")
|
||||
peer=$(${pkgs.jq}/bin/jq -r .peer <<< "$json_sel")
|
||||
|
||||
createConfigScript=$(nix build --no-link --print-out-paths --impure --show-trace --expr \
|
||||
'let flk = builtins.getFlake "${../../.}"; in (flk.extraLib.wireguard "'"$wgName"'").wgQuickConfigScript "${pkgs.system}" "'"$serverNode"'" "'"$peer"'"')
|
||||
|
||||
"$createConfigScript" | tee /dev/tty | ${pkgs.qrencode}/bin/qrencode -t ansiutf8
|
||||
createConfigScript=$(nix build --no-link --print-out-paths --impure --show-trace --expr \
|
||||
'let flk = builtins.getFlake "${../../.}"; in (flk.extraLib.wireguard "'"$wgName"'").wgQuickConfigScript "${pkgs.system}" "'"$serverNode"'" "'"$peer"'"')
|
||||
"$createConfigScript" | tee /dev/tty | ${pkgs.qrencode}/bin/qrencode -t ansiutf8
|
||||
done <<< "$json_sel"
|
||||
''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue