Switch remaining containers over to new registries; Continued bash refactoring

This commit is contained in:
Jason Ertel
2020-11-16 15:11:08 -05:00
parent a343e3f31e
commit 8234b6f835
7 changed files with 26 additions and 25 deletions

View File

@@ -95,6 +95,7 @@ update_docker_containers() {
local CURLTYPE=$1 local CURLTYPE=$1
local IMAGE_TAG_SUFFIX=$2 local IMAGE_TAG_SUFFIX=$2
local PROGRESS_CALLBACK=$3 local PROGRESS_CALLBACK=$3
local LOG_FILE=$4
local CONTAINER_REGISTRY=quay.io local CONTAINER_REGISTRY=quay.io
local SIGNPATH=/root/sosigs local SIGNPATH=/root/sosigs
@@ -103,6 +104,10 @@ update_docker_containers() {
CURLTYPE=unknown CURLTYPE=unknown
fi fi
if [ -z "$LOG_FILE" ]; then
LOG_FILE=/dev/tty
fi
# Recheck the version for scenarios were the VERSION wasn't known before this script was imported # Recheck the version for scenarios were the VERSION wasn't known before this script was imported
set_version set_version
set_os set_os
@@ -114,26 +119,26 @@ update_docker_containers() {
# Let's make sure we have the public key # Let's make sure we have the public key
curl -sSL https://raw.githubusercontent.com/Security-Onion-Solutions/securityonion/master/KEYS | gpg --import - curl -sSL https://raw.githubusercontent.com/Security-Onion-Solutions/securityonion/master/KEYS | gpg --import -
rm -rf $SIGNPATH rm -rf $SIGNPATH >> "$LOG_FILE" 2>&1
mkdir -p $SIGNPATH mkdir -p $SIGNPATH >> "$LOG_FILE" 2>&1
# Download the containers from the interwebs # Download the containers from the interwebs
for i in "${TRUSTED_CONTAINERS[@]}" for i in "${TRUSTED_CONTAINERS[@]}"
do do
if [ -z "$PROGRESS_CALLBACK" ]; then if [ -z "$PROGRESS_CALLBACK" ]; then
echo "Downloading $i" echo "Downloading $i" >> "$LOG_FILE" 2>&1
else else
$PROGRESS_CALLBACK $i $PROGRESS_CALLBACK $i
fi fi
# Pull down the trusted docker image # Pull down the trusted docker image
local image=$i:$VERSION$IMAGE_TAG_SUFFIX local image=$i:$VERSION$IMAGE_TAG_SUFFIX
docker pull $CONTAINER_REGISTRY/$IMAGEREPO/$image docker pull $CONTAINER_REGISTRY/$IMAGEREPO/$image >> "$LOG_FILE" 2>&1
# Get signature # Get signature
curl -A "$CURLTYPE/$CURRENTVERSION/$OS/$(uname -r)" https://sigs.securityonion.net/$VERSION/$i:$VERSION$IMAGE_TAG_SUFFIX.sig --output $SIGNPATH/$image.sig curl -A "$CURLTYPE/$CURRENTVERSION/$OS/$(uname -r)" https://sigs.securityonion.net/$VERSION/$i:$VERSION$IMAGE_TAG_SUFFIX.sig --output $SIGNPATH/$image.sig >> "$LOG_FILE" 2>&1
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo "Unable to pull signature file for $image" echo "Unable to pull signature file for $image" >> "$LOG_FILE" 2>&1
exit 1 exit 1
fi fi
# Dump our hash values # Dump our hash values
@@ -143,7 +148,7 @@ update_docker_containers() {
echo "$DOCKERINSPECT" | jq ".[0].Created, .[0].RootFS.Layers" >> $SIGNPATH/$image.txt echo "$DOCKERINSPECT" | jq ".[0].Created, .[0].RootFS.Layers" >> $SIGNPATH/$image.txt
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo "Unable to inspect $image" echo "Unable to inspect $image" >> "$LOG_FILE" 2>&1
exit 1 exit 1
fi fi
GPGTEST=$(gpg --verify $SIGNPATH/$image.sig $SIGNPATH/$image.txt 2>&1) GPGTEST=$(gpg --verify $SIGNPATH/$image.sig $SIGNPATH/$image.txt 2>&1)
@@ -153,15 +158,14 @@ update_docker_containers() {
if [ -z "$HOSTNAME" ]; then if [ -z "$HOSTNAME" ]; then
HOSTNAME=$(hostname) HOSTNAME=$(hostname)
fi fi
docker tag $CONTAINER_REGISTRY/$IMAGEREPO/$image $HOSTNAME:5000/$IMAGEREPO/$image docker tag $CONTAINER_REGISTRY/$IMAGEREPO/$image $HOSTNAME:5000/$IMAGEREPO/$image >> "$LOG_FILE" 2>&1
docker push $HOSTNAME:5000/$IMAGEREPO/$image docker push $HOSTNAME:5000/$IMAGEREPO/$image >> "$LOG_FILE" 2>&1
fi fi
else else
echo "There is a problem downloading the $image image. Details: " echo "There is a problem downloading the $image image. Details: " >> "$LOG_FILE" 2>&1
echo "" echo "" >> "$LOG_FILE" 2>&1
echo $GPGTEST echo $GPGTEST >> "$LOG_FILE" 2>&1
exit 1 exit 1
fi fi
done done
} }

View File

@@ -43,13 +43,13 @@ dstatslogdir:
so-domainstatsimage: so-domainstatsimage:
cmd.run: cmd.run:
- name: docker pull --disable-content-trust=false docker.io/{{ IMAGEREPO }}/so-domainstats:HH1.0.3 - name: docker pull {{ MANAGER }}:5000/{{ IMAGEREPO }}/so-domainstats:{{ VERSION }}
so-domainstats: so-domainstats:
docker_container.running: docker_container.running:
- require: - require:
- so-domainstatsimage - so-domainstatsimage
- image: docker.io/{{ IMAGEREPO }}/so-domainstats:HH1.0.3 - image: {{ MANAGER }}:5000/{{ IMAGEREPO }}/so-domainstats:{{ VERSION }}
- hostname: domainstats - hostname: domainstats
- name: so-domainstats - name: so-domainstats
- user: domainstats - user: domainstats

View File

@@ -43,13 +43,13 @@ freqlogdir:
so-freqimage: so-freqimage:
cmd.run: cmd.run:
- name: docker pull --disable-content-trust=false docker.io/{{ IMAGEREPO }}/so-freqserver:HH1.0.3 - name: docker pull {{ MANAGER }}:5000/{{ IMAGEREPO }}/so-freqserver:{{ VERSION }}
so-freq: so-freq:
docker_container.running: docker_container.running:
- require: - require:
- so-freqimage - so-freqimage
- image: docker.io/{{ IMAGEREPO }}/so-freqserver:HH1.0.3 - image: {{ MANAGER }}:5000/{{ IMAGEREPO }}/so-freqserver:{{ VERSION }}
- hostname: freqserver - hostname: freqserver
- name: so-freqserver - name: so-freqserver
- user: freqserver - user: freqserver

View File

@@ -67,7 +67,7 @@ noderedlog:
so-nodered: so-nodered:
docker_container.running: docker_container.running:
- image: {{ IMAGEREPO }}/so-nodered:HH1.2.2 - image: {{ MANAGER }}:5000/{{ IMAGEREPO }}/so-nodered:{{ VERSION }}
- interactive: True - interactive: True
- binds: - binds:
- /opt/so/conf/nodered/:/data:rw - /opt/so/conf/nodered/:/data:rw

View File

@@ -45,7 +45,7 @@ dockerregistryconf:
# Install the registry container # Install the registry container
so-dockerregistry: so-dockerregistry:
docker_container.running: docker_container.running:
- image: registry:latest - image: ghcr.io/security-onion-solutions/registry:latest
- hostname: so-registry - hostname: so-registry
- restart_policy: always - restart_policy: always
- port_bindings: - port_bindings:

View File

@@ -901,10 +901,7 @@ docker_seed_registry() {
docker_seed_update_percent=25 docker_seed_update_percent=25
# Save output descriptors for use in docker_seed_registry_update function update_docker_containers 'netinstall' '' 'docker_seed_update' "$setup_log"
exec 10>&1 20>&2
update_docker_containers 'netinstall' '' 'docker_seed_update' >> "$setup_log" 2>&1
else else
tar xvf /nsm/docker-registry/docker/registry.tar -C /nsm/docker-registry/docker >> "$setup_log" 2>&1 tar xvf /nsm/docker-registry/docker/registry.tar -C /nsm/docker-registry/docker >> "$setup_log" 2>&1
rm /nsm/docker-registry/docker/registry.tar >> "$setup_log" 2>&1 rm /nsm/docker-registry/docker/registry.tar >> "$setup_log" 2>&1

View File

@@ -601,7 +601,7 @@ fi
fi fi
import_registry_docker >> $setup_log 2>&1 import_registry_docker >> $setup_log 2>&1
salt-call state.apply -l info registry >> $setup_log 2>&1 salt-call state.apply -l info registry >> $setup_log 2>&1
docker_seed_registry 2>> "$setup_log" # ~ 60% when finished docker_seed_registry # ~ 60% when finished
set_progress_str 60 "$(print_salt_state_apply 'manager')" set_progress_str 60 "$(print_salt_state_apply 'manager')"
if [[ "$STRELKARULES" == 1 ]]; then if [[ "$STRELKARULES" == 1 ]]; then