20 Commits

Author SHA1 Message Date
f
272c4f0291 fix: saltos de línea 2026-06-13 12:42:06 -03:00
f
2dce1caf71 feat: abrir puertos con upnp 2026-05-05 13:40:11 -03:00
f
8d41d76fd2 Merge branch 'antifascista' of https://git.coopcloud.tech/escuela-comun/huerta-init into antifascista 2026-04-29 00:08:10 -03:00
f
e3f428e8cb feat: habilitar ipv6 en docker 2026-04-21 20:20:15 -03:00
f
a7efbcc9b8 fix: reiniciar tinc durante la instalación 2026-04-21 20:20:01 -03:00
f
ffbb9a20a7 feat: habilitar local discovery en tinc 2026-04-21 20:13:12 -03:00
f
e9a50bb610 Merge branch 'antifascista' of https://git.coopcloud.tech/escuela-comun/huerta-init into antifascista 2026-04-20 13:42:06 -03:00
f
5c386f4dd5 fix: readme 2026-04-20 12:57:27 -03:00
f
ddc7ee9380 Merge branch 'antifascista' of https://git.coopcloud.tech/escuela-comun/huerta-init into antifascista 2026-04-20 12:54:31 -03:00
f
0803734092 fix: copiar archivo de hosts 2026-04-17 01:37:21 -03:00
f
607c3cb9f4 Merge branch 'antifascista' of https://git.coopcloud.tech/escuela-comun/huerta-init into antifascista 2026-04-17 01:23:32 -03:00
f
9aab277654 fix: permitir las conexiones directas entre nodos 2026-04-17 01:17:09 -03:00
f
b2292e77b0 fix: rap 2026-04-14 21:43:29 -03:00
f
ef9e62d1af fix: dns público 2026-04-14 21:13:58 -03:00
f
f05afa52b6 fix: dominio .rap 2026-04-14 21:08:11 -03:00
f
5ef8f78dec fix: swarm 2026-04-14 21:00:20 -03:00
f
873ff0c4dd fix: rap 2026-04-14 21:00:14 -03:00
f
bc0170982d fix: sdb opcional 2026-04-14 20:50:58 -03:00
f
f2b78a1214 feat: rap 2026-04-14 20:38:41 -03:00
f
97312a00b8 feat: fork! 2026-04-14 20:33:08 -03:00
7 changed files with 208 additions and 223 deletions

View File

@ -1,14 +1,13 @@
# huerta-init
# gallinero-init
Es el instalador de huertas para la Escuela Común. Se encarga de toda
la configuración post instalación, incluyendo:
Es el instalador de nodos del Gallinero. Se encarga de toda la
configuración post instalación, incluyendo:
* Cifrar el disco de datos (si existe)
* Crear el nodo en la red Común (hay que darlo de alta en el proxy
luego)
* Configurar `initramfs` para que podamos conectarnos por red a la
huerta sin necesidad de conectarle teclado y monitor ni estar
físicamente al lado de la huerta.
* Crear el nodo en la red autónoma pirata (rap)
* Configurar `initramfs` para que podamos conectarnos por red al
nodo sin necesidad de conectarle teclado y monitor ni estar
físicamente al lado del nodo.
* Instalar `abra` y hacer la configuración inicial de `traefik`.
# Pasos
@ -24,12 +23,12 @@ la configuración post instalación, incluyendo:
utilizado después. Preferimos usar `lvextend` luego que manipular
las opciones de particionado del instalador.
* ¡Usar un _hostname_ sin guiones en el nombre! Luego genera
incompatibilidades en la red Común y Coopcloud.
incompatibilidades en la rap y Coopcloud.
* Si no instalamos una llave SSH desde GitHub, este es el momento de
hacerlo:
```sh
ssh-copy-id usuarie@192.168.0.10 # IP de la huerta en la red local
ssh-copy-id usuarie@192.168.0.10 # IP de la nodo en la red local
```
* Ingresar por SSH al sistema:
@ -42,36 +41,35 @@ la configuración post instalación, incluyendo:
```sh
# Hacer esto una sola vez
git clone https://git.coopcloud.tech/escuela-comun/huerta-init.git
git clone https://git.coopcloud.tech/gallinero/gallinero-init.git
# Hacer esto cada vez que queramos correr un script
cd huerta-init
# Hacer esto para actualizar huerta-init
cd gallinero-init
# Hacer esto para actualizar gallinero-init
git pull
# Hacer la instalación base, se puede correr múltiples veces. Es
# posible que nos pida la contraseña de cifrado de disco varias veces.
sudo ./huerta-init.sh
sudo ./gallinero-init.sh
# Nos va a pedir que reiniciemos
```
* Luego de reiniciar y haber activado el nodo en la red Común,
* Luego de reiniciar y haber activado el nodo en la rap,
deberíamos poder conectarnos por SSH a su dirección:
```sh
# Ingresar a la huerta a través del proxy
ssh usuarie@huerta.abyaya.la -p 3000 # puerto asignado por el proxy
ssh usuarie@192.168.0.10
# Desbloquear el disco con la contraseña de cifrado
cryptroot-unlock
```
**Estos dos comandos son los que vamos a tener que correr cada vez que
se reinicie la huerta.**
se reinicie el nodo.**
* Luego, hacer la instalación de Coopcloud:
```sh
# Volver a ingresar
ssh usuarie@huerta.abyaya.la -p 3000 # puerto asignado por el proxy
cd huerta-init
ssh usuarie@192.168.0.10
cd gallinero-init
./abra-init.sh # sin sudo
exit # cerrar y volver a entrar
```
@ -79,44 +77,21 @@ la configuración post instalación, incluyendo:
* Terminar la instalación de Traefik:
```sh
ssh usuarie@huerta.abyaya.la -p 3000 # puerto asignado por el proxy
cd huerta-init
# Volver a ingresar
ssh usuarie@192.168.0.10
cd gallinero-init
./traefik-init.sh # sin sudo
```
* A partir de ahora podemos instalar aplicaciones ingresando por `ssh`
y usando `abra`.
* Cada vez que reinicie la huerta tendremos que usar `cryptroot-unlock`.
* Cada vez que reinicie el nodo tendremos que usar `cryptroot-unlock`.
# Errores comunes
## No puedo conectarme por SSH después de desbloquear la huerta
## No puedo conectarme por SSH después de desbloquear el nodo
Es posible que tarde unos minutos en terminar de iniciar y reconectar
a la huerta. Si después de 5 minutos no es posible ingresar a la huerta
al nodo. Si después de 5 minutos no es posible ingresar al nodo
or `ssh`, reportar el problema.
## No hay conexión a la huerta a través del proxy
* Chequear que el archivo `/tmp/comun.dot` en el proxy contenga el
nombre de la huerta.
* Chequear que la interfaz `comun` en la huerta tenga asignada una IP en
el rango `10.13.12.0/24`:
```sh
ip address show comun
```
* Chequear que `netplan` no esté gestionando la interfaz:
```sh
netplan status
```
Si dice que la interfaz `comun` está _unmanaged_, quiere decir que
tenemos que correr nuestro propio cliente dhcp.
Si la red empieza a funcionar con `dhcpcd comun`, por favor reportar
el error.

179
gallinero-init.sh Executable file
View File

@ -0,0 +1,179 @@
#!/bin/bash
set -e
ok () { echo "ok -- $@" >&2; }
not_ok () { echo "not ok -- $@" >&2; }
if ! test $UID -eq 0 ; then
not_ok "Correr con sudo!"
exit 1
fi
dir="`realpath $0 | xargs dirname`"
authorized_keys=/home/$SUDO_USER/.ssh/authorized_keys
if ! test -f $authorized_keys; then
not_ok "Primero usa ssh-copy-id desde tu computadora para copiar llaves SSH!"
exit 1
fi
apt update
apt install -y dropbear-initramfs busybox-initramfs smartmontools git rsync make tinc dialog locales bash-completion gnutls-bin nano miniupnpc
ok "No permitir suspensión"
sed -re "s/^#(HandleLidSwitch=).*/\1ignore/" \
-e "s/^#(HandleLidSwitchDocked=).*/\1ignore/" \
-e "s/^#(LidSwitchIgnoreInhibited=).*/\1no/" \
-i /etc/systemd/logind.conf
if ! test -d /root/rap; then
ok "Clonando repositorio RAP"
git clone https://git.coopcloud.tech/escuela-comun/rap /root/rap
fi
ok "Actualizando repositorio RAP"
git -C /root/rap pull
cd /root/rap
node_dir=/root/rap/networks/rap/$HOSTNAME
if ! test -d $node_dir ; then
ok "Iniciando nodo RAP"
NETWORK=rap ./rap init $HOSTNAME
fi
sed -re "/^IndirectData /d" -i $node_dir/hosts/$HOSTNAME $node_dir/../hosts/$HOSTNAME
grep -q "LocalDiscovery" $node_dir/tinc.conf || echo "LocalDiscovery = yes" >> $node_dir/tinc.conf
NETWORK=rap ./rap install $HOSTNAME
systemctl restart tinc
if test -b /dev/sdb ; then
if ! test -b /dev/mapper/dm_crypt-1 ; then
ok "Cifrando el disco, usa la misma contraseña de cifrado que usaste durante la instalación"
cryptsetup luksFormat /dev/sdb
fi
if ! test -b /dev/mapper/dm_crypt-1 ; then
ok "Abriendo el disco cifrado"
cryptsetup open /dev/sdb dm_crypt-1
fi
key_file=/etc/dm_crypt-1.key
if ! test -f "$key_file" ; then
ok "Creando archivo de contraseña"
dd bs=512 count=4 if=/dev/random iflag=fullblock | install -m 0600 /dev/stdin "$key_file"
ok "Asignando archivo de contraseña"
cryptsetup luksAddKey /dev/sdb /etc/dm_crypt-1.key
fi
if ! grep -q dm_crypt-1 /etc/crypttab ; then
uuid="`blkid /dev/sdb -o value -p | head -n2 | tail -n 1`"
ok "Agregando $uuid a /etc/crypttab"
echo "dm_crypt-1 UUID=$uuid /etc/dm_crypt-1.key luks" >> /etc/crypttab
fi
if ! test -d /var/lib/docker; then
ok "Creando directorio de datos de Docker"
mkdir -p /var/lib/docker
fi
if ! pvdisplay /dev/mapper/dm_crypt-1 &>/dev/null; then
ok "Creando el PV de LVM para el disco de datos"
pvcreate /dev/mapper/dm_crypt-1
fi
if ! vgdisplay data-vg &>/dev/null ; then
ok "Creando VG de LVM para el disco de datos"
vgcreate data-vg /dev/mapper/dm_crypt-1
fi
if ! lvdisplay /dev/data-vg/data-lv &>/dev/null ; then
ok "Creando LV de LVM para el disco de datos"
lvcreate -l 100%FREE data-vg -n data-lv
mkfs.xfs /dev/data-vg/data-lv
fi
if ! grep -q /var/lib/docker /etc/fstab ; then
ok "Agregando directorio de datos de Docker a fstab"
echo "/dev/data-vg/data-lv /var/lib/docker xfs defaults 0 1" >> /etc/fstab
fi
fi
if ! grep -q IP=dhcp /etc/initramfs-tools/initramfs.conf; then
ok "Configurando DHCP durante el inicio"
echo IP=dhcp >> /etc/initramfs-tools/initramfs.conf
fi
default_interface="`ip route | grep default | cut -d " " -f 5`"
if ! grep -q DEVICE=$default_interface /etc/initramfs-tools/initramfs.conf; then
ok "Configurando interfaz de red para DHCP durante el inicio"
sed -re "s/^(#*)DEVICE=.*$/DEVICE=${default_interface}/" -i /etc/initramfs-tools/initramfs.conf
fi
ok "Configurando DHCP"
sed -re "s/#\s*(clientid)/\1/" -e "s/^(duid)/# \1/" -i /etc/dhcpcd.conf
if ! test -f /etc/dropbear/initramfs/authorized_keys; then
ln $authorized_keys /etc/dropbear/initramfs/authorized_keys
fi
ok "Copiando identificador de host de OpenSSH a Dropbear"
rm -f /etc/dropbear/initramfs/dropbear_*
dropbearconvert openssh dropbear /etc/ssh/ssh_host_rsa_key /etc/dropbear/initramfs/dropbear_rsa_host_key
dropbearconvert openssh dropbear /etc/ssh/ssh_host_ed25519_key /etc/dropbear/initramfs/dropbear_ed25519_host_key
dropbearconvert openssh dropbear /etc/ssh/ssh_host_ecdsa_key /etc/dropbear/initramfs/dropbear_ecdsa_host_key
ok "Sincronizando archivos de initramfs-tools"
rsync -av --chown 0:0 $dir/initramfs-tools/ /etc/initramfs-tools/
ok "Generando initramfs"
update-initramfs -u
if test -b /dev/sdb; then
if ! mount | grep -q /var/lib/docker ; then
ok "Montando almacenamiento docker"
mount /var/lib/docker
fi
fi
ok "Configurando el idioma"
localectl set-locale LANG=es_AR.UTF-8
if ! which docker &>/dev/null; then
ok "Instalando Docker"
curl https://get.docker.com | bash
ok "Configurando Docker"
echo '{"ipv6":true,"registry-mirrors":["https://hormuz.respaldos.abyaya.la"]}' >/etc/docker/daemon.json
systemctl restart docker
ok "Configurando la red IPv6"
subnet="`ip a show rap | grep acab | tr -s " " | cut -d " " -f 3 | sed -re "s/::/:/" -e "s|/32|::/80|"`"
docker network create \
--ipv6 \
--subnet $subnet \
--opt com.docker.network.bridge.name=docker_gwbridge \
--opt com.docker.network.bridge.enable_ip_forwarding=true \
--opt com.docker.network.bridge.enable_ip_masquerade=true \
docker_gwbridge
ok "Iniciando Swarm"
docker swarm init --advertise-addr 127.0.0.1
ok "Creando red"
docker network create -d overlay proxy
ok "Agregando $SUDO_USER al grupo Docker"
usermod -aG docker $SUDO_USER
fi
if test -f /etc/ssh/ssh_config.d/keep_alive.conf; then
echo "ClientAliveInterval 60" >/etc/ssh/sshd_config.d/keep_alive.conf
/etc/ssh/ssh_config.d/keep_alive.conf
fi
ok "Ahora puedes reiniciar el gallinero!"

