From 28190b6d4664508ad8b1cf88a82378b02f487cfa Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Mon, 9 Nov 2020 20:16:44 +0100 Subject: Support ssh server for remote debugging --- build/buildah-astra.sh | 33 +++++++++++++++++++++++++++++++++ build/buildah-ccpi.sh | 21 +++++++++++++++++++++ build/buildah.sh | 34 ++-------------------------------- build/setup/repos.sh | 18 +++++++++++++----- build/update.sh | 2 +- run/devel.sh | 4 +++- run/run-ssh.sh | 13 +++++++++++++ run/run.sh | 3 ++- 8 files changed, 88 insertions(+), 40 deletions(-) create mode 100644 build/buildah-astra.sh create mode 100644 build/buildah-ccpi.sh create mode 100644 run/run-ssh.sh diff --git a/build/buildah-astra.sh b/build/buildah-astra.sh new file mode 100644 index 0000000..fa69db6 --- /dev/null +++ b/build/buildah-astra.sh @@ -0,0 +1,33 @@ +#! /usr/bin/env bash + +set -o errexit + +container=$(buildah from nvidia/cuda:10.1-devel-ubuntu18.04) + +buildah config --label maintainer="Suren A. Chilingaryan " $container +buildah config --env LANG="C.UTF-8" --env LC_ALL="C.UTF-8" --env TERM="xterm" $container + +buildah run $container sh -c 'echo "ssh:x:101:" >> /etc/group' +buildah run $container sh -c 'echo "sshd:x:101:101:sshd:/dev/null:/sbin/nologin" >> /etc/passwd' +buildah run $container sh -c 'echo "messagebus:x:102:" >> /etc/group' +buildah run $container sh -c 'echo "messagebus:x:102:102:messagebus:/dev/null:/sbin/nologin" >> /etc/passwd' +buildah run $container sh -c 'echo "rdma:x:103:" >> /etc/group' +buildah run $container sh -c 'echo "systemd-journal:x:104:" >> /etc/group' +buildah run $container sh -c 'echo "systemd-network:x:105:" >> /etc/group' +buildah run $container sh -c 'echo "systemd-network:x:105:105:systemd-network:/dev/null:/sbin/nologin" >> /etc/passwd' +buildah run $container sh -c 'echo "systemd-resolve:x:106:" >> /etc/group' +buildah run $container sh -c 'echo "systemd-resolve:x:106:106:systemd-resolve:/dev/null:/sbin/nologin" >> /etc/passwd' + +buildah run $container sh -c 'apt-get update --fix-missing && apt-get install -y bash wget bzip2 mc ca-certificates git openssh-server' +buildah run $container sh -c 'apt-get install -y python3 python3-setuptools python3-pip cython3' +buildah run $container sh -c 'apt-get install -y cmake autoconf automake libtool libboost-all-dev' + +buildah run $container sh -c 'update-alternatives --remove python /usr/bin/python2' +buildah run $container sh -c 'update-alternatives --install /usr/bin/python python /usr/bin/python3 10' + +buildah copy $container pre-setup /root/pre-setup +buildah run $container pip3 install -r /root/pre-setup/requirements.txt + +buildah copy $container setup /root/setup +buildah run $container bash /root/setup/repos.sh "astra" +buildah commit --format docker $container astra:latest diff --git a/build/buildah-ccpi.sh b/build/buildah-ccpi.sh new file mode 100644 index 0000000..1bc6b10 --- /dev/null +++ b/build/buildah-ccpi.sh @@ -0,0 +1,21 @@ +#! /usr/bin/env bash + +set -o errexit + +container=$(buildah from astra:latest) + +buildah config --env LANG="C.UTF-8" --env LC_ALL="C.UTF-8" --env TERM="xterm" --env CIL_VERSION=19.10 --env HOME=/ccpi/data $container +buildah config --port 2222 $container + +buildah run $container bash /root/setup/repos.sh "all" + +buildah run $container sh -c "echo '$(id -ng):x:$(id -g):' >> /etc/group" +#buildah run $container sh -c "echo '$(id -nu):x:$(id -u):$(id -g):$(id -nu):/ccpi/data:/bin/bash' >> /etc/passwd" +buildah run $container sh -c "echo '$(id -nu):x:0:0:$(id -nu):/ccpi/data:/bin/bash' >> /etc/passwd" + +buildah run $container sh -c 'service ssh start' +buildah run $container sh -c "echo '$(id -nu):test' | chpasswd" +buildah commit --format docker $container ccpi:latest + +echo $container + diff --git a/build/buildah.sh b/build/buildah.sh index 45ee576..2f4f283 100644 --- a/build/buildah.sh +++ b/build/buildah.sh @@ -1,34 +1,4 @@ -#! /usr/bin/env bash - set -o errexit -#container=$(buildah from nvidia/cuda:10.1-base-ubuntu18.04) -container=$(buildah from nvidia/cuda:10.1-devel-ubuntu18.04) - -buildah config --label maintainer="Suren A. Chilingaryan " $container -buildah config --env LANG="C.UTF-8" --env LC_ALL="C.UTF-8" --env TERM="xterm" --env CIL_VERSION=19.10 --env HOME=/ccpi/data $container - -buildah run $container sh -c 'echo "ssh:x:101:" >> /etc/group' -buildah run $container sh -c 'echo "messagebus:x:102:" >> /etc/group' -buildah run $container sh -c 'echo "rdma:x:103:" >> /etc/group' -buildah run $container sh -c 'echo "messagebus:x:101:102:messagebus:/dev/null:/sbin/nologin" >> /etc/passwd' - -buildah run $container sh -c 'apt-get update --fix-missing && apt-get install -y bash wget bzip2 mc ca-certificates git' -buildah run $container sh -c 'apt-get install -y python3 python3-setuptools python3-pip cython3' -buildah run $container sh -c 'apt-get install -y cmake autoconf automake libtool libboost-all-dev' - -buildah run $container sh -c 'update-alternatives --remove python /usr/bin/python2' -buildah run $container sh -c 'update-alternatives --install /usr/bin/python python /usr/bin/python3 10' - -buildah copy $container pre-setup /root/pre-setup -buildah run $container pip3 install -r /root/pre-setup/requirements.txt - -buildah copy $container setup /root/setup -buildah run $container bash /root/setup/repos.sh - -buildah commit --format docker $container ccpi:latest - - - -echo $container - +bash buildah-astra.sh +bash buildah-ccpi.sh diff --git a/build/setup/repos.sh b/build/setup/repos.sh index 9e76208..92c1a2f 100644 --- a/build/setup/repos.sh +++ b/build/setup/repos.sh @@ -2,19 +2,27 @@ set -o errexit -setup_path="$1" -repos_path="$2" +repo_group="$1" +setup_path="$2" +repos_path="$3" +[ -z "$repo_group" ] && repo_group="all" [ -z "$setup_path" ] && setup_path="/root/setup" [ -z "$repos_path" ] && repos_path="/ccpi/repos" -repos=( \ - "https://github.com/astra-toolbox/astra-toolbox.git tags/v1.8.3 astra.sh" \ +repos_astra=( \ + "https://github.com/astra-toolbox/astra-toolbox.git master astra.sh" \ +) + +repos_ccpi=( \ "https://github.com/vais-ral/CCPi-Framework.git master ccpi.sh" \ "https://github.com/vais-ral/CCPi-FrameworkPlugins.git master ccpi.sh" \ - "https://github.com/vais-ral/CCPi-astra.git update_projectors ccpi.sh" \ + "https://github.com/vais-ral/CCPi-astra.git master ccpi.sh" \ "https://github.com/vais-ral/CCPi-Regularisation-Toolkit.git master ccpi.sh" \ ) +repos_all=("${repos_astra[@]}" "${repos_ccpi[@]}") +declare -n repos="repos_$repo_group" + function install_repo { repo="$1" name=$(basename "$repo" .git) diff --git a/build/update.sh b/build/update.sh index 7f5dcd0..0201a4d 100644 --- a/build/update.sh +++ b/build/update.sh @@ -10,7 +10,7 @@ container=$(buildah from localhost/ccpi) buildah config --env CIL_VERSION=19.10 --env HOME=/ccpi/data $container buildah copy $container setup /root/setup -buildah run $container bash /root/setup/repos.sh "/root/setup" +buildah run $container bash /root/setup/repos.sh "all" "/root/setup" #buildah commit --format docker $container ccpi:latest echo "buildah commit --format docker $container ccpi:latest" diff --git a/run/devel.sh b/run/devel.sh index 57ec7f0..ad8fa15 100644 --- a/run/devel.sh +++ b/run/devel.sh @@ -6,4 +6,6 @@ if [ ! -d ../repos ]; then buildah unshare bash ../build/extract.sh fi -podman run --name "ccpi-devel" -it --rm --hooks-dir /usr/share/containers/oci/hooks.d/ -v ~/ccpi/data:/ccpi/data -v ~/ccpi/repos:/ccpi/repos localhost/ccpi bash -c "bash /root/setup/provision.sh; bash" +port="$(($(id -u) - 900))22" + +podman run --name "ccpi-devel" -it --rm --hooks-dir /usr/share/containers/oci/hooks.d/ -p $port:2222/tcp -v ~/ccpi/data:/ccpi/data -v ~/ccpi/repos:/ccpi/repos localhost/ccpi bash -c "bash /root/setup/provision.sh; bash" diff --git a/run/run-ssh.sh b/run/run-ssh.sh new file mode 100644 index 0000000..950024a --- /dev/null +++ b/run/run-ssh.sh @@ -0,0 +1,13 @@ +#! /bin/bash + +set -o errexit + +port="$(($(id -u) - 900))22" + +echo "Running on the port $port" +echo "Create ssh tunnel and connect:" +echo " ssh -L $port:localhost:$port $(hostname)" +echo " and connect locally " +echo " ssh -p $port localhost" + +podman run --name "ccpi-run" -it --rm --hooks-dir /usr/share/containers/oci/hooks.d/ -p ${port}:2222/tcp -v ~/ccpi/data:/ccpi/data localhost/ccpi /usr/sbin/sshd -D -p 2222 diff --git a/run/run.sh b/run/run.sh index 5ebb075..0010e1d 100644 --- a/run/run.sh +++ b/run/run.sh @@ -2,4 +2,5 @@ set -o errexit -podman run --name "ccpi-run" -it --rm --hooks-dir /usr/share/containers/oci/hooks.d/ -v ~/ccpi/data:/ccpi/data localhost/ccpi bash +port="$(($(id -u) - 900))22" +podman run --name "ccpi-run" -it --rm --hooks-dir /usr/share/containers/oci/hooks.d/ -p $port:2222/tcp -v ~/ccpi/data:/ccpi/data localhost/ccpi bash -- cgit v1.2.3