]> www.wagner.pp.ru Git - oss/fubar.git/blob - setup_userdir
Reimport after CVS crash
[oss/fubar.git] / setup_userdir
1 #
2 # This is a helper script for FUBAR, which creates user preferences
3 # directory and populates it with default files, taken from system-wide
4 # library directory
5 #
6
7 if [llength [info command link]] {
8     proc symlink {source dest} {
9         link -sym $source $dest
10     }
11 } else {
12     proc symlink {source dest} {
13         exec ln -s $source $dest
14     }
15 }
16 #
17 # variables CONFIGDIR and LIBRARYDIR should be provided by invoking
18 # script
19 #
20 proc copyhier {src dest} {
21     file mkdir $dest
22     foreach f [glob -nocomplain $src/*] {
23         set s [file join $dest [file tail $f]]
24         if [catch {file readlink $f} d] {
25             if [file isdirectory $f] {
26                 copyhier $f $s 
27             } else {
28                 symlink $f $s 
29             }
30         } else {
31             symlink $d $s
32         }
33     }
34 }
35
36
37 file mkdir $CONFIGDIR
38 copyhier $LIBRARYDIR/menu $CONFIGDIR/menu
39
40 foreach file [glob -nocomplain $LIBRARYDIR/plugins/*] {
41         # skip documentation
42         if {[string match *.txt $file]} continue 
43         symlink $f [file join $CONFIGDIR plugins [file tail $file]]
44 }       
45
46 foreach f {hosts associations holydays} {
47   if [file exists $LIBRARYDIR/$f] {
48     file copy $LIBRARYDIR/$f $CONFIGDIR/$f
49   }
50 }
51
52 symlink $LIBRARYDIR/mail $CONFIGDIR/mail
53
54 close [open  "$CONFIGDIR/phonebook" a+]
55