Skip to content

Commit 6bc6e87

Browse files
rminnichorangecms
authored andcommitted
Add an S99cpud init for buildroot
Tested and working on buildroot for the bananapi f3 start, stop, and restart work. Signed-off-by: Ronald G Minnich <[email protected]>
1 parent 4bb4134 commit 6bc6e87

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

sysvinit/S99cpud-init-buildroot

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/sh
2+
# This has been tested on a bpi f3 with buildroot init
3+
# it was placed in an overlay before buildroot.
4+
# board/bananapi/bananapi-f3/rootfs_overlay/etc/init.d/S99cpud
5+
# cpud is in sbin, and cpu_rsa.pub is in etc
6+
# origin https://github.com/Mr-Bossman/bpi-f3-buildroot (fetch)
7+
# 726897faf4692b06d594797940d22f3155e4d0b7 (HEAD -> master, origin/master, origin/HEAD)
8+
# This is a single user image, so you'll need to
9+
# put the pub key in /etc/cpud/.
10+
#
11+
# Starts cpud sshd.
12+
#
13+
14+
# Allow a few customizations from a config file
15+
test -r /etc/default/cpud && . /etc/default/cpud
16+
17+
start() {
18+
CPUD_ARGS="$CPUD_ARGS -pk /etc/cpu_rsa.pub"
19+
20+
# If /etc/cpud is a symlink to /var/run/cpud, and
21+
# - the filesystem is RO (i.e. we can not rm the symlink),
22+
# create the directory pointed to by the symlink.
23+
# - the filesystem is RW (i.e. we can rm the symlink),
24+
# replace the symlink with an actual directory
25+
if [ -L /etc/cpud \
26+
-a "$(readlink /etc/cpud)" = "/var/run/cpud" ]
27+
then
28+
if rm -f /etc/cpud >/dev/null 2>&1; then
29+
mkdir -p /etc/cpud
30+
else
31+
echo "No persistent location to store SSH host keys. New keys will be"
32+
echo "generated at each boot. Are you sure this is what you want to do?"
33+
mkdir -p "$(readlink /etc/cpud)"
34+
fi
35+
fi
36+
37+
printf "Starting cpud: "
38+
umask 077
39+
40+
start-stop-daemon -S -b -m -p /var/run/cpud.pid \
41+
-x /sbin/cpud -- $CPUD_ARGS
42+
[ $? = 0 ] && echo "OK" || echo "FAIL"
43+
}
44+
stop() {
45+
printf "Stopping cpud: "
46+
start-stop-daemon -K -p /var/run/cpud.pid
47+
[ $? = 0 ] && echo "OK" || echo "FAIL"
48+
}
49+
restart() {
50+
stop
51+
start
52+
}
53+
54+
case "$1" in
55+
start)
56+
start
57+
;;
58+
stop)
59+
stop
60+
;;
61+
restart|reload)
62+
restart
63+
;;
64+
*)
65+
echo "Usage: $0 {start|stop|restart}"
66+
exit 1
67+
esac
68+
69+
exit $?

0 commit comments

Comments
 (0)