This file is indexed.

postinst is in geneweb 6.05.1-1.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#! /bin/sh
# postinst script for GeneWeb
#
# see: dh_installdeb(1)

set -e 

# Needs Depends: iso-codes, isoquery
ISOQUERY=/usr/bin/isoquery

# These will be used here and there below
SERVICES=/etc/services
OLDRCFILE=/etc/geneweb/genewebrc
NEWRCFILE=/etc/default/geneweb
INITFILE=/etc/init.d/geneweb
GENEWEBUSER=geneweb


# We we'll need some variables defined there
# We first define some defaults values...just in case
GENEWEBDB=/var/lib/geneweb
USERS_GROUP=geneweb
LOGFILE=/var/log/geneweb.log

# Default settings
DEFAULTLNG="en"
DEFAULTFULLLNG="English"
DEFAULTPORT=2317
DEFAULTRUNMODE="Always on"
DEFAULTREMOVE=false
DEFAULTOPTIONS=""


# Reads config file (will override defaults above)
[ -r $NEWRCFILE ] && . $NEWRCFILE

. /usr/share/debconf/confmodule
db_version 2.0

write_rcfile() {
   cat >$NEWRCFILE <<EOF
#
# GeneWeb Configuration Data
#
# This file may be changed manually, or by running "dpkg-reconfigure geneweb"

# The port which the daemon listens to
PORT="${PORT}"

# The default language
# Look at Geneweb documentation for valid values
# Versions prior to 4.10-9 used LANG which could mix up with
# the system's localisation settings
LNG="${LNG}"

# The run mode
# Two possible values: "Always on" or "Manual"
# You need to use quotes
RUN_MODE="${RUN_MODE}"

# Additionnal options for gwd
# Example: OPTIONS="-a 192.168.1.1" for binding the daemon to a given address
# This setting is not handled by debconf
OPTIONS="${OPTIONS}"
EOF
}

get_debconf() {
    db_get geneweb/port
    PORT=$RET
    # If not present, use default
    if [ "$PORT" = "" ]
    then
	PORT=$DEFAULTPORT
    fi


    db_get geneweb/lang
    FULLLNG=$RET
    # If not present, use default
    if [ "$FULLLNG" = "" ]
    then
	FULLLNG=$DEFAULTFULLLNG
    fi
    # Find the two letter code for language
    # LNG=`echo $FULLLNG | cut -f 2 -d "(" | cut -f 1 -d ")"`
    LNG=`$ISOQUERY --iso=639 | grep "${FULLLNG}\$" | cut -f3`


    db_get geneweb/run_mode
    RUN_MODE="$RET"
    # If not present, use default
    if [ "$RUN_MODE" = "" ]
    then
	RUN_MODE="$DEFAULTRUNMODE"
    fi
}




case "$1" in
    configure)

	# NEWRCFILE has to be world-readable if we want the entry menu to work
	[ -f $NEWRCFILE ] && chmod g+r,a+r $NEWRCFILE

	[ -f $INITFILE ] && chmod a+rx $INITFILE

	if [ -d "/usr/share/doc/geneweb/$LNG" ]; then
		ln -sf /usr/share/doc/geneweb/$LNG /usr/share/doc/geneweb/doc_choice
	else
		ln -sf /usr/share/doc/geneweb/en /usr/share/doc/geneweb/doc_choice
	fi

	if [ ! -x `which addgroup` ]; then
	    echo "addgroup(8) from the \'adduser\' package is needed...";
	    exit 1;
	fi

	# Make sure user group is available
	if ! getent group ${USERS_GROUP} >/dev/null
	then
	    echo "Adding $USERS_GROUP group ... "
	    addgroup --quiet --force-badname $USERS_GROUP
	fi
	
	if [ ! -x `which adduser` ]; then
	    echo "adduser(8) from the \'adduser\' package is needed...";
	    exit 1;
	fi

	# Make sure geneweb user exists
	if ! getent passwd ${GENEWEBUSER} >/dev/null
	then
	    echo "Adding $GENEWEBUSER user ... "
	    adduser --quiet --system --home /var/lib/geneweb --no-create-home --ingroup $USERS_GROUP $GENEWEBUSER
	fi
	
	# Permissions and groups changes come back
	# to the configure stage again.
	# Problems may remains if users previously messed up
	# the permissions...but more huge problems will
	# occur if this stage occurs _before_ the geneweb
	# group creation (was bug 171570 on 4.07-3 release)

	if [ ! -f $LOGFILE ]
	then
	    touch $LOGFILE
	fi

	# Thus all files created there will have geneweb as group
	chown root:$USERS_GROUP $GENEWEBDB $GENEWEBDB/images $GENEWEBDB/cnt $GENEWEBDB/etc
	# The database directory is writable by geneweb group
	chmod ug+rwx,o-rwx $GENEWEBDB $GENEWEBDB/images $GENEWEBDB/cnt $GENEWEBDB/etc
	# SetGID bit on the database directory owned by geneweb group
	chmod g+s $GENEWEBDB $GENEWEBDB/images $GENEWEBDB/cnt $GENEWEBDB/etc

	# The log file is written by gwd running as the geneweb user
	# Make it readable/writable by this user only
	chown $GENEWEBUSER:$USERS_GROUP $LOGFILE
	chmod 600 $LOGFILE

	# Fix incorrect database and images directories permissions
	# These directories have to be group-writable
	# as the daemon now runs with an unprivileged UID
	#
	# Thanks to Russell Sutherland for pointing this to me
	# Bug: 179918
	#
	# Deal properly with database names that contain spaces
	OLDIFS=${IFS}
	IFS='
'
	for base in `find $GENEWEBDB -type d -name \*.gwb`
	do
	    chgrp $USERS_GROUP "$base"
	    chmod g+w,g+s "$base"
	    # Fix files permissions. See #219779
	    for file in `find $base -type f`
	    do
		chgrp $USERS_GROUP "$file"
		chmod g+w "$file"
	    done
	done
	for imagedir in `find $GENEWEBDB/images -type d`
	do
	    chgrp $USERS_GROUP "$imagedir"
	    chmod g+w,g+s "$imagedir"
	done
	IFS=${OLDIFS}

	# Values are read from debconf
	# to update variables
	get_debconf
	# The settings file is written
	# Moved to postinst
	write_rcfile

	;;
    *)
	;;
esac

# Transition of init scripts links: we don't want them in runlevels
# 0 and 6 anymore
if dpkg --compare-versions "$2" lt "5.01-4"; then
	update-rc.d -f geneweb remove
fi

# Automatically added by dh_installinit
if [ -x "/etc/init.d/geneweb" ]; then
	if [ ! -e "/etc/init/geneweb.conf" ]; then
		update-rc.d geneweb defaults >/dev/null
	fi
	invoke-rc.d geneweb start || exit $?
fi
# End automatically added section
# Automatically added by dh_installmenu
if [ "$1" = "configure" ] && [ -x "`which update-menus 2>/dev/null`" ]; then
	update-menus
fi
# End automatically added section