home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / var / lib / dpkg / info / samba-common.postinst < prev    next >
Encoding:
Text File  |  2007-05-22  |  3.2 KB  |  105 lines

  1. #!/bin/sh
  2. #
  3. #
  4.  
  5. set -e
  6.  
  7. # Do debconf stuff here
  8. . /usr/share/debconf/confmodule
  9.  
  10. # We need a default smb.conf file. If one doesn't exist we put in place
  11. #    one that has some basic defaults.
  12. if [ ! -e /etc/samba/smb.conf ]; then
  13.     cp -a /usr/share/samba/smb.conf /etc/samba/
  14. fi
  15.  
  16. # Static tempfile location, dpkg-style
  17. TMPFILE=/etc/samba/smb.conf.dpkg-tmp
  18.  
  19. # ------------------------- Debconf questions start ---------------------
  20.  
  21. # Is the user configuring with debconf, or he/she prefers swat/manual
  22. #    config?
  23. db_get samba-common/do_debconf || true
  24. if [ "${RET}" = "true" ]; then
  25.     # Get workgroup name
  26.     db_get samba-common/workgroup || true
  27.     WORKGROUP="${RET}"
  28.  
  29.     # Oh my GOD, this is ugly.  Why would anyone put these
  30.     # characters in a workgroup name?  Why, Lord, why???
  31.     WORKGROUP=`echo $WORKGROUP | \
  32.                sed -e's/\\\\/\\\\\\\\/g
  33.                       s#/#\\\\/#g
  34.                       s/&/\\\&/g
  35.                       s/\\\$/\\\\\\\$/g'`
  36.  
  37.     sed -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
  38.         /^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ \
  39.             s/^\([[:space:]]*\)workgroup[[:space:]]*=.*/\1workgroup = ${WORKGROUP}/i" \
  40.         < /etc/samba/smb.conf >${TMPFILE}
  41.     mv -f ${TMPFILE} /etc/samba/smb.conf
  42.  
  43.     # Encrypt passwords?
  44.     db_get samba-common/encrypt_passwords || true
  45.     ENCRYPT_PASSWORDS="${RET}"
  46.  
  47.     sed -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
  48.         /^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ \
  49.                 s/^\([[:space:]]*\)encrypt passwords[[:space:]]*=.*/\1encrypt passwords = ${ENCRYPT_PASSWORDS}/i" \
  50.         < /etc/samba/smb.conf >${TMPFILE}
  51.     mv -f ${TMPFILE} /etc/samba/smb.conf
  52.  
  53.     # Install DHCP support
  54.     db_get samba-common/dhcp && DHCPVAL="$RET"
  55.     db_fget samba-common/dhcp applied || true
  56.     if [ "$DHCPVAL" = true ] && [ "$RET" != true ] && \
  57.        ! grep -q dhcp.conf /etc/samba/smb.conf
  58.     then
  59.         sed -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
  60.             /^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ {
  61.                 /wins server[[:space:]]*=/a \\
  62. \\
  63. # If we receive WINS server info from DHCP, override the options above. \\
  64.    include = /etc/samba/dhcp.conf
  65. }" < /etc/samba/smb.conf > ${TMPFILE}
  66.         mv -f ${TMPFILE} /etc/samba/smb.conf
  67.     elif [ "$RET" != true ] && grep -q dhcp.conf /etc/samba/smb.conf
  68.     then
  69.         :
  70.         # FIXME: here we /delete/ the lines?
  71.     fi
  72.     # Once we get here, the config has been applied, whatever
  73.     # it is.
  74.     if [ "$RET" != true ]; then
  75.         db_fset samba-common/dhcp applied true
  76.     fi
  77.  
  78.     if grep -qi "^[[:space:]]*passdb backend[[:space:]]*=.*unixsam" /etc/samba/smb.conf
  79.     then
  80.         sed -e 's/^\([[:space:]]*\)passdb backend/\1passdb backend/i
  81.             /^[[:space:]]*passdb backend/ {
  82.                 s/unixsam/guest/i
  83.             }' < /etc/samba/smb.conf > ${TMPFILE}
  84.         mv -f ${TMPFILE} /etc/samba/smb.conf
  85.     fi
  86.  
  87.     if [ -n "$2" ] && dpkg --compare-versions "$2" lt 3.0.23b-2 \
  88.        && grep -qi "^[[:space:]]*passdb backend[[:space:]]*=.*guest" /etc/samba/smb.conf
  89.     then
  90.         sed -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
  91.             /^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ \
  92.                     s/^\([[:space:]]*passdb backend[[:space:]]*=[^,]*\),\?[[:space:]]*guest[[:space:]]*$/\1/i" \
  93.             < /etc/samba/smb.conf >${TMPFILE}
  94.         mv -f ${TMPFILE} /etc/samba/smb.conf
  95.     fi
  96. fi
  97.  
  98. chmod a+r /etc/samba/smb.conf
  99.  
  100. # ------------------------- Debconf questions end ---------------------
  101.  
  102. db_stop
  103.  
  104.  
  105.