annotate debian/dropbear-server.postinst @ 522:8cc0598b0b9a maemo

- Split into separate debs
author Matt Johnston <matt@ucc.asn.au>
date Tue, 18 Nov 2008 12:53:48 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
522
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 #!/bin/sh
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2 set -e
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4 test "$1" = 'configure' || exit 0
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6 if test ! -e /etc/dropbear/dropbear_rsa_host_key; then
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7 if test -f /etc/ssh/ssh_host_rsa_key; then
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8 echo "Converting existing OpenSSH RSA host key to Dropbear format."
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
9 /usr/lib/dropbear/dropbearconvert openssh dropbear \
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
10 /etc/ssh/ssh_host_rsa_key /etc/dropbear/dropbear_rsa_host_key
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
11 else
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
12 echo "Generating Dropbear RSA key. Please wait."
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
13 dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
14 fi
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
15 fi
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
16 if test ! -e /etc/dropbear/dropbear_dss_host_key; then
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
17 if test -f /etc/ssh/ssh_host_dsa_key; then
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
18 echo "Converting existing OpenSSH RSA host key to Dropbear format."
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
19 /usr/lib/dropbear/dropbearconvert openssh dropbear \
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
20 /etc/ssh/ssh_host_dsa_key /etc/dropbear/dropbear_dss_host_key
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
21 else
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
22 echo "Generating Dropbear DSS key. Please wait."
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
23 dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
24 fi
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
25 fi
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
26 if test ! -s /etc/default/dropbear; then
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
27 # check whether OpenSSH seems to be installed.
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
28 if test -x /usr/sbin/sshd; then
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
29 cat <<EOT
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
30 OpenSSH appears to be installed. Setting /etc/default/dropbear so that
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
31 Dropbear will not start by default. Edit this file to change this behaviour.
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
32
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
33 EOT
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
34 cat >>/etc/default/dropbear <<EOT
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
35 # disabled because OpenSSH is installed
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
36 # change to NO_START=0 to enable Dropbear
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
37 NO_START=1
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
38
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
39 EOT
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
40 fi
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
41 cat >>/etc/default/dropbear <<EOT
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
42 # the TCP port that Dropbear listens on
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
43 DROPBEAR_PORT=22
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
44
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
45 # any additional arguments for Dropbear
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
46 DROPBEAR_EXTRA_ARGS=
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
47
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
48 # specify an optional banner file containing a message to be
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
49 # sent to clients before they connect, such as "/etc/issue.net"
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
50 DROPBEAR_BANNER=""
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
51
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
52 # RSA hostkey file (default: /etc/dropbear/dropbear_rsa_host_key)
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
53 #DROPBEAR_RSAKEY="/etc/dropbear/dropbear_rsa_host_key"
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
54
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
55 # DSS hostkey file (default: /etc/dropbear/dropbear_dss_host_key)
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
56 #DROPBEAR_DSSKEY="/etc/dropbear/dropbear_dss_host_key"
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
57
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
58 # Receive window size - this is a tradeoff between memory and
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
59 # network performance
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
60 DROPBEAR_RECEIVE_WINDOW=65536
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
61 EOT
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
62 fi
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
63
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
64 if test -x /etc/init.d/dropbear; then
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
65 update-rc.d dropbear defaults >/dev/null
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
66 if test -x /usr/sbin/invoke-rc.d; then
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
67 invoke-rc.d dropbear restart
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
68 else
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
69 /etc/init.d/dropbear restart
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
70 fi
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
71 fi
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
72
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
73 if test -n "$2" && dpkg --compare-versions "$2" lt '0.50-4' &&
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
74 update-service --check dropbear 2>/dev/null; then
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
75 update-service --remove /etc/dropbear 2>/dev/null || :
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
76 sleep 6
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
77 rm -rf /var/run/dropbear /var/run/dropbear.log
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
78 update-service --add /etc/dropbear || :
8cc0598b0b9a - Split into separate debs
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
79 fi