5dd126
#!/bin/bash
5dd126
# This script delivers current documentation/configs and assures it has the intended
5dd126
# settings for a particular branch/release.
5dd126
# For questions reach to Jindrich Novy <jnovy@redhat.com>
5dd126
5dd126
ensure() {
5dd126
  if grep ^$2[[:blank:]].*= $1 > /dev/null
5dd126
  then
5dd126
    sed -i "s;^$2[[:blank:]]=.*;$2 = $3;" $1
5dd126
  else
5dd126
    if grep ^\#.*$2[[:blank:]].*= $1 > /dev/null
5dd126
    then
5dd126
      sed -i "/^#.*$2[[:blank:]].*=/a \
5dd126
$2 = $3" $1
5dd126
    else
c929c0
      echo "$2 = $3" >> $1
5dd126
    fi
5dd126
  fi
5dd126
}
5dd126
5dd126
#./pyxis.sh
5dd126
#./update-vendored.sh
5dd126
spectool -f -g containers-common.spec
c929c0
for FILE in *; do
c929c0
  [ -s "$FILE" ]
c929c0
  if [ $? == 1 ] && [ "$FILE" != "sources" ]; then
c929c0
    echo "empty file: $FILE"
c929c0
    exit 1
c929c0
  fi
c929c0
done
5dd126
ensure storage.conf    driver                        \"overlay\"
5dd126
ensure storage.conf    mountopt                      \"nodev,metacopy=on\"
5dd126
if pwd | grep rhel-8 > /dev/null
5dd126
then
c929c0
awk -i inplace '/#default_capabilities/,/#\]/{gsub("#","",$0)}1' containers.conf
2b1b9b
ensure registries.conf unqualified-search-registries [\"registry.access.redhat.com\",\ \"registry.redhat.io\",\ \"docker.io\"]
5dd126
ensure registries.conf short-name-mode               \"permissive\"
5dd126
ensure containers.conf runtime                       \"runc\"
21a30b
ensure containers.conf events_logger                 \"file\"
21a30b
ensure containers.conf log_driver                    \"k8s-file\"
e2e81a
ensure containers.conf network_backend               \"cni\"
ce5e36
if ! grep \"NET_RAW\" containers.conf > /dev/null
ce5e36
then
ce5e36
  sed -i '/^default_capabilities/a \
c929c0
  "NET_RAW",' containers.conf
ce5e36
fi
8498d9
if ! grep \"SYS_CHROOT\" containers.conf > /dev/null
8498d9
then
8498d9
  sed -i '/^default_capabilities/a \
8498d9
  "SYS_CHROOT",' containers.conf
8498d9
fi
5dd126
else
2b1b9b
ensure registries.conf unqualified-search-registries [\"registry.access.redhat.com\",\ \"registry.redhat.io\",\ \"docker.io\"]
5dd126
ensure registries.conf short-name-mode               \"enforcing\"
5dd126
ensure containers.conf runtime                       \"crun\"
5dd126
fi
c929c0
[ `grep \"keyctl\", seccomp.json | wc -l` == 0 ] && sed -i '/\"kill\",/i \
5dd126
				"keyctl",' seccomp.json
c929c0
[ `grep \"socket\", seccomp.json | wc -l` == 0 ] && sed -i '/\"socketcall\",/i \
5dd126
				"socket",' seccomp.json