From e77c78cd09ebcf7cdcc99d06bb82f8cf00fed09f Mon Sep 17 00:00:00 2001 From: f Date: Wed, 25 Aug 2021 18:04:24 -0300 Subject: [PATCH] =?UTF-8?q?Poder=20correr=20comandos=20en=20la=20ra=C3=ADz?= =?UTF-8?q?=20de=20Sutty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- haini.sh | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/haini.sh b/haini.sh index bf2a69c..9add081 100755 --- a/haini.sh +++ b/haini.sh @@ -6,16 +6,24 @@ set -e uname -m | grep -q x86_64 || exit 1 DIR="$(dirname "$(realpath "$0")")" +ROOT="$(dirname "$DIR")" # Sólo se puede correr desde el directorio de Sutty -if test "$(dirname "$DIR")" != "$(dirname "$PWD")"; then - echo "¡No estás corriendo dentro de una carpeta dentro de Sutty!" +if test "$ROOT" != "$(dirname "$PWD")" && test "$ROOT" != "$PWD"; then + echo "¡No estás corriendo dentro de una carpeta de Sutty!" exit 1 fi +# Si estamos corriendo el comando desde la raíz de trabajo no hay que +# agregar el directorio. +if test "$ROOT" = "$PWD"; then + WORKDIR="/Sutty" +else + WORKDIR="/Sutty/${PWD##*/}/" +fi # Podemos cambiar el entorno -ENTORNO=${ENTORNO:-../hain} +ENTORNO=${ENTORNO:-${ROOT}/hain} correr() { echo "> $1" @@ -42,7 +50,7 @@ correr() { --unshare-uts \ --unshare-cgroup-try \ --bind "$ENTORNO" / \ - --bind .. /Sutty \ + --bind "$ROOT" /Sutty \ --ro-bind /etc/hosts /etc/hosts \ --ro-bind /etc/passwd /etc/passwd \ --ro-bind /etc/group /etc/group \ @@ -52,7 +60,7 @@ correr() { --dev-bind /sys /sys \ --dev-bind /proc /proc \ --dev-bind /tmp /tmp \ - --chdir "/Sutty/${PWD##*/}" \ + --chdir "$WORKDIR" \ /bin/sh -l -c "$1" < "${stdin:-/dev/null}" } @@ -66,8 +74,8 @@ generar_certificado() { domain_csr="/etc/ssl/private/sutty.local.csr" domain_crt="/etc/ssl/certs/sutty.local.crt" - if test -f "$DIR/../sutty.local/domain/sutty.local.crt"; then - SUTTY_LOCAL="$DIR/../sutty.local" + if test -f "$ROOT/sutty.local/domain/sutty.local.crt"; then + SUTTY_LOCAL="$ROOT/sutty.local" echo "Migrando certificados de sutty.local..."