This file is indexed.

config is in backup-manager 0.7.10.1-2.

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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
#!/bin/bash
set -e

. /usr/share/debconf/confmodule

# enable back-tracking
db_capb backup || true

# Set values from the configuration file.

CONFIGFILE=/etc/backup-manager.conf
CONFIG_OK="false"
if [ -f $CONFIGFILE ] && [ -r $CONFIGFILE ]; then
    set +e
    . $CONFIGFILE
    if [ $? -eq 0 ]; then
        CONFIG_OK="true"
    fi
    set -e
fi

# Ensure unset variables will not be considered if sourcing errors occure
# (the values stored in the debconf database will be used as a fallback).
# NOTE:
# To guarantee correctness, declare *after* sourcing the configuration file.

db_safeset()	# $1=debconf key, $2=value
{
    if [ "$CONFIG_OK" = "false" ] && [ "X$2" = "X" ]; then
        return
    fi
    db_set $1 "$2"
}

# Preceed values

db_safeset backup-manager/backup-repository "$BM_REPOSITORY_ROOT"

db_safeset backup-manager/repo_user     "$BM_REPOSITORY_USER"
db_safeset backup-manager/repo_group    "$BM_REPOSITORY_GROUP"
db_safeset backup-manager/filetype      "$BM_TARBALL_FILETYPE"
db_safeset backup-manager/dump_symlinks "$BM_TARBALL_DUMPSYMLINKS"
db_safeset backup-manager/name-format   "$BM_TARBALL_NAMEFORMAT"
db_safeset backup-manager/time-to-live  "$BM_ARCHIVE_TTL"
db_safeset backup-manager/directories   "$BM_TARBALL_DIRECTORIES"
db_safeset backup-manager/blacklist     "$BM_TARBALL_BLACKLIST"

# no debconf template for this one
if [ "$BM_ENCRYPTION_METHOD" == "gpg" ]; then
    db_set backup-manager/enable_encryption "true"
else
    db_set backup-manager/enable_encryption "false"
fi
db_safeset backup-manager/encryption_recipient "$BM_ENCRYPTION_RECIPIENT"

db_safeset backup-manager/transfert_mode "$BM_UPLOAD_METHOD"
db_get backup-manager/transfert_mode
if [ -z "$RET" ] || [ "$RET" = "none" ]; then
    db_set backup-manager/want_to_upload "false"
else
    db_set backup-manager/want_to_upload "true"
fi

db_safeset backup-manager/upload-hosts    "$BM_UPLOAD_HOSTS"
db_safeset backup-manager/upload-user-ftp "$BM_UPLOAD_FTP_USER"
db_safeset backup-manager/upload-passwd   "$BM_UPLOAD_FTP_PASSWORD"
db_safeset backup-manager/upload-user-scp "$BM_UPLOAD_SSH_USER"
db_safeset backup-manager/upload-key      "$BM_UPLOAD_SSH_KEY"
db_safeset backup-manager/upload-dir      "$BM_UPLOAD_DESTINATION"

db_safeset backup-manager/burning-method  "$BM_BURNING_METHOD"
db_get backup-manager/burning-method
if [ -z "$RET" ] || [ "$RET" = "none" ]; then
    db_set backup-manager/burning-enabled "false"
else
    db_set backup-manager/burning-enabled "true"
fi
db_safeset backup-manager/burning-device  "$BM_BURNING_DEVICE"
db_safeset backup-manager/burning-maxsize "$BM_BURNING_MAXSIZE"

# Ask questions.

# State variables (with two we can tell the direction of a transition).
SRC_STATE=0
DST_STATE=1

# Flag to signal that blacklist processing has been performed.
BL_DONE="false"

# Variables to store the old debconf value, before setting a new one.
# We need to initialize them before the loop, since the BL_DONE flag
# is not set.

db_get backup-manager/backup-repository
PREV_REPO="$RET"

# Since debconf frontends do not yet honor {begin/end}block commands,
# we are stuck with one input per state if we want going forth and back
# between questions to behave intuitively.

