setup-basic.sh 1.37 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#!/bin/sh

##
## Initialize some basic useful stuff.
##

set -x

DIRNAME=`dirname $0`

# Gotta know the rules!
if [ $EUID -ne 0 ] ; then
    echo "This script must be run as root" 1>&2
    exit 1
fi

# Grab our libs
. "$DIRNAME/setup-lib.sh"

if [ "$HOSTNAME" != "$CONTROLLER" ]; then
    exit 0;
fi

24 25
logtstart "basic"

26 27 28 29 30 31
if [ -f $SETTINGS ]; then
    . $SETTINGS
fi

. $OURDIR/admin-openrc.sh

32
#
33 34
# Fork off a bunch of parallelizable tasks, then do some misc stuff,
# then wait.
35
#
36 37 38 39 40 41 42 43 44
echo "*** Backgrounding quota setup..."
$DIRNAME/setup-basic-quotas.sh  >> $OURDIR/setup-basic-quotas.log 2>&1 &
quotaspid=$!
echo "*** Backgrounding network setup..."
$DIRNAME/setup-basic-networks.sh  >> $OURDIR/setup-basic-networks.log 2>&1 &
networkspid=$!
echo "*** Backgrounding user setup..."
$DIRNAME/setup-basic-users.sh  >> $OURDIR/setup-basic-users.log 2>&1 &
userspid=$!
45

46
. $DIRNAME/setup-images-lib.sh
47
$LOCKFILE $IMAGESETUPLOCKFILE
48 49 50 51 52
if [ -f $IMAGEUPLOADCMDFILE ]; then
    echo "*** Adding Images ..."
    . $OURDIR/admin-openrc.sh
    . $IMAGEUPLOADCMDFILE
fi
53
$RMLOCKFILE $IMAGESETUPLOCKFILE
54 55 56

ARCH=`uname -m`
if [ "$ARCH" = "aarch64" ] ; then
57
    echo "*** Doing aarch64-specific setup..."
58 59
    $DIRNAME/setup-basic-aarch64.sh
else
60
    echo "*** Doing x86_64-specific setup..."
61 62 63
    $DIRNAME/setup-basic-x86_64.sh
fi

64 65 66 67
for pid in "$quotaspid $networkspid $userspid" ; do
    wait $pid
done

68 69
logtend "basic"

70
exit 0