home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 August - Disc 1 / PCNET_CD_2006_08_1.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / usr / sbin / gaim-autosetup.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2006-02-21  |  2.9 KB  |  94 lines

  1. #!/bin/sh
  2. #
  3. # gaim-autosetup.sh -- generates autologin configuration for GAIM 
  4. #                      so that starting GAIM will log user into #puppylinux
  5. #
  6. # Copyright 2006 Jonathan Marsden
  7. #
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License version 2 ,
  10. # as published by the Free Software Foundation.
  11. #           
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU General Public License for more details.
  16. #                           
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  20.  
  21. IRCHOST='irc.freenode.net'
  22. IRCCHANNEL='#puppylinux'
  23. IRCPORT=6667
  24. PREFIX='PupUser-'
  25. GAIMCONFIGDIR=~/.gaim
  26. PROMPT="Enter the IRC Nickname you wish to use"
  27. XDIALOGOPTIONS="--stdout --no-buttons --title $0"
  28.  
  29. # Exit if either of the two files we are generating already exists
  30. if test -f $GAIMCONFIGDIR/accounts.xml
  31. then
  32.   exit 1
  33. fi
  34.  
  35. if test -f $GAIMCONFIGDIR/blist.xml
  36. then
  37.   exit 2
  38. fi
  39.  
  40. # Generate a semi-random IRC username
  41. USERNAME=$PREFIX`(date ;cat /proc/cpuinfo)|md5sum|sed -e's/^\(......\).*$/\1/'`
  42.  
  43. # Prompt for Nick if -v option used
  44. if test "$1" = "-v"
  45. then
  46.   NEWNAME=`Xdialog $XDIALOGOPTIONS --inputbox "$PROMPT" 0 0 "$USERNAME"`
  47.   if test "$?" -eq 0
  48.   then
  49.     USERNAME=`echo $NEWNAME |tr -cd 'A-Za-z0-9[-\`{-}'` # See RFC 2812 2.3.1
  50.   fi  
  51. fi
  52.  
  53. # Create the two config files
  54. cat >$GAIMCONFIGDIR/accounts.xml <<EOF
  55. <?xml version='1.0' encoding='UTF-8' ?>
  56.  
  57. <accounts version='1.0'>
  58.  <account>
  59.   <protocol>prpl-irc</protocol>
  60.   <name>$USERNAME@$IRCHOST</name>
  61.   <settings>
  62.    <setting name='username' type='string'>$USERNAME</setting>
  63.    <setting name='encoding' type='string'>UTF-8</setting>
  64.    <setting name='realname' type='string'>$USERNAME</setting>
  65.    <setting name='port' type='int'>$IRCPORT</setting>
  66.   </settings>
  67.   <settings ui='gtk-gaim'>
  68.    <setting name='auto-login' type='bool'>1</setting>
  69.   </settings>
  70.  </account>
  71. </accounts>
  72. EOF
  73.  
  74. cat >$GAIMCONFIGDIR/blist.xml <<EOF
  75. <?xml version='1.0' encoding='UTF-8' ?>
  76.  
  77. <gaim version='1.0'>
  78.         <blist>
  79.                 <group name="Buddies">
  80.                         <setting name="collapsed" type="bool">0</setting>
  81.                         <chat proto="prpl-irc" account="$USERNAME@$IRCHOST">
  82.                                 <component name="channel">$IRCCHANNEL</component>
  83.                                 <component name="password"></component>
  84.                                 <setting name="gtk-autojoin" type="bool">1</setting>
  85.                         </chat>
  86.                 </group>
  87.         </blist>
  88.         <privacy>
  89.                 <account proto="prpl-irc" name="$USERNAME@$IRCHOST" mode="1">
  90.                 </account>
  91.         </privacy>
  92. </gaim>
  93. EOF
  94.