-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRiceInstaller.sh
281 lines (241 loc) Β· 9.86 KB
/
RiceInstaller.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
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
#!/usr/bin/env bash
# ____ ___ ____ _ _ ___ _ _ ____ _____ _ _ _ _____ ____
# | _ \|_ _/ ___| | | | |_ _| \ | / ___|_ _|/ \ | | | | | ____| _ \
# | |_) || | | | |_| | | || \| \___ \ | | / _ \ | | | | | _| | |_) |
# | _ < | | |___| _ | | || |\ |___) || |/ ___ \| |___| |___| |___| _ <
# |_| \_|___\____|_| |_| |___|_| \_|____/ |_/_/ \_|_____|_____|_____|_| \_\
#
# Script to install kali's dotfiles
# Author: PunGrumpy
set -e
# Color definitions
RED="\033[0;31m"
GREEN="\033[0;32m"
YELLOW="\033[0;33m"
BLUE="\033[0;34m"
PURPLE="\033[0;35m"
CYAN="\033[0;36m"
BOLD="\033[1m"
RESET="\033[0m"
# URLs
declare -A URLS=(
["DOTFILE"]="https://github.com/PunGrumpy/kali-dotfiles.git"
["DOTFILE_SSH"]="[email protected]:PunGrumpy/kali-dotfiles.git"
["FISHER"]="https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish"
["FONT_HACK"]="https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.2/Hack.tar.xz"
["FONT_NOTOSANS"]="https://fonts.google.com/download?family=Noto%20Sans"
["FONT_NOTOSANS_THAI"]="https://fonts.google.com/download?family=Noto%20Sans%20Thai"
["BREWFILE"]="https://raw.githubusercontent.com/PunGrumpy/kali-dotfiles/main/Brewfile"
)
DOTFILE_DIR="$HOME/.dotfiles"
DATE=$(date +"%A %d %B %Y (%H:%M:%S)")
# Helper functions
print_banner() {
local text="$1"
echo -e "\n${BOLD}${BLUE}==== $text ====${RESET}\n"
}
print_step() {
local step="$1"
echo -e "${YELLOW}$step${RESET}"
}
print_success() {
local message="$1"
echo -e "${GREEN}β $message${RESET}"
}
print_error() {
local message="$1"
echo -e "${RED}β $message${RESET}"
}
confirm() {
local prompt="$1"
local default="${2:-Y}"
local options="Y/n"
[[ $default == "N" ]] && options="y/N"
while true; do
read -rp "$prompt [$options] " yn
case $yn in
[Yy]*) return 0 ;;
[Nn]*) return 1 ;;
"") [[ $default == "Y" ]] && return 0 || return 1 ;;
*) echo -e "${RED}Please answer yes or no.${RESET}" ;;
esac
done
}
# ASCII Art functions
ascii_ghost() {
echo -en "
ββββββββββ
ββββββββββββββββββββ
ββ ββββββββββ
ββ ββββββββ
ββββ ββββββββ
ββ ββββ ββββββ ββββββββ
ββ ββββ ββββββββ ββββββββ
ββββ ββ ββββ ββββββ ββββββββ
ββ ββββββββββββββββ
ββ ββ ββ ββββββ
ββ ββββ ββ ββββ
ββ ββββββ ββββββ ββββ
ββ ββββββββ ββββββ βββββ β β β β β β β β β β β ${RED}PunGrumpy Dotfiles${RESET}
ββββββββββββ ββ ββββββ ββββ
ββββββββ ββ ββββββββββ ββ ββββ
ββββββ ββ ββββββββββ ββ ββββ
ββββββ ββ ββββββββββ ββββββββββ
ββββββ ββ ββββββββββ ββββββββ
ββββββ ββββ ββββββββββ ββββββββββ
ββββββ ββββ ββββββββββββ ββββββββ
ββββββββββββββββββββββββββββββββ ββββββββ
ββββββββββββββββββββββββββββββββββββββββββ
ββββββββ ββββββββββββββββββββββ\n\n"
}
banner() {
local text="${1:?}"
ascii_ghost
printf ' %s [%s%s %s%s %s]%s\n\n' "${RED}" "${RESET}" "${YELLOW}" "${text}" "${RESET}" "${RED}" "${RESET}"
}
# Check if running as root
if [[ $EUID -eq 0 ]]; then
print_error "This script must NOT be run as root"
exit 1
fi
# Check if emoji is supported
if [[ $(locale charmap) != 'UTF-8' ]]; then
print_error "Emoji is not supported in your system"
exit 1
fi
# Welcome message
banner "π Welcome!"
echo -e "${BOLD}${CYAN}Date: $DATE${RESET}\n"
echo -e "This script will install and configure your Kali Linux rice."
echo -e "It will install necessary dependencies, clone dotfiles, and set up your environment."
echo -e "\n${BOLD}${RED}Note: You will be prompted for your password to install dependencies and make system changes.${RESET}\n"
confirm "Do you want to continue?" || exit 0
# Check internet connection
banner "π Checking Internet Connection"
if ping -q -c 1 -W 1 google.com >/dev/null; then
print_success "Internet connection available"
else
print_error "No internet connection"
exit 1
fi
# Install Homebrew
banner "πΊ Installing Homebrew"
if ! command -v brew >/dev/null; then
print_step "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
print_success "Homebrew installed"
else
print_success "Homebrew already installed"
fi
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
# Download Brewfile
banner "π₯ Downloading Brewfile"
print_step "Downloading Brewfile..."
curl -fsSL "${URLS["BREWFILE"]}" -o "$HOME/Brewfile"
if [ $? -eq 0 ]; then
print_success "Brewfile downloaded successfully"
else
print_error "Failed to download Brewfile"
exit 1
fi
# Install dependencies using downloaded Brewfile
banner "π¦ Installing dependencies"
print_step "Installing dependencies from downloaded Brewfile..."
brew bundle --file="$HOME/Brewfile"
if [ $? -eq 0 ]; then
print_success "Dependencies installed successfully"
else
print_error "Failed to install dependencies"
exit 1
fi
# Clean up downloaded Brewfile
rm "$HOME/Brewfile"
# Install Fisher and plugins
banner "π£ Installing Fisher and plugins"
if ! command -v fisher >/dev/null; then
print_step "Installing Fisher..."
curl -sL "${URLS["FISHER"]}" | source && fisher install jorgebucaran/fisher
print_success "Fisher installed"
else
print_success "Fisher already installed"
fi
fisher_plugins=(
"jethrokuan/z"
"PatrickF1/fzf.fish"
"nickeb96/puffer-fish"
"laughedelic/pisces"
"danhper/fish-ssh-agent"
"IlanCosman/tide@v6"
)
for plugin in "${fisher_plugins[@]}"; do
print_step "Installing $plugin..."
fisher install $plugin
done
# Clone dotfiles
banner "π Cloning dotfiles"
if [[ -d $DOTFILE_DIR ]]; then
if confirm "Dotfiles already exist. Do you want to delete and re-clone?"; then
rm -rf $DOTFILE_DIR
else
print_success "Skipping dotfiles clone"
fi
fi
if [[ ! -d $DOTFILE_DIR ]]; then
print_step "Cloning dotfiles..."
git clone "${URLS["DOTFILE_SSH"]}" "$DOTFILE_DIR" || git clone "${URLS["DOTFILE"]}" "$DOTFILE_DIR"
print_success "Dotfiles cloned"
fi
# Backup existing configurations
banner "π¦ Creating backup"
backup_dir="$HOME/.backup_dotfiles/$DATE"
mkdir -p "$backup_dir"
cp -R "$HOME/.config" "$HOME/.gitconfig" "$HOME/.gitignore" "$backup_dir"
print_success "Backup created at $backup_dir"
# Link dotfiles
banner "π Linking dotfiles"
for file in $DOTFILE_DIR/.config $DOTFILE_DIR/.gitignore $DOTFILE_DIR/.gitconfig; do
print_step "Linking $file..."
ln -sf "$file" "$HOME/"
done
# Install fonts
banner "π Installing fonts"
fonts_dir="$HOME/.local/share/fonts"
mkdir -p "$fonts_dir"
install_font() {
local url="$1"
local dest="$2"
curl -L "$url" -o "$dest"
tar -xf "$dest" -C "$fonts_dir"
rm -rf "$dest"
}
install_font "${URLS["FONT_HACK"]}" "$fonts_dir/Hack.tar.xz"
print_step "Installing Noto Sans font..."
sudo mkdir -p "/usr/share/fonts/noto-sans"
sudo curl -L "${URLS["FONT_NOTOSANS"]}" -o "/usr/share/fonts/noto-sans.zip"
sudo unzip "/usr/share/fonts/noto-sans.zip" -d "/usr/share/fonts/noto-sans"
sudo rm -rf "/usr/share/fonts/noto-sans.zip"
print_step "Installing Noto Sans Thai font..."
sudo mkdir -p "/usr/share/fonts/noto-sans-thai"
sudo curl -L "${URLS["FONT_NOTOSANS_THAI"]}" -o "/usr/share/fonts/noto-sans-thai.zip"
sudo unzip "/usr/share/fonts/noto-sans-thai.zip" -d "/usr/share/fonts/noto-sans-thai"
sudo rm -rf "/usr/share/fonts/noto-sans-thai.zip"
print_success "Fonts installed"
# Set fish as default shell
banner "π Setting fish as default shell"
if [[ "$SHELL" != "/home/linuxbrew/.linuxbrew/bin/fish" ]]; then
print_step "Changing default shell to fish..."
sudo chsh -s /home/linuxbrew/.linuxbrew/bin/fish $USER
print_success "Default shell changed to fish"
else
print_success "Fish is already the default shell"
fi
# Final message
banner "π Installation Complete"
echo -e "${BOLD}${GREEN}Your rice has been installed successfully!${RESET}"
echo -e "\n${BOLD}${YELLOW}Please restart your computer to apply all changes.${RESET}"
if confirm "Do you want to restart now?"; then
sudo reboot
else
echo -e "\n${BOLD}${CYAN}Remember to restart your computer later to apply all changes.${RESET}"
fi
exit 0