]>
Commit | Line | Data |
---|---|---|
cdfeb278 DY |
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 | ||
8bcfd683 | 7 | # called by dracut |
cdfeb278 | 8 | check() { |
7f347723 | 9 | [[ $mount_needs ]] && return 1 |
38164332 | 10 | |
30e6e809 HH |
11 | # If our prerequisites are not met, fail. |
12 | require_binaries ssh scp || return 1 | |
13 | ||
cdfeb278 DY |
14 | if [[ $sshkey ]]; then |
15 | [ ! -f $sshkey ] && { | |
38164332 | 16 | derror "ssh key: $sshkey is not found!" |
cdfeb278 DY |
17 | return 1 |
18 | } | |
cdfeb278 DY |
19 | fi |
20 | ||
38164332 | 21 | return 255 |
cdfeb278 DY |
22 | } |
23 | ||
8bcfd683 | 24 | # called by dracut |
cdfeb278 DY |
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 ]] && { | |
53fe81e7 HH |
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 | |
cdfeb278 DY |
42 | } |
43 | ||
44 | # Copy over root and system-wide ssh configs. | |
53fe81e7 HH |
45 | [[ -f /root/.ssh/config ]] && inst_simple /root/.ssh/config |
46 | [[ -f /etc/ssh/ssh_config ]] && inst_simple /etc/ssh/ssh_config | |
cdfeb278 DY |
47 | |
48 | return 0 | |
49 | } | |
50 | ||
8bcfd683 | 51 | # called by dracut |
cdfeb278 | 52 | install() { |
af119460 | 53 | inst_multiple ssh scp |
cdfeb278 DY |
54 | inst_sshenv |
55 | } | |
56 |