-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7fad387
commit 102f1d7
Showing
1 changed file
with
49 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ GOTTY_DIR=/opt/gotty | |
mkdir -p $GOTTY_DIR || true | ||
chmod -R 644 $GOTTY_DIR | ||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" | ||
echo "running script from : " $SCRIPT_DIR | ||
|
||
retVal=0 | ||
|
||
|
@@ -16,24 +15,38 @@ display_usage() { | |
echo " --cleanup-tools Cleanup tools after REPLs installation" | ||
echo " --run-tests Run tests" | ||
echo " --help Display this help message" | ||
echo " --username USERNAME Specify the username for installation" | ||
} | ||
|
||
cleanup_tools=0 | ||
run_tests=0 | ||
|
||
for arg in "$@"; do | ||
case $arg in | ||
--cleanup-tools) cleanup_tools=1 | ||
;; | ||
--run-tests) run_tests=1 | ||
;; | ||
--help) display_usage; exit 0 | ||
;; | ||
*) echo "Invalid argument: $arg"; display_usage; exit 1 | ||
;; | ||
username=$(whoami) | ||
|
||
# Parse command-line arguments | ||
while [[ "$#" -gt 0 ]]; do | ||
case $1 in | ||
--cleanup-tools) cleanup_tools=1; shift ;; | ||
--run-tests) run_tests=1; shift ;; | ||
--help) display_usage; exit 0 ;; | ||
--username) | ||
if [[ -n "$2" && "$2" != --* ]]; then | ||
username="$2"; shift 2 | ||
else | ||
echo "Error: --username requires a value" | ||
display_usage | ||
exit 1 | ||
fi | ||
;; | ||
*) | ||
echo "Invalid argument: $1" | ||
display_usage | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
echo "running script from : " $SCRIPT_DIR | ||
echo "username: " $username | ||
|
||
cd ~ | ||
|
||
|
@@ -95,7 +108,7 @@ npm install [email protected] -g | |
#/usr/bin/cling 21321 .q > /dev/null 2>&1 & | ||
cd $GOTTY_DIR | ||
|
||
if [[ -e "/usr/local/bin/cling" ]]; then | ||
if [ -e "/usr/local/bin/cling" ]; then | ||
echo "File /usr/local/bin/cling exists." | ||
else | ||
echo "File /usr/local/bin/cling does not exist. installing..." | ||
|
@@ -107,6 +120,24 @@ else | |
rm cling-Ubuntu-22.04-x86_64-1.0~dev-d47b49c.tar.bz2 | ||
fi | ||
|
||
#install rust and set all the required env | ||
RUSTUP_HOME="$GOTTY_DIR/rust" | ||
CARGO_HOME="$GOTTY_DIR/rust" | ||
if [ -e "$RUSTUP_HOME/bin/rustc" ]; then | ||
echo "File $RUSTUP_HOME/bin/rustc exists." | ||
else | ||
echo "File $RUSTUP_HOME/bin/rustc does not exist. installing..." | ||
mkdir -p $RUSTUP_HOME | ||
curl https://sh.rustup.rs -sSf | env RUSTUP_HOME=$RUSTUP_HOME CARGO_HOME=$CARGO_HOME sh -s -- --default-toolchain stable --profile default -y | ||
echo "export RUSTUP_HOME=$RUSTUP_HOME" | tee /etc/profile.d/rust.sh | ||
echo "export CARGO_HOME=$CARGO_HOME" | tee -a /etc/profile.d/rust.sh | ||
echo "export PATH=\$PATH:\$RUSTUP_HOME/bin" | tee -a /etc/profile.d/rust.sh | ||
chmod +x /etc/profile.d/rust.sh | ||
bash -c 'echo "if [ -f /etc/profile.d/rust.sh ]; then . /etc/profile.d/rust.sh; fi" >> /etc/bash.bashrc' | ||
bash -c 'echo "if [ -f /etc/profile.d/rust.sh ]; then . /etc/profile.d/rust.sh; fi" >> /etc/profile' | ||
fi | ||
|
||
|
||
|
||
#install gointerpreter | ||
git clone https://github.com/vickeykumar/Go-interpreter.git | ||
|
@@ -165,6 +196,9 @@ if [ $cleanup_tools -eq 1 ]; then | |
apt-get -y autoremove | ||
fi | ||
|
||
# finally give the ownership to username | ||
chown -R $username:$username $GOTTY_DIR | ||
|
||
#test | ||
if [ $run_tests -eq 1 ]; then | ||
test_commands=( | ||
|
@@ -187,6 +221,8 @@ if [ $run_tests -eq 1 ]; then | |
"gdb --version" | ||
"jq --version" | ||
"echo 'puts [info patchlevel]' | tclsh" | ||
"rustc --version" | ||
"rust-gdb --version" | ||
) | ||
|
||
|
||
|