# # DockerBashOOP - Implementation of BashOOP for Docker. # Copyright (C) 2022 Ad5001 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # This class contains various utils required for Docker. # Returns the base command for docker, with it's executable and sudo if necessary. # Signature: () -> string Utils.DockerCommand() { if [ $(Docker.RequiresSudo) == true ]; then echo -n "sudo "; fi echo "$(Docker.Executable)" } # Checks if the user has permission to use docker. # Signature: () -> bool Utils.hasPermission() { $(Utils.DockerCommand) ps 2>&1 | grep -q "permission denied" # Check status of last command. If permission denied is found, then we do not have permission to use docker. if [ $? ]; then echo false; else echo true; fi }