Subversion Repositories

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

Rev 2 | Rev 62 | Go to most recent revision | Details | Compare with Previous | 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"
40 magnus 60
# Configuration file generated by lsh-server.postinst.
2 magnus 61
# You can change the lsh-server configuration either by editing
40 magnus 62
# this file, or by running dpkg-reconfigure lsh-server.
2 magnus 63
#
64
EOF
65
 
66
	echo "LSHD_PORT=\"$LSHD_PORT\"" >>"$LSHD_DEFAULTS"
67
	echo "ENABLE_SFTP=\"$ENABLE_SFTP\"" >> "$LSHD_DEFAULTS"
68
 
69
	# Versions before 2.0.1cdbs-4 have a security issue, therefore
70
	# have the random seed regenerated.
71
	if [ "$2" ] && [ -e "/var/spool/lsh/yarrow-seed-file" ] \
72
		&& dpkg --compare-versions "$2" lt "2.0.1cdbs-4"; then
73
		echo " Removing /var/spool/lsh/yarrow-seed-file, because of you are upgrading from a"
74
		echo " version with a known security bug, so we can't trust the seed any more."
75
		echo " It will be automatically regenerated from /dev/random."
76
		rm /var/spool/lsh/yarrow-seed-file
77
	fi
78
 
79
	# Disable ssh if needed
80
	if [ "$LSHD_PORT" -eq 22 ] ; then
81
	    if [ ! -d /etc/ssh ] ; then
82
		mkdir -p /etc/ssh
83
	    fi
84
 
85
	    file=/etc/ssh/sshd_not_to_be_run
86
	    if [ ! -f "$file" ] ; then
87
# stop ssh from starting at bootup
88
		cat  <<"EOF" >"$file"
89
LSH_SERVER_CONFIG_GENERATED
40 magnus 90
# Generated by lsh-server.postinst
2 magnus 91
# Please don't remove this file unless you have first disabled lsh, and don't
92
# change the first line ... otherwise lsh-server won't recognise it!!!
93
EOF
94
	    fi
95
	fi
96
    ;;
97
 
98
    abort-upgrade|abort-remove|abort-deconfigure)
99
 
100
    ;;
101
 
102
    *)
103
        echo "postinst called with unknown argument \`$1'" >&2
104
        exit 1
105
    ;;
106
esac
107
 
108
# dh_installdeb will replace this with shell code automatically
109
# generated by other debhelper scripts
110
 
111
#DEBHELPER#
112
 
113
exit 0