source: debian/postinst @ 136

Revision 136, 2.4 KB checked in by anarcat, 9 years ago (diff)

[project @ alternc: changeset 2003-08-14 00:09:53 by root]
on laisse la description en francais :)

Original author: root
Date: 2003-08-14 00:09:53

Line 
1#!/bin/sh
2
3case "$1" in
4    configure)
5
6    # Prepare the sasldb for postfix :
7    touch /etc/sasldb
8    chgrp 33 /etc/sasldb
9    chmod g+w /etc/sasldb
10
11    # Source debconf library.
12    . /usr/share/debconf/confmodule
13    db_version 2.0
14    db_title AlternC
15    db_input medium alternc/welcomeconfirm
16    db_go
17
18    # Check the answer.
19    db_get  alternc/welcomeconfirm
20    if [ "$RET" = "false" ]; then
21        exit -1
22    fi
23
24    db_fset alternc/info seen false
25    db_input medium alternc/info
26    db_go
27
28    # Now configure the default values for the config file :
29    # only if needed (config file with "exit" on line 1)
30    if [ "`head -1 /etc/alternc/alternc.conf`" = "exit" ]
31    then
32   
33        # myip
34        # Return the ip of the first found interface on the computer
35        myip=`cat /etc/network/interfaces |grep address |grep -v "#" |head -1|sed -e 's/^.*address[^0-9\.]*\([0-9\.]*\)/\1/' `
36        # fqdn
37        # Return the complete dns name of the computer
38        fqdn=`cat /etc/mailname`
39        mx=`cat /etc/mailname`
40       
41        # DATA_PART
42        # Return the disk partition where /var/alternc is mounted
43        DATA_PART=`mount |grep 'on /var/alternc '|sed -e 's/^\([^ ]*\).*$/\1/' `
44        if [ -z "$DATA_PART" ]
45            then
46            DATA_PART=`mount |grep 'on /var '|sed -e 's/^\([^ ]*\).*$/\1/' `
47        fi
48        if [ -z "$DATA_PART" ]
49            then
50            DATA_PART=`mount |grep 'on / '|sed -e 's/^\([^ ]*\).*$/\1/' `
51        fi
52       
53        DATA_PART=`echo "$DATA_PART" | sed -e 's/\//\\\\\//g'`
54        # Generate random passwords
55        dbpwd=`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..10)' `
56        myrandom=`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..10)' `
57        ldap_userpwd=`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..10)' `
58        ldap_rootpwd=`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..10)' `
59       
60        # Now substitute it on the conf file ;)
61        cat /etc/alternc/alternc.conf | sed -e "s/^myip=.*/myip=$myip/" | sed -e "s/^fqdn=.*/fqdn=$fqdn/" | sed -e "s/^mx=.*/mx=$mx/" | sed -e "s/^DATA_PART=.*/DATA_PART=$DATA_PART/" | sed -e "s/^dbpwd=.*/dbpwd=$dbpwd/" | sed -e "s/^myrandom=.*/myrandom=$myrandom/" | sed -e "s/^ldap_userpwd=.*/ldap_userpwd=$ldap_userpwd/" | sed -e "s/^ldap_rootpwd=.*/ldap_rootpwd=$ldap_rootpwd/" >/etc/alternc/alternc.conf.new
62        rm /etc/alternc/alternc.conf
63        mv /etc/alternc/alternc.conf.new /etc/alternc/alternc.conf
64    fi
65
66
67esac
68
69# dh_installdeb will replace this with shell code automatically
70# generated by other debhelper scripts.
71
72#DEBHELPER#
73
74exit 0
75
76
77
78
Note: See TracBrowser for help on using the repository browser.