-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller.sh
executable file
·87 lines (79 loc) · 2.02 KB
/
installer.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
#!/bin/bash
declare -A APPS
usage()
{
echo ""
echo "Usage:"
echo " ./installer.sh --app <appname> [--branch <branchname>]"
echo ""
echo "Parameters:"
echo " -a | --app <appname> is the app to install"
echo " -b | --branch <branchname> is the app branch to clone (default is develop)"
echo " -h | --help this help"
echo ""
echo "Apps:"
for service in ${!APPS[@]}
do
printf " - %s\n" $service
done
echo ""
}
# we should rename these repositories!
APPS[fizzbuzzkata]="git@github.com-elplaza:elplaza/fizzbuzzkata.git"
APPS[my-first-ci-test]="git@github.com-elplaza:elplaza/my-first-ci-test.git"
APPS[mypsr]="git@github.com-elplaza:elplaza/mypsr.git"
APPS[localizer]="git@github.com-elplaza:elplaza/localizer.git"
APPS[phpcs]="git@github.com-elplaza:elplaza/PHP_CodeSniffer.git"
APPS[phpcs-configurator]="git@github.com-elplaza:elplaza/phpcs-configurator.git"
APPS[creationart]="git@github.com-elplaza:elplaza/creationart.git"
APPS[nodeapi]="git@github.com-elplaza:elplaza/nodeapi.git"
APPS[javascripting]="git@github.com-elplaza:elplaza/javascripting.git"
APPS[learnyounode]="git@github.com-elplaza:elplaza/learnyounode.git"
# Default Branch
BRANCH="master"
# App
while [[ "$#" > 0 ]]; do
case $1 in
-a | --app) shift
APP=$1
;;
-b | --branch) shift
BRANCH=$1
;;
-h | --help) usage
exit
;;
*) usage
exit 1
esac
shift
done
if [ -z "$APP" ]; then
echo ""
echo "[ERROR] App name is required!"
usage
exit
fi
if [[ ! " ${!APPS[@]} " =~ " ${APP} " ]]; then
echo ""
echo "[ERROR] App '$APP' is not supported!"
usage
exit
fi
APP_DIR="apps/$APP/"
mkdir -p $APP_DIR
echo ""
echo "Installing branch '$BRANCH' of app '$APP' in '$APP_DIR':"
if [ -z "$(ls -A $APP_DIR)" ]; then
echo "the folder '$APP_DIR' is empty"
git clone -b $BRANCH ${APPS[$APP]} $APP_DIR
else
echo "the folder '$APP_DIR' is not empty ..."
REPOSITORY_DIR="$APP_DIR/.git"
if [ -d $REPOSITORY_DIR ]; then
echo "... '$APP_DIR' is already a git repository"
else
echo "... '$APP_DIR' is not a git repository"
fi;
fi;
echo ""