-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathdeploy-samples.sh
executable file
·121 lines (96 loc) · 3.61 KB
/
deploy-samples.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Deploys sample to LightSail II
#
# rsync-destination must be defined in a .rsync-file for each sample
# -----------------------------------------------------------------------------
# Vars die in .bashrc gesetzt werden. ~ (DEV_DOCKER, DEV_SEC, DEV_LOCAL) ~~~~~~
# [] müssen entfernt werden (IJ Bug https://goo.gl/WJQGMa)
if [ -z ${DEV_DOCKER+set} ]; then echo "Var 'DEV_DOCKER' nicht gesetzt!"; exit 1; fi
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Abbruch bei Problemen (https://goo.gl/hEEJCj)
#
# Wenn ein Fehler nicht automatisch zu einem exit führen soll dann
# kann 'command || true' verwendet werden
#
# Für die $1, $2 Abfragen kann 'CMDLINE=${1:-}' verwendet werden
#
# -e Any subsequent(*) commands which fail will cause the shell script to exit immediately
# -o pipefail sets the exit code of a pipeline to that of the rightmost command
# -u treat unset variables as an error and exit
# -x print each command before executing it
set -eou pipefail
APPNAME="`basename $0`"
SCRIPT=`realpath $0`
SCRIPTPATH=`dirname ${SCRIPT}`
#------------------------------------------------------------------------------
# Einbinden der globalen Build-Lib
# Hier sind z.B. Farben, generell globale VARs und Funktionen definiert
#
GLOBAL_DIR="${DEV_DOCKER}/_global"
LIB_DIR="${GLOBAL_DIR}/lib"
SAMPLES_LIB="samples.lib.sh"
if [[ ! -f "${LIB_DIR}/${SAMPLES_LIB}" ]]
then
echo "Samples-lib ${LIB_DIR}/${SAMPLES_LIB} existiert nicht!"
exit 1
fi
. "${LIB_DIR}/${SAMPLES_LIB}"
#------------------------------------------------------------------------------
# BASIS
#------------------------------------------------------------------------------
# Functions
#
#------------------------------------------------------------------------------
# Options
#
#------------------------------------------------------------------------------
# Options
#
usage() {
echo
echo "Usage: ${APPNAME} [ options ]"
echo -e "\t-l | --list [example_name] Lists all examples from '${YELLOW}${EXAMPLE_FOLDER}'${NC}-folder"
echo -e "\t-d | --deploy [example_name] Creates 'deploy'-dir for Dart"
echo -e "\t-p | --publish [example_name] [--force] Publish samples to AWS/S3 (only on day ${PUBLISH_ONLY_ON_DAY})"
echo -e "\t use --force to ignore Monday as publishing day"
}
CMDLINE=${1:-}
OPTION1=${2:-}
OPTION2=${3:-}
case "${CMDLINE}" in
-l|list|-list|--list)
if [ -n "${OPTION1+set}" -a "${OPTION1}" != "" ]; then
listSamples "${EXAMPLE_FOLDER}/${OPTION1}"
else
listSamples "${EXAMPLES[@]}"
fi
;;
-d|deploy|-deploy|--deploy)
if [ -n "${OPTION1+set}" -a "${OPTION1}" != "" ]; then
deploySamples "${EXAMPLE_FOLDER}/${OPTION1}"
else
deploySamples "${EXAMPLES[@]}"
fi
;;
-p|publish|-publish|--publish)
if [ -n "${OPTION1+set}" -a "${OPTION1}" != "--force" ]; then
publishSamples "${EXAMPLE_FOLDER}/${OPTION1}"
else
publishSamples "${EXAMPLES[@]}"
fi
;;
-g|generate|-generate|--generate)
if [ -n "${OPTION1+set}" -a "${OPTION1}" != "--force" -a "${OPTION1}" != "" ]; then
generateRsyncSetting "${EXAMPLE_FOLDER}/${OPTION1}"
else
generateRsyncSetting "${EXAMPLES[@]}"
fi
;;
-h|-help|--help|*)
usage
;;
esac
#------------------------------------------------------------------------------
# Alles OK...
exit 0