Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/sh
- set -e
- # summary of how this script can be called:
- # * <postinst> `configure' <most-recently-configured-version>
- # * <old-postinst> `abort-upgrade' <new version>
- # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
- # <new-version>
- # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
- # <failed-install-package> <version> `removing'
- # <conflicting-package> <version>
- # Enable debconf
- . /usr/share/debconf/confmodule
- BUILD_LTSP_CLIENT=false
- msg() {
- msg="$1"
- logger -p user.info -t ltsp-server "$msg"
- echo "ltsp-server: $msg"
- }
- case "$1" in
- configure)
- if [ ! "$(grep -sq '^/opt/ltsp' /etc/exports)" ] && [ "$(dpkg -l nfs-kernel-server|grep ii)" ]; then
- echo 'NOTE: you will probably want to add to /etc/exports:'
- echo '/opt/ltsp *(ro,no_root_squash,async)'
- echo 'and then run:'
- echo 'invoke-rc.d nfs-kernel-server reload'
- fi
- # Build LTSP chroot if debconf preseeding enabled it
- db_get ltsp-server/build_client
- if [ true = "$RET" ] ; then
- BUILD_LTSP_CLIENT=true
- fi
- # enable the ldm info daemon in inetd.conf
- update-inetd --group LTSP --add "9572 stream tcp nowait nobody /usr/sbin/tcpd /usr/sbin/nbdswapd"
- # Check if we are in an environment where /opt/ltsp/i386 already exists (Trisquel)
- # and if so, configure it properly
- if [ -f /etc/trisquel_ltsp_install ] && [ -d /opt/ltsp/i386 ]; then
- rm /etc/trisquel_ltsp_install
- # Generate ssh keys if missing
- if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
- ssh-keygen -q -f /etc/ssh/ssh_host_rsa_key -N "" -t rsa
- fi
- if [ ! -f /etc/ssh/ssh_host_dsa_key ]; then
- ssh-keygen -q -f /etc/ssh/ssh_host_dsa_key -N "" -t dsa
- fi
- if [ ! -f /etc/ssh/ssh_host_ecdsa_key ]; then
- ssh-keygen -q -f /etc/ssh/ssh_host_ecdsa_key -N "" -t ecdsa
- fi
- # Add entries to ssh_known_hosts for the idefault IP and current hostname
- if [ -f /etc/ssh/ssh_host_rsa_key ]; then
- rsa_key=$(cat /etc/ssh/ssh_host_rsa_key.pub | cut -d " " -f 2)
- echo "$(cat /etc/hostname) ssh-rsa $rsa_key" > /opt/ltsp/i386/etc/ssh/ssh_known_hosts
- echo "192.168.0.254 ssh-rsa $rsa_key" >> /opt/ltsp/i386/etc/ssh/ssh_known_hosts
- fi
- if [ -f /etc/ssh/ssh_host_dsa_key ]; then
- dsa_key=$(cat /etc/ssh/ssh_host_dsa_key.pub | cut -d " " -f 2)
- echo "$(cat /etc/hostname) ssh-dsa $dsa_key" >> /opt/ltsp/i386/etc/ssh/ssh_known_hosts
- echo "192.168.0.254 ssh-dsa $dsa_key" >> /opt/ltsp/i386/etc/ssh/ssh_known_hosts
- fi
- if [ -f /etc/ssh/ssh_host_ecdsa_key ]; then
- ecdsa_key=$(cat /etc/ssh/ssh_host_ecdsa_key.pub | cut -d " " -f 2)
- echo "$(cat /etc/hostname) ssh-ecdsa $ecdsa_key" >> /opt/ltsp/i386/etc/ssh/ssh_known_hosts
- echo "192.168.0.254 ssh-ecdsa $ecdsa_key" >> /opt/ltsp/i386/etc/ssh/ssh_known_hosts
- fi
- # Rebuild the image
- ltsp-update-image -a i386
- ltsp-update-kernels
- fi
- ;;
- abort-upgrade|abort-remove|abort-deconfigure)
- ;;
- *)
- echo "postinst called with unknown argument \`$1'" >&2
- exit 1
- ;;
- esac
- if [ true = "$BUILD_LTSP_CLIENT" ] ; then
- if [ -d "/opt/ltsp/$(dpkg --print-architecture)" ] ; then
- msg "warning: LTSP client environment already exist. Not generating."
- else
- if ltsp-build-client >/var/log/ltsp-server-build.log 2>&1 </dev/null ; then
- msg "error: generating LTSP client failed. exit code $?"
- fi
- fi
- fi
- db_stop
- # dh_installdeb will replace this with shell code automatically
- # generated by other debhelper scripts.
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement