blob: cc888b351fb2cb27b6f88589ce85280b77fd13cf (
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
|
#!/sbin/openrc-run
# The first boot init service
# read kernel options
init_KOPT() {
for opt in $(cat /proc/cmdline 2>/dev/null); do
case "$opt" in
ssh_*=*)
eval "KOPT_${opt%%=*}='${opt#*=}'" ;;
esac
done
}
depend() {
keyword -vserver -lxc
init_KOPT
[ -n "$KOPT_ssh_key" ] && need sshd
[ -n "$KOPT_ssh_pass" ] && use sshd
}
start() {
init_KOPT
local rc=0
ebegin "Starting ${RC_SVCNAME}"
if [ -n "$KOPT_ssh_key" ] && [ ! -f "/root/.ssh/authorized_keys" ]; then
einfo "Fetching ssh keys"
mkdir -pm 700 /root/.ssh
case "$KOPT_ssh_key" in
http://*|https://*|ftp://*|ftps://*)
wget -q "$KOPT_ssh_key" -O /root/.ssh/authorized_keys
rc=$?;;
*) echo "$KOPT_ssh_key" > /root/.ssh/authorized_keys;;
esac
chmod 600 /root/.ssh/authorized_keys
fi
if [ -n "$KOPT_ssh_pass" ]; then
echo "root:$KOPT_ssh_pass" | /usr/sbin/chpasswd
command_args="-o PermitRootLogin=yes" rc-service sshd start --quiet
fi
eend $rc
}
|