Subversion Repositories

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

Rev 40 | Go to most recent revision | Details | Last modification | View Log | RSS feed

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