Line | |
---|
1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # Upload image to the 'distribution' server. First try WL network,
|
---|
4 | # else use inet as last resort. Need to have shell access to distribution server.
|
---|
5 | #
|
---|
6 | # XXX: Needs Type and such as well properly
|
---|
7 | #
|
---|
8 | # Rick van der Zwet <info@rickvanderzwet.nl>
|
---|
9 |
|
---|
10 | SERVERS="sunfire.wleiden.net sunfire.wirelessleiden.nl"
|
---|
11 | TIMESTAMP=`date "+%Y%m%d-%H%M"`
|
---|
12 | BASEDIR=`dirname $0`
|
---|
13 | SSH_USER=${SSH_USER:-$USER}
|
---|
14 | TYPE="$1"
|
---|
15 | RELEASE="$2"
|
---|
16 |
|
---|
17 | . $BASEDIR/package-build.inc.sh
|
---|
18 |
|
---|
19 | if [ -z "$RELEASE" ]; then
|
---|
20 | echo "Usage: $0 <full|image> <release_name>"
|
---|
21 | exit 1
|
---|
22 | fi
|
---|
23 |
|
---|
24 | # Make sure we find the right image
|
---|
25 | if [ "$TYPE" = "full" ]; then
|
---|
26 | find_disk_full ""
|
---|
27 | elif [ "$TYPE" = "image" ]; then
|
---|
28 | find_disk_image ""
|
---|
29 | else
|
---|
30 | echo "Usage: $0 <full|image> <release_name>"
|
---|
31 | exit 1
|
---|
32 | fi
|
---|
33 |
|
---|
34 | check_reachable() {
|
---|
35 | ping -c 2 -t 1 -q $1 1>/dev/null 2>/dev/null
|
---|
36 | return $?
|
---|
37 | }
|
---|
38 |
|
---|
39 | # XXX: Hack this should actually be done during building phase
|
---|
40 | echo "# Compressing image '$IMG'"
|
---|
41 | gzip -v -k -f $IMG
|
---|
42 | IMG="$IMG.gz"
|
---|
43 |
|
---|
44 | echo "# Trying to upload to server, alarm messages are normal"
|
---|
45 | # Upload the image to the defined place
|
---|
46 | for SERVER in $SERVERS; do
|
---|
47 | if check_reachable $SERVER; then
|
---|
48 | TARGET="$SSH_USER@$SERVER:/usr/local/www/images/$RELEASE/node-$TYPE-$TIMESTAMP.img.gz"
|
---|
49 | echo "# Source: $IMG"
|
---|
50 | echo "# Target: $TARGET"
|
---|
51 | echo "# To cancel, please CTRL+C within 3 seconds"
|
---|
52 | sleep 3
|
---|
53 | scp $IMG $TARGET
|
---|
54 | exit $?
|
---|
55 | fi
|
---|
56 | done
|
---|
57 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.