-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·42 lines (33 loc) · 1.07 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
#!/bin/bash
set -e
if [[ "${OSTYPE}" == "linux"* ]]; then
FILE="mysql2parquet-linux_amd64.tar.gz"
elif [[ "$OSTYPE" == "darwin"* ]]; then
FILE="mysql2parquet-darwin_amd64.tar.gz"
else
echo "Only works on Linux or Darwin amd64."
exit
fi
if [[ $EUID -ne 0 ]]; then
echo "The script install.sh is not running as root. Try using sudo."
exit 2
fi
if ! type "wget" &> /dev/null; then
echo "The program 'wget' is currently not installed, please install it to continue."
exit
fi
TAG=$(wget -qO- "https://api.github.com/repos/debeando/mysql2parquet/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -f /usr/local/bin/mysql2parquet ]; then
rm -f /usr/local/bin/mysql2parquet
fi
if [ -L /usr/bin/mysql2parquet ]; then
rm -f /usr/bin/mysql2parquet
fi
if [ -n "${FILE}" ]; then
wget -qO- "https://github.com/debeando/mysql2parquet/releases/download/${TAG}/${FILE}" | tar xz -C /usr/local/bin/
fi
if [[ "${OSTYPE}" == "linux"* ]]; then
if [ -f /usr/local/bin/mysql2parquet ]; then
ln -s /usr/local/bin/mysql2parquet /usr/bin/mysql2parquet
fi
fi