blob: f98ae9701036634e328e936b2e47ee9d28f65f0f (
plain)
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/bash -e
set -e
# Source debconf library
. /usr/share/debconf/confmodule
# This conf script is capable of backing up
#db_version 2.0
#db_capb backup
#db_metaget debconf/priority value
#CONFPRIO=$RET
# Handle with debconf or not?
db_input medium boxbackup-server/debconf || true
db_go
db_get boxbackup-server/debconf
if [ "$RET" = "false" ]; then
exit 0
fi
# RAID directories
db_get boxbackup-server/raidDirectories
OLDRAIDDIR=$RET
RAIDOK=0
while [ $RAIDOK = 0 ]; do
db_input critical boxbackup-server/raidDirectories || true
db_go
db_get boxbackup-server/raidDirectories
DIR1=`echo "$RET" | awk '{ print $1 }'`
DIR2=`echo "$RET" | awk '{ print $2 }'`
DIR3=`echo "$RET" | awk '{ print $3 }'`
if [ -n "$DIR1" ]; then
if [ -z "$DIR2" -o -z "$DIR3" ]; then
DIR2="$DIR1"
DIR3="$DIR1"
fi
PATHOK=1
for i in "$DIR1" "$DIR2" "$DIR3"; do
if [ `echo $i | awk '{ if (/^\/[A-Za-z0-9\.\-_]+\/?([A-Za-z0-9\.\-_]+\/?)*$/) { print 1 } else { print 0 } }'` = 0 ]; then
PATHOK=0
fi
done
if [ $PATHOK = 1 ]; then
RAIDOK=1;
fi
fi
if [ $RAIDOK = 0 ]; then
db_input critical boxbackup-server/incorrectDirectories || true
db_go
fi
done
# RAID block size
# Try to figure out the block size of the first partition given
db_get boxbackup-server/raidDirectories
if [ "$OLDRAIDDIR" != "$RET" ]; then # Directories have been changed so we can try to guess the block size
TMPDIR=`echo "$DIR1" | sed 's/\/$//'`
while [ "$TMPDIR" != "" ]; do
DEV=`df -P | grep "$TMPDIR$" | awk '{ print $1 }'`
if [ -z "$DEV" ]; then
TMPDIR=`echo "$TMPDIR" | sed 's/\/[^\/]*$//'`
else
TMPDIR=""
fi
done
if [ "$DEV" != "" ]; then
TUNE2FS="$(command -v tune2fs)"
if [ -x "${TUNE2FS}" ]; then
BS=`${TUNE2FS} -l $DEV 2>/dev/null | grep 'Block size' | awk '{print $3 }'`
if [ $? = 0 -a "$BS" != "" ]; then
db_set boxbackup-server/raidBlockSize "$BS"
fi
fi
fi
fi
BSOK=0
while [ $BSOK = 0 ]; do
db_input critical boxbackup-server/raidBlockSize || true
db_go
db_get boxbackup-server/raidBlockSize
if [ `echo $RET | awk '{ if (/^[0-9]+$/) { print 1 } else { print 0 } }'` = 1 ]; then
if [ `echo $RET | awk '{ bs=sqrt($1); if (bs ~ /^[0-9]+$/) { print 1 } else { print 0 } }'` = 1 ]; then
BSOK=1
fi
fi
if [ "$BSOK" = 0 ]; then
db_input critical boxbackup-server/incorrectBlocksize || true
db_go
fi
done
# x509 and private key
db_input medium boxbackup-server/generateCertificate || true
db_go
exit 0
|