]> git.ipfire.org Git - thirdparty/dracut.git/blob - modules.d/95ssh-client/module-setup.sh
Factor out all the "type -V" commands
[thirdparty/dracut.git] / modules.d / 95ssh-client / module-setup.sh
1 #!/bin/bash
2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
4
5 # fixme: assume user is root
6
7 # called by dracut
8 check() {
9 [[ $mount_needs ]] && return 1
10
11 # If our prerequisites are not met, fail.
12 require_binaries ssh scp || return 1
13
14 if [[ $sshkey ]]; then
15 [ ! -f $sshkey ] && {
16 derror "ssh key: $sshkey is not found!"
17 return 1
18 }
19 fi
20
21 return 255
22 }
23
24 # called by dracut
25 depends() {
26 # We depend on network modules being loaded
27 echo network
28 }
29
30 inst_sshenv()
31 {
32 if [ -d /root/.ssh ]; then
33 inst_dir /root/.ssh
34 chmod 700 ${initdir}/root/.ssh
35 fi
36
37 # Copy over ssh key and knowhosts if needed
38 [[ $sshkey ]] && {
39 inst_simple $sshkey
40 [[ -f /root/.ssh/known_hosts ]] && inst_simple /root/.ssh/known_hosts
41 [[ -f /etc/ssh/ssh_known_hosts ]] && inst_simple /etc/ssh/ssh_known_hosts
42 }
43
44 # Copy over root and system-wide ssh configs.
45 [[ -f /root/.ssh/config ]] && inst_simple /root/.ssh/config
46 [[ -f /etc/ssh/ssh_config ]] && inst_simple /etc/ssh/ssh_config
47
48 return 0
49 }
50
51 # called by dracut
52 install() {
53 inst_multiple ssh scp
54 inst_sshenv
55 }
56