update_server.sh 1.59 KB
Newer Older
1
2
3
4
5
6
#!/bin/bash
#
# FlockLab2 server update script.

USER="flocklab"
HOST="flocklab-dev-server"
Reto Da Forno's avatar
Reto Da Forno committed
7
RSYNCPARAMS="-a -z -c -K --exclude=.git"
8

9
10
11
12
if [ $# -gt 0 ]; then
    HOST=$1
fi

13
14
15
16
echo "Going to update files on FlockLab server $HOST..."
sleep 2   # give the user time to abort, just in case

# testmanagement server files
Reto Da Forno's avatar
Reto Da Forno committed
17
18
# optional to only look for changed files:  | grep '^<fc' | cut -d' ' -f2
RES=$(rsync ${RSYNCPARAMS} -i --dry-run -e 'ssh -q' testmanagementserver ${USER}@${HOST}:testmanagementserver)
19
20
21
22
if [ -z "$RES" ]; then
    echo "Testmanagement server files are up to date."
else
    printf "Updating testmanagement server files... "
Reto Da Forno's avatar
Reto Da Forno committed
23
    rsync ${RSYNCPARAMS} -e 'ssh -q' testmanagementserver ${USER}@${HOST}:
24
25
26
27
28
29
30
31
    if [ $? -ne 0 ]; then
        printf "Failed to copy files!\n"
        continue
    else
        printf "done.\n"
    fi
fi
# webserver files
Reto Da Forno's avatar
Reto Da Forno committed
32
RES=$(rsync ${RSYNCPARAMS} -i --dry-run -e 'ssh -q' webserver ${USER}@${HOST}:webserver)
33
34
35
36
if [ -z "$RES" ]; then
    echo "Webserver files are up to date."
else
    printf "Updating webserver files..."
Reto Da Forno's avatar
Reto Da Forno committed
37
    rsync ${RSYNCPARAMS} -e 'ssh -q' webserver ${USER}@${HOST}:
38
39
40
41
42
43
44
    if [ $? -ne 0 ]; then
        printf "failed to copy repository files!\n"
        continue
    else
        printf "done.\n"
    fi
fi
Reto Da Forno's avatar
Reto Da Forno committed
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# tools
RES=$(rsync ${RSYNCPARAMS} -i --dry-run -e 'ssh -q' tools ${USER}@${HOST}:tools)
if [ -z "$RES" ]; then
    echo "Tools are up to date."
else
    printf "Updating tools... "
    rsync ${RSYNCPARAMS} -e 'ssh -q' tools ${USER}@${HOST}:
    if [ $? -ne 0 ]; then
        printf "Failed to copy files!\n"
        continue
    else
        printf "done.\n"
    fi
fi