mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-08-05 13:27:09 +02:00
main/openrc: add firstboot service for installation through SSH
Currently this service serves the purpose of allowing Alpine installation through SSH.
This commit is contained in:
parent
1e7862203c
commit
6534855ffe
@ -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"
|
||||
|
44
main/openrc/firstboot.initd
Normal file
44
main/openrc/firstboot.initd
Normal file
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user