Rev 5 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5 | Rev 56 | ||
---|---|---|---|
1 | #!/bin/sh |
1 | #!/bin/sh |
2 | # postinst script for lsh-server |
2 | # postinst script for lsh-server |
3 | # |
3 | # |
4 | # see: dh_installdeb(1) |
4 | # see: dh_installdeb(1) |
5 | 5 | ||
6 | set -e |
6 | set -e |
7 | 7 | ||
8 | # summary of how this script can be called: |
8 | # summary of how this script can be called: |
9 | # * <postinst> `configure' <most-recently-configured-version> |
9 | # * <postinst> `configure' <most-recently-configured-version> |
10 | # * <old-postinst> `abort-upgrade' <new version> |
10 | # * <old-postinst> `abort-upgrade' <new version> |
11 | # * <conflictor's-postinst> `abort-remove' `in-favour' <package> |
11 | # * <conflictor's-postinst> `abort-remove' `in-favour' <package> |
12 | # <new-version> |
12 | # <new-version> |
13 | # * <deconfigured's-postinst> `abort-deconfigure' `in-favour' |
13 | # * <deconfigured's-postinst> `abort-deconfigure' `in-favour' |
14 | # <failed-install-package> <version> `removing' |
14 | # <failed-install-package> <version> `removing' |
15 | # <conflicting-package> <version> |
15 | # <conflicting-package> <version> |
16 | # for details, see http://www.debian.org/doc/debian-policy/ or |
16 | # for details, see http://www.debian.org/doc/debian-policy/ or |
17 | # the debian-policy package |
17 | # the debian-policy package |
18 | # |
18 | # |
19 | # quoting from the policy: |
19 | # quoting from the policy: |
20 | # Any necessary prompting should almost always be confined to the |
20 | # Any necessary prompting should almost always be confined to the |
21 | # post-installation script, and should be protected with a conditional |
21 | # post-installation script, and should be protected with a conditional |
22 | # so that unnecessary prompting doesn't happen if a package's |
22 | # so that unnecessary prompting doesn't happen if a package's |
23 | # installation fails and the `postinst' is called with `abort-upgrade', |
23 | # installation fails and the `postinst' is called with `abort-upgrade', |
24 | # `abort-remove' or `abort-deconfigure'. |
24 | # `abort-remove' or `abort-deconfigure'. |
25 | 25 | ||
26 | 26 | ||
27 | LSHD_DEFAULTS=/etc/default/lsh-server |
27 | LSHD_DEFAULTS=/etc/default/lsh-server |
28 | 28 | ||
29 | case "$1" in |
29 | case "$1" in |
30 | configure) |
30 | configure) |
31 | 31 | ||
32 | # This needs to be fixed. If we do stuff this way, strange things will |
32 | # This needs to be fixed. If we do stuff this way, strange things will |
33 | # happen ... the user can specify stuff to debconf and old options can |
33 | # happen ... the user can specify stuff to debconf and old options can |
34 | # still be written to the config file :-( |
34 | # still be written to the config file :-( |
35 | # First, get default options |
35 | # First, get default options |
36 | #[ -e "$LSHD_DEFAULTS" ] && . "$LSHD_DEFAULTS" |
36 | #[ -e "$LSHD_DEFAULTS" ] && . "$LSHD_DEFAULTS" |
37 | 37 | ||
38 | # Fall back to default options if necessary |
38 | # Fall back to default options if necessary |
39 | LSHD_PORT=${LSHD_PORT:-2222} |
39 | LSHD_PORT=${LSHD_PORT:-2222} |
40 | ENABLE_SFTP=${ENABLE_SFTP:-false} |
40 | ENABLE_SFTP=${ENABLE_SFTP:-false} |
41 | 41 | ||
42 | # Make sure ENABLE_SFTP is either "true" or "false", set up option |
42 | # Make sure ENABLE_SFTP is either "true" or "false", set up option |
43 | case "$ENABLE_SFTP" in |
43 | case "$ENABLE_SFTP" in |
44 | true|TRUE|y*|Y*) |
44 | true|TRUE|y*|Y*) |
45 | ENABLE_SFTP=true |
45 | ENABLE_SFTP=true |
46 | ;; |
46 | ;; |
47 | *) |
47 | *) |
48 | ENABLE_SFTP=false |
48 | ENABLE_SFTP=false |
49 | ;; |
49 | ;; |
50 | esac |
50 | esac |
51 | 51 | ||
52 | . /usr/share/debconf/confmodule |
52 | . /usr/share/debconf/confmodule |
53 | 53 | ||
54 | db_get "lsh-server/lshd_port"; LSHD_PORT="$RET" |
54 | db_get "lsh-server/lshd_port"; LSHD_PORT="$RET" |
55 | db_get "lsh-server/sftp"; ENABLE_SFTP="$RET" |
55 | db_get "lsh-server/sftp"; ENABLE_SFTP="$RET" |
56 | 56 | ||
57 | # OK, now make the config file |
57 | # OK, now make the config file |
58 | 58 | ||
59 | cat <<"EOF" >"$LSHD_DEFAULTS" |
59 | cat <<"EOF" >"$LSHD_DEFAULTS" |
60 | # Configuration file generated by lsh-server-config. |
60 | # Configuration file generated by lsh-server.postinst. |
61 | # You can change the lsh-server configuration either by editing |
61 | # You can change the lsh-server configuration either by editing |
62 | # this file, or by running /usr/sbin/lsh-server-config, which uses |
62 | # this file, or by running dpkg-reconfigure lsh-server. |
63 | # a debconf interface to set up lsh-server. |
- | |
64 | # |
63 | # |
65 | EOF |
64 | EOF |
66 | 65 | ||
67 | echo "LSHD_PORT=\"$LSHD_PORT\"" >>"$LSHD_DEFAULTS" |
66 | echo "LSHD_PORT=\"$LSHD_PORT\"" >>"$LSHD_DEFAULTS" |
68 | echo "ENABLE_SFTP=\"$ENABLE_SFTP\"" >> "$LSHD_DEFAULTS" |
67 | echo "ENABLE_SFTP=\"$ENABLE_SFTP\"" >> "$LSHD_DEFAULTS" |
69 | 68 | ||
70 | # Versions before 2.0.1cdbs-4 have a security issue, therefore |
69 | # Versions before 2.0.1cdbs-4 have a security issue, therefore |
71 | # have the random seed regenerated. |
70 | # have the random seed regenerated. |
72 | if [ "$2" ] && [ -e "/var/spool/lsh/yarrow-seed-file" ] \ |
71 | if [ "$2" ] && [ -e "/var/spool/lsh/yarrow-seed-file" ] \ |
73 | && dpkg --compare-versions "$2" lt "2.0.1cdbs-4"; then |
72 | && dpkg --compare-versions "$2" lt "2.0.1cdbs-4"; then |
74 | echo " Removing /var/spool/lsh/yarrow-seed-file, because of you are upgrading from a" |
73 | echo " Removing /var/spool/lsh/yarrow-seed-file, because of you are upgrading from a" |
75 | echo " version with a known security bug, so we can't trust the seed any more." |
74 | echo " version with a known security bug, so we can't trust the seed any more." |
76 | echo " It will be automatically regenerated from /dev/random." |
75 | echo " It will be automatically regenerated from /dev/random." |
77 | rm /var/spool/lsh/yarrow-seed-file |
76 | rm /var/spool/lsh/yarrow-seed-file |
78 | fi |
77 | fi |
79 | 78 | ||
80 | # Disable ssh if needed |
79 | # Disable ssh if needed |
81 | if [ "$LSHD_PORT" -eq 22 ] ; then |
80 | if [ "$LSHD_PORT" -eq 22 ] ; then |
82 | if [ ! -d /etc/ssh ] ; then |
81 | if [ ! -d /etc/ssh ] ; then |
83 | mkdir -p /etc/ssh |
82 | mkdir -p /etc/ssh |
84 | fi |
83 | fi |
85 | 84 | ||
86 | file=/etc/ssh/sshd_not_to_be_run |
85 | file=/etc/ssh/sshd_not_to_be_run |
87 | if [ ! -f "$file" ] ; then |
86 | if [ ! -f "$file" ] ; then |
88 | # stop ssh from starting at bootup |
87 | # stop ssh from starting at bootup |
89 | cat <<"EOF" >"$file" |
88 | cat <<"EOF" >"$file" |
90 | LSH_SERVER_CONFIG_GENERATED |
89 | LSH_SERVER_CONFIG_GENERATED |
91 | # Generated by lsh-server-config |
90 | # Generated by lsh-server.postinst |
92 | # Please don't remove this file unless you have first disabled lsh, and don't |
91 | # Please don't remove this file unless you have first disabled lsh, and don't |
93 | # change the first line ... otherwise lsh-server won't recognise it!!! |
92 | # change the first line ... otherwise lsh-server won't recognise it!!! |
94 | EOF |
93 | EOF |
95 | fi |
94 | fi |
96 | fi |
95 | fi |
97 | ;; |
96 | ;; |
98 | 97 | ||
99 | abort-upgrade|abort-remove|abort-deconfigure) |
98 | abort-upgrade|abort-remove|abort-deconfigure) |
100 | 99 | ||
101 | ;; |
100 | ;; |
102 | 101 | ||
103 | *) |
102 | *) |
104 | echo "postinst called with unknown argument \`$1'" >&2 |
103 | echo "postinst called with unknown argument \`$1'" >&2 |
105 | exit 1 |
104 | exit 1 |
106 | ;; |
105 | ;; |
107 | esac |
106 | esac |
108 | 107 | ||
109 | # dh_installdeb will replace this with shell code automatically |
108 | # dh_installdeb will replace this with shell code automatically |
110 | # generated by other debhelper scripts |
109 | # generated by other debhelper scripts |
111 | 110 | ||
112 | #DEBHELPER# |
111 | #DEBHELPER# |
113 | 112 | ||
114 | exit 0 |
113 | exit 0 |