#!/bin/bash ### # ShALLaX's i2c stuff wizard # Copyright (C) Thomas "ShALLaX" Pedley (gentoox@shallax.com) # # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ### trap null 20 2 null() { echo -n "" } ### # Set the colours for text here ### export bluetxt="\033[01;34m" export redtxt="\033[01;31m" export normaltxt="\033[00m" export greentxt="\033[01;32m" export yellowtxt="\033[01;33m" errors=0 check() { if [ $? == 0 ]; then echo -e "${bluetxt}[ ${greentxt}ok ${bluetxt}]${normaltxt}" else echo -e "${bluetxt}[ ${redtxt}!! ${bluetxt}]${normaltxt}" errors=`expr $errors + 1` fi } countErrors() { echo "" echo -n "All done (Errors: " if [ $errors -gt "0" ]; then echo -ne "$redtxt" else echo -ne "$greentxt" fi echo -e "${errors}${normaltxt})" } export properdir=`pwd | grep shallaxs_i2c_stuff` case "$1" in build) if [ ! -z $properdir ]; then if [ ! -d ./bin/ ]; then echo -n "Making bin directory... " mkdir ./bin/ check echo -n "Compiling ./src/fan.c -> ./bin/fanctl... " gcc -static ./src/fan.c -o ./bin/fanctl check echo -n "Compiling ./src/temp.c -> ./bin/xboxtemp... " gcc -static ./src/temp.c -o ./bin/xboxtemp check echo -n "Compiling ./src/testi2c.c -> ./bin/testi2c... " gcc -static ./src/testi2c.c -o ./bin/testi2c check echo -n "Compiling ./src/eject.c -> ./bin/eject_xbox... " gcc -static ./src/eject.c -o ./bin/eject_xbox check echo -n "Compiling ./src/led.c -> ./bin/led... " gcc -static ./src/led.c -o ./bin/led check echo -n "Compiling ./src/video.c -> ./bin/video... " gcc -static ./src/video.c -o ./bin/video check echo -n "Compiling ./src/loadmonitor.c -> ./bin/loadmonitor... " gcc -static ./src/loadmonitor.c -o ./bin/loadmonitor check countErrors export whererus=`pwd` else echo -n "You have already compiled the tools, run $0 clean first... " false check countErrors fi else echo -n "You are not in the right directory... " false check countErrors fi exit ;; clean) if [ ! -z $properdir ]; then echo -n "Deleting ./bin... " rm -rf ./bin check countErrors else echo -n "You are not in the right directory... " false check countErrors fi exit ;; install) if [ `whoami` == "root" ]; then if [ ! -z $properdir ]; then if [ -d ./bin ]; then echo -n "Copying ./bin/eject_xbox -> /bin/... " cp ./bin/eject_xbox /bin 1> /dev/null 2> /dev/null check echo -n "Copying ./bin/fanctl -> /bin/... " cp ./bin/fanctl /bin 1> /dev/null 2> /dev/null check echo -n "Copying ./bin/led -> /bin/... " cp ./bin/led /bin 1> /dev/null 2> /dev/null check echo -n "Copying ./bin/testi2c -> /bin/... " cp ./bin/testi2c /bin 1> /dev/null 2> /dev/null check echo -n "Copying ./bin/video -> /bin/... " cp ./bin/video /bin 1> /dev/null 2> /dev/null check echo -n "Copying ./bin/loadmonitor -> /bin/... " cp ./bin/loadmonitor /bin 1> /dev/null 2> /dev/null check echo -n "Copying ./bin/xboxtemp -> /bin/... " cp ./bin/xboxtemp /bin 1> /dev/null 2> /dev/null check echo -n "Copying ./script/blink -> /bin/... " cp ./script/blink /bin/ 1> /dev/null 2> /dev/null check echo -n "Copying ./script/fantest -> /bin/... " cp ./script/fantest /bin/ 1> /dev/null 2> /dev/null check echo -n "Copying ./script/randblink -> /bin/... " cp ./script/randblink /bin/ 1> /dev/null 2> /dev/null check echo -n "Setting ownership... " checker=0 chown root:root /bin/fanctl checker=`expr $checker + $?` chown root:root /bin/testi2c checker=`expr $checker + $?` chown root:root /bin/xboxtemp checker=`expr $checker + $?` chown root:root /bin/loadmonitor checker=`expr $checker + $?` chown root:root /bin/blink checker=`expr $checker + $?` chown root:root /bin/randblink checker=`expr $checker + $?` chown root:root /bin/led checker=`expr $checker + $?` chown root:root /bin/fantest checker=`expr $checker + $?` chown root:root /bin/video checker=`expr $checker + $?` if [ $checker -gt 0 ]; then false else true fi check echo -n "Setting permissions... " checker=0 chmod 744 /bin/fanctl checker=`expr $checker + $?` chmod 744 /bin/testi2c checker=`expr $checker + $?` chmod 755 /bin/xboxtemp checker=`expr $checker + $?` chmod 755 /bin/video checker=`expr $checker + $?` chmod 744 /bin/loadmonitor checker=`expr $checker + $?` chmod 744 /bin/blink checker=`expr $checker + $?` chmod 744 /bin/randblink checker=`expr $checker + $?` chmod 744 /bin/fantest checker=`expr $checker + $?` chmod 744 /bin/led checker=`expr $checker + $?` chmod +s /bin/xboxtemp checker=`expr $checker + $?` chmod +s /bin/video checker=`expr $checker + $?` if [ $checker -gt 0 ]; then false else true fi check countErrors else echo -n "You have not yet built the source, run $0 build first... " false check countErrors fi else echo -n "You are not in the right directory... " false check countErrors fi else echo -n "You must be root to install these files... " false check countErrors fi ;; uninstall) if [ `whoami` == "root" ]; then echo -n "Removing /bin/fanctl... " rm -rf /bin/fanctl check echo -n "Removing /bin/testi2c... " rm -rf /bin/testi2c check echo -n "Removing /bin/xboxtemp... " rm -rf /bin/xboxtemp check echo -n "Removing /bin/loadmonitor... " rm -rf /bin/loadmonitor check echo -n "Removing /bin/led... " rm -rf /bin/led check echo -n "Removing /bin/blink... " rm -rf /bin/blink check echo -n "Removing /bin/fantest... " rm -rf /bin/fantest check echo -n "Removing /bin/randblink... " rm -rf /bin/randblink check echo -n "Removing /bin/video... " rm -rf /bin/video check countErrors fi ;; *) echo "Usage: $0 [ clean | build | install | uninstall ]" echo "" echo "NOTE:" echo "You must be in the shallaxs_i2c_stuff directory to use this wizard" ;; esac