Skip to content

Commit

Permalink
install rust
Browse files Browse the repository at this point in the history
  • Loading branch information
vickeykumar committed Jun 16, 2024
1 parent 7fad387 commit b2dff01
Showing 1 changed file with 47 additions and 12 deletions.
59 changes: 47 additions & 12 deletions install_prerequisite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,33 @@ 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

Expand Down Expand Up @@ -95,7 +107,7 @@ npm install npm@8.5.1 -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..."
Expand All @@ -107,6 +119,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
Expand Down Expand Up @@ -165,6 +195,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=(
Expand All @@ -187,6 +220,8 @@ if [ $run_tests -eq 1 ]; then
"gdb --version"
"jq --version"
"echo 'puts [info patchlevel]' | tclsh"
"rustc --version"
"rust-gdb --version"
)


Expand Down

0 comments on commit b2dff01

Please sign in to comment.