-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-rstudio-ubuntu.sh
More file actions
98 lines (76 loc) · 3.01 KB
/
install-rstudio-ubuntu.sh
File metadata and controls
98 lines (76 loc) · 3.01 KB
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
#!/bin/bash
# RStudio Auto-Installer for Ubuntu
# Downloads and installs the latest RStudio Desktop from the daily builds
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${GREEN}RStudio Auto-Installer for Ubuntu${NC}"
echo "=================================="
# Get system information
UBUNTU_CODENAME=$(lsb_release -cs)
UBUNTU_VERSION=$(lsb_release -rs)
ARCH=$(dpkg --print-architecture)
echo "Detected Ubuntu: $UBUNTU_VERSION ($UBUNTU_CODENAME)"
echo "Architecture: $ARCH"
# Build platform key directly from codename
PLATFORM_KEY="$UBUNTU_CODENAME-$ARCH"
echo "Using platform key: $PLATFORM_KEY"
# Download the JSON release info
echo "Fetching latest release information..."
JSON_URL="https://dailies.rstudio.com/rstudio/latest/index.json"
JSON_FILE="/tmp/rstudio_releases.json"
if ! curl -s "$JSON_URL" -o "$JSON_FILE"; then
echo -e "${RED}Error: Failed to download release information${NC}"
exit 1
fi
# Parse JSON to get download URL and other info
DOWNLOAD_URL=$(jq -r ".products.electron.platforms.\"$PLATFORM_KEY\".link" "$JSON_FILE")
FILENAME=$(jq -r ".products.electron.platforms.\"$PLATFORM_KEY\".filename" "$JSON_FILE")
SHA256=$(jq -r ".products.electron.platforms.\"$PLATFORM_KEY\".sha256" "$JSON_FILE")
VERSION=$(jq -r ".products.electron.platforms.\"$PLATFORM_KEY\".version" "$JSON_FILE")
SIZE=$(jq -r ".products.electron.platforms.\"$PLATFORM_KEY\".size" "$JSON_FILE")
# Check if the platform is supported
if [[ "$DOWNLOAD_URL" == "null" ]]; then
echo -e "${RED}Error: No RStudio package available for $PLATFORM_KEY${NC}"
echo "Available Ubuntu platforms:"
jq -r '.products.electron.platforms | to_entries[] | select(.value.name | contains("Ubuntu")) | .key' "$JSON_FILE"
exit 1
fi
echo "Found RStudio Desktop $VERSION"
echo "Package size: $(numfmt --to=iec $SIZE)"
echo "Download URL: $DOWNLOAD_URL"
# Download the package
echo "Downloading RStudio package..."
DEB_FILE="/tmp/$FILENAME"
if ! wget -O "$DEB_FILE" "$DOWNLOAD_URL" --progress=bar:force; then
echo -e "${RED}Error: Failed to download RStudio package${NC}"
exit 1
fi
# Verify SHA256 checksum
echo "Verifying package integrity..."
DOWNLOADED_SHA256=$(sha256sum "$DEB_FILE" | cut -d' ' -f1)
if [[ "$DOWNLOADED_SHA256" != "$SHA256" ]]; then
echo -e "${RED}Error: SHA256 checksum mismatch!${NC}"
echo "Expected: $SHA256"
echo "Got: $DOWNLOADED_SHA256"
exit 1
fi
echo -e "${GREEN}Package integrity verified successfully${NC}"
# Install dependencies (if needed)
echo "Installing dependencies..."
sudo apt update
sudo apt install -y gdebi-core
# Install RStudio
echo "Installing RStudio Desktop..."
if sudo gdebi -n "$DEB_FILE"; then
echo -e "${GREEN}RStudio Desktop $VERSION installed successfully!${NC}"
else
echo -e "${RED}Error: Failed to install RStudio${NC}"
exit 1
fi
# Cleanup
rm -f "$JSON_FILE" "$DEB_FILE"
echo -e "${GREEN}Installation complete! You can now run RStudio from your applications menu or by typing 'rstudio' in the terminal.${NC}"