-
Notifications
You must be signed in to change notification settings - Fork 1
/
install_rstudio.sh
137 lines (123 loc) · 4.96 KB
/
install_rstudio.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
echo "+-----------------------+"
echo "| AE5 RStudio Installer |"
echo "+-----------------------+"
if [[ -z "$TOOL_PROJECT_URL" || -z "$TOOL_HOST" || -z "$TOOL_OWNER" ]]; then
echo 'ERROR: this script must be run within an AE5 session.'
exit -1
elif ! grep -q /tools/ /opt/continuum/scripts/start_user.sh; then
echo 'ERROR: this version of the RStudio Installer requires AE5.5.1 or later.'
exit -1
elif [ -z "$RSTUDIO_PREFIX" ]; then
RSTUDIO_PREFIX=/tools/rstudio
elif [ $RSTUDIO_PREFIX = /tools/rstudio ]; then
:
elif [ $RSTUDIO_PREFIX != /usr/lib/rstudio-server ]; then
echo "ERROR: RStudio must be installed in one of the following directories:"
echo "- /tools/rstudio"
echo "- /usr/lib/rstudio-server"
echo "The first is strongly preferred. Please refer to README.md for details."
exit -1
fi
RSTUDIO_PARENT=$(dirname $RSTUDIO_PREFIX)
if [[ -d $RSTUDIO_PREFIX || $RSTUDIO_PREFIX != /tools/rstudio ]]; then
if [ ! -d $RSTUDIO_PREFIX ]; then
echo "The directory $RSTUDIO_PREFIX is missing. Please add this volume"
echo "to your configuration, then stop and restart this session."
exit -1
elif [ ! -w $RSTUDIO_PREFIX ]; then
echo "The directory $RSTUDIO_PREFIX is readonly. Please ensure that its"
echo "volume is set to read-write, then stop and restart this session."
exit -1
elif [ ! -z "$(ls -A $RSTUDIO_PREFIX)" ]; then
echo "The directory $RSTUDIO_PREFIX is not empty. To prevent overwriting an"
echo "existing installation, the script expects this directory to be empty."
echo "Please manually remove the contents before proceeding."
ls -A $RSTUDIO_PREFIX
exit -1
fi
elif [ ! -d $RSTUDIO_PARENT ]; then
echo "ERROR: The directory $RSTUDIO_PARENT is missing. Please follow the instructions"
echo "in README.md to create this volume, and stop and restart this session."
exit -1
elif [ ! -w $RSTUDIO_PARENT ]; then
echo "ERROR: The directory $RSTUDIO_PARENT is readonly. Please follow the instructions"
echo "in README.md to set it to read-write, and stop and restart this session."
exit -1
fi
echo "- Install prefix: $RSTUDIO_PREFIX"
if grep -q 'release 9' /etc/redhat-release; then
main_ver=9
else
main_ver=8
fi
missing=
for v in $main_ver; do
fname=rs-centos$v.rpm
[ -f $fname ] || [ -f data/$fname ] || missing="$missing$fname "
done
if [ -n "$missing" ]; then
echo "ERROR: one or more of the RStudio missing:"
echo "- $missing"
echo "Please follow the directions in README.md to"
echo "bring these binaries into the project."
exit -1
fi
for fname in Rprofile configure_env.sh rsession.sh \
start_rstudio.sh default_env.py profile.sh; do
[ -e $fname ] || missing=$missing"$fname "
done
if [ ! -z "$missing" ]; then
echo "One or more of the installer support files is missing:"
echo "- $missing"
echo "Please restore the full contents of the installer project."
exit -1
fi
for v in $main_ver; do
fname=rs-centos$v.rpm
[ -f $fname ] || fname=data/$fname
echo "- Verifying $fname"
if ! rpm2cpio $fname >/dev/null; then
echo "- ERROR: $fname is not a valid RPM package. Please remove this file and re-download it."
exit -1
fi
done
if [ ! -d $RSTUDIO_PREFIX ]; then
echo "- Creating directory $RSTUDIO_PREFIX"
if ! mkdir -p $RSTUDIO_PREFIX; then
echo "ERROR: The directory $RSTUDIO_PREFIX could not be created. Because the"
echo "parent directory $RSTUDIO_PARENT is writable, this is unexpected. Please correct"
echo "this issue before proceeding further."
exit -1
fi
fi
first=yes
for v in $main_ver; do
echo "- Unpacking RHEL${v}/CentOS${v} package"
mkdir -p $RSTUDIO_PREFIX/staging${v}/usr/lib/rstudio-server
fname=rs-centos${v}.rpm
[ -f $fname ] || fname=data/$fname
rpm2cpio $fname | (cd $RSTUDIO_PREFIX/staging${v} && cpio -ic)
done
echo "- Moving files into final position"
mv $RSTUDIO_PREFIX/staging${main_ver}/usr/lib/rstudio-server/* $RSTUDIO_PREFIX
rm -rf $RSTUDIO_PREFIX/staging*
echo "- Installing support files"
cp -rf Rprofile configure_env.sh rsession.sh \
start_rstudio.sh default_env.py skeleton $RSTUDIO_PREFIX/
cp profile.sh $RSTUDIO_PREFIX/resources/terminal/hooks
find $RSTUDIO_PREFIX/skeleton -name '.keep' -exec rm -f {} \; || :
chmod +x $RSTUDIO_PREFIX/{start_rstudio.sh,rsession.sh}
echo "+-----------------------+"
echo "RStudio installation is complete."
echo "Once you have verified the installation, feel free to"
echo "shut down this session and delete the project."
echo "+-----------------------+"
if [ ! -d /tools/java ]; then
echo "WARNING: Many R packages make use of Java, and it seems"
echo "not to be present on this installation of AE5. To make"
echo "Java available to all AE5 users, run install_java.sh, or"
echo "manually download a JDK Linux x64 archive and unpack its"
echo "contents into the directory /tools/java."
echo "+-----------------------+"
fi