#!/bin/bash NEW_VERSION=30 REMOTE_HOST=hs-242-lejos.internal ID_FILE="${HOME}/.ssh/lejos_rsa" STDERR_REDIR="${HOME}/.nxj/install.log" # "/dev/null" function install-files { mkdir -p ~/.nxj curl -o ~/.nxj/classes.jar http://$REMOTE_HOST/classes.jar 2>$STDERR_REDIR cp ~/.nxj/classes.jar ~/Applications/lejos_nxj_classes.jar curl -o ~/.nxj/upload.sh http://$REMOTE_HOST/upload_script.sh 2>$STDERR_REDIR mkdir -p ~/.ssh curl -o $ID_FILE http://$REMOTE_HOST/lejos_rsa 2>$STDERR_REDIR chmod 0600 $ID_FILE chmod a+x ~/.nxj/upload.sh mkdir -p ~/Library/Preferences/org.bluej/extensions curl -o ~/Library/Preferences/org.bluej/extensions/bluejos.jar http://$REMOTE_HOST/bluejos.jar 2>$STDERR_REDIR curl -o ~/.nxj/bash_commands http://$REMOTE_HOST/nxj_commands.sh 2>$STDERR_REDIR echo "Latest LeJOS client successfully installed! Please restart terminal now." echo "(Or run 'source ~/.nxj/bash_commands' in your current terminal sessions.)" } cd ~ if [ "x$LEJOS_VERSION" == x ]; then echo "Installing LeJOS client..." mkdir -p ~/.ssh echo -e "\n\nHost lejos\n HostName $REMOTE_HOST\n User lejos\n IdentityFile $ID_FILE">> ~/.ssh/config echo -e "hs-242-lejos.internal,10.30.0.242 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDv7aJaWOLa5HDekddGlymnF50zWg4oUVHFfbuihk1hP0bwQLpqXCwIEK3eloL5rwhkacncR/+22W5zPChWuNBp14Dipgcon9yuJp2ypqO5t+jRda1Lo19E6nAty3/FVpyGi/ZWGO7JdiB/ZFmr6MPUZ6bN3nTgCE2GH82Ezjhxb4QN4LS44C1+OEQ/b/TFuKUaIwEqKnzU0/sq1c8RFfYR9ztb10DRpFgMU83UJO3uZUTdkzQVzPVjuuLXXcXTR+4u9g9l7fKVs+3BABTtQFTl3EtrULqAzSCJfLsFxQ6B9CA77gC5uXzlwxQvKNpiNm5kRtRpM86awpGGMO1M/JjF" >> ~/.ssh/known_hosts #echo -e "$ID_FILE" | ssh-keygen 2>$STDERR_REDIR >/dev/null #echo #echo "Enter \"yes\", then \"lejos\" at the following password prompt." #echo #{ cat ${ID_FILE}.pub; } | ssh lejos@$REMOTE_HOST "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys; test -x /sbin/restorecon && /sbin/restorecon .ssh .ssh/authorized_keys" install-files ssh lejos "mkdir -p ~/$USER" -o StrictHostKeyChecking=no 2>/dev/null echo echo -e "\n\nsource ~/.nxj/bash_commands" >> .bash_profile elif [[ $LEJOS_VERSION -lt $NEW_VERSION ]]; then echo "Upgrading LeJOS client..." install-files else echo "LeJOS client already setup and up-to-date." echo echo "If things aren't working, please reset your SSH and Bash configurations and then try again." fi