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

PREFIX=

. "$PREFIX/lib/libalpine.sh"

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

11
Setup sshd daemon
12 13 14

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

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

27 28 29 30 31 32
if [ "$sshdchoice" = "" ]; then
	echo "sshd to setup? (openssh, dropbear, none) [openssh]"
	default_read sshdchoice "openssh"
fi

if [ "$sshdchoice" = "none" ]; then 
Jeff Bilyk's avatar
Jeff Bilyk committed
33
	exit 0
34 35 36 37
fi

acfinstalled="`apk version acf-core -q | awk '{print $1}'`"

38
if [ "$sshdchoice" = "openssh" ]; then
Jeff Bilyk's avatar
Jeff Bilyk committed
39 40 41 42 43
	if [ "$acfinstalled" != "ERROR:" ]; then
		apk add acf-openssh -q
	else
		apk add openssh -q
	fi
44
elif [ "$sshdchoice" = "dropbear" ]; then
Jeff Bilyk's avatar
Jeff Bilyk committed
45
	apk add dropbear
46 47
fi

48 49 50 51 52 53
if [ -e /etc/init.d/sshd ]; then
	/etc/init.d/sshd start
	rc-update add sshd default
else
	echo "$sshdchoice failed to install"
fi