aboutsummaryrefslogtreecommitdiff
path: root/install.sh
blob: 104dfa5a1bb85f8587b42717cfdca74062c490ae (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
#!/bin/bash

# install.sh

check_is_sudo() {
    if [ "$EUID" -ne 0 ]; then
        echo "Please run as root."
        exit
    fi
}

usage() {
    echo "Usage: sudo bash install.sh [OPTION]"
    echo "  base - install base pkgs"
    echo "  dotfiles - get dotfiles from GitHub and set soft links"
    echo "  all - install all things listed above"
}

base_install() {
    echo "--------- Install Base Packages Now ---------"
    if command -v apt > /dev/null; then
        apt update
        apt upgrade
        apt install git \
            curl \
            cmake \
            build-essential \
            python3-dev \
            autojump \
            zsh \
            gcc \
            make \

            pkg-config autoconf automake \
            python3-docutils \
            libseccomp-dev \
            libjansson-dev \
            libyaml-dev \
            libxml2-dev
    else if command -v pacman > /dev/null; then
        pacman -S autojump
    else if command -v brew > /dev/null; then
        brew install autojump
    fi
    # Universal Ctags
    git clone [email protected]:universal-ctags/ctags.git
    (
    cd ctags
    ./autogen.sh
    ./configure
    make
    make install
    )
}

get_dotfiles() {
    # create subshell
    (
    echo "--------- Get Dotfiles Now ---------"

    read -r -p "It will remove the dotfiles folder if it exists and overwrite all dotfiles. Are you sure? [y/N] " response
    response=${response,,} # tolower
    if [[ "$response" =~ ^(yes|y)$ ]]; then

        cd "$HOME"
        rm -rf dotfiles
        git clone [email protected]:humpylin/dotfiles.git

        rm -rf .vimrc .tmux.conf .bashrc .zshrc .gitconfig
        ln -s dotfiles/.vimrc .vimrc
        ln -s dotfiles/.tmux.conf .tmux.conf
        ln -s dotfiles/.bashrc .bashrc
        ln -s dotfiles/.gitconfig .gitconfig
        ln -s dotfiles/.zshrc .zshrc
    fi
    )
}

main() {
    local cmd=$1

    if [[ -z "$cmd" ]]; then
        usage
        exit 1
    fi

    check_is_sudo

    if [[ $cmd == all ]]; then
        base_install
        get_dotfiles
    fi
}

main "$@"