aboutsummaryrefslogtreecommitdiffstats
path: root/setup-sshd.in
blob: 714279b7f6d219412641118212955215072c89fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh

PREFIX=

. "$PREFIX/lib/libalpine.sh"

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

Setup sshd daemon

options:
 -h  Show this help
 -c  Choice of SSH daemon: openssh dropbear none
__EOF__
        exit 1
}

while getopts "hc:" opt; do
        case $opt in
		h) usage;;
		c) sshdchoice="$OPTARG";;
        esac
done

if [ "$sshdchoice" = "" ]; then
	echo "sshd to setup? (openssh, dropbear, none) [openssh]"
	default_read sshdchoice "openssh"
fi

if [ "$sshdchoice" = "none" ]; then 
	exit 0
fi

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

if [ "$sshdchoice" = "openssh" ]; then
	if [ "$acfinstalled" != "ERROR:" ]; then
		apk add acf-openssh -q
	else
		apk add openssh -q
	fi
elif [ "$sshdchoice" = "dropbear" ]; then
	apk add dropbear
fi

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