Update scripts to check if docker is usable for $USER

Added new script for checking user permissions on
docker command execution

Change-Id: I3b727590d9a29f416f5b847912b7250c555c2333
Closes-Bug: #1473554
This commit is contained in:
Swapnil Kulkarni 2015-07-13 07:11:27 +00:00
parent 69338a94ba
commit 1f0acbd0cd
5 changed files with 26 additions and 5 deletions

View File

@ -1,13 +1,10 @@
#!/bin/bash
if [[ $EUID -eq 0 ]]; then
echo "This script must not be run as root. Instead add yourself to the docker group." 1>&2
exit 1
fi
TOPDIR=$(git rev-parse --show-toplevel)
IMGDIR="$(cd "$(dirname "$0")" && pwd)"
. $TOPDIR/tools/validate-docker-execute
RELEASE_NAMESPACE=kollaglue
NAMESPACE=kollaglue
PREFIX=centos-rdo-

View File

@ -4,6 +4,8 @@
REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
cd "$(dirname "$REAL_PATH")/.."
. tools/validate-docker-execute
# Remove docker containers
docker ps -a -q | while read -r line ; do
echo "Removing docker containers"

View File

@ -1,3 +1,9 @@
#!/bin/bash
# Move to top level directory
REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
cd "$(dirname "$REAL_PATH")/.."
. tools/validate-docker-execute
docker rmi $@ $(docker images -a -q)

View File

@ -6,6 +6,8 @@
REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
cd "$(dirname "$REAL_PATH")/.."
. tools/validate-docker-execute
NETWORK_MANAGER=$(grep -sri NETWORK_MANAGER ./compose/openstack.env | cut -f2 -d'=')
if [[ -z "$NETWORK_MANAGER" ]]; then
echo 'No network manager defined in ./compose/openstack.env, defaulting to "neutron".'

14
tools/validate-docker-execute Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
#
# This script can be used to check user privilege to execute
# docker commands
function check_dockerexecute {
docker ps &>/dev/null
return_val=$?
if [ $return_val -ne 0 ]; then
echo "User $USER can't seem to run Docker commands. Verify product documentation to allow user to execute docker commands" 1>&2
exit 1
fi
}
check_dockerexecute