]> err.no Git - dotfiles/blob - link-dotfiles
loosen font specs a bit
[dotfiles] / link-dotfiles
1 #! /bin/sh
2
3 # Do the solaris dance to get a real shell.
4 if [ ! -d ~root ]  ; then
5     if exec /usr/xpg4/bin/sh $0 "$@" ; then
6         echo "No POSIX shell available, call <person responsible>";
7         exit
8     fi
9 fi
10
11 KNOWNMD5SUMS=$(cat <<EOF
12 006050225ddcf746105440fe2e239455
13 22bfb8c1dd94b5f3813a2b25da67463f
14 3a2cb73ec920744185de72cd55f19e21
15 40b31b69676f239da8a2c7f0b375b879
16 4f1b2088f8e15011ee1e0306c2d64cee
17 508db38f182e99be2ddbe78d2c5b92ca
18 57a81d1c93493a29c4c3eba3490c8d2a
19 694af1f3e59a85ea124dc04d6992a5dc
20 7455657be214e67f36009154d3653e1b
21 7d550185ecf13512f3cb6d82228a0480
22 914d3bb4d80f787f100a5f298343d7e0
23 ab95ebdcfc2acb958912ac1c9dc7350d
24 b5239e7dfbecaf832e18a5377b794b09
25 bcf280733af4838244de094bca4c0316
26 c5f1155761187900cbb3b6554c2b2533
27 cc44c6693e6313d26d665aac57f7b7f7
28 d1a8c44e7dd1bed2f3e75d1343b6e4e1
29 d8e9ecd0b80102c82966a045544bbf68
30 d96c12497684c56ea77d9d1f589b0634
31 de2b922ef0623ba36dda5fb6f7f7d9ea
32 e18d7cffe9023214e4768df0865299ce
33 e9d2739d6f3d7672222c07d901d46e21
34 ee190fd94cb7bfe8a663447386c065e8
35 ef6c1cd4a3d89a2c0f6b16d209d27ab7
36 f2a26bacd5cd1a2a5c294dbb2da8d58b
37 084a1a5de99b4e9ec2bc6b029d9a6b2a
38 3e8337f44f84b298a8a99869ae8ca76a
39 f119c865306c35e64eb00f65d7279664
40 06577ad194f3e671d6c5b88d6b925f10
41 60e17d4bf5a626a29b440fc9d3d71af6
42 EOF
43 )
44
45 DOTFILESDIR=$HOME/dotfiles
46 MD5SUM=`which md5sum`
47 if test -z "$MD5SUM" || ! test -x "$MD5SUM"; then
48     MD5SUM=`which md5`
49 fi
50 if test -z "$MD5SUM" || ! test -x "$MD5SUM"; then
51     MD5SUM=`which openssl`
52     if test -x "$MD5SUM"; then
53         MD5SUM="$MD5SUM md5"
54     fi
55 fi
56
57 if test ! -d $DOTFILESDIR; then
58     echo "$DOTFILESDIR does not exist!  exiting"
59     exit 1
60 fi
61
62 if test -z "$MD5SUM"; then
63     echo "Cannot find md5sum program"
64     exit 1
65 fi
66
67 linkdir () {
68     for file in $1/*; do
69         file=`basename $file`
70         if test "$file" = "CVS" || test "$file" = "`basename $0`" || test "`echo $file | sed 's/^.*\(.\)/\1/'`" = "~"; then
71             continue
72         elif test -d  "$1/$file"; then
73             if test ! -d "$2/$DOT$file"; then
74                 mkdir $2/$DOT$file
75             fi
76             local OLDDOT=$DOT
77             local DOT=
78             linkdir $1/$file $2/$OLDDOT$file
79             DOT=$OLDDOT
80             continue
81         elif test ! -f "$1/$file"; then
82             continue
83         fi
84         if test -f $2/$DOT$file; then
85             C_MD5SUM=`$MD5SUM < $2/$DOT$file | awk '{print $1}'`
86             N_MD5SUM=`$MD5SUM < $1/$file | awk '{print $1}'`
87             if test "$C_MD5SUM" = "$N_MD5SUM"; then
88                 rm -f $2/$DOT$file
89             else
90                 found=0
91                 for md5 in $KNOWNMD5SUMS; do
92                     if [ "$md5" = "$C_MD5SUM" ]; then
93                         rm -f $2/$DOT$file
94                         found=1
95                         break
96                     fi
97                 done
98                 if [ "$found" = "0" ]; then
99                     echo "$2/$DOT$file different from $1/$file, not known ok, and not symlink: skipping"
100                     continue
101                 fi
102             fi
103         fi
104         ln -s $1/$file $2/$DOT$file
105     done
106 }
107 DOT=.
108 linkdir $DOTFILESDIR $HOME