All pastes #520279 Raw Edit

Unnamed

public text v1 · immutable
#520279 ·published 2007-05-29 21:51 UTC
rendered paste body

# First reconfigure try:
motin@laptop:~$ LANG=C sudo dpkg-reconfigure boxbackup-server
User bbstored already exists.
[: 204: -z: unexpected operator

# I obviously need to remove user first:
motin@laptop:~$ sudo deluser bbstored
Tar bort användaren "bbstored" ...
Klar.

# Second try
motin@laptop:~$ LANG=C sudo dpkg-reconfigure boxbackup-server
Creating bbstored user.
Adding system user `bbstored' (UID 119) ...
Adding new group `bbstored' (GID 127) ...
Adding new user `bbstored' (UID 119) with group `bbstored' ...
Not creating home directory `/var'.
[: 204: -z: unexpected operator

# Here I believe there is supposed to be more configuration taking place since I answered questions about more than about user additions...

# The script:

#!/bin/bash -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 medium 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
	if [ -x /sbin/tune2fs ]; then
	    BS=`/sbin/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 medium 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