1#!/bin/sh
2
3DAEMON="pb-console"
4
5PB_CONSOLE_PORT=${2:-"console"}
6PB_CONSOLE_ARGS="--getty --detach -- -n -i 0 $PB_CONSOLE_PORT linux"
7
8# shellcheck source=/dev/null
9[ -r "/etc/default/petitboot" ] && . "/etc/default/petitboot"
10
11start() {
12	printf 'Starting %s on %s: ' "$DAEMON" "$PB_CONSOLE_PORT"
13	mkdir -p /var/log/petitboot
14
15	# shellcheck disable=SC2086 # we need the word splitting
16	start-stop-daemon -S -q -x "/usr/libexec/petitboot/$DAEMON" \
17		-- $PB_CONSOLE_ARGS
18	status=$?
19	if [ "$status" -eq 0 ]; then
20		echo "OK"
21	else
22		echo "FAIL"
23	fi
24	return "$status"
25}
26
27case "$1" in
28	start)
29		"$1";;
30	stop|restart|reload)
31		;;
32	*)
33		echo "Usage: $0 {start|stop|restart|reload} [port]"
34		exit 1
35		;;
36esac
37