-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpacman.sh
executable file
·107 lines (91 loc) · 2.05 KB
/
pacman.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
#!/bin/bash
set -e
BASEDIR="`dirname $0`"
LIBDIR="$BASEDIR/lib"
function loadScript() {
scriptPath="$LIBDIR/$1.sh"
if [ ! -f $scriptPath ]; then
echo "** Failed to load: $scriptPath"
else
source $scriptPath
fi;
}
function print_usage() {
printf "Usage: $0 [arguments]\n"
printf "\n"
printf "Arguments:\n"
printf "\t configure\n"
printf "\t configure-from-env\n"
printf "\t setup-gradle\n"
printf "\t setup-maven\n"
printf "\t setup-pip\n"
printf "\t clean\n"
printf "\n"
printf "Environment variables:\n"
printf "\t GATEWAY_URL: The base URL of the security gateway without trailing /\n"
printf "\t GATEWAY_USERNAME: Username to authenticate with gateway\n"
printf "\t GATEWAY_PASSWORD: Password to authenticate with gateway\n"
printf "\n"
}
function validateRunningEnv() {
if [ -z "$GATEWAY_URL" ]; then
error_msg "Gateway URL is missing"
exit -1
fi;
if [ -z "$GATEWAY_USERNAME" ]; then
error_msg "Gateway Username is missing"
exit -1
fi;
if [ -z "$GATEWAY_PASSWORD" ]; then
error_msg "Gateway Password is missing"
exit -1
fi;
}
function applyOverrides() {
if [ "$GATEWAY_USERNAME" != "" ] && [ "$GATEWAY_PROJECT_ID" != "" ]; then
print_msg "Applying projectId:$GATEWAY_PROJECT_ID in username"
export GATEWAY_USERNAME="$GATEWAY_PROJECT_ID/$GATEWAY_USERNAME"
fi
}
function configurePm() {
scriptName=$1
validateRunningEnv
applyOverrides
loadScript $scriptName
}
function main() {
loadScript "utils"
loadScript "conventions"
loadScript "configuration"
command=$1
if [ -z "$command" ]; then
print_usage
exit -1
fi;
loadConfigurationIfPresent
case $command in
configure-from-env)
configureFromEnv
;;
configure)
interactiveConfiguration
;;
setup-gradle)
configurePm "gradle"
;;
setup-maven)
configurePm "maven"
;;
setup-pip)
configurePm "pip"
;;
clean)
loadScript "clean"
;;
*)
error_msg "Unknown command: $command"
;;
esac
applyConfigSecurity
}
main $@