-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
101 lines (88 loc) · 2.09 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
set -e
VERSION=$(curl -s https://api.github.com/repos/avakarev/dotfiles-cli/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
OS="$(uname -s)"
ARCH="$(uname -m)"
case $OS in
"Linux")
case $ARCH in
"x86_64")
ARCH=amd64
;;
"aarch64")
ARCH=arm64
;;
"armv6l")
ARCH=armv6
;;
"armv7l")
ARCH=armv7
;;
"armv8")
ARCH=arm64
;;
.*386.*)
echo "Error: 386 arch is not supported"
exit 1
;;
esac
PLATFORM="linux_$ARCH"
;;
"Darwin")
echo "Macos detected. Use Homebrew on macos instead: \"brew tap avakarev/tap && brew install dotfiles\""
exit 1
;;
esac
if [ -z "$PLATFORM" ]; then
echo "Error: operating system $OS is not supported"
exit 1
fi
if [ -f /etc/os-release ]; then
DISTRO=$(awk -F= '$1=="ID_LIKE" { print $2 ;}' /etc/os-release)
fi
if [ -z "$DISTRO" ]; then
echo "Error: distro is not detected"
exit 1
fi
TEMP_DIRECTORY=$(mktemp -d)
download() {
PACKAGE="dotfiles_${VERSION}_${PLATFORM}.${1}"
URL="https://github.com/avakarev/dotfiles-cli/releases/download/$VERSION/$PACKAGE"
curl -Ls -o $TEMP_DIRECTORY/$PACKAGE $URL
if [ $? -ne 0 ]; then
echo "Download failed! Exiting."
exit 1
fi
echo $TEMP_DIRECTORY/$PACKAGE
}
install_deb() {
echo "Installing dotfiles $VERSION..."
echo "Downloading deb package..."
_pkg=$(download "deb")
echo "Installing deb package..."
echo "$_pkg"
sudo apt install "$_pkg"
rm -f $_pkg
}
install_rpm() {
echo "Installing dotfiles $VERSION..."
echo "Downloading rpm package..."
_pkg=$(download "rpm")
echo "Installing rpm package..."
echo "$_pkg"
sudo yum localinstall "$_pkg"
rm -f $_pkg
}
case $DISTRO in
*debian*|*ubuntu*)
install_deb
;;
*rhel*|*centos*|*fedora*)
install_rpm
;;
*)
echo "Error: \"$DISTRO\" distro is not supported"
exit 1
;;
esac
echo "Done!"