@@ -6,7 +6,6 @@ GOTTY_DIR=/opt/gotty
6
6
mkdir -p $GOTTY_DIR || true
7
7
chmod -R 644 $GOTTY_DIR
8
8
SCRIPT_DIR=" $( cd " $( dirname " $0 " ) " && pwd) "
9
- echo " running script from : " $SCRIPT_DIR
10
9
11
10
retVal=0
12
11
@@ -16,24 +15,38 @@ display_usage() {
16
15
echo " --cleanup-tools Cleanup tools after REPLs installation"
17
16
echo " --run-tests Run tests"
18
17
echo " --help Display this help message"
18
+ echo " --username USERNAME Specify the username for installation"
19
19
}
20
20
21
21
cleanup_tools=0
22
22
run_tests=0
23
-
24
- for arg in " $@ " ; do
25
- case $arg in
26
- --cleanup-tools) cleanup_tools=1
27
- ;;
28
- --run-tests) run_tests=1
29
- ;;
30
- --help) display_usage; exit 0
31
- ;;
32
- * ) echo " Invalid argument: $arg " ; display_usage; exit 1
33
- ;;
23
+ username=$( whoami)
24
+
25
+ # Parse command-line arguments
26
+ while [[ " $# " -gt 0 ]]; do
27
+ case $1 in
28
+ --cleanup-tools) cleanup_tools=1; shift ;;
29
+ --run-tests) run_tests=1; shift ;;
30
+ --help) display_usage; exit 0 ;;
31
+ --username)
32
+ if [[ -n " $2 " && " $2 " != --* ]]; then
33
+ username=" $2 " ; shift 2
34
+ else
35
+ echo " Error: --username requires a value"
36
+ display_usage
37
+ exit 1
38
+ fi
39
+ ;;
40
+ * )
41
+ echo " Invalid argument: $1 "
42
+ display_usage
43
+ exit 1
44
+ ;;
34
45
esac
35
46
done
36
47
48
+ echo " running script from : " $SCRIPT_DIR
49
+ echo " username: " $username
37
50
38
51
cd ~
39
52
@@ -95,7 +108,7 @@ npm install npm@8.5.1 -g
95
108
# /usr/bin/cling 21321 .q > /dev/null 2>&1 &
96
109
cd $GOTTY_DIR
97
110
98
- if [[ -e " /usr/local/bin/cling" ] ]; then
111
+ if [ -e " /usr/local/bin/cling" ]; then
99
112
echo " File /usr/local/bin/cling exists."
100
113
else
101
114
echo " File /usr/local/bin/cling does not exist. installing..."
@@ -107,6 +120,24 @@ else
107
120
rm cling-Ubuntu-22.04-x86_64-1.0~dev-d47b49c.tar.bz2
108
121
fi
109
122
123
+ # install rust and set all the required env
124
+ RUSTUP_HOME=" $GOTTY_DIR /rust"
125
+ CARGO_HOME=" $GOTTY_DIR /rust"
126
+ if [ -e " $RUSTUP_HOME /bin/rustc" ]; then
127
+ echo " File $RUSTUP_HOME /bin/rustc exists."
128
+ else
129
+ echo " File $RUSTUP_HOME /bin/rustc does not exist. installing..."
130
+ mkdir -p $RUSTUP_HOME
131
+ curl https://sh.rustup.rs -sSf | env RUSTUP_HOME=$RUSTUP_HOME CARGO_HOME=$CARGO_HOME sh -s -- --default-toolchain stable --profile default -y
132
+ echo " export RUSTUP_HOME=$RUSTUP_HOME " | tee /etc/profile.d/rust.sh
133
+ echo " export CARGO_HOME=$CARGO_HOME " | tee -a /etc/profile.d/rust.sh
134
+ echo " export PATH=\$ PATH:\$ RUSTUP_HOME/bin" | tee -a /etc/profile.d/rust.sh
135
+ chmod +x /etc/profile.d/rust.sh
136
+ bash -c ' echo "if [ -f /etc/profile.d/rust.sh ]; then . /etc/profile.d/rust.sh; fi" >> /etc/bash.bashrc'
137
+ bash -c ' echo "if [ -f /etc/profile.d/rust.sh ]; then . /etc/profile.d/rust.sh; fi" >> /etc/profile'
138
+ fi
139
+
140
+
110
141
111
142
# install gointerpreter
112
143
git clone https://github.com/vickeykumar/Go-interpreter.git
@@ -165,6 +196,9 @@ if [ $cleanup_tools -eq 1 ]; then
165
196
apt-get -y autoremove
166
197
fi
167
198
199
+ # finally give the ownership to username
200
+ chown -R $username :$username $GOTTY_DIR
201
+
168
202
# test
169
203
if [ $run_tests -eq 1 ]; then
170
204
test_commands=(
@@ -187,6 +221,8 @@ if [ $run_tests -eq 1 ]; then
187
221
" gdb --version"
188
222
" jq --version"
189
223
" echo 'puts [info patchlevel]' | tclsh"
224
+ " rustc --version"
225
+ " rust-gdb --version"
190
226
)
191
227
192
228
0 commit comments