postinst is in wims-moodle 4.0-11.
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 | #!/bin/sh
# postinst script for wims-moodle
#
# see: dh_installdeb(1)
set -e
[ -e /usr/share/debconf/confmodule ] && . /usr/share/debconf/confmodule
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
###########################################################################
## Getting the address for Wims
db_get wims-moodle/remoteurl
remoteurl="$RET"
localwims_path="/var/lib/wims/log/classes/.connections/localwims"
create_localwims(){
mkdir -p $(dirname $localwims_path)
cat <<EOF > $localwims_path
# This is an example of identification file for connection to another
# platform. It is used for platform authentification.
# If you copy this file to another one in the same directory,
# and modify the definitions, you get another platform identification
# whose name is the name of that file.
# calling the same WIMS server.
# For security reasons, it is highly recommended that you only accept
# localhost connections. Accept several sites, but no wildcard.
ident_site=127.0.0.1
# Short description
ident_desc=This local WIMS server
# User agent of the connecting platform must identify itself as such.
#ident_agent=WIMS-webget
# if ident_agent is void, there will be no check.
ident_agent=
# https is highly recommended for security.
ident_protocol=https
# password must be a word composed of alpha-numeric characters.
# This identification is disabled by the * in the password definition.
ident_password=secret
# type of remote platform.
# available types: wims.
ident_type=wims
# The address and identifier/password pair for calling back.
back_url=https://localhost/wims/wims.cgi
back_ident=myself
back_password=***
# allowed or disabled requests. At most one of the two should be active.
# ident_allow=
# ident_deny=deluser delclass
EOF
}
manage_config(){
# fixes the permissions of the configuration files and sets a random
# password shared between Wims and Moodle
pass=$(pwgen -1)
###### Moodle side
f=/etc/moodle/wimsconf.php
echo '<? // this file was generated by wims-moodle package postinst script' > $f
echo '$CFG->passwims='$pass';' >> $f
echo '$CFG->wimsRemoteUrl="'$remoteurl'";' >> $f;
echo '?>' >> $f
chown www-data:www-data $f $f.dpkg-dist
chmod 440 $f $f.dpkg-dist
###### Wims side
[ -f $localwims_path ] || create_localwims;
sed -e 's/ident_password=.*/ident_password='$pass'/' $localwims_path \
> $localwims_path.tmp && \
mv $localwims_path.tmp $localwims_path
}
case "$1" in
configure)
manage_config
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
exit 0
|