View File

@ -1,170 +0,0 @@
#!/bin/bash
set -e
ok () { echo "ok -- $@" >&2; }
not_ok () { echo "not ok -- $@" >&2; }
if ! test $UID -eq 0 ; then
not_ok "Correr con sudo!"
exit 1
fi
dir="`realpath $0 | xargs dirname`"
authorized_keys=/home/$SUDO_USER/.ssh/authorized_keys
if ! test -f $authorized_keys; then
not_ok "Primero usa ssh-copy-id desde tu computadora para copiar llaves SSH!"
exit 1
fi
apt update
apt install -y dropbear-initramfs busybox-initramfs smartmontools git rsync make tinc dialog locales bash-completion gnutls-bin nano
ok "No permitir suspensión"
sed -re "s/^#(HandleLidSwitch=).*/\1ignore/"
-e "s/^#(HandleLidSwitchDocked=).*/\1ignore/"
-e "s/^#(LidSwitchIgnoreInhibited=).*/\1no/"
-i /etc/systemd/logind.conf
if ! test -d /root/rap; then
ok "Clonando repositorio RAP"
git clone https://git.coopcloud.tech/escuela-comun/rap /root/rap
fi
ok "Actualizando repositorio RAP"
git -C /root/rap pull
cd /root/rap
node_dir=/root/rap/networks/comun/$HOSTNAME
if ! test -d $node_dir ; then
ok "Iniciando nodo RAP"
NETWORK=comun ./rap init $HOSTNAME
fi
ok "Reparando la RAP"
sed -re "s/^..(:.*)$/02\1/" -i $node_dir/mac
rm -f $node_dir/hosts/abyayala*
NETWORK=comun ./rap add-host $HOSTNAME abyayala
NETWORK=comun ./rap install $HOSTNAME
if ! test -b /dev/mapper/dm_crypt-1 ; then
ok "Cifrando el disco, usa la misma contraseña de cifrado que usaste durante la instalación"
cryptsetup luksFormat /dev/sdb
fi
if ! test -b /dev/mapper/dm_crypt-1 ; then
ok "Abriendo el disco cifrado"
cryptsetup open /dev/sdb dm_crypt-1
fi
key_file=/etc/dm_crypt-1.key
if ! test -f "$key_file" ; then
ok "Creando archivo de contraseña"
dd bs=512 count=4 if=/dev/random iflag=fullblock | install -m 0600 /dev/stdin "$key_file"
ok "Asignando archivo de contraseña"
cryptsetup luksAddKey /dev/sdb /etc/dm_crypt-1.key
fi
if ! grep -q dm_crypt-1 /etc/crypttab ; then
uuid="`blkid /dev/sdb -o value -p | head -n2 | tail -n 1`"
ok "Agregando $uuid a /etc/crypttab"
echo "dm_crypt-1 UUID=$uuid /etc/dm_crypt-1.key luks" >> /etc/crypttab
fi
if ! test -d /var/lib/docker; then
ok "Creando directorio de datos de Docker"
mkdir -p /var/lib/docker
fi
if ! pvdisplay /dev/mapper/dm_crypt-1 &>/dev/null; then
ok "Creando el PV de LVM para el disco de datos"
pvcreate /dev/mapper/dm_crypt-1
fi
if ! vgdisplay data-vg &>/dev/null ; then
ok "Creando VG de LVM para el disco de datos"
vgcreate data-vg /dev/mapper/dm_crypt-1
fi
if ! lvdisplay /dev/data-vg/data-lv &>/dev/null ; then
ok "Creando LV de LVM para el disco de datos"
lvcreate -l 100%FREE data-vg -n data-lv
mkfs.xfs /dev/data-vg/data-lv
fi
if ! grep -q /var/lib/docker /etc/fstab ; then
ok "Agregando directorio de datos de Docker a fstab"
echo "/dev/data-vg/data-lv /var/lib/docker xfs defaults 0 1" >> /etc/fstab
fi
if ! grep -q IP=dhcp /etc/initramfs-tools/initramfs.conf; then
ok "Configurando DHCP durante el inicio"
echo IP=dhcp >> /etc/initramfs-tools/initramfs.conf
fi
default_interface="`ip route | grep default | cut -d " " -f 5`"
if ! grep -q DEVICE=$default_interface /etc/initramfs-tools/initramfs.conf; then
ok "Configurando interfaz de red para DHCP durante el inicio"
sed -re "s/^(#*)DEVICE=.*$/DEVICE=${default_interface}/" -i /etc/initramfs-tools/initramfs.conf
fi
ok "Configurando DHCP"
sed -re "s/#\s*(clientid)/\1/" -e "s/^(duid)/# \1/" -i /etc/dhcpcd.conf
if ! test -f /etc/dropbear/initramfs/authorized_keys; then
ln $authorized_keys /etc/dropbear/initramfs/authorized_keys
fi
ok "Copiando identificador de host de OpenSSH a Dropbear"
rm -f /etc/dropbear/initramfs/dropbear_*
dropbearconvert openssh dropbear /etc/ssh/ssh_host_rsa_key /etc/dropbear/initramfs/dropbear_rsa_host_key
dropbearconvert openssh dropbear /etc/ssh/ssh_host_ed25519_key /etc/dropbear/initramfs/dropbear_ed25519_host_key
dropbearconvert openssh dropbear /etc/ssh/ssh_host_ecdsa_key /etc/dropbear/initramfs/dropbear_ecdsa_host_key
ok "Sincronizando archivos de initramfs-tools"
rsync -av --chown 0:0 $dir/initramfs-tools/ /etc/initramfs-tools/
ok "Generando initramfs"
update-initramfs -u
if ! mount | grep -q /var/lib/docker ; then
ok "Montando almacenamiento docker"
mount /var/lib/docker
fi
ok "Configurando el idioma"
localectl set-locale LANG=es_AR.UTF-8
if ! which docker &>/dev/null; then
ok "Instalando Docker"
curl https://get.docker.com | bash
ok "Iniciando Swarm"
docker swarm init --advertise-addr 127.0.0.1
ok "Creando red"
docker network create -d overlay proxy
ok "Agregando $SUDO_USER al grupo Docker"
usermod -aG docker $SUDO_USER
fi
if ! grep -q https://hormuz.respaldos.abyaya.la /etc/docker/daemon.json ; then
ok "Configurando Docker"
echo '{"registry-mirrors":["https://hormuz.respaldos.abyaya.la"]}' >/etc/docker/daemon.json
systemctl restart docker
fi
if test -f /etc/ssh/ssh_config.d/keep_alive.conf; then
echo "ClientAliveInterval 60" >/etc/ssh/sshd_config.d/keep_alive.conf
/etc/ssh/ssh_config.d/keep_alive.conf
fi
ok "Ahora puedes reiniciar la huerta!"

