setup-sshd.in 850 Bytes
Newer Older
1 2 3 4 5 6 7
#!/bin/sh

PREFIX=

. "$PREFIX/lib/libalpine.sh"

usage() {
8 9
	cat <<-__EOF__
		usage: setup-sshd [-h] [-c choice of SSH daemon]
10

11
		Setup sshd daemon
12

13 14 15 16
		options:
		 -h  Show this help
		 -c  Choice of SSH daemon: openssh dropbear none
	__EOF__
17
	exit 1
18 19
}

20
while getopts "hc:" opt; do
21
	case $opt in
22
		h) usage;;
23
		c) sshdchoice="$OPTARG";;
24
	esac
25 26
done

27
if [ "$sshdchoice" = "" ]; then
28
	echo -n "Which SSH server? ('openssh', 'dropbear' or 'none') [openssh] "
29 30 31
	default_read sshdchoice "openssh"
fi

32
if [ "$sshdchoice" = "none" ]; then
33
	exit 0
34 35
fi

36 37 38
pkgs="$sshdchoice"
if [ "$sshdchoice" = "openssh" ] && apk info --quiet --installed acf-core; then
	pkgs="$pkgs acf-openssh"
39 40
fi

41 42 43 44 45 46 47 48 49 50 51
apk add --quiet $pkgs

svc=
case "$sshdchoice" in
	openssh) svc=sshd;;
	dropbear) svc=dropbear;;
esac

if [ -n "$svc" ]; then
	rc-update add $svc default
	rc-service $svc start
52
fi