-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_utilities.sh
executable file
·107 lines (104 loc) · 3.56 KB
/
setup_utilities.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash -x
# ---------------------------------------------------------------------------- #
# Flags
# ---------------------------------------------------------------------------- #
# -s skip updates
#
#
#
SKIPUPDATE=false
while getopts ":s" opt; do
case ${opt} in
s )
SKIPUPDATE=true
;;
\? )
echo "Invalid option: $OPTARG" 1>&2
;;
esac
done
shift $((OPTIND -1))
# ---------------------------------------------------------------------------- #
# Find package manager
# ---------------------------------------------------------------------------- #
if [[ -x "/usr/bin/apt-get" ]]; then
PCK_MGR="/usr/bin/apt-get"
elif [[ -x "/usr/bin/yum" ]]; then
PCK_MGR="/usr/bin/yum"
else
echo "Not yum or apt: exiting"
exit 1
fi
if [[ $SKIPUPDATE == false ]]; then
$PCK_MGR update -y || echo "Some packages failed to update"
fi
# ---------------------------------------------------------------------------- #
# Setup vim
# https://github.com/neovim/neovim/wiki/Installing-Neovim
# https://spacevim.org/
# ---------------------------------------------------------------------------- #
if ! command -V nvim; then
if ! command -V python3; then
curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim.appimage
chmod u+x nvim.appimage
./nvim.appimage --appimage-extract
ln -sv $PWD/squashfs-root/usr/bin/nvim /usr/bin
elif [[ $PCK_MGR == "/usr/bin/yum" ]]; then
# adds repository for yum package manager
$PCK_MGR install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm;
$PCK_MGR install -y python3-neovim neovim
else
$PCK_MGR install -y neovim
fi
else
echo "neovim already installed"
fi
if [[ ! -d "$HOME/.SpaceVim" ]]; then
curl -sLf https://spacevim.org/install.sh | bash
else
echo "SpaceVim already installed"
fi
# ---------------------------------------------------------------------------- #
# Install kubernetes
# ---------------------------------------------------------------------------- #
if ! command -V kubectl; then
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x ./kubectl
mv ./kubectl /usr/local/bin/kubectl
else
echo "kubectl already installed"
fi
# ---------------------------------------------------------------------------- #
# Install YQ
# ---------------------------------------------------------------------------- #
if ! command -V yq; then
YQVERSION='3.4.0'
YQBINARY='yq_linux_amd64'
curl -LO "https://github.com/mikefarah/yq/releases/download/$YQVERSION/$YQBINARY"
chmod +x ./$YQBINARY
mv ./$YQBINARY /usr/bin/yq
else
echo "yq already installed"
fi
# ---------------------------------------------------------------------------- #
# Install Terraform
# ---------------------------------------------------------------------------- #
if ! command -V terraform; then
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install terraform
else
echo "Terraform already installed"
fi
# ---------------------------------------------------------------------------- #
# Cleanup file ownership
# ---------------------------------------------------------------------------- #
if ! logname; then
THISUSER="$USER"
else
THISUSER="$(logname)"
fi
if [[ "$THISUSER" != "root" ]]; then
echo "updating file ownership of home directory"
chown -R "$THISUSER":"$THISUSER" "$HOME"
fi