summaryrefslogtreecommitdiff
path: root/compile.sh
blob: 43c8b4fd13312d7ab895a0f0aa27149a18a83be7 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash    

LORA_GATEWAY_DRIVER_PATH=../lora_gateway

TARGET_IP_ADDRESS=192.168.0.1
TARGET_PATH=/home/pi/lora-net
TARGET_USER=pi

clean_all() {
    make clean -C $LORA_GATEWAY_DRIVER_PATH
    if [ $? != 0 ]
    then
        echo "ERROR: Failed to clean $LORA_GATEWAY_DRIVER_PATH"
        exit 1
    fi
    make clean
    if [ $? != 0 ]
    then
        exit 1
    fi
}

build_all() {
    make all -C $LORA_GATEWAY_DRIVER_PATH
    if [ $? != 0 ]
    then
        echo "ERROR: Failed to compile $LORA_GATEWAY_DRIVER_PATH"
        exit 1
    fi
    make all
    if [ $? != 0 ]
    then
        exit 1
    fi
}

install() {
    scp ./lora_pkt_fwd/lora_pkt_fwd $TARGET_USER@$TARGET_IP_ADDRESS:$TARGET_PATH
    if [ $? != 0 ]
    then
        echo "ERROR: Failed to install the packet forwarder"
        echo "       target info: $TARGET_IP_ADDRESS, $TARGET_USER, $TARGET_PATH"
        exit 1
    fi
}   

case "$1" in
    install)
        install
    ;;

    clean)
        clean_all
    ;;

    cleanall)
        # clean and rebuild
        clean_all
        build_all
    ;;

    -h)
        echo "Compile the complete gateway software (driver & packet forwarder)"
        echo "Usage: $0 [clean/cleanall/install]"
        exit 1
    ;;

    *)
        # rebuild
        build_all
    ;;
esac

exit 0