aboutsummaryrefslogtreecommitdiffstats
path: root/main/openrc
diff options
context:
space:
mode:
authorTuan M. Hoang <tmhoang@flatglobe.org>2018-05-21 17:54:30 +0000
committerCarlo Landmeter <clandmeter@alpinelinux.org>2018-05-23 12:42:39 +0000
commit6534855ffe9c130d907c3dd653ab698e2dc0572a (patch)
tree15140f1c05922fdb9f0d3cb459e600fa3f56dac7 /main/openrc
parent1e7862203c56fafaeed4354339bcf8fc22bf1366 (diff)
downloadaports-6534855ffe9c130d907c3dd653ab698e2dc0572a.tar.bz2
aports-6534855ffe9c130d907c3dd653ab698e2dc0572a.tar.xz
main/openrc: add firstboot service for installation through SSH
Currently this service serves the purpose of allowing Alpine installation through SSH.
Diffstat (limited to 'main/openrc')
-rw-r--r--main/openrc/APKBUILD6
-rw-r--r--main/openrc/firstboot.initd44
2 files changed, 48 insertions, 2 deletions
diff --git a/main/openrc/APKBUILD b/main/openrc/APKBUILD
index 2db659d5dc..5f9914af41 100644
--- a/main/openrc/APKBUILD
+++ b/main/openrc/APKBUILD
@@ -2,7 +2,7 @@
pkgname=openrc
pkgver=0.35.5
_ver=${pkgver/_git*/}
-pkgrel=1
+pkgrel=2
pkgdesc="OpenRC manages the services, startup and shutdown of a host"
url="https://gitweb.gentoo.org/proj/openrc.git"
arch="all"
@@ -28,6 +28,7 @@ source="$pkgname-$pkgver.tar.gz::https://github.com/OpenRC/openrc/archive/$pkgve
networking.initd
modloop.confd
sysfsconf.initd
+ firstboot.initd
"
builddir="$srcdir/$pkgname-$_ver"
@@ -94,4 +95,5 @@ b04058ec630e19de0bafefe06198dc1bff8c8d5d2c89e4660dd83dda8bb82a76cdb1d8661cce88e4
27c036a2c07f658f7fb1e066c59dc494674ba0d81bcb85fea9caffec28ee537eb11e863e20aa4b1c88607f12496ac66d5b092c787c86ff8b8a80e423a8d99440 modloop.initd
55df0ac13dac1f215f0c573ac07b150d31232a5204eccfc8941d5af73f91b4535a85d79b7f6514217038ecbe6bffa28cb83fd8d46fd4c596e07103deb8bc8a57 networking.initd
80e43ded522e2d48b876131c7c9997debd43f3790e0985801a8c1dd60bc6e09f625b35a127bf225eb45a65eec7808a50d1c08a5e8abceafc61726211e061e0a2 modloop.confd
-d76c75c58e6f4b0801edac4e081b725ef3d50a9a8c9bbb5692bf4d0f804af7d383bf71a73d5d03ed348a89741ef0b2427eb6a7cbf5a9b9ff60a240639fa6ec88 sysfsconf.initd"
+d76c75c58e6f4b0801edac4e081b725ef3d50a9a8c9bbb5692bf4d0f804af7d383bf71a73d5d03ed348a89741ef0b2427eb6a7cbf5a9b9ff60a240639fa6ec88 sysfsconf.initd
+baee47a6288108e35d78f47873885111fb4fee9fc690c58d0bfb0385b9796d0879b99449c909dbe5b1921733354a85698e92bb5c08f9e4ea6f031b00e86a0240 firstboot.initd"
diff --git a/main/openrc/firstboot.initd b/main/openrc/firstboot.initd
new file mode 100644
index 0000000000..cc888b351f
--- /dev/null
+++ b/main/openrc/firstboot.initd
@@ -0,0 +1,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
+}
+