summaryrefslogtreecommitdiffstats
path: root/misc/stardict-tools/sd
blob: c5592b2b71ae121a83db0158c442ee3f848f7495 (plain)
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
#!/bin/sh

# sd: the dictionaries collections manager for StarDict

#
# RUN THE BELOW COMMAND ONCE AS ROOT
#

# chgrp users /usr/share/stardict ; chmod 775 /usr/share/stardict ; exit

#
# RUN THE ABOVE COMMAND ONCE AS ROOT
#

if [ "$1" == "" ]
then
    cd /usr/share/stardict/
    ls -l | grep '\->' | sed 's/.* dic \->/dic ->/'
    ls | grep '^dic\.'
elif [ "$1" == "?" ]
then
    cd /usr/share/stardict/
    for d in dic.*
    do
	echo
	ls -l | grep $d | sed 's/.* dic/dic/'
	ls -1 /usr/share/stardict/$d
    done
elif [ "$2" == "?" ]
then
    if [ -e /usr/share/stardict/dic.$1 ]
    then
	ls -1 /usr/share/stardict/dic.$1
    else
	echo "There is no /usr/share/stardict/dic.$1."
    fi
elif [ -e /usr/share/stardict/dic.$1 ]
then
    if [ "$(ps ax | grep 'stardict' | grep -v 'grep')" != "" ]
    then
	killall stardict
    fi
    cd /usr/share/stardict/
    rm dic
    ln -s dic.$1 dic
    cd
    if [ ! -e ~/.stardict/stardict.cfg.$1 ]
    then
	cp ~/.stardict/stardict.cfg.template ~/.stardict/stardict.cfg.$1
    fi
    cp ~/.stardict/stardict.cfg.$1 ~/.stardict/stardict.cfg
    ls -l /usr/share/stardict/ | grep '\->' | sed 's/.* dic \->/dic ->/'
    ls -1 /usr/share/stardict/dic.$1
else
    echo "There is no /usr/share/stardict/dic.$1."
fi