summaryrefslogtreecommitdiffstats
path: root/xlators/features/marker/utils/gsyncd.in
blob: a7af8c0b0b4674deb5ea5c7ad745d03b121024ca (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
#!/bin/sh

prefix="@prefix@"
exec_prefix="@exec_prefix@"
libexecdir=`eval echo "@libexecdir@"`
sbindir=`eval echo "@sbindir@"`

gluster="$sbindir"/gluster

# glusterd service autodetection

config_wanted=1
if [ "$_GLUSTERD_CALLED_" = 1 ]; then
    # OK, we know glusterd called us, no need to look for further config
    config_wanted=0
    # ... altough this conclusion should not inherit to our children
    unset _GLUSTERD_CALLED_
else
    # look for a -c option -- if present, we are already configured.

    for a in "$@"; do
        # -c found, see if it has an argument
        if [ "$one_more_arg" = 1 ]; then
            if echo "$a" | grep -qv ^-; then
                config_wanted=0
                break
            fi
            one_more_arg=0
        fi

        if [ "$a" = -c ] || [ "$a" = --config-file ]; then
            one_more_arg=1
            continue
        fi

        if echo $a | grep -qE '^(-c.|--config-file=)'; then
            config_wanted=0;
            break
        fi
    done

fi

if [ $config_wanted = 1 ]; then
    wd="`${gluster} system:: getwd`"
    if [ $? -eq 0 ]; then
        config_file="$wd/geo-replication/gsyncd.conf"
    fi
fi

if [ -z "$config_file" ]; then
    exec @PYTHON@ "$libexecdir"/glusterfs/python/syncdaemon/gsyncd.py "$@"
else
    exec @PYTHON@ "$libexecdir"/glusterfs/python/syncdaemon/gsyncd.py -c "$config_file" "$@"
fi