summaryrefslogtreecommitdiff
path: root/bin/installer/includes/functions.sh
blob: a6f8c84101d01356c60bc6b6788da9de422e4323 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
function inst_configureOS() {
    echo "Platform: $OSTYPE"
    case "$OSTYPE" in
        solaris*) echo "Solaris is not supported yet" ;;
        darwin*)  source "$AC_PATH_INSTALLER/includes/os_configs/osx.sh" ;;  
        linux*)
            # If available, use LSB to identify distribution
            if [ -f /etc/lsb-release -o -d /etc/lsb-release.d ]; then
                DISTRO=$(lsb_release -i | cut -d: -f2 | sed s/'^\t'//)
            # Otherwise, use release info file
            else
                DISTRO=$(ls -d /etc/[A-Za-z]*[_-][rv]e[lr]* | grep -v "lsb" | cut -d'/' -f3 | cut -d'-' -f1 | cut -d'_' -f1)
            fi

            DISTRO=${DISTRO,,}

            # TODO: implement different configurations by distro
            source "$AC_PATH_INSTALLER/includes/os_configs/$DISTRO.sh"
        ;;
        bsd*)     echo "BSD is not supported yet" ;;
        msys*)    source "$AC_PATH_INSTALLER/includes/os_configs/windows.sh" ;;
        *)        echo "This platform is not supported" ;;
    esac
}

function inst_updateRepo() {
    git pull origin $(git rev-parse --abbrev-ref HEAD)
}

function inst_resetRepo() {
    git reset --hard $(git rev-parse --abbrev-ref HEAD)
    git clean -f
}

function inst_compile() {
    comp_configure
    comp_build
}

function inst_cleanCompile() {
    comp_clean
    inst_compile
}

function inst_assembleDb {
    dbasm_import true true true
}

function inst_allInOne() {
    inst_configureOS
    inst_updateRepo
    inst_compile
    inst_assembleDb
}

function inst_module_search {
    search=""
    if [ -z "$1" ]; then
        echo "Type what to search or leave blank for full list"
        read -p "Insert name: " res

        search="+$res"
    fi
    echo "Searching ..."
    echo "";

    for i in `curl -s "https://api.github.com/search/repositories?q=org%3Aazerothcore${search}+fork%3Atrue+topic%3Acore-module+sort%3Astars&type=" | grep \"name\" | cut -d ':' -f 2-3|tr -d '",'`; do
        echo "-> $i"; 
    done

    echo "";
    echo "";
}

function inst_module_install {
    if [ -z "$1" ]; then
        echo "Type the name of the module to install"
        read -p "Insert name: " res
    fi

    git clone "https://github.com/azerothcore/$res" "modules/$res" && echo "Done, please re-run compiling and db assembly. Read instruction on module repository for more information"

    echo "";
    echo "";
}

function inst_module_update {
    if [ -z "$1" ]; then
        echo "Type the name of the module to update"
        read -p "Insert name: " res
    fi

    cd "modules/$res"

    #git reset --hard master
    #git clean -f
    git pull origin master && echo "Done"

    cd "../../"

    echo "";
    echo "";
}

function inst_module_remove {
    if [ -z "$1" ]; then
        echo "Type the name of the module to remove"
        read -p "Insert name: " res
    fi

    rm -rf "modules/$res" && echo "Done"

    echo "";
    echo "";
}