-
Notifications
You must be signed in to change notification settings - Fork 0
/
base.sh
executable file
·85 lines (76 loc) · 3.05 KB
/
base.sh
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
#!/bin/bash
OS_NAME="$(uname | awk '{print tolower($0)}')"
OS_FULL="$(uname -a)"
if [ "${OS_NAME}" == "linux" ]; then
if [ $(echo "${OS_FULL}" | grep -c "amzn1") -gt 0 ]; then
OS_TYPE="yum"
elif [ $(echo "${OS_FULL}" | grep -c "amzn2") -gt 0 ]; then
OS_TYPE="yum"
elif [ $(echo "${OS_FULL}" | grep -c "el6") -gt 0 ]; then
OS_TYPE="yum"
elif [ $(echo "${OS_FULL}" | grep -c "el7") -gt 0 ]; then
OS_TYPE="yum"
elif [ $(echo "${OS_FULL}" | grep -c "Ubuntu") -gt 0 ]; then
OS_TYPE="apt"
elif [ $(echo "${OS_FULL}" | grep -c "coreos") -gt 0 ]; then
OS_TYPE="apt"
fi
elif [ "${OS_NAME}" == "darwin" ]; then
OS_TYPE="brew"
fi
echo "================================================================================"
echo "${OS_NAME} [${OS_TYPE}]"
if [ "${OS_TYPE}" == "" ]; then
echo "Not supported OS. [${OS_NAME}]"
exit 1
fi
# brew for mac
if [ "${OS_TYPE}" == "brew" ]; then
command -v brew > /dev/null || ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
# for ubuntu
if [ "${OS_TYPE}" == "apt" ]; then
export LC_ALL=C
fi
# ssh keygen
[ ! -f ~/.ssh/id_rsa ] && ssh-keygen -q -f ~/.ssh/id_rsa -N ''
# update
echo "================================================================================"
echo "update..."
if [ "${OS_TYPE}" == "brew" ]; then
brew update && brew upgrade
command -v fzf > /dev/null || brew install fzf
command -v git > /dev/null || brew install git
command -v jenv > /dev/null || brew install jenv
command -v jq > /dev/null || brew install jq
command -v k9s > /dev/null || brew install k9s
command -v pyenv > /dev/null || brew install pyenv
command -v telnet > /dev/null || brew install telnet
command -v wget > /dev/null || brew install wget
# command -v tmux > /dev/null || brew install tmux
# command -v yq > /dev/null || brew install yq
# getopt
GETOPT=$(getopt 2>&1 | head -1 | xargs)
if [ "${GETOPT}" == "--" ]; then
brew install gnu-getopt
brew link --force gnu-getopt
fi
elif [ "${OS_TYPE}" == "apt" ]; then
sudo apt update && sudo apt upgrade -y
command -v ab > /dev/null || sudo apt install -y apache2-utils
command -v git > /dev/null || sudo apt install -y git
command -v jq > /dev/null || sudo apt install -y jq
command -v pip > /dev/null || sudo apt install -y python-pip
command -v telnet > /dev/null || sudo apt install -y telnet
# command -v tmux > /dev/null || sudo apt install -y tmux
# command -v yq > /dev/null || sudo apt install -y yq
elif [ "${OS_TYPE}" == "yum" ]; then
sudo yum update -y
command -v ab > /dev/null || sudo yum install -y httpd-tools
command -v git > /dev/null || sudo yum install -y git
command -v jq > /dev/null || sudo yum install -y jq
command -v pip > /dev/null || sudo yum install -y python-pip
command -v telnet > /dev/null || sudo yum install -y telnet
# command -v tmux > /dev/null || sudo yum install -y tmux
# command -v yq > /dev/null || sudo yum install -y yq
fi