while true; do
    case $DST_STATE in
    1)
        # While the flag is not set (ie the user goes back and forth
        # without entering blacklist block), do not update PREV_REPO.

        if [ BL_DONE = "true" ]; then
            db_get backup-manager/backup-repository
            PREV_REPO=$(echo "$RET" | sed 's:\(.\)\(/\+\)$:\1:')
            # Unset the flag after putting a new value to PREV_REPO
            BL_DONE="false"
        fi
        db_input high backup-manager/backup-repository || true
        ;;
    2)
        db_input medium backup-manager/repo_user || true
        ;;
    3)
        db_input medium backup-manager/repo_group || true
        ;;
    4)
        db_input low backup-manager/filetype || true
        ;;
    5)
        db_get backup-manager/filetype
        # Only the tar / dar commands can dereference symlinks.
        if [ "$RET" != "zip" ]; then
            db_input low backup-manager/dump_symlinks || true
        else
            db_set backup-manager/dump_symlinks "false"
        fi
        ;;
    6)
        db_input low backup-manager/name-format || true
        ;;
    7)
        db_input medium backup-manager/time-to-live || true
        ;;
    8)
        db_input high backup-manager/directories || true
        ;;
    9)
        # Substitute in blacklist only if we are moving forward.
        # In order to forgivingly consider all the possible path variants
        # (such as dir/ , dir// , patha//pathb , etc.) we canonicalize
        # before comparing and replacing.

        if [ $SRC_STATE -lt $DST_STATE ]; then

            db_get backup-manager/blacklist
            NEW_BLACKLIST="$RET"

            # Update both the base repository root and its subdirectories.

            db_get backup-manager/backup-repository
            NEW_REPO=$(echo "$RET" | sed 's:\(.\)\(/\+\)$:\1:')

            if [ "$NEW_REPO" != "$PREV_REPO" ]; then

                NEW_BLACKLIST=$(echo "$NEW_BLACKLIST" | sed \
                  -e "s:^\($PREV_REPO\)\(/*\|\s\+\):$NEW_REPO\2:" \
                  -e "s:\(\s\+\)\($PREV_REPO\)\(/*\|\s\+\):\1$NEW_REPO\3:g" \
                  -e "s:\(\s\+\)\($PREV_REPO\)\(/*\)$:\1$NEW_REPO:" \
                  -e "s:^\($PREV_REPO\)\(/*\)$:$NEW_REPO:" )

                PREV_REPO="$NEW_REPO"
            fi

            # Remove any entry contained in directories, either verbatim or
            # with a trailing / or a /* wildcard. But do not remove either
            # subdirectories, or more limited wildcards, or relative paths,
            # or the backup repository.

            db_get backup-manager/directories
            for entry in $(echo "$RET" \
              | tr ' ' '\n' | grep '^/' | sed 's:\(.\)\(/\+\)$:\1:' \
              ); do
                if [ "$entry" = "$NEW_REPO" ]; then
                    continue
                fi
                full_entry="$entry\(/*\(\*\)\?\)\?"
                NEW_BLACKLIST=$(echo "$NEW_BLACKLIST" | sed \
                  -e "s:^\($full_entry\)\(\s\+\)::" \
                  -e "s:\(\s\+\)\($full_entry\)\(\s\+\): :g" \
                  -e "s:\(\s\+\)\($full_entry\\)$::" \
                  -e "s:^\($full_entry\)$::" )
            done

            # Now, check if repository is in the blacklist; if not
            # add it (recursive backups are never a good idea).

            if echo "$NEW_BLACKLIST" | tr ' ' '\n' \
              | grep --quiet "^$NEW_REPO\(/*\)\?$" 2>/dev/null ; then
                :
            elif [ $(echo "$NEW_BLACKLIST" | sed 's:\s*::g' \
              | tr -d '\n' | wc --chars) -eq 0 ]; then
                NEW_BLACKLIST="$NEW_REPO"
            else
                NEW_BLACKLIST="$NEW_BLACKLIST $NEW_REPO"
            fi

            # Store blacklist and set the done flag here.

            db_set backup-manager/blacklist "$NEW_BLACKLIST"
            BL_DONE="true"
        fi

        db_input medium backup-manager/blacklist || true
        ;;
    10)
        # Manage deprecated /etc/cron.d/backup-manager (<= 0.7.8 versions).

        if [ -f /etc/cron.d/backup-manager ]; then
            db_input high backup-manager/cron_d_remove_deprecated || true
        fi
        ;;
    11)
        # Look where the cronscript is.

        BOGUS="sentinel"
        for freq in daily weekly monthly $BOGUS; do
            if [ -f /etc/cron.$freq/backup-manager ]; then
                db_set backup-manager/cron_frequency "$freq"
                break
            fi
        done
        if [ "$freq" = "$BOGUS" ] && [ -n "$2" ]; then
            # They don't have one; if upgrading, then they don't want it.
            db_set backup-manager/cron_frequency "none"
        fi
        db_input medium backup-manager/cron_frequency || true
        ;;

        # Now, we have the extra-features

        # Encryption?
    12)
        db_input medium backup-manager/enable_encryption || true
        ;;
    13)
        db_get backup-manager/enable_encryption
        if [ "$RET" = "true" ]; then
            db_input medium backup-manager/encryption_recipient || true
        fi
        ;;

        # Uploading system.
    14)
        db_input low backup-manager/want_to_upload || true
        ;;
    15)
        db_get backup-manager/want_to_upload
        if [ "$RET" = "true" ]; then
            db_input low backup-manager/transfert_mode || true
        fi
        ;;

        # Group alternative paths to a set of states.
    16|17)
        db_get backup-manager/want_to_upload
        if [ "$RET" = "true" ]; then
            db_get backup-manager/transfert_mode
            case "$RET" in
            ftp)
                case $DST_STATE in
                16)  db_input low backup-manager/upload-user-ftp || true ;;
                17)  db_input low backup-manager/upload-passwd || true ;;
                esac
                ;;
            scp)
                case $DST_STATE in
                16)  db_input low backup-manager/upload-user-scp || true ;;
                17)  db_input low backup-manager/upload-key || true ;;
                esac
                ;;
            *)
                ;;
            esac
        fi
        ;;

    18|19)
        db_get backup-manager/want_to_upload
        if [ "$RET" = "true" ]; then
            case $DST_STATE in
            18)  db_input low backup-manager/upload-hosts || true ;;
            19)  db_input low backup-manager/upload-dir || true ;;
            esac
        fi
        ;;

        # Optical disks burning?
    20)
        db_input low backup-manager/burning-enabled || true
        ;;

    21|22|23)
        db_get backup-manager/burning-enabled
        if [ "$RET" = "true" ]; then
            case $DST_STATE in
            21)  db_input low backup-manager/burning-device || true ;;
            22)  db_input low backup-manager/burning-method || true ;;
            23)  db_input low backup-manager/burning-maxsize || true ;;
            esac
        fi
        ;;

        # Final state; leave the state machine.
    *)
        break
        ;;
    esac

    # Advance the state machine.

    SRC_STATE=$DST_STATE
    if db_go; then
        DST_STATE=$(($DST_STATE + 1))
    else
        DST_STATE=$(($DST_STATE - 1))
    fi
    if [ $DST_STATE -le 0 ]; then
        # The user requested to back up from the first question;
        # leave package unconfigured.
        exit 10
    fi
done