monotone

monotone Mtn Source Tree

Root/monotone-server.config

1#! /bin/sh
2# vim: set ft=sh sw=4 et:
3# postinst script for monotone-server
4#
5# see: dh_installdeb(1)
6
7set -e
8
9# source debconf stuff
10. /usr/share/debconf/confmodule
11
12# we only want to change these values on the initial configuration
13
14gen_pass ()
15{
16 # this used to use $RANDOM, but dash doesn't have that
17 # also, the perl version is clearer
18
19 MATRIX="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
20 LENGTH="$1"
21 if [ -z "$LENGTH" ]; then
22 LENGTH=8
23 fi
24
25 PASS=`perl -e '
26 @matrix = split //, $ARGV[0];
27$length = $ARGV[1];
28print $matrix[int(rand($#matrix + 1))] for 1..$length;
29print "\n";
30 ' "$MATRIX" "$LENGTH"`
31}
32
33case "$1" in
34 configure)
35 # set the default monotone keyname
36 db_set monotone-server/key "monotone@`hostname --fqdn`"
37
38 db_input medium monotone-server/manage-db || true
39 db_go || true
40
41 # make sure we should manage things
42 db_get monotone-server/manage-db
43 if [ "$RET" = "true" ]; then
44
45 db_input low monotone-server/key || true
46 db_input low monotone-server/passphrase || true
47 db_go || true
48
49 # no passphrase was entered, generate one
50 # make sure this is the initial configuration
51 db_get monotone-server/passphrase
52 if [ -z "$RET" ] && [ -z "$2" ]; then
53 gen_pass
54 db_set monotone-server/passphrase "$PASS"
55 fi
56 fi
57 ;;
58 reconfigure)
59 db_input medium monotone-server/manage-db || true
60 db_go || true
61
62 # make sure we should manage things
63 db_get monotone-server/manage-db
64 if [ "$RET" = "true" ]; then
65 db_input low monotone-server/key || true
66 db_input low monotone-server/passphrase || true
67 db_go || true
68
69 # Now let's store the passphrase and key in a file. We only do
70 # this on reconfigure, postinst handles this in all other cases.
71 MTN_CONFDIR=/etc/monotone
72
73 db_get monotone-server/key
74 MTN_KEY="$RET"
75
76 db_get monotone-server/passphrase
77 MTN_KEY_PASSWD="$RET"
78
79 echo "$MTN_KEY \"$MTN_KEY_PASSWD\"" > $MTN_CONFDIR/passphrases
80 db_set monotone-server/passphrase ""
81 fi
82 ;;
83 *)
84 echo "config called with unknown argument \`$1'" >&2
85 exit 1
86 ;;
87esac
88

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status