-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_curl.go
64 lines (56 loc) · 1.57 KB
/
install_curl.go
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
package main
// Curl may not be present on the system, but is required for the
// standard Deno installer script.
var installCurlScript = `#!/bin/sh
# Run some OS detection first, maybe we do more sophisticated
# stuff with this later.
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
export OS=$NAME
export VER=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
# linuxbase.org
export OS=$(lsb_release -si)
export VER=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
# For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
export OS=$DISTRIB_ID
export VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc.
export OS=Debian
export VER=$(cat /etc/debian_version)
else
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
OS=$(uname -s)
VER=$(uname -r)
fi
echo "OS DETECTED: $OS $VER"
echo ""
# Use our corny method of installing curl: look for
# well-known package managers and call them.
if ! [ -x "$(command -v curl)" ]; then
echo "curl executable not detected"
if [ -x "$(command -v apt-get)" ]; then
echo 'using apt-get'
apt-get update
apt-get install -y curl
elif [ -x "$(command -v yum)" ]; then
echo "using yum"
yum update
yum install -y curl
elif [ -x "$(command -v apk)" ]; then
echo "using apk"
apk add --no-cache curl
else
echo "package manager not detected"
exit 1
fi
fi
if ! [ -x "$(command -v curl)" ]; then
echo "curl installed, but not available to our process"
exit 1
fi
`