Skip to content

Commit 28a79a4

Browse files
Minor updates to jq and go installation scripts
1 parent a0b2d7b commit 28a79a4

File tree

2 files changed

+58
-45
lines changed

2 files changed

+58
-45
lines changed

public/install-go.sh

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
deps=( curl jq )
88

99
for dep in "${deps[@]}"; do
10-
if ! command -v "$dep" &> /dev/null; then
11-
echo "$dep is not installed. Downloading and executing the script..."
12-
curl -sSL https://rollkit.dev/install-jq.sh | bash
13-
exit $?
14-
fi
10+
if ! command -v "$dep" &> /dev/null; then
11+
echo "$dep is not installed. Downloading and executing the script..."
12+
curl -sSL https://rollkit.dev/install-jq.sh | bash
13+
fi
1514
done
1615

1716
version="${1:-$(curl -s 'https://go.dev/dl/?mode=json' | jq -r '.[0].version')}"
@@ -25,15 +24,26 @@ update_go() {
2524
local arch="$1"
2625
local os="$2"
2726

28-
local go_url="https://golang.org/dl/${version}.${os}-${arch}.tar.gz"
27+
local go_url="https://golang.org/dl/go${version}.${os}-${arch}.tar.gz"
2928

30-
curl -so "/tmp/${version}.${os}-${arch}.tar.gz" -L "$go_url" && \
31-
rm -rf /usr/local/go && tar -C /usr/local -xzf /tmp/${version}.${os}-${arch}.tar.gz
29+
echo "Downloading Go from ${go_url}"
3230

33-
tar -C /usr/local -xzf "/tmp/${version}.${os}-${arch}.tar.gz" && \
34-
echo "Go updated to version ${version}"
31+
curl -so "/tmp/go${version}.${os}-${arch}.tar.gz" -L "$go_url"
32+
if [ $? -eq 0 ]; then
33+
tar -C /usr/local -xzf "/tmp/go${version}.${os}-${arch}.tar.gz"
34+
if [ $? -ne 0 ]; then
35+
echo "Failed to extract Go. Possibly corrupted download."
36+
rm "/tmp/go${version}.${os}-${arch}.tar.gz"
37+
exit 1
38+
else
39+
echo "Go updated to version ${version}"
40+
fi
41+
else
42+
echo "Failed to download Go from ${go_url}"
43+
exit 1
44+
fi
3545

36-
rm "/tmp/${version}.${os}-${arch}.tar.gz"
46+
rm "/tmp/go${version}.${os}-${arch}.tar.gz"
3747
}
3848

3949
case "$(uname -s)" in

public/install-jq.sh

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,42 @@
11
#!/bin/bash
22

33
if [[ "$OSTYPE" == "darwin"* ]]; then
4-
echo "Detected macOS. Installing jq..."
5-
if ! command -v brew &> /dev/null; then
6-
echo "Homebrew is not installed. Installing Homebrew..."
7-
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
8-
# adding /opt/homebrew/bin to the $PATH variable based on the shell
9-
if [[ -f "$HOME/.bash_profile" ]]; then
10-
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> "$HOME/.bash_profile"
11-
source "$HOME/.bash_profile"
12-
elif [[ -f "$HOME/.zshrc" ]]; then
13-
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> "$HOME/.zshrc"
14-
source "$HOME/.zshrc"
15-
else
16-
echo "Unsupported shell. Please add /opt/homebrew/bin to your PATH manually."
17-
18-
fi
19-
brew install jq
20-
echo "jq has been installed successfully."
21-
4+
echo "Detected macOS. Installing jq..."
5+
if ! command -v brew &> /dev/null; then
6+
echo "Homebrew is not installed. Installing Homebrew..."
7+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
8+
# adding /opt/homebrew/bin to the $PATH variable based on the shell
9+
if [[ -f "$HOME/.bash_profile" ]]; then
10+
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> "$HOME/.bash_profile"
11+
source "$HOME/.bash_profile"
12+
elif [[ -f "$HOME/.bashrc" ]]; then
13+
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> "$HOME/.bashrc"
14+
source "$HOME/.bashrc"
15+
elif [[ -f "$HOME/.zshrc" ]]; then
16+
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> "$HOME/.zshrc"
17+
source "$HOME/.zshrc"
18+
else
19+
echo "Unsupported shell. Please add /opt/homebrew/bin to your PATH manually."
20+
exit 1
21+
fi
22+
fi # Closing the brew installation check
23+
brew install jq
24+
echo "jq has been installed successfully."
2225
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
23-
echo "Detected Linux. Installing jq..."
24-
if command -v apt &> /dev/null; then
25-
sudo apt update
26-
sudo apt install -y jq
27-
elif command -v yum &> /dev/null; then
28-
sudo yum install -y epel-release
29-
sudo yum install -y jq
30-
else
31-
echo "Unsupported package manager. Please install jq manually."
32-
exit 1
33-
fi
34-
echo "jq has been installed successfully."
35-
26+
echo "Detected Linux. Installing jq..."
27+
if command -v apt &> /dev/null; then
28+
sudo apt update
29+
sudo apt install -y jq
30+
elif command -v yum &> /dev/null; then
31+
sudo yum install -y epel-release
32+
sudo yum install -y jq
33+
else
34+
echo "Unsupported package manager. Please install jq manually."
35+
exit 1
36+
fi
37+
echo "jq has been installed successfully."
3638
else
37-
echo "Unsupported operating system."
38-
exit 1
39-
fi
39+
echo "Unsupported operating system."
40+
exit 1
41+
fi # Closing the OS type check
42+

0 commit comments

Comments
 (0)