-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·77 lines (63 loc) · 1.88 KB
/
install.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
#!/usr/bin/env sh
PLATFORM="$(uname | awk '{print tolower($0)}')"
REPORTED_ARCH="$(uname -m)"
if [ "$REPORTED_ARCH" = "x86_64" ]; then
DOWNLOAD_ARCH="amd64"
elif [ "$REPORTED_ARCH" = "i686" ]; then
DOWNLOAD_ARCH="386"
elif [ "$REPORTED_ARCH" = "i386" ]; then
DOWNLOAD_ARCH="386"
elif [ "$REPORTED_ARCH" = "arm" ]; then
DOWNLOAD_ARCH="arm"
elif [ "$REPORTED_ARCH" = "armv7l" ]; then
DOWNLOAD_ARCH="arm"
elif [ "$REPORTED_ARCH" = "aarch64" ]; then
DOWNLOAD_ARCH="arm64"
elif [ "$REPORTED_ARCH" = "arm64" ]; then
DOWNLOAD_ARCH="arm64"
else
echo "Unknown Architecture"
exit
fi
URL="https://github.com/omranjamal/mono-cd/releases/latest/download/mono-cd_${PLATFORM}_${DOWNLOAD_ARCH}"
INSTALL_PATH="$HOME/.local/share/omranjamal/mono-cd"
create_directory() {
mkdir -p "$INSTALL_PATH" && return 0
}
download() {
echo "> download: 📥 downloading mono-cd_${DOWNLOAD_ARCH}" && \
wget -qO "$INSTALL_PATH/mono-cd" "$URL" && return 0
}
update_permissions() {
echo "> permissions: 💪 setting execution permission" && chmod +x "$INSTALL_PATH/mono-cd" && return 0
}
add_to_shell() {
if [ -f "$HOME/.bashrc" ]; then
echo "> detected: ~/.bashrc"
echo "> shell function: ⚡ Adding to ~/.bashrc"
$INSTALL_PATH/mono-cd --install "$HOME/.bashrc"
echo "\e[0m"
echo " 🚀 Run this, or re-start your bash terminal:"
echo " $ \e[1msource ~/.bashrc\e[0m"
echo "\e[2m"
fi
if [ -f "$HOME/.zshrc" ]; then
echo "> detected: ~/.zshrc"
echo "> shell function: ⚡ Adding to ~/.zshrc"
$INSTALL_PATH/mono-cd --install "$HOME/.zshrc"
echo "\e[0m"
echo " 🚀 Run this, or re-start your zsh terminal:"
echo " $ \e[1msource ~/.zshrc\e[0m"
echo "\e[2m"
fi
}
completed() {
return 0
}
printf "\e[2m"
create_directory && \
download && \
update_permissions && \
add_to_shell && \
completed
printf "\e[0m"