View File

@ -19,12 +19,13 @@ rm "$DESTDIR/etc/dhcpcd.conf"
grep root: "$DESTDIR/etc/passwd" | sed -re "s/root:/`hostname`:/" >> "$DESTDIR/etc/passwd"
grep root: "$DESTDIR/etc/passwd" | sed -re "s/root:/${SUDO_USER}:/" >> "$DESTDIR/etc/passwd"
copy_file config /etc/hosts
copy_file config /etc/dhcpcd.conf
copy_file config /var/lib/dhcpcd/duid
copy_file config /var/lib/dhcpcd/secret
mkdir -p "$DESTDIR/etc/tinc"
cp -a /etc/tinc/comun "$DESTDIR/etc/tinc"
cp -a /etc/tinc/rap "$DESTDIR/etc/tinc"
exit 0

View File

@ -8,7 +8,7 @@ case $1 in
prereqs) prereqs; exit 0 ;;
esac
NETNAME=comun
NETNAME=rap
echo "Cerrando RAP: $NETNAME"

View File

@ -8,7 +8,7 @@ case $1 in
prereqs) prereqs; exit 0 ;;
esac
NETNAME=comun
NETNAME=rap
echo "Iniciando RAP: $NETNAME"

View File

@ -21,7 +21,7 @@ cd ~/certificados
ok "Actualizando repositorio de certificados"
git pull
domain=$HOSTNAME.abyaya.la
domain=$HOSTNAME.rap.partidopirata.com.ar
traefik=traefik.$domain
if ! test -f ~/.abra/servers/default/$traefik.env; then