GitLab - Clients¶
Settings required¶
- Configure the client machine settings : Settings
Table of contents
Configure GitLab system clients¶
- Configure the system hosts and certificates (as administrator) :
Task sources: clients:system
#!/usr/bin/env bash
# Mise
#MISE description="Configure the client system hosts and trusted GitLab certificates (as administrator)"
# Configurations
set -e -o pipefail
# Sources
# shellcheck source=lib/common.sh
source "${MISE_PROJECT_ROOT:?}/lib/common.sh"
# Prepare settings
settings_require
sudo -v
# Install dependencies
if ! type certutil >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y libnss3-tools
fi
# Configure system hosts
step "Configure GitLab hosts in '${SYSROOT}/etc/hosts'"
system_block "${SYSROOT}/etc/hosts" 'DNS' "\
${DOMAIN_IP:?} ${DOMAIN_GITLAB:?}
${DOMAIN_IP:?} ${DOMAIN_PAGES:?}
${DOMAIN_IP:?} projects.${DOMAIN_PAGES:?}
${DOMAIN_IP:?} ${DOMAIN_REGISTRY:?}"
# Acquire certificates
certificates="${SYSROOT}/usr/local/share/ca-certificates"
if [ -e "${certificates}" ]; then
for server in "${DOMAIN_GITLAB:?}:${PORT_GITLAB:?}" "${DOMAIN_PAGES:?}:${PORT_PAGES:?}" "${DOMAIN_REGISTRY:?}:${PORT_REGISTRY:?}"; do
domain="${server%:*}"
step "Acquire certificate from ${server}"
sudo rm -fv "${SYSROOT}/etc/ssl/certs/${domain:?}.crt"
certificate_acquire "${server}" "${domain}" | sudo tee "${certificates}/${domain}.crt" >/dev/null
test -s "${certificates}/${domain}.crt" || fail "Empty certificate from ${server}"
done
fi
# Refresh CA certificates
if sudo which update-ca-certificates >/dev/null 2>&1; then
sudo update-ca-certificates --fresh | grep -v '^Replacing\|Mono' || true
fi
# Test GitLab certificate
step "Test https://${DOMAIN_GITLAB:?}:${PORT_GITLAB:?}"
curl -sS -o /dev/null -w ' HTTP status: %{http_code}\n' "https://${DOMAIN_GITLAB:?}:${PORT_GITLAB:?}"
# Restart Docker service
if systemctl cat docker.service >/dev/null 2>&1; then
confirm 'Restart the Docker service ?'
sudo systemctl restart docker
fi
Configure GitLab user clients¶
- Configure the user certificates of Chrome and Firefox (as user) :
Task sources: clients:user
#!/usr/bin/env bash
# Mise
#MISE description="Trust the GitLab certificates in the user browsers (Chrome NSS and Firefox, as user)"
# Configurations
set -e -o pipefail
# Sources
# shellcheck source=lib/common.sh
source "${MISE_PROJECT_ROOT:?}/lib/common.sh"
# Prepare settings
settings_require
certificates="${SYSROOT}/usr/local/share/ca-certificates"
# Import certificates in a NSS database
nss_import() {
local database="${1:?}"
local trust="${2:?}"
local certificate_file certificate_name
for certificate_file in "${certificates}"/*.crt; do
[ -e "${certificate_file}" ] || continue
certificate_name="${certificate_file##*/}"
certificate_name="${certificate_name%.crt}"
certutil -d "${database}" -D -n "${certificate_name}" 2>/dev/null | grep -v '^Notice:' || true
certutil -d "${database}" -A -t "${trust}" -n "${certificate_name}" -i "${certificate_file}" | grep -v '^Notice:' || true
done
}
# Refresh user certificates
if [ -e "${HOME}/.pki/nssdb" ]; then
step 'Refresh user NSS certificates'
nss_import "sql:${HOME}/.pki/nssdb" 'CP,CP,'
fi
# Refresh Firefox certificates
while IFS= read -r profile_db; do
step "Refresh Firefox certificates of '$(dirname "${profile_db}")'"
nss_import "$(dirname "${profile_db}")" 'TCu,Cuw,Tuw'
done < <(find ~/.mozilla/ -name 'cert*.db' 2>/dev/null || true)
# Test browsers
for browser in firefox google-chrome; do
if type "${browser}" >/dev/null 2>&1 && interactive; then
"${browser}" "https://${DOMAIN_GITLAB:?}:${PORT_GITLAB:?}" >/dev/null 2>&1 &
sleep 1
fi
done