aports/main/openrc/firstboot.initd
Mick Tarsel bec7d16f8e main/openrc: Allow http:// for ssh_key
A slight revert of commit 4ef156921798938 which removed http://*
Since the kernel argument is downloading the public key, we
are not required to use an encrypted protocol. This will also
be easier for a local development environment.
2018-06-21 07:44:55 +00:00

34 lines
703 B
Plaintext

#!/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
}
start() {
rm -f /etc/runlevels/*/$RC_SVCNAME
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
https://*|ftps://*|http://*)
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
eend $rc
}