-
Notifications
You must be signed in to change notification settings - Fork 17
/
init
executable file
·39 lines (34 loc) · 1021 Bytes
/
init
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
#!/bin/bash
if [ -z "$COOG_CODE_DIR" ] || [ ! -d "$COOG_CODE_DIR" ] || [ -z "$COOG_DATA_DIR" ]
then
{
echo "Please make sure that these two env vars are set:"
echo " COOG_CODE_DIR: your coog-admin install folder"
echo " COOG_DATA_DIR: the folder where to keep your custom config"
} >&2 && exit 1
fi
migrate() {
[ -z "$1" ] || config_data_migrate "$1"
}
main() {
source "$COOG_CODE_DIR/config.fn"
local v
if [ -d "$COOG_DATA_DIR" ]
then
[ -d "$COOG_DATA_DIR/.git" ] \
&& echo already initialized >&2 \
&& return 1
[ -z "$1" ] \
&& echo "missing coog version from which you are coming" >&2 \
&& return 1
v="$1"
else
[ ! -z "$1" ] && echo "skipping parameter: $1" >&2
mkdir "$COOG_DATA_DIR"
fi
( cd "$COOG_DATA_DIR" \
&& config_data_bootstrap \
&& ( [ -f "$COOG_DATA_DIR/config" ] || config_data_reset_base ) \
&& migrate "$v" )
}
main "$@"