[Atrix 4G Android Development] mistadman:
My Contribution....

gladroot.sh - v4.2!

#!/bin/bash

###### CHANGE TO FULL PATH OF YOUR ADB BINARY OR LEAVE AS IS IF THE ADB BINARY IS IN YOUR PATH #####
adb="./adb"

###### DO NOT CHANGE ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING ###################

enable_update=
enable_custom_tethering_apn=
enable_sideload=

function enable_sideloading() {
# Change the install_non_market_apps value from 0 to 1
echo
echo
$adb shell sqlite3 /data/data/com.motorola.android.providers.settings/databases/settings.db "UPDATE settings SET value=0 WHERE name='force_only_market_apps';"
echo "Sideloading enabled! Unknown sources check box is now enabled via Settings->Applications Settings"
echo
sleep 5
}

function enable_custom_tethering_apn() {

# Add a custom APN to the list available in:
# Settings - Wireless & networks - Mobile networks - Access point names
echo
echo
echo "Enabling tethering..."
$adb shell /system/bin/sqlite3 /data/data/com.android.providers.telephony/databases/telephony.db "UPDATE carriers set preloaded='false';" > /dev/null 2>&1
sleep 2 > /dev/null
$adb shell /system/bin/sqlite3 /data/data/com.android.providers.telephony/databases/telephony.db "INSERT INTO carriers (name, numeric, mcc, mnc, apn, user, server, password, proxy, port, mmsproxy, mmsport, mmsc, mmsc2, authtype, type, current, preloaded) VALUES ('AT&T (Custom Tethering)','310410','310','410','wap.cingular','WAP@CINGULARGPRS.COM','','CINGULAR1','','80','wireless.cingular.com ','80','http://mmsc.cingular.com ','','-1','','1','false');" > /dev/null 2>&1

echo
echo "Tethering enabled."
echo
sleep 3
}

function enable_upgrade() {
clear
echo
echo
echo "Pushing backupsu.sh..."
echo

# Copy the needed files and set permissions, then execute the script
$adb push bin/backupsu.sh /data/local/tmp/ 2>/dev/null
$adb shell chmod 0755 /data/local/tmp/backupsu.sh 2>/dev/null

# Execute script and verify it worked
$adb shell ./data/local/tmp/backupsu.sh 2>/dev/null
echo
echo "Process complete. "
echo "If no errors, go to Settings -^> About phone -^> System update to update phone"
echo "Then run afterupdate.sh when the update completes."
echo
}

function exit2() {
# Kill the ADB server so that the directory is no longer in use.
$adb kill-server

echo
echo
echo "All done! Enjoy your rooted Atrix!"
sleep 2
}

function abort() {
echo
echo $1
echo

$adb kill-server
sleep 3
exit
}

# Logo
clear
echo
echo ' ____ __ ______ ____ ____ _____ _____ ______ __ __ '
echo ' /\ _`\ /\ \ /\ _ \/\ _`\ /\ _`\ /\ __`\/\ __`\/\__ _\ /\ \\ \ '
echo ' \ \ \L\_\ \ \ \ \ \L\ \ \ \/\ \ \ \L\ \ \ \/\ \ \ \/\ \/_/\ \/ __ __\ \ \\ \ '
echo ' \ \ \L_L\ \ \ __\ \ __ \ \ \ \ \ \ , /\ \ \ \ \ \ \ \ \ \ \ \ /\ \/\ \\ \ \\ \_ '
echo ' \ \ \/, \ \ \L\ \\ \ \/\ \ \ \_\ \ \ \\ \\ \ \_\ \ \ \_\ \ \ \ \ \ \ \_/ |\ \__ ,__\ '
echo ' \ \____/\ \____/ \ \_\ \_\ \____/\ \_\ \_\ \_____\ \_____\ \ \_\ \ \___/ \/_/\_\_/ '
echo ' \/___/ \/___/ \/_/\/_/\/___/ \/_/\/ /\/_____/\/_____/ \/_/ \/__/ \/_/ '
echo ' Root v4 '

sleep 5

