#!/bin/bash # RAPC - Copyright 2005-2007 James Dinan # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ############################################ # Set up some defaults url="http://www.cse.ohio-state.edu/rapcs/" # Location of html2text. Most distros have a package for this. # Or you can get the source at http://www.mbayer.de/html2text/ html2text=$(which html2text) # The default user name user="" # Fullscreen args to rdesktop (-f option) f_opts="-a 16 -f" # 1024x768 windowed rdesktop args (-w option) w_opts="-a 16 -g 1152x864" # Set the default rdesktop args rd_opts=$w_opts ############################################ ############################################ # Some globals version="0.3" logfile=`mktemp` firstavail="" ############################################ usage () { echo "RAPC v$version: by James Dinan " echo " Helps get you connected to a free RAPC." echo echo "Usage: `basename $0` [rapc_args] [-- [rdesktop_args]]" echo echo "Options:" echo " -a Connect to the first available RAPC. Otherwise," echo " display a list of RAPCS and choose interactively." echo " -c num Connect to specific RAPC" echo " -f Use fullscreen settings" echo " -w Use windowed settings" # This has no effect at OSU since the RAPC machines are set to "always prompt for password" # echo " -p Prompt for password" echo " -u user Specify a username" echo " -nd Don't use the default rdesktop options. Useful if" echo " you want completely override them rather than add to them." echo " Where this is in the argument list matters. If you" echo " speficy \"-nd -f\" -f will override -nd and vice versa." echo " Example: rapc -nd -- -a 32 -g 90%" } while [ $1 ] do case "$1" in -a) firstavail="w00t!" ;; -c) shift connect_to=$1 ;; -nd) rd_opts="" user="" ;; -f) rd_opts=$f_opts ;; -w) rd_opts=$w_opts ;; -u) shift user=$1 ;; -p) passwd=true ;; --) shift rd_opts=$rd_opts$@ break ;; -h|--help|-help) usage exit 0 ;; *) usage exit 0 ;; esac shift; done if [ $connect_to ] then rapc=rapc$connect_to.cse.ohio-state.edu else if [ -z $html2text ] then echo "Error: html2text not found" exit 1 fi [ ! $firstavail ] && echo "Downloading list of RAPCs (this may take a moment) ..." $html2text -o $logfile $url if [ $firstavail ] then rapc=`sed -e 's/[\ \t]*\(rapc.\.cse\.ohio-state\.edu\)[\ \t]*Free/\1/p' -e'd' $logfile | head -n1` if [ -z $rapc ] then echo "ERROR: No available RAPCs!" exit 1 fi else # Grep off garbage from html2text grep -v "" $logfile echo -e "\nEnter the number of the RAPC you would like to connect to." echo -n ": " read rapc_num [ -z $rapc_num ] && echo "aborting." && exit 0 rapc=rapc$rapc_num.cse.ohio-state.edu echo Connecting to $rapc ... fi fi [ $passwd ] && rd_opts="-p - $rd_opts" [ $user ] && rd_opts="-u $user $rd_opts" echo "rd_opts=$rd_opts, rapc=$rapc" rdesktop $rd_opts $rapc &