From 245c9b84b02f0c02b9cff8b8e4c9927210501ffe Mon Sep 17 00:00:00 2001 From: f Date: Wed, 25 Aug 2021 18:05:33 -0300 Subject: [PATCH] =?UTF-8?q?Comunicar=20mejor=20y=20sugerir=20configuraci?= =?UTF-8?q?=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #16 --- haini.sh | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/haini.sh b/haini.sh index 9add081..8ef5a8a 100755 --- a/haini.sh +++ b/haini.sh @@ -7,10 +7,16 @@ uname -m | grep -q x86_64 || exit 1 DIR="$(dirname "$(realpath "$0")")" ROOT="$(dirname "$DIR")" +SELF="$(basename "$0")" # Sólo se puede correr desde el directorio de Sutty if test "$ROOT" != "$(dirname "$PWD")" && test "$ROOT" != "$PWD"; then echo "¡No estás corriendo dentro de una carpeta de Sutty!" +fi + +# Necesitamos bubblewrap +if ! type bwrap >/dev/null 2>&1 ; then + echo "Por favor, instala el paquete bubblewrap" exit 1 fi @@ -28,9 +34,6 @@ ENTORNO=${ENTORNO:-${ROOT}/hain} correr() { echo "> $1" - # Necesitamos bubblewrap - type bwrap >/dev/null || exit 1 - mkdir -p "$ENTORNO/home" # migrar de versiones anteriores de hainish test -d "$ENTORNO$HOME" && mv "$ENTORNO$HOME" "$ENTORNO/home/suttier" @@ -119,9 +122,9 @@ crear_entorno() { ALPINE_URL="https://dl-cdn.alpinelinux.org/alpine/v${ALPINE%.*}/releases/x86_64/alpine-minirootfs-${ALPINE}-x86_64.tar.gz" # Definir si vamos a usar wget o curl - type wget >/dev/null && download="wget -O -" - type busybox >/dev/null && download="busybox wget -O -" - type curl >/dev/null && download="curl" + type wget >/dev/null 2>&1 && download="wget -O -" + type busybox >/dev/null 2>&1 && download="busybox wget -O -" + type curl >/dev/null 2>&1 && download="curl" # Si no hay ninguno de los dos, salir test -z "${download}" && exit 1 @@ -167,5 +170,14 @@ crear_entorno() { test -f "$ENTORNO/etc/ssl/certs/sutty.local.crt" || generar_certificado } -crear_entorno -stdin=/dev/stdin correr "${1:-sh}" +case $1 in + init) echo "export PATH=$DIR:\$PATH" ;; + *) + if ! type "$SELF" >/dev/null 2>&1 ; then + echo "Tip: Inicia haini.sh con 'eval \$($0 init)'" >&2 + fi + + crear_entorno + stdin=/dev/stdin correr "${1:-sh}" + ;; +esac