Guest User

Untitled

a guest
Jun 13th, 2010
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.78 KB | None | 0 0
  1. #!/bin/sh
  2. # Gconf Optimizer
  3. # Copyright 2006 Joel Bryan T. Juliano <[email protected]>
  4. # GNU Public License
  5.  
  6. gconf_share_dir="/usr/share/gconf"
  7. gconf_etc_dir="/etc/gconf"
  8. gconf_home_gnome_dir="$HOME/.gnome2"
  9. gconf_home_gconf_dir="$HOME/.gconf"
  10.  
  11. action_share="`find $gconf_share_dir -type f -exec file '{}' \; | grep "XML document text"`"
  12. action_etc="`find $gconf_etc_dir -type f -exec file '{}' \; | grep "XML document text"`"
  13. action_home_gnome="`find $gconf_home_gnome_dir -type f -exec file '{}' \; | grep "XML document text"`"
  14. action_home_gconf="`find $gconf_home_gconf_dir -type f -exec file '{}' \; | grep "XML document text"`"
  15.  
  16. gconf_file_list_share="`echo $action_share | sed 's/: XML document text//g'`"
  17. gconf_file_list_etc="`echo $action_etc | sed 's/: XML document text//g'`"
  18. gconf_file_list_home_gnome="`echo $action_home_gnome | sed 's/: XML document text//g'`"
  19. gconf_file_list_home_gconf="`echo $action_home_gconf | sed 's/: XML document text//g'`"
  20.  
  21. gconf_share_directories="`find $gconf_share_dir -type d`"
  22. gconf_etc_directories="`find $gconf_etc_dir -type d`"
  23. gconf_home_gnome_directories="`find $gconf_home_gnome_dir -type d`"
  24. home_gconf_directories="`find $gconf_home_gconf_dir -type d`"
  25.  
  26. tmpdir="/tmp"
  27. tmp_suffix="_tmp"
  28.  
  29. for a in $gconf_share_directories
  30. do
  31. mkdir -p "$tmpdir$a"
  32. done
  33.  
  34. for b in $gconf_etc_directories
  35. do
  36. mkdir -p "$tmpdir$b"
  37. done
  38.  
  39. for c in $gconf_home_gnome_directories
  40. do
  41. mkdir -p "$tmpdir$c"
  42. done
  43.  
  44. for d in $home_gconf_directories
  45. do
  46. mkdir -p "$tmpdir$d"
  47. done
  48.  
  49. counter=0
  50. rounds=2
  51.  
  52. while [ $counter -ne $rounds ]
  53.     do
  54.  
  55.         for f in $gconf_file_list_share
  56.         do
  57.         cat $f | sed -e '/^[ \t]*$/d;s,^[ \t]*,,;s,>[ \t]*<,><,g;s,[ \t]*$,,' > "$tmpdir$f$tmp_suffix"
  58.         cat "$tmpdir$f$tmp_suffix" | tr '\012' ' ' > "$tmpdir$f"  2> /dev/null
  59.         sudo cp "$tmpdir$f" "$f" 2> /dev/null
  60.         rm -rf "$tmpdir$f$tmp_suffix"
  61.         done
  62.  
  63.         for g in $gconf_file_list_etc
  64.         do
  65.         cat $g | sed -e '/^[ \t]*$/d;s,^[ \t]*,,;s,>[ \t]*<,><,g;s,[ \t]*$,,' > "$tmpdir$g$tmp_suffix"
  66.         cat "$tmpdir$g$tmp_suffix" | tr '\012' ' ' > "$tmpdir$g"  2> /dev/null
  67.         sudo cp "$tmpdir$g" "$g" 2> /dev/null
  68.         rm -rf "$tmpdir$g$tmp_suffix"
  69.         done
  70.  
  71.         for h in $gconf_file_list_home_gnome
  72.         do
  73.         cat $h | sed -e '/^[ \t]*$/d;s,^[ \t]*,,;s,>[ \t]*<,><,g;s,[ \t]*$,,' > "$tmpdir$h$tmp_suffix"
  74.         cat "$tmpdir$h$tmp_suffix" | tr '\012' ' ' > "$tmpdir$h"  2> /dev/null
  75.         sudo cp "$tmpdir$h" "$h" 2> /dev/null
  76.         rm -rf "$tmpdir$h$tmp_suffix"
  77.         done
  78.  
  79.         for i in $gconf_file_list_home_gconf
  80.         do
  81.         cat $i | sed -e '/^[ \t]*$/d;s,^[ \t]*,,;s,>[ \t]*<,><,g;s,[ \t]*$,,' > "$tmpdir$i$tmp_suffix"
  82.         cat "$tmpdir$i$tmp_suffix" | tr '\012' ' ' > "$tmpdir$i"  2> /dev/null
  83.         sudo cp "$tmpdir$i" "$i" 2> /dev/null
  84.         rm -rf "$tmpdir$i$tmp_suffix"
  85.         done
  86.  
  87.         counter=$(( $counter + 1 ))
  88.     done
Advertisement
Add Comment
Please, Sign In to add comment