aboutsummaryrefslogtreecommitdiff
path: root/tools/validate-docker-execute.sh
blob: cca6589ddf1c50042d1d9dd8052988068a70166d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env bash
#
# This script can be used to check user privilege to execute
# docker or podman commands depending on CONTAINER_ENGINE 
# environment variable

function check_dockerexecute {
    sudo $CONTAINER_ENGINE ps &>/dev/null
    return_val=$?
    if [ $return_val -ne 0 ]; then
        echo "User $USER can't seem to run ${CONTAINER_ENGINE^} commands. Verify product documentation to allow user to execute ${CONTAINER_ENGINE^} commands" 1>&2
        exit 1
    fi
}
check_dockerexecute