aboutsummaryrefslogtreecommitdiff
path: root/lib/hydra/provision
blob: 54d9bcf687808ea0e508b8968fd0e09a8aeb961b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash

# Load provision configuration
function hydra_provision_config_load {
  hydra_install_package facter

  domain="`facter domain`"

  if [ ! -z "$1" ]; then
    if [ -f "$1" ]; then
      echo "Using configuration from file $1..."
      source "$1"
    elif [ -f "$1.conf" ]; then
      echo "Using configuration from file $1.conf..."
      source "$1.conf"
    elif [ -f "$1.$domain.conf" ]; then
      echo "Using configuration from file $1.$domain.conf..."
      source "$1.$domain.conf"
    elif [ -f "$HYDRA_FOLDER/config/provision/$1" ]; then
      echo "Using configuration from $HYDRA_FOLDER/config/provision/$1..."
      source "$HYDRA_FOLDER/config/provision/$1"
    elif [ -f "$HYDRA_FOLDER/config/provision/$1.conf" ]; then
      echo "Using configuration from $HYDRA_FOLDER/config/provision/$1.conf..."
      source "$HYDRA_FOLDER/config/provision/$1.conf"
    elif [ -f "$APP_BASE/share/config/provision/$1" ]; then
      echo "Using configuration from $APP_BASE/share/config/provision/$1..."
      source "$APP_BASE/share/config/provision/$1"
    elif [ -f "$APP_BASE/share/config/provision/$1.conf" ]; then
      echo "Using configuration from $APP_BASE/share/config/provision/$1.conf..."
      source "$APP_BASE/share/config/provision/$1.conf"
    else
      echo "Profile not found: $1"
      exit 1
    fi
  fi
}

# Networking.
function hydra_provision_networking {
  echo "Doing a basic network config..."
  cat <<-EOF | $SUDO tee $WORK/etc/network/interfaces/eth0 > /dev/null
auto eth0
allow-hotplug eth0
iface eth0 inet dhcp
EOF
}

function hydra_provision_fingerprints {
  echo "OpenSSH fingerprints:"
  #hydra_sudo_run chroot $WORK ssh-keygen -l -f /etc/ssh/ssh_host_dsa_key.pub
  hydra_sudo_run chroot $WORK ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub
  hydra_sudo_run chroot $WORK ssh-keygen -l -f /etc/ssh/ssh_host_ecdsa_key.pub
  hydra_sudo_run chroot $WORK ssh-keygen -l -f /etc/ssh/ssh_host_ed25519_key.pub
}