diff options
author | davidovski <david@davidovski.xyz> | 2022-03-29 23:37:34 +0100 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2022-03-29 23:37:34 +0100 |
commit | d28d2287b138ede0591d9facd5dbe7ca4f329f83 (patch) | |
tree | cea79933059dd721d6a9578f6214ac6fe9057d56 /extra/openrc/firstboot.initd | |
parent | 14a1fee0a54d94f0f57f50d2532849f3c2383a15 (diff) |
added sysvinit and openrc
Diffstat (limited to 'extra/openrc/firstboot.initd')
-rw-r--r-- | extra/openrc/firstboot.initd | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/extra/openrc/firstboot.initd b/extra/openrc/firstboot.initd new file mode 100644 index 0000000..eac4ef8 --- /dev/null +++ b/extra/openrc/firstboot.initd @@ -0,0 +1,34 @@ +#!/sbin/openrc-run + +# The first boot init service + +# read kernel options +init_KOPT() { + eval "set -- $(cat /proc/cmdline 2>/dev/null)" + for opt; 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 + checkpath -fm 0600 /root/.ssh/authorized_keys + 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 + fi + eend $rc +} + |