# Disclaimer
clear
echo
echo
echo "*DISCLAIMER*"
echo
echo "This script makes changes to the /system files on your phone."
echo
echo "By continuing you agree that you KNOW WHAT YOU ARE DOING and"
echo "that you accept responsibility if something goes wrong."
echo
echo "We are NOT responsible if this bricks your phone. Thank you."
echo
echo "-Management"
echo
sleep 3

# Main body of Script
clear
echo
echo
echo "Preparing your computer and phone for install..."

# Start the ADB server
echo
echo "Starting ADB server..."
$adb start-server 2>&1 >/dev/null

# Make sure that we actually have a device listening on $adb.
echo
echo Checking device state...

if [ ! "`$adb get-state`" = "device" ]; then
abort "Unable to detect a device over $adb."
fi

# If we do, since we need to run several commands as root, use psneuter to
# temporarily root the device.
echo
echo "Obtaining temporary root access..."

if [ ! "$($adb push bin/psneuter /tmp/psneuter 2> /dev/null && echo yes)" = "yes" ]; then
abort "Unable to send psneuter."
fi

if [ ! "$($adb shell /bin/chmod 6755 /tmp/psneuter 2> /dev/null && echo yes)" = "yes" ]; then
abort "Unable to chmod psneuter.";
fi

$adb shell /tmp/psneuter 2>/dev/null

# Make sure we're root.
echo
echo "Waiting for root access to kick in..."
echo
for x in `seq 1 10`; do
if [ $x -eq 10 ]; then
abort "Something when wrong, psneuter failed to execute properly!"
else
[ "$($adb shell /usr/bin/whoami 2>&1)" = "root" ] && break
fi

sleep 2
echo "Still waiting..."
done

# Remount the /system read/write.
echo
echo "Mounting /system as read/write..."
$adb shell mount -o rw,remount /dev/block/mmcblk0p12 /system 2>/dev/null

# Install sqlite3 for additional system changes required later in the script.
# This is silent because it shouldn't interfere with anything even if it's
# not used.
$adb push bin/sqlite3 /system/bin 2>/dev/null
$adb shell chmod 6755 /system/bin/sqlite3

echo
echo "Ready to root."
echo
sleep 3

# Let's root!
# Check for duplicate busybox installation and remove it.
if [ $($adb shell find /system/xbin -type l | wc -l) -gt 0 ]; then
echo
echo "Cleaning up SuperOneClick mess..."
$adb shell find /system/xbin -type l | xargs rm
[ "$($adb shell ls /system/xbin/busybox 2> /dev/null && echo yes)" = "yes" ] && $adb shell rm /system/xbin/busybox
fi

# Copy su over and set permissions for use.
echo
echo "Rooting your device ..."
$adb push bin/su /system/bin 2>/dev/null
$adb shell chmod 6755 /system/bin/su 2>/dev/null

# Install the Superuser app for allowing other apps root access.
echo
echo Installing Superuser app...
$adb install -r bin/Superuser.apk 2>/dev/null

echo
echo Root complete.
echo
sleep 3

# Ask user if they want to install sideloading.
while true; do
clear
echo
echo
read -p "Do you want to install sideloading? [y/n] " yn
case $yn in
[Yy]* ) enable_sideloading; break;;
[Nn]* ) break;;
* ) echo -e "\nPlease answer [y]es or [n]o."; sleep 2;;
esac
done

# Ask user if they want to install the tethering APN.
while true; do
clear
echo
echo
echo "Do you want to install custom tethering APN?"
read -p "(Say [N]O if you already enabled this, or you will get duplicates) [y/n] " yn
case $yn in
[Yy]* ) enable_custom_tethering_apn; break;;
[Nn]* ) break;;
* ) echo -e "\nPlease answer [y]es or [n]o."; sleep 2;;
esac
done

# Ask user if they plan to upgraded.
while true; do
clear
echo
echo
read -p "Are you updating an AT&T Atrix on 1.26 to 1.57? [y/n] " yn
case $yn in
[Yy]* ) enable_upgrade; break;;
[Nn]* ) break;;
* ) echo -e "\nPlease answer [y]es or [n]o."; sleep 2;;
esac
done