p/fuel: ci/deploy.sh: Fix deploy without sudo
[armband.git] / ci / deploy.sh
1 #!/bin/bash
2 #
3 # (c) 2016 Enea Software AB
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 set -e
11
12 SCRIPT_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]}))
13
14 export ARMBAND_BASE=$(readlink -e ${SCRIPT_DIR}/..)
15
16 cd ${WORKSPACE:-${ARMBAND_BASE}}
17 make patches-import
18
19 # source local environment variables
20 if ! [ -z $LAB_CONFIG_URL ]; then
21     while getopts "l:p:" OPTION 2>/dev/null
22     do
23         case $OPTION in
24             l) TARGET_LAB=$OPTARG;;
25             p) TARGET_POD=$OPTARG;;
26         esac
27     done
28     local_env=${LAB_CONFIG_URL}/labs/${TARGET_LAB}/${TARGET_POD}/fuel/config/local_env
29     # try to fetch this file, but don't create it if it does not exist.
30     # We add "|| true" to ignore the curl error when the file does not exist
31     echo "curl -s -f -O $local_env || true"
32     curl -s -f -O $local_env || true
33     local_env=$(basename $local_env)
34     if [ -e $local_env ]; then
35         echo "-- Sourcing local environment file"
36         source $local_env
37     fi
38 fi
39
40 unset SSH_KEY
41 cd upstream/fuel/ci
42 ./deploy.sh $@