File: install.sh

package info (click to toggle)
ding 1.1-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 4,320 kB
  • ctags: 9
  • sloc: tcl: 3,394; sh: 85; makefile: 54; perl: 13
file content (96 lines) | stat: -rwxr-xr-x 2,193 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/sh

DEFBINDIR="/usr/local/bin"
DEFLIBDIR="/usr/local/lib"

if [ "x`echo -n`" = "x-n" ]; then
    ECHO=echo
    END="\c"
else
    ECHO="echo -n"
    END=""
fi

echo "   --------------- Installation of Ding ---------------"
echo "A Dictionary lookup program and a German-English Dictionary"
echo ""

NEEDPROG="wish"

$ECHO "Looking for $NEEDPROG ... $END"
FOUND=0
OIFS="$IFS"
IFS=":"
# for d in `echo $PATH | sed -e 's/:/ /g'`; do
for d in $PATH; do
    if [ -x "$d/$NEEDPROG" ]; then
        FOUND=1
        DIR="$d"
        break
    fi
done
IFS="$OIFS"

if [ $FOUND -eq 0 ]; then
    echo  "Hmm, $NEEDPROG not found. You will need it to run 'ding'!"
    $ECHO "Install anyway?  [y]/n: $END"
    read yn
    if [ "x$yn" = "xn" -o "x$yn" = "xN" ]; then
        exit
    fi
else
    echo "found in $DIR"
fi
echo ""

OK=0
while [ $OK -eq 0 ] ; do
    $ECHO "Where do you want to install the program 'ding' [$DEFBINDIR]: $END"
    read BINDIR
    if [ "x$BINDIR" = "x" ]; then
        BINDIR=$DEFBINDIR
    fi
    if [ ! -d $BINDIR ]; then
        echo "No such directory: $BINDIR"
    elif [ ! -w $BINDIR ]; then
        echo "Can't write to $BINDIR - no permissions!"
    else
        OK=1
    fi
done
OK=0
while [ $OK -eq 0 ] ; do
    $ECHO "Where do you want to install the dictionary [$DEFLIBDIR]: $END"
    read LIBDIR
    if [ "x$LIBDIR" = "x" ]; then
        LIBDIR=$DEFLIBDIR
    fi 
    if [ ! -d $LIBDIR ]; then
        echo "No such directory: $BINDIR"
    elif [ ! -w $LIBDIR ]; then
        echo "Can't write to $LIBDIR - no permissions!"
    else
        OK=1
    fi
done                     

echo ""
$ECHO "Ok, install to $BINDIR and $LIBDIR? [y]/n: $END"
read yn
if [ "x$yn" != "xn" -a "x$yn" != "xN" ]; then
    sed -e "s#/usr/dict/ger-eng.txt#$LIBDIR/ger-eng.txt#" ding > /tmp/ding.$$
 
    echo /bin/cp ding "$BINDIR/ding"
    /bin/mv /tmp/ding.$$ "$BINDIR/ding"
    chmod 755 "$BINDIR/ding"
    echo /bin/cp ger-eng.txt "$LIBDIR/ger-eng.txt"
    /bin/cp ger-eng.txt "$LIBDIR/ger-eng.txt"
    chmod 644 "$LIBDIR/ger-eng.txt"
else
    echo "Install aborted."
    exit
fi
echo ""
if [ $? = 0 ]; then
    echo "Installation seems to be ok, have fun using $BINDIR/ding"
fi