-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·186 lines (154 loc) · 6.24 KB
/
install
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/usr/bin/env bash
set -eo pipefail
DOTFILES=$HOME/.dotfiles
ZSH=$HOME/.oh-my-zsh
#=========================================================================
# ---------------| Common |---------------
#=========================================================================
#kubectxAutoCompletion() {
# mkdir -p ~/.oh-my-zsh/completions
# chmod -R 755 ~/.oh-my-zsh/completions
# wget -O $HOME/.oh-my-zsh/completions/_kubectx.zsh https://raw.githubusercontent.com/ahmetb/kubectx/master/completion/_kubectx.zsh
# wget -O $HOME/.oh-my-zsh/completions/_kubens.zsh https://raw.githubusercontent.com/ahmetb/kubectx/master/completion/_kubens.zsh
#}
kubectlPlugin() {
kubectl krew install open-svc # -- Open the Kubernetes URL(s) for the specified service in your browser.
kubectl krew install pod-shell # -- Display a list of pods to execute a shell in
kubectl krew install node-shell # -- Spawn a root shell on a node via kubectl
kubectl krew install pod-lens # -- Show pod-related resources
kubectl krew install sick-pods # -- Find and debug Pods that are "Not Ready"
kubectl krew install neat # -- Remove clutter from Kubernetes manifests to make them more readable.
}
#=========================================================================
# ---------------| MacOS |---------------
#=========================================================================
macOS() {
if test ! $(which brew); then # -- Check for Homebrew and install if don't have it
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >>$HOME/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
setupRepo
brew update # -- Update Homebrew recipes
brew bundle install --file=$DOTFILES/Brewfile # -- Install all contents from Brewfile
# kubectxAutoCompletion
kubectlPlugin
}
#=========================================================================
# ---------------| Ubuntu |---------------
#=========================================================================
installEZA() {
sudo mkdir -p /etc/apt/keyrings
wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | sudo gpg --dearmor -o /etc/apt/keyrings/gierens.gpg
echo "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main" | sudo tee /etc/apt/sources.list.d/gierens.list
sudo chmod 644 /etc/apt/keyrings/gierens.gpg /etc/apt/sources.list.d/gierens.list
sudo apt update
sudo apt install -y eza
}
ubuntu() {
echo "$USER ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/$USER
# Ask for user confirmation before adding the SSH key
read -p "Do you want to add the SSH key from GitHub? (y/N): " confirm
confirm=${confirm:-N}
if [[ "$confirm" =~ ^[Yy]$ ]]; then
if [[ ! -d $HOME/.ssh ]]; then
mkdir -p $HOME/.ssh
chmod 700 $HOME/.ssh
fi
KEYS_URL="https://github.com/tankibaj.keys"
AUTHORIZED_KEYS_FILE="$HOME/.ssh/authorized_keys"
wget -qO- $KEYS_URL >> $AUTHORIZED_KEYS_FILE # -- Fetch SSH public key from GitHub profile
chmod 600 $AUTHORIZED_KEYS_FILE
echo "SSH key added to $AUTHORIZED_KEYS_FILE"
else
echo "Skipping adding SSH key."
fi
# Install necessary packages
sudo apt update
sudo apt install -qq -y zsh curl vim git jq zip ntp net-tools
# Call additional setup functions
installEZA
# Set ZSH as the default shell for the user
sudo usermod -s /usr/bin/zsh $(whoami)
setupRepo
}
#=========================================================================
# ---------------| Common |---------------
#=========================================================================
backup() {
if [[ -e $HOME/.zshrc ]]; then
cp $HOME/.zshrc $HOME/.zshrc.original
fi
if [[ -e $HOME/.bashrc ]]; then
cp $HOME/.bashrc $HOME/.bashrc.original
fi
}
cleanUp() {
if [[ -L $HOME/.p10k.zsh ]]; then
sudo rm -f $HOME/.p10k.zsh
fi
if [[ -L $HOME/.zshrc ]]; then
sudo rm -f $HOME/.zshrc
fi
if [[ -L $HOME/.gitignore ]]; then
sudo rm -f $HOME/.gitignore
fi
if [[ -d $DOTFILES ]]; then
sudo rm -rf $DOTFILES
fi
if [[ -d $ZSH ]]; then
sudo rm -rf $ZSH
fi
}
setupRepo() {
git clone https://github.com/tankibaj/dotfiles.git $DOTFILES # -- Clone Dotfiles
git clone https://github.com/ohmyzsh/ohmyzsh.git $ZSH # -- Clone Oh My Zsh
git clone https://github.com/romkatv/powerlevel10k.git $ZSH/themes/powerlevel10k # -- Clone PowerLeve10K theme
# -- Clone PowerLeve10K plugins for autosuggestion and syntax highlighting:
git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH/plugins/zsh-syntax-highlighting
ln -s $DOTFILES/.zshrc $HOME/.zshrc # -- Symlinks the .zshrc file from the .dotfiles/.zshrc
ln -s $DOTFILES/.p10k.zsh $HOME/.p10k.zsh # -- Symlinks the .p10k.zsh file from .dotfiles/.p10k.zsh
# -- Git config
ln -s $DOTFILES/.gitignore $HOME/.gitignore
if [[ -e $HOME/.gitconfig ]]; then
rm -f $HOME/.gitconfig
fi
ln -s $DOTFILES/.gitconfig $HOME/.gitconfig
# git config --global core.excludesfile $HOME/.dotfiles/.gitignore
# git config --global init.defaultBranch main
# git config --global alias.squash-all '!f() { count=$(git rev-list --count HEAD); git rebase -i HEAD~$((count - 1)); }; f'
}
install() {
echo
echo
echo "Setting up dotfiles....."
echo
echo
cleanUp # -- Remove old files and directories if exist
backup # -- Backup existing .zshrc or .bashrc before install Oh My Zsh
if [[ "$(uname -s)" == "Darwin" ]]; then
macOS
elif [[ "$(uname -s)" == "Linux" ]]; then
if [[ "$(cat /etc/issue | grep Ubuntu | awk '{ print $1}')" = "Ubuntu" ]] || [[ "$(cat /etc/issue | grep Debian | awk '{ print $1}')" = "Debian" ]]; then
ubuntu
fi
fi
echo
echo
echo "[INFO] Setup has been completed!!! Please restart your terminal"
echo
}
if [[ ! -d $DOTFILES ]]; then
install
else
read -p "[INFO] Dotfiles already installed. Do you want to reinstall? [y/N]: " confirmation
case $(echo $confirmation | tr '[A-Z]' '[a-z]') in
y | yes)
install
;;
*)
exit 1
;;
esac
fi