aboutsummaryrefslogtreecommitdiffstats
path: root/net-p2p/mldonkey-serverspy/files/wrapper.sh
blob: a47d229bf3790f25c025c97de8349d7616b48fd3 (plain) (blame)
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
#!/bin/sh

PREFIX="%%PREFIX%%"
CONFIG="%%CONFIG%%"
IMAGE="%%IMAGE%%"
PROGRAM="${0}"
DIRNAME=${HOME}/.mldonkey-serverspy

if [ ! -d ${DIRNAME} ]
then
    mkdir -p ${DIRNAME}
fi

if [ ! -h ${DIRNAME}/${PROGRAM##*/} ]
then
    ln -sf ${PREFIX}/bin/${PROGRAM##*/}-real ${DIRNAME}/${PROGRAM##*/}
fi

if [ ! -f ${DIRNAME}/${IMAGE} -o ! -h ${DIRNAME}/${IMAGE} ]
then
    ln -sf ${PREFIX}/share/mldonkey-serverspy/${IMAGE} \
        ${DIRNAME}/${IMAGE}
fi

if [ ! -f ${DIRNAME}/${CONFIG} ]
then
    rm -f ${DIRNAME}/${CONFIG}
    cp -f ${PREFIX}/share/mldonkey-serverspy/${CONFIG} \
        ${DIRNAME}/${CONFIG}

    echo Edit the configuration file ${DIRNAME}/${CONFIG} then run ${PROGRAM##*/} again.
else
    echo " ${*} " | grep " \-createdironly " ||
    {
        cd ${DIRNAME} &&
        echo Running under ${DIRNAME} &&
        exec ./${PROGRAM##*/} "${@}" ||
        echo PROBLEM. Cannot create directory ${DIRNAME}, make sure you have the proper permissions to create it and try again
    }
fi