github.com/Cloud-Foundations/Dominator@v0.3.4/cmd/subd/set-owner (about)

     1  #! /bin/bash --posix
     2  #
     3  # Set the subd owner for the machine.
     4  
     5  set -e
     6  
     7  readonly dirname='/etc/subd/conf.d'
     8  
     9  umask 022
    10  mkdir -p "$dirname"
    11  username="$1"
    12  
    13  if [ -z "$username" ]; then
    14      # Try Keymaster certificate.
    15      username=$(openssl x509 -subject -nameopt sep_multiline -noout \
    16  		       -in "$HOME/.ssl/keymaster.cert"             \
    17  		       | fgrep CN= | tr = ' ' | awk '{print $2}')
    18  fi
    19  
    20  if [ -z "$username" ]; then
    21      echo "Username not specified on command line and not found in Keymaster certificate"
    22      exit 1
    23  fi
    24  
    25  cat > "$dirname/90_set_owner" <<EndOfJson
    26  {
    27      "OwnerUsers": ["$username"]
    28  }
    29  EndOfJson