File: run_docker_ost

package info (click to toggle)
openstructure 2.9.3-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 205,228 kB
  • sloc: cpp: 188,129; python: 35,361; ansic: 34,298; fortran: 3,275; sh: 286; xml: 146; makefile: 29
file content (28 lines) | stat: -rwxr-xr-x 646 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash

# end when error
set -e

image_name=$1
script_path=$2

if [[ ${#@} -lt 1 ]]; then
    echo "Usage: run_docker_ost <IMAGE_NAME> [<SCRIPT_PATH>]"
    exit 1
fi

if [[ -z ${script_path} ]]; then
    docker run -ti --rm -v $(pwd):/home ${image_name}
else
    if [[ -e $script_path ]]; then
        abspath=$(readlink -f $script_path)
        dirpath=$(dirname $abspath)
        name=$(basename $script_path)
        docker run --rm -v ${dirpath}:/home ${image_name} /home/${name} ${@:3}
    else
        # it is maybe an action if it does not exist
        docker run --rm -v $(pwd):/home ${image_name} ${script_path} ${@:3}
    fi
fi