summaryrefslogtreecommitdiff
path: root/share/spack/docker/entrypoint.bash
blob: 58d6281084f51e1b6738cf4637e2f4484266fae8 (plain) (blame)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#! /usr/bin/env bash -e
#
# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

if [ "$1" '=' 'docker-shell' ] ; then
    if [ -t 0 ] ; then
        exec bash -il
    else
        (
            echo -n "It looks like you're trying to run an intractive shell"
            echo -n " session, but either no psuedo-TTY is allocateed for this"
            echo -n " container's STDIN, or it is closed."
            echo

            echo -n "Make sure you run docker with the --interactive and --tty"
            echo -n " options."
            echo
        ) >&2

        exit 1
    fi
else
    exec 3>&1
    exec 4>&2

    exec 1>&-
    exec 2>&-

    source /etc/profile.d/spack.sh
    source /etc/profile.d/handle-ssh.sh

    exec 1>&3
    exec 2>&4

    exec 3>&-
    exec 4>&-

    spack "$@"
    exit $?
fi