summaryrefslogtreecommitdiffstats
path: root/bin/infest-cac
blob: d7d7bb96c80ba07bf5a64b40826a4d7ab812d8e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! /bin/sh
set -euf

server=$(cac-get-server-by servername "$1")
hostname=$2

serverstatus=$(echo $server | jq -r .status)
case $serverstatus in
  'Powered On') : ;;
  *)
    echo $0: bad server status: $serverstatus >&2
    exit 2
esac

template=$(echo $server | jq -r .template)
case $template in
  'CentOS-7-64bit') infest-"$template" "$server" "$hostname";;
  *)
    echo $0: bad template: $template >&2
    exit 3
esac