#!/usr/bin/env bash # # ------------------------------------------------------------------ # made by sputnick in da FreAkY lApPy lAb (c) 2008 # gilles.quenot gmail com # # This program is free software; you can redistribute it and/or # modify it under the terms of version 2 of the GNU General Public # License published by the Free Software Foundation. # (see http://www.gnu.org/licenses/gpl.html). # ------------------------------------------------------------------ # ,,_ # o" )@ # '''' # ------------------------------------------------------------------ # [ "$BASH" ] || { bash=$(which bash 2>/dev/null) echo "Hey dude ! You must call $0 with ${bash:-"bash"} ! Quitting." exit 2 } Dp() { (( $1 != 0 )) && tput setaf $1 tput bold echo -e "$2" tput sgr0 [[ $3 ]] && exit $3 } if type &>/dev/null kdialog; then Xquery(){ kdialog --title "${0##*/}" --yesno "$1"; } Xdisplay(){ kdialog --title "${0##*/}" --msgbox "$1"; } elif type &>/dev/null zenity; then Xquery(){ zenity --question --title "${0##*/}" --text "$1"; } Xdisplay(){ zenity --info --title "${0##*/}" --text "$1"; } else Dp 1 "You need to install zenity or kdialog." 2 fi TMPFILE=/tmp/${0##*/} # wgetvar=( *** ) shopt -s nocasematch shopt -s extglob trap 'LastReturn=$!; rm -rf "$TMPFILE"; exit $LastReturn' 0 1 2 3 15 if [[ $KDE_FULL_SESSION == true ]]; then de_su(){ kdesudo $@; } elif [[ $GNOME_DESKTOP_SESSION_ID ]]; then de_su(){ gksu $@; } else if type &>/dev/null sudo; then de_su(){ sudo $@; } else Dp 1 "There's no gksu, kdesu, or sudo, quitting." 2 fi fi Xquery "I will open all the Window$ applications one by one. Simply follow the steps. Most of the time, you only need to choose defaults choices. Don't run MyPhoneExplorer when it's just installed. (You'll see the Pop up) Ready ?" || exit $! mkdir -p "$TMPFILE" cd "$TMPFILE" # get stuff from web if { wget "http://www.kegel.com/wine/winetricks" && wget "http://www.fjsoft.at/download.php?id=1" && wget "http://files.manitougs.at/mpe/MPE_script/OLEAUT32.DLL"; } then true else Dp 1 "At least one wget failed !" 2 fi # installing needed libs sh winetricks vb6run sh winetricks msxml3 mv ~/.wine/drive_c/windows/system32/oleaut32.dll ~/.wine/drive_c/windows/system32/oleaut32-alt.dll 2>/dev/null /bin/mv OLEAUT32.DLL ~/.wine/drive_c/windows/system32/oleaut32.dll pushd 1>/dev/null ~/.wine/drive_c/windows/system32 wine regsvr32 oleaut32.dll popd 1>/dev/null # devices DEV=( /dev/ttyACM* ) if(( ${#DEV[@]} < 1 )); then if ! Xquery "Please plug your phone & continue."; then Xdisplay "Maybe you need to run \"mknod /dev/ttyACM0 c 166 0\"" 2 fi fi pushd 1>/dev/null ~/.wine/dosdevices || Dp 1 "Cannot cd to ~/.wine/dosdevices !" 2 de_su chmod 777 /dev/ttyACM* ln -is /dev/ttyACM0 com1 popd 1>/dev/null # installing MPE stuff + libs wine MyPhoneExplorer_Setup_1.7.0.exe pushd 1>/dev/null ~/.wine/drive_c/Program\ Files/MyPhoneExplorer/DLL for Dll in ccrpDtp6.ocx ccrpUCW6.dll ShellMgr.dll SSubTmr6.dll vbalExpBar6.ocx vbalIml6.ocx vbalSGrid6.ocx; do wine regsvr32 "$Dll" done popd 1>/dev/null # creating the startup script echo '#!/usr/bin/env bash' > ~/MyPhoneExplorer.bash BT() { echo "Running scan... please wait" export scan=( $(hcitool scan) ) i=3 #start counter off at after scanning... while (( i < ${#scan[@]} )); do scanname="$scanname ${scan[i++]}" done if [[ "${scan[2]}" ]]; then echo "Found bluetooth device :)" echo "Hex = ${scan[2]}" echo "Name = $scanname" bluetoothcompat=1 else echo "Your bluetooth device is not supported... sorry :(" bluetoothcompat=0 fi if (( bluetoothcompat == 1 )) then echo "Binding Hex address..." de_su rfcomm bind 0 ${scan[2]} echo "Done" echo "Restarting bluetooth..." de_su /etc/init.d/bluetooth restart cd ~/.wine/dosdevices de_su chmod 777 /dev/rfcomm0 ln -is /dev/rfcomm0 ~/.wine/dosdevices/com2 de_su chmod 777 ~/.wine/dosdevices/com2 echo "Connecting to phone..." de_su rfcomm connect 0 ${scan[2]} 2 echo "If this device hasn't been paired with this computer, you should receive a pairing message now..." echo ATZ > /dev/rfcomm0 cat<<-EOF >> ~/MyPhoneExplorer.bash export scan=(\$(hcitool scan)) i=3 #start counter off at after scanning... while (( i < \${#scan[@]} )); do scanname="\$scanname \${scan[i++]}" #echo "host number \$i is \${host[i++]}" done if [[ ! "\${scan[2]}" ]]; then echo 'Your bluetooth device is not supported... sorry :(' bluetoothcompat=0 else echo 'Found bluetooth device :)' echo "Hex = \${scan[2]}" echo "Name = \$scanname" bluetoothcompat=1 fi if (( \$bluetoothcompat == 1 )) then echo 'Binding Hex address...' de_su rfcomm bind 0 \${scan[2]} echo 'Done' echo 'Restarting bluetooth...' de_su '/etc/init.d/bluetooth restart' cd ~/.wine/dosdevices de_su chmod 777 /dev/rfcomm0 fi EOF fi } Xquery "Do you need to configure bluetooth device ?" && BT # typing end of the script cat<> ~/MyPhoneExplorer.bash echo "Running MyPhoneExplorer now..." cd ~/.wine/drive_c/Program\ Files/MyPhoneExplorer WINEDLLOVERRIDES="oleaut32=n" wine ./MyPhoneExplorer.exe EOF chmod +x ~/MyPhoneExplorer.bash if Xquery " Instructions: When MPE starts, click on File > Options, then type COM1 in the com port text box (for a USB connection) or type COM2 (for a bluetooth connection), then check Stable connection and click OK. Lastly, click on the 'refresh' button (in the top corner, next to the Down arrow) and MPE will connect. $( if [[ -f ~/Desktop/MyPhoneExplorer.desktop ]]; then echo 'You only need to click on the desktop icon to run MyPhoneExplorer next times.' else echo '"You only need to execute ~/MyPhoneExplorer.bash to run MyPhoneExplorer next times.' fi ) All is done. Do you want me to run ~/MyPhoneExplorer.bash ?" then bash ~/MyPhoneExplorer.bash & else exit 0 fi