-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·81 lines (67 loc) · 1.7 KB
/
setup.sh
File metadata and controls
executable file
·81 lines (67 loc) · 1.7 KB
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
#!/bin/bash
OSNAME=`uname -s`
function unsupported() {
echo "Unsupported Operating System: $1"
exit 1
}
function msg() {
echo -n -e "\x1B[1;36m### $1\x1B[0m"
}
function install_bin() {
local _binary=$1
local _install="$2"
msg "Checking for ${_binary}... "
which $_binary
[[ $? -ne 0 ]] && echo "missing. Going to install" && $_install
}
function set_git_user() {
git config --global user.name > /dev/null
if [ $? -ne 0 ]; then
msg "Enter your full name: "
read USER
git config --global user.name "$USER"
fi
git config --global user.email > /dev/null
if [ $? -ne 0 ]; then
msg "Enter your e-mail address: "
read EMAIL
git config --global user.email $MAIL
fi
}
function run_ansible() {
msg "Running Ansible playbook...\n"
ansible-playbook -i hosts -K site.yml
}
function install_mac() {
set_git_user
install_bin pip 'sudo easy_install pip'
install_bin ansible 'sudo pip install ansible'
install_bin brew '/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"'
run_ansible
}
function install_ubuntu() {
set_git_user
install_bin pip 'sudo apt -y install python-pip'
install_bin ansible 'sudo pip install ansible'
run_ansible
}
function install_fedora() {
set_git_user
install_bin pip 'sudio yum -y install python3-pip'
install_bin ansible 'sudo pip install ansible'
run_ansible
}
function install_linux() {
DISTNAME=`lsb_release -si`
case $DISTNAME in
'Ubuntu') install_ubuntu ;;
'Fedora') install_fedora ;;
*) unsupported $DISTNAME ;;
esac
}
case $OSNAME in
'Darwin') install_mac ;;
'Linux') install_linux ;;
*) unsupported $OSNAME ;;
esac
exit 0