Se puede hacer que la máquina linux arranque automáticamente el Mainframe en la primera consola y un terminal en la segunda (se cambia con <alt>+F2
, y se vuelve con <alt>+F1
), quedando linux “oculto”. Con esta configuración se pueden conectar hasta 6 terminales por el puerto 3270. También se aplicará un firewall.
Se crean los siguientes script en /root/bin
(creando el directorio si no existe):
#!/bin/bash cd /root/tk4-plus if [ -e format-jes2 ] then rm -f format-jes2 diff scripts/SCR101A_specific03 scripts/SCR101A_default > /dev/null if [ $? -ne 0 ] then rm -f scripts/SCR101A_default ln scripts/SCR101A_specific03 scripts/SCR101A_default fi else diff scripts/SCR101A_ scripts/SCR101A_default > /dev/null if [ $? -ne 0 ] then rm -f scripts/SCR101A_default ln scripts/SCR101A_ scripts/SCR101A_default fi fi ./mvs echo > log/3033.log shutdown -h now
Este script permite formatear el JES2 si se crea un archivo (vacio) llamado format-jes2
, para ello se puede usar la orden
touch tk4-plus/format-jes2
#!/bin/bash while true do /bin/sleep 10 /usr/local/bin/c3270 local done
#!/bin/bash URL=http://localhost:8038/cgi-bin/tasks/syslog wget -q ${URL}?command=script%20scripts/shutdown -O /dev/null
#!/bin/bash /bin/sleep 10 cd /root/tk4-plus while true do [ -e format-jes2 ] && f=YES || f=NO dialog --backtitle "System Menu" --title "Boot Options" \ --ok-label "Edit" \ --msgbox "\nInitialize JES2 at boot: ${f}" 7 35 if [ $? -eq 0 ] then [ -e format-jes2 ] && f=on || f=off option=$(dialog --backtitle "System Menu" \ --title "Edit Boot Options" \ --checklist "Press <SPACE> to change" 8 50 1 \ I "Initialize JES2 at boot" ${f} \ 3>&1 1>&2 2>&3) if [ $? -eq 0 ] then if [ "${option}" = "\"I\"" ] then touch format-jes2 else rm -f format-jes2 fi fi fi done
Se hacen ejecutables
chmod 755 mvs-start mvs-3270 mvs-down mvs-menu
Se edita /etc/inittab
realizando los cambios destacados en rojo:
# # /etc/inittab: system runlevel description # # Runlevels: # 0 Halt # 1(S) Single-user # 2 Multi-user # 3 Mainframe # 4-5 Not used # 6 Reboot id:2:initdefault: rc::sysinit:/etc/rc rs:S1:wait:/etc/rc.single rm:23:wait:/etc/rc.multi rd:06:wait:/etc/rc.shutdown su:S:wait:/sbin/sulogin -p c1:2:respawn:/sbin/agetty -f /etc/issue.console 38400 tty1 linux c2:2:respawn:/sbin/agetty 38400 tty2 linux m1:3:respawn:/sbin/agetty -nl /root/bin/mvs-start 38400 tty1 linux m2:3:respawn:/sbin/agetty -nl /root/bin/mvs-3270 38400 tty2 linux c3:23:respawn:/sbin/agetty 38400 tty3 linux c4:23:respawn:/sbin/agetty 38400 tty4 linux c5:23:respawn:/sbin/agetty 38400 tty5 linux c6:23:respawn:/sbin/agetty 38400 tty6 linux #s1:23:respawn:/sbin/agetty 38400 ttyS0 vt100 #s2:23:respawn:/sbin/agetty 38400 ttyS1 vt100 m12:3:respawn:/sbin/agetty -nl /root/bin/mvs-menu 38400 tty12 linux #ca::ctrlaltdel:/sbin/shutdown -t3 -h now ca::ctrlaltdel:/root/bin/mvs-down # End of file
Tamibién se edita /etc/lilo.conf
realizando los cambios destacados en rojo:
# # /etc/lilo.conf: lilo(8) configuration, see lilo.conf(5) # lba32 install=text boot=/dev/hda prompt timeout=20 default=Mainframe image=/boot/vmlinuz label=Linux root=/dev/hda1 read-only append="quiet 2" image=/boot/vmlinuz label=Mainframe root=/dev/hda1 read-only append="quiet 3" # End of file
Y se activan los cambios ejecutando:
root@s370:~ # lilo Added Linux Added Mainframe * root@s370:~ # _
También es necesario activar la ejecución web de comandos (en tk4- viene activado por defecto, pero en tk4-plus no). Se edita conf/tk4-.cnf
y se elimina el comentario (marcado en rojo) a las líneas:
#HTTP PORT ${HTTPPORT:=8038} #HTTP ROOT hercules/httproot #HTTP START
Para terminar se cambia el /etc/rc.d/firewall
por este
#!/bin/bash #=============================================================================== # /etc/rc.d/firewall: (des)habilitar las reglas del firewall #------------------------------------------------------------------------------- . /etc/rc.conf IPTABLES="/usr/sbin/iptables" #------------------------------------------------------------------------------- IP0=192.168.56.41 # ETH0 - LAN NET0=192.168.56.0/24 function local_config { ssh_server web_server term3270 } #------------------------------------------------------------------------------- function ssh_server { # Servicio SSH/SFTP: solo red local # Debe coincidir con "sshd" en /etc/hosts.allow ${IPTABLES} -A INPUT -s ${NET0} -d ${IP0} -p tcp --dport ssh -j ACCEPT ${IPTABLES} -A OUTPUT -s ${IP0} -d ${NET0} -p tcp --sport ssh -j ACCEPT } function web_server { # Servicios HTTP(s): solo red local ${IPTABLES} -A INPUT -s ${NET0} -d ${IP0} \ -p tcp -m multiport --dports http,https -j ACCEPT ${IPTABLES} -A OUTPUT -s ${IP0} -d ${NET0} \ -p tcp -m multiport --sports http,https -j ACCEPT } function term3270 { # Terminal 3270 al mainframe ${IPTABLES} -A INPUT -s ${NET0} -d ${IP0} \ -p tcp --dport 3270 -j ACCEPT ${IPTABLES} -A OUTPUT -s ${IP0} -d ${NET0} \ -p tcp --sport 3270 -j ACCEPT } #------------------------------------------------------------------------------- case $1 in start|restart) echo -n "Aplicando Reglas de Firewall..." # Eliminar todas las reglas y prohibir acceso por defecto ${IPTABLES} -F ${IPTABLES} -X ${IPTABLES} -Z ${IPTABLES} -P INPUT DROP ${IPTABLES} -P OUTPUT DROP ${IPTABLES} -P FORWARD DROP # Permitir "localhost" y direcciones IP propias ${IPTABLES} -A INPUT -i lo -j ACCEPT ${IPTABLES} -A OUTPUT -o lo -j ACCEPT ${IPTABLES} -A INPUT -s ${IP0} -j ACCEPT ${IPTABLES} -A OUTPUT -d ${IP0} -j ACCEPT # Acceso a los servidores DNS incluidos en rc.conf for IP in ${DNS[@]} do if [ "${IP}" != "127.0.0.1" ] then ${IPTABLES} -A INPUT -s ${IP} -d ${IP0} \ -p udp --sport domain -j ACCEPT ${IPTABLES} -A OUTPUT -s ${IP0} -d ${IP} \ -p udp --dport domain -j ACCEPT fi done local_config # Acceso a los servidores NTP incluidos en rc.conf for IP in ${TIMESERVERS} do if [ "${IP}" != "127.0.0.1" ] then ${IPTABLES} -A INPUT -s ${IP} -d ${IP0} \ -p udp --sport ntp -j ACCEPT ${IPTABLES} -A OUTPUT -s ${IP0} -d ${IP} \ -p udp --dport ntp -j ACCEPT fi done # # Registrar paquetes no interceptados en el Log # ${IPTABLES} -A INPUT -j LOG --log-level debug # ${IPTABLES} -A OUTPUT -j LOG --log-level debug # Asegurar que no entra ni sale nada mas ${IPTABLES} -A INPUT -j DROP ${IPTABLES} -A OUTPUT -j DROP echo " OK." ;; stop) echo -n "Eliminando Reglas de Firewall..." # Eliminar todas las reglas y permitir acceso por defecto ${IPTABLES} -F ${IPTABLES} -X ${IPTABLES} -Z ${IPTABLES} -P INPUT ACCEPT ${IPTABLES} -P OUTPUT ACCEPT ${IPTABLES} -P FORWARD ACCEPT echo " OK." ;; status) $IPTABLES -L -n | less ;; *) echo "usage: $0 [ start | stop | restart | status ]" ;; esac #===============================================================================
y se añade a la línea SERVICES
(tras crond
y antes de sshd
y apache
) en el archivo /etc/rc.conf