Subversion Repositories

?revision_form?Rev ?revision_input??revision_submit??revision_endform?

Rev 2 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 5
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-config.
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 /usr/sbin/lsh-server-config, which uses
63
# a debconf interface to set up lsh-server.
63
# a debconf interface to set up lsh-server.
64
#
64
#
65
EOF
65
EOF
66
66
67
	echo "LSHD_PORT=\"$LSHD_PORT\"" >>"$LSHD_DEFAULTS"
67
	echo "LSHD_PORT=\"$LSHD_PORT\"" >>"$LSHD_DEFAULTS"
68
	echo "ENABLE_SFTP=\"$ENABLE_SFTP\"" >> "$LSHD_DEFAULTS"
68
	echo "ENABLE_SFTP=\"$ENABLE_SFTP\"" >> "$LSHD_DEFAULTS"
69
69
70
	# Versions before 2.0.1cdbs-4 have a security issue, therefore
70
	# Versions before 2.0.1cdbs-4 have a security issue, therefore
71
	# have the random seed regenerated.
71
	# have the random seed regenerated.
72
	if [ "$2" ] && [ -e "/var/spool/lsh/yarrow-seed-file" ] \
72
	if [ "$2" ] && [ -e "/var/spool/lsh/yarrow-seed-file" ] \
73
		&& dpkg --compare-versions "$2" lt "2.0.1cdbs-4"; then
73
		&& 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"
74
		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."
75
		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."
76
		echo " It will be automatically regenerated from /dev/random."
77
		rm /var/spool/lsh/yarrow-seed-file
77
		rm /var/spool/lsh/yarrow-seed-file
78
	fi
78
	fi
79
79
80
	# Disable ssh if needed
80
	# Disable ssh if needed
81
	if [ "$LSHD_PORT" -eq 22 ] ; then
81
	if [ "$LSHD_PORT" -eq 22 ] ; then
82
	    if [ ! -d /etc/ssh ] ; then
82
	    if [ ! -d /etc/ssh ] ; then
83
		mkdir -p /etc/ssh
83
		mkdir -p /etc/ssh
84
	    fi
84
	    fi
85
85
86
	    file=/etc/ssh/sshd_not_to_be_run
86
	    file=/etc/ssh/sshd_not_to_be_run
87
	    if [ ! -f "$file" ] ; then
87
	    if [ ! -f "$file" ] ; then
88
# stop ssh from starting at bootup
88
# stop ssh from starting at bootup
89
		cat  <<"EOF" >"$file"
89
		cat  <<"EOF" >"$file"
90
LSH_SERVER_CONFIG_GENERATED
90
LSH_SERVER_CONFIG_GENERATED
91
# Generated by lsh-server-config
91
# Generated by lsh-server-config
92
# Please don't remove this file unless you have first disabled lsh, and don't
92
# 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!!!
93
# change the first line ... otherwise lsh-server won't recognise it!!!
94
EOF
94
EOF
95
	    fi
95
	    fi
96
	fi
96
	fi
97
    ;;
97
    ;;
98
98
99
    abort-upgrade|abort-remove|abort-deconfigure)
99
    abort-upgrade|abort-remove|abort-deconfigure)
100
100
101
    ;;
101
    ;;
102
102
103
    *)
103
    *)
104
        echo "postinst called with unknown argument \`$1'" >&2
104
        echo "postinst called with unknown argument \`$1'" >&2
105
        exit 1
105
        exit 1
106
    ;;
106
    ;;
107
esac
107
esac
108
108
109
# dh_installdeb will replace this with shell code automatically
109
# dh_installdeb will replace this with shell code automatically
110
# generated by other debhelper scripts
110
# generated by other debhelper scripts
111
111
112
#DEBHELPER#
112
#DEBHELPER#
113
113
114
exit 0
114
exit 0