summaryrefslogtreecommitdiffstats
path: root/lass/5pkgs/untilport/default.nix
blob: 61bcc2b897dca2d614b08c832180bd13671e06c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{ pkgs, ... }:

pkgs.writeDashBin "untilport" ''
  set -euf

  usage() {
    echo 'untiport $target $port'
    echo 'Sleeps until the destinated port is reachable.'
    echo 'ex: untilport google.de 80 && echo "google is now reachable"'
  }


  if [ $# -ne 2 ]; then
    usage
  else
    until ${pkgs.netcat-openbsd}/bin/nc -z "$@"; do sleep 1; done
  fi
''