Commit 52dac8a5 authored by Vesa Vertainen's avatar Vesa Vertainen

updated resolving docker user

parent 867e2a71
Pipeline #83132538 failed with stage
in 1 minute and 19 seconds
......@@ -40,35 +40,33 @@ echo "* Private registry setup *"
echo ""
# FUNCTIONS
# Functions
# Get/ask for Docker username (because root is not necessarily the Docker user), cincan credentials, and login to registry
function getCredentials() {
# Get docker user's name
DOCKER_USERNAME=$(cat /etc/group |grep docker | awk '{print $1 }' RS=":" |tail -1)
if [ ! $? -eq 0 ]; then
echo -e "Type in your DOCKER username if not root [root]:"
read -r DOCKER_USERNAME
if [ "$DOCKER_USERNAME" = "" ]; then DOCKER_USERNAME="root";fi
# Get docker user's name from /etc/group (tries the last user mentioned in docker group)
if [ ! "$DOCKER_USERNAME" ]; then
DOCKER_USERNAME=$(cat /etc/group |grep docker: |tail -1 | awk -F "," '{print $NF }' |awk -F ":" '{print $NF }')
fi
echo "Login to private registry:"
sudo su "$DOCKER_USERNAME" -c "docker login 172.20.0.6:5000" || { echo "Login failed"; exit 1; }
sudo su "$DOCKER_USERNAME" -c "docker login 172.20.0.6:5000" || { echo "Could not resolve docker user."; \
echo "Type in your username in docker group (q to quit): "; read -r DOCKER_USERNAME; \
if [ "$DOCKER_USERNAME -eq 'q'" ];then exit 0;else getCredentials; fi }
}
# Clone tools repository (or update if exists)
function cloneRepo() {
echo -e "$CHECK Cloning the tools repository"
if [ ! -d "tools" ];then
git clone https://gitlab.com/CinCan/tools.git
cd tools || exit
else
cd tools || exit
git pull
fi
echo -e "$CHECK Cloning the tools repository"
if [ ! -d "tools" ];then
git clone https://gitlab.com/CinCan/tools.git
cd tools || exit
else
cd tools || exit
git pull
fi
}
......@@ -104,8 +102,7 @@ function createMenuOptions() {
function selectImages() {
TOOLS_TO_INSTALL=$(whiptail --title "Cincan private registry setup" --checklist --fb --backtitle \
" CinCan - Continuous Integration for the Collaborative Analysis of Incidents " \
"Choose the images to install. Make sure you have the private registry \
set up, and that you are logged in. There are $TOOLS_COUNT images available." \
"There are $TOOLS_COUNT images available. Choose the images to install:" \
30 80 20 $OPTIONS 3>&1 1>&2 2>&3)
if [ ! "$TOOLS_TO_INSTALL" ]; then echo "Cancelled"; exit; fi
......@@ -122,7 +119,7 @@ function installationMethod() {
15 60 4 \
"1" "Build images from dockerfiles" \
"2" "Download images from hub.docker.com" \
"3" "<-- RETURN TO IMAGE SELECTION MENU" 3>&1 1>&2 2>&3)
"3" " RETURN TO IMAGE SELECTION MENU" 3>&1 1>&2 2>&3)
case "$INSTALLATION_METHOD" in
"")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment