Advertisement
quiliro

/var/lib/dpkg/info/ltsp-server.postinst

Aug 21st, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. #! /bin/sh
  2.  
  3. set -e
  4.  
  5. # summary of how this script can be called:
  6. # * <postinst> `configure' <most-recently-configured-version>
  7. # * <old-postinst> `abort-upgrade' <new version>
  8. # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
  9. # <new-version>
  10. # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
  11. # <failed-install-package> <version> `removing'
  12. # <conflicting-package> <version>
  13.  
  14. # Enable debconf
  15. . /usr/share/debconf/confmodule
  16.  
  17. BUILD_LTSP_CLIENT=false
  18.  
  19. msg() {
  20. msg="$1"
  21. logger -p user.info -t ltsp-server "$msg"
  22. echo "ltsp-server: $msg"
  23. }
  24.  
  25. case "$1" in
  26. configure)
  27. if [ ! "$(grep -sq '^/opt/ltsp' /etc/exports)" ] && [ "$(dpkg -l nfs-kernel-server|grep ii)" ]; then
  28. echo 'NOTE: you will probably want to add to /etc/exports:'
  29. echo '/opt/ltsp *(ro,no_root_squash,async)'
  30. echo 'and then run:'
  31. echo 'invoke-rc.d nfs-kernel-server reload'
  32. fi
  33. # Build LTSP chroot if debconf preseeding enabled it
  34. db_get ltsp-server/build_client
  35. if [ true = "$RET" ] ; then
  36. BUILD_LTSP_CLIENT=true
  37. fi
  38. # enable the ldm info daemon in inetd.conf
  39. update-inetd --group LTSP --add "9572 stream tcp nowait nobody /usr/sbin/tcpd /usr/sbin/nbdswapd"
  40.  
  41.  
  42. # Check if we are in an environment where /opt/ltsp/i386 already exists (Trisquel)
  43. # and if so, configure it properly
  44. if [ -f /etc/trisquel_ltsp_install ] && [ -d /opt/ltsp/i386 ]; then
  45. rm /etc/trisquel_ltsp_install
  46.  
  47. # Generate ssh keys if missing
  48. if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
  49. ssh-keygen -q -f /etc/ssh/ssh_host_rsa_key -N "" -t rsa
  50. fi
  51. if [ ! -f /etc/ssh/ssh_host_dsa_key ]; then
  52. ssh-keygen -q -f /etc/ssh/ssh_host_dsa_key -N "" -t dsa
  53. fi
  54. if [ ! -f /etc/ssh/ssh_host_ecdsa_key ]; then
  55. ssh-keygen -q -f /etc/ssh/ssh_host_ecdsa_key -N "" -t ecdsa
  56. fi
  57.  
  58. # Add entries to ssh_known_hosts for the idefault IP and current hostname
  59. if [ -f /etc/ssh/ssh_host_rsa_key ]; then
  60. rsa_key=$(cat /etc/ssh/ssh_host_rsa_key.pub | cut -d " " -f 2)
  61. echo "$(cat /etc/hostname) ssh-rsa $rsa_key" > /opt/ltsp/i386/etc/ssh/ssh_known_hosts
  62. echo "192.168.0.254 ssh-rsa $rsa_key" >> /opt/ltsp/i386/etc/ssh/ssh_known_hosts
  63. fi
  64.  
  65. if [ -f /etc/ssh/ssh_host_dsa_key ]; then
  66. dsa_key=$(cat /etc/ssh/ssh_host_dsa_key.pub | cut -d " " -f 2)
  67. echo "$(cat /etc/hostname) ssh-dsa $dsa_key" >> /opt/ltsp/i386/etc/ssh/ssh_known_hosts
  68. echo "192.168.0.254 ssh-dsa $dsa_key" >> /opt/ltsp/i386/etc/ssh/ssh_known_hosts
  69. fi
  70.  
  71. if [ -f /etc/ssh/ssh_host_ecdsa_key ]; then
  72. ecdsa_key=$(cat /etc/ssh/ssh_host_ecdsa_key.pub | cut -d " " -f 2)
  73. echo "$(cat /etc/hostname) ssh-ecdsa $ecdsa_key" >> /opt/ltsp/i386/etc/ssh/ssh_known_hosts
  74. echo "192.168.0.254 ssh-ecdsa $ecdsa_key" >> /opt/ltsp/i386/etc/ssh/ssh_known_hosts
  75. fi
  76.  
  77. # Rebuild the image
  78. ltsp-update-image -a i386
  79. ltsp-update-kernels
  80. fi
  81. ;;
  82.  
  83. abort-upgrade|abort-remove|abort-deconfigure)
  84.  
  85. ;;
  86.  
  87. *)
  88. echo "postinst called with unknown argument \`$1'" >&2
  89. exit 1
  90. ;;
  91. esac
  92.  
  93. if [ true = "$BUILD_LTSP_CLIENT" ] ; then
  94. if [ -d "/opt/ltsp/$(dpkg --print-architecture)" ] ; then
  95. msg "warning: LTSP client environment already exist. Not generating."
  96. else
  97. if ltsp-build-client >/var/log/ltsp-server-build.log 2>&1 </dev/null ; then
  98. msg "error: generating LTSP client failed. exit code $?"
  99. fi
  100. fi
  101. fi
  102.  
  103. db_stop
  104.  
  105. # dh_installdeb will replace this with shell code automatically
  106. # generated by other debhelper scripts.
  107.  
  108.  
  109.  
  110. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement