-
Notifications
You must be signed in to change notification settings - Fork 3
/
install
165 lines (152 loc) · 6.87 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
#!/bin/bash
#Color Variables
NC='\e[0m'
BLACK='\e[0;30m'
RED='\e[0;31m'
GREEN='\e[0;32m'
WHITE='\e[1;37m'
ORANGE='\e[0;33m'
BLUE='\e[0;34m'
PURPLE='\e[0;35m'
CYAN='\e[0;36m'
YELLOW='\e[1;33m'
DARGRAY='\e[1;30m'
#Lighter Colors
LIGRAY='\e[0;37m'
LIGREEN='\e[1;32m'
LIRED='\e[1;31m'
LIBLUE='\e[1;34m'
LIPURPLE='\e[1;35m'
LICYAN='\e[1;36m'
#Background Color Variables
BACKBLACK='\e[0;40m'
BACKRED='\e[0;41m'
BACKGREEN='\e[0;42m'
BACKWHITE='\e[1;47m'
BACKORANGE='\e[0;43m'
BACKBLUE='\e[0;44m'
BACKPURPLE='\e[0;45m'
BACKCYAN='\e[0;46m'
BACKYELLOW='\e[1;43m'
#Lighter Colors
BACKLIGRAY='\e[0;47m'
BACKLIGREEN='\e[1;42m'
BACKLIRED='\e[1;41m'
BACKLIBLUE='\e[1;44m'
BACKLIPURPLE='\e[1;45m'
BACKLICYAN='\e[1;46m'
#Markup Variables
UNDERLINE='\e[4m'
BOLD='\e[1m'
BLINK='\e[5m'
REVVID='\e[7m'
# Code
if [ "$(whoami)" == "root" ]; then
sudo=""
else
sudo="sudo"
fi
if [[ ! "$SHELL" =~ "bash" ]]; then
echo -e "${YELLOW}You aren't using bash... This install script (and ${LICYAN}update${YELLOW}) is written in bash, so you might have some problems.${NC}"
fi
case $(uname) in
Linux)
if [[ "$(cat /etc/*-release || cat /etc/issue || lsb_release -a)" =~ "debian" ]] || [[ "$(cat /etc/*-release || cat /etc/issue || lsb_release -a)" =~ "Debian" ]] || [[ "$(cat /etc/*-release || cat /etc/issue || lsb_release -a)" =~ "ubuntu" ]] || [[ "$(cat /etc/*-release || cat /etc/issue || lsb_release -a)" =~ "Ubuntu" ]] || [[ "$(cat /etc/*-release || cat /etc/issue || lsb_release -a)" =~ "raspbian" ]] || [[ "$(cat /etc/*-release || cat /etc/issue || lsb_release -a)" =~ "Raspbian" ]] || command -v apt-get &>/dev/null || command -v apt &>/dev/null; then
distro="debian"
elif [[ "$(cat /etc/*-release || cat /etc/redhat-release || cat /etc/issue || lsb_release -a)" =~ "fedora" ]] || [[ "$(cat /etc/*-release || cat /etc/redhat-release || cat /etc/issue || lsb_release -a)" =~ "Fedora" ]] || [[ "$(cat /etc/*-release || cat /etc/redhat-release || cat /etc/issue || lsb_release -a)" =~ "CentOS" ]] || [[ "$(cat /etc/*-release || cat /etc/redhat-release || cat /etc/issue || lsb_release -a)" =~ "centos" ]] || [[ "$(cat /etc/*-release || cat /etc/redhat-release || cat /etc/issue || lsb_release -a)" =~ "Red Hat" ]] || [[ "$(cat /etc/*-release || cat /etc/redhat-release || cat /etc/issue || lsb_release -a)" =~ "red hat" ]] || command -v dnf &>/dev/null; then
distro="fedora"
elif [[ "$(cat /etc/*-release || lsb_release -a || cat /etc/issue)" =~ "Arch" ]] || [[ "$(cat /etc/*-release || lsb_release -a || cat /etc/issue)" =~ "arch" ]] || [[ "$(cat /etc/*-release || lsb_release -a || cat /etc/issue)" =~ "Manjaro" ]] || [[ "$(cat /etc/*-release || lsb_release -a || cat /etc/issue)" =~ "manjaro" ]] || command -v pacman &>/dev/null; then
distro="arch"
fi
case $distro in
"debian")
rm -f update*.deb
printf "\n${WHITE}Downloading ${CYAN}${BOLD}update${NC}${WHITE}...${NC}\n\n"
LATEST=$(curl -s https://api.github.com/repos/Crilum/update/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
curl -s https://api.github.com/repos/Crilum/update/releases/latest |
grep browser_download_url |
grep 'all.deb"' |
cut -d '"' -f 4 |
xargs -n 1 curl -L -s -o update_${LATEST}_all.deb
if command -v update &>/dev/null; then
printf "\n${WHITE}Uninstalling update...${NC}"
$sudo apt remove -y update
printf "\n${GREEN}Done!${NC}"
fi
printf "\n${WHITE}Installing update...${NC}"
$sudo apt install -yf ./update_${LATEST}_all.deb
printf "\n${GREEN}Done!${NC}\n"
rm update_${LATEST}_all.deb
;;
"fedora")
if command -v dnf &>/dev/null; then
pkg_manager="dnf"
elif command -v yum &>/dev/null; then
pkg_manager="yum"
else
echo "No suitable package manager found!! Exiting..."; exit 1
fi
rm -f update*.rpm
printf "\n${WHITE}Downloading ${CYAN}${BOLD}update${NC}${WHITE}...${NC}\n\n"
LATEST=$(curl -s https://api.github.com/repos/Crilum/update/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
curl -s https://api.github.com/repos/Crilum/update/releases/latest |
grep browser_download_url |
grep 'noarch.rpm"' |
cut -d '"' -f 4 |
xargs -n 1 curl -L -s -o update-${LATEST}-1.noarch.rpm
if command -v update &>/dev/null; then
printf "\n${WHITE}Uninstalling update...${NC}"
$sudo $pkg_manager remove -y update
printf "\n${GREEN}Done!${NC}"
fi
printf "\n${WHITE}Installing update...${NC}"
$sudo $pkg_manager install ./update-${LATEST}-1.noarch.rpm -y
printf "\n${GREEN}Done!${NC}\n"
rm update-${LATEST}-1.noarch.rpm
;;
*)
if ! command -v curl &>/dev/null || ! command -v chmod &>/dev/null || ! command -v wget &>/dev/null || ! command -v git &>/dev/null; then
echo -e "${LIRED}Error: Missing dependencies! Please install \`curl\`, \`wget\`, \`git\`, and of course, \`bash\` (If you got this far, you should already have it installed).${NC}"
exit 1
fi
LATEST=$(curl -s https://api.github.com/repos/Crilum/update/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
printf "\n${WHITE}Downloading ${CYAN}${BOLD}update${NC}${WHITE}...${NC}\n\n"
cd /tmp/
git clone https://github.com/Crilum/update -b $LATEST
cd /tmp/update
$sudo cp -f update /usr/bin/
$sudo ln -sf /usr/bin/update /usr/bin/up
$sudo chmod +x /usr/bin/update /usr/bin/up
;;
esac
;;
Darwin)
if ! command -v curl &>/dev/null || ! command -v chmod &>/dev/null || ! command -v wget &>/dev/null || ! command -v git &>/dev/null; then
if ! command -v homebrew &>/dev/null; then
printf "\n${WHITE}Update needs some dependencies (curl, chmod, git, and wget). Do you want to install Homebrew (for installing dependencies)? [Y/n] ${LIBLUE}"
read instHomebrew
if [[ $instHomebrew =~ "yYYesyesYES" ]]; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
printf "\n${RED}User error: user chose not to install Homebrew!"
exit 1
fi
fi
printf "\n${WHITE}Installing dependencies with Homebrew...${NC}\n\n"
brew install curl chmod wget git
fi
LATEST=$(curl -s https://api.github.com/repos/Crilum/update/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
printf "\n${WHITE}Downloading ${CYAN}${BOLD}update${NC}${WHITE}...${NC}\n\n"
cd /tmp/
git clone https://github.com/Crilum/update -b $LATEST
cd /tmp/update
$sudo cp update /usr/local/bin/
$sudo ln -s /usr/local/bin/update /usr/local/bin/up
$sudo chmod +x /usr/local/bin/update /usr/local/bin/up
;;
*)
echo "${LIRED}Error: you are not running a suppoted system (supported systems are: Linux or MacOS)! If you are, please file a bug report at https://github.com/Crilum/update/issues/new.${NC}"
exit 1
;;
esac
printf "${GREEN}All finished installing!\n${WHITE}Try \'${CYAN}${BOLD}update ${YELLOW}help${WHITE}\' (or, \'${LICYAN}up${NC} ${YELLOW}help${WHITE}\') to learn how to use ${CYAN}${BOLD}update${WHITE}!${NC}\n"