config3270.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/sh
  2. #
  3. # config3270 -- Autoconfigure /dev/3270/* and /etc/inittab
  4. #
  5. # Usage:
  6. # config3270
  7. #
  8. # Output:
  9. # /tmp/mkdev3270
  10. #
  11. # Operation:
  12. # 1. Run this script
  13. # 2. Run the script it produces: /tmp/mkdev3270
  14. # 3. Issue "telinit q" or reboot, as appropriate.
  15. #
  16. P=/proc/tty/driver/tty3270
  17. ROOT=
  18. D=$ROOT/dev
  19. SUBD=3270
  20. TTY=$SUBD/tty
  21. TUB=$SUBD/tub
  22. SCR=$ROOT/tmp/mkdev3270
  23. SCRTMP=$SCR.a
  24. GETTYLINE=:2345:respawn:/sbin/mingetty
  25. INITTAB=$ROOT/etc/inittab
  26. NINITTAB=$ROOT/etc/NEWinittab
  27. OINITTAB=$ROOT/etc/OLDinittab
  28. ADDNOTE=\\"# Additional mingettys for the 3270/tty* driver, tub3270 ---\\"
  29. if ! ls $P > /dev/null 2>&1; then
  30. modprobe tub3270 > /dev/null 2>&1
  31. fi
  32. ls $P > /dev/null 2>&1 || exit 1
  33. # Initialize two files, one for /dev/3270 commands and one
  34. # to replace the /etc/inittab file (old one saved in OLDinittab)
  35. echo "#!/bin/sh" > $SCR || exit 1
  36. echo " " >> $SCR
  37. echo "# Script built by /sbin/config3270" >> $SCR
  38. if [ ! -d /dev/dasd ]; then
  39. echo rm -rf "$D/$SUBD/*" >> $SCR
  40. fi
  41. echo "grep -v $TTY $INITTAB > $NINITTAB" > $SCRTMP || exit 1
  42. echo "echo $ADDNOTE >> $NINITTAB" >> $SCRTMP
  43. if [ ! -d /dev/dasd ]; then
  44. echo mkdir -p $D/$SUBD >> $SCR
  45. fi
  46. # Now query the tub3270 driver for 3270 device information
  47. # and add appropriate mknod and mingetty lines to our files
  48. echo what=config > $P
  49. while read devno maj min;do
  50. if [ $min = 0 ]; then
  51. fsmaj=$maj
  52. if [ ! -d /dev/dasd ]; then
  53. echo mknod $D/$TUB c $fsmaj 0 >> $SCR
  54. echo chmod 666 $D/$TUB >> $SCR
  55. fi
  56. elif [ $maj = CONSOLE ]; then
  57. if [ ! -d /dev/dasd ]; then
  58. echo mknod $D/$TUB$devno c $fsmaj $min >> $SCR
  59. fi
  60. else
  61. if [ ! -d /dev/dasd ]; then
  62. echo mknod $D/$TTY$devno c $maj $min >>$SCR
  63. echo mknod $D/$TUB$devno c $fsmaj $min >> $SCR
  64. fi
  65. echo "echo t$min$GETTYLINE $TTY$devno >> $NINITTAB" >> $SCRTMP
  66. fi
  67. done < $P
  68. echo mv $INITTAB $OINITTAB >> $SCRTMP || exit 1
  69. echo mv $NINITTAB $INITTAB >> $SCRTMP
  70. cat $SCRTMP >> $SCR
  71. rm $SCRTMP
  72. exit 0