- 
      
- 
        Save rms1000watt/d2dde576d0e82ad49841d73753297527 to your computer and use it in GitHub Desktop. 
    ryan script for general functionality on Darwin
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/usr/bin/env bash | |
| set -e | |
| help() { | |
| echo "Usage: | |
| ryan container CONTAINER_NAME # Get container ID | |
| " 1>&2 | |
| exit 1 | |
| } | |
| cmd_container() { | |
| if [[ -z $1 ]]; then | |
| echo "ERROR: Container name not provided" 1>&2 | |
| help | |
| fi | |
| containerName=${1} | |
| containerID="$(docker ps -a | grep ${containerName} | cut -d' ' -f1 | tr '\n' ' ')" | |
| if sed 's/[[:blank:]]*$//' <<< "${containerID}" | grep -q '[[:space:]]'; then | |
| echo "ERROR: Multiple container IDs found: containerName=${containerName} containerID=${containerID}" 1>&2 | |
| exit 1 | |
| fi | |
| echo $containerID | |
| } | |
| case "$1" in | |
| container) | |
| cmd_container ${@:2};; | |
| *) | |
| help; exit 1 | |
| esac | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment