#!/bin/bash #this script will constantly maintain (via crontab) a remote forward connection to another machine. This can #be used as a way to connect to a jumpbox to get over a pesky NAT remote_listen_port=2222 local_ssh_port=22 remote_host=example.com remote_user=user1 identity_file=/home/user1/.ssh/key1 connect_string="ssh -N -T -R ${remote_listen_port}:localhost:${local_ssh_port} ${remote_user}@${remote_host} -i ${identity_file} -o ConnectTimeout=60 ServerAliveInterval=10" process_is_up(){ ps aux | grep "${connect_string}" | grep -v grep } start_bot(){ ${connect_string} } if process_is_up ; then echo process is up, exiting exit 1 else echo process is down, starting now start_bot & fi; #add to root homedir and then crontab with the following line: #* * * * * /root/ssh-bot-script.sh > /dev/null
Tuesday, July 23, 2013
SSH Persistent Connection Script
I just reinstalled a test machine and forgot to save my ssh tunnel script so i decided to write a new one.
Labels:
Bash,
Programming,
SSH
Get/Set Fan Speeds for AMD Video Cards in Linux
I'm messing around with GPU cracking and I've been changing fan speeds manually a lot so I wrote a script to do it for me. This script will output the temperature & fan speed of the two cards in my system, as well as allow me to set the fan speeds for either/both:
#!/bin/bash #ati-stats.sh - gives environmental stats about the ATI videocards. this assumes you have two cards get_fan_speed () { DISPLAY=:0.${1} aticonfig --pplib-cmd "get fanspeed 0" | grep '%' | cut -d ':' -f 3 } set_fan_speed () { DISPLAY=:0.${1} aticonfig --pplib-cmd "set fanspeed 0 ${2}" } get_temp () { aticonfig --adapter=${1} --odgt | grep Temp |cut -d '-' -f 2 } if [[ -z ${1} ]]; then #if no arguments then output stats echo "0: $(get_temp 0) --$(get_fan_speed 0 )" echo "1: $(get_temp 1) --$(get_fan_speed 1 )" else case ${1} in get) get_fan_speed ${2} ;; set) oldspeed=$(get_fan_speed ${2}) set_fan_speed ${2} ${3} echo "${2}: ${oldspeed} -> $(get_fan_speed ${2})" ;; setboth) oldspeed=$(get_fan_speed 0) set_fan_speed 0 ${2} echo "0: ${oldspeed} -> $(get_fan_speed 0)" oldspeed=$(get_fan_speed 1) set_fan_speed 1 ${2} echo "1: ${oldspeed} -> $(get_fan_speed 1)" ;; *) echo "Usage: $0 [get Adapter_NUM | set Adapter_NUM fan_PERCENT | setboth fan_PERCENT]" ;; esac; fi;
Labels:
Bash,
Hardware,
Programming
Subscribe to:
Posts (Atom)