-
Notifications
You must be signed in to change notification settings - Fork 4
/
start-registry.sh
executable file
·50 lines (44 loc) · 1.26 KB
/
start-registry.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
#!/usr/bin/env bash
log_lvl_info() {
NOW=$(date +"%Y/%m/%d %H:%M:%S")
echo "${NOW} [info] ${1}"
}
log_lvl_error() {
NOW=$(date +"%Y/%m/%d %H:%M:%S")
echo "${NOW} [error] ${1}"
}
checkauth() {
log_lvl_info "Checking authentication configuration..."
if [[ ! -d conf/auth ]]; then
createuser
else
if [[ ! -f conf/auth/htpasswd ]]; then
createuser
fi
fi
log_lvl_info "Completed"
}
createuser() {
echo "Please enter credentials for your registry login"
mkdir -p conf/auth
echo "Username"
read username
echo -n "Password":
read -s password
docker run --rm --entrypoint htpasswd registry:2 -Bbn ${username} ${password} > conf/auth/htpasswd
log_lvl_info "Authentication configuration completed."
}
###########################
# MAIN
###########################
#check if a domain name is passed to the function
if [[ -z "$1" ]]; then
log_lvl_error "Please specify a domain name (e.g. example.com) as first parameter. \n
The second paramter should be the email address as second parameter.\n
For example: ${0} example.com [email protected]"
exit
fi
export DOCKER_REGISTRY_DOMAIN_NAME=$1
export DOCKER_REGISTRY_CERT_EMAIL_ADDRESS=$2
checkauth
docker-compose up -d