aboutsummaryrefslogtreecommitdiff
path: root/module-setup.sh
blob: 8708778622dd440a27740178fc0f5b21312f5f94 (plain) (blame)
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
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh

check() {
  return 255
}

depends() {
  echo 'ssh-client busybox'
}

install() {
  local tmpdir=$(mktemp -d --tmpdir dracut-acquire-key-over-ssh.XXXX)
  local genconf="${tmpdir}/acquire-key-over-ssh.conf"
  local installconf="/etc/acquire-key-over-ssh.conf"

  [[ -z "${keyserver_port}" ]] && keyserver_port=22

  echo -e "#!/bin/bash\n\n" >> "$genconf"
  echo "keyserver_interface='${keyserver_interface}'" >> "$genconf"
  echo "keyserver_host='$keyserver_host'" >> "$genconf"
  echo "keyserver_user='$keyserver_user'" >> "$genconf"
  echo "keyserver_port='$keyserver_port'" >> "$genconf"
  echo "client_ssh_keys_device='${client_ssh_keys_device}'" >> "$genconf"
  echo "client_ssh_keys_mountpoint='$client_ssh_keys_mountpoint'" >> "$genconf"
  echo "client_identity_file='$client_identity_file'" >> "$genconf"
  echo "shred_keys_after_use='$shred_keys_after_use'" >> "$genconf"

  inst_hook initqueue/settled 99 "$moddir/start-ssh-acquire.sh"
  inst_script "$moddir/poll-ssh-acquire.sh" "/bin/poll-ssh-acquire.sh"
  inst_simple "/root/.ssh/known_hosts"
  inst_simple "/root/.ssh/id_rsa.pub"
  inst_simple "/root/.ssh/id_rsa"
  inst "$genconf" "$installconf"

  rm -rf $tmpdir
}