[General Topics] S0AndS0:
Read Page 10 for why this script is posted

#!/bin/bash

# insert "set -x" on a new line to "watch" bash work

# insert "set +x" on a new line to stop this latter on

# use the above commands to selectively see where errors are occurring.

# and or just watch it if that's what you're into.

echo “see these two sites and related material for why this script is useful or needed”

echo “http://xdaforums.com/showthread.php?t=2240397&page=10”

echo “and”

echo “http://wiki.bitcraze.se/projects:virtualmachine:create_vm“

echo “and Link to current version of this script”

echo “with full Guided Tour through all the commands used throughout”

echo “https://docs.google.com/document/d/1A64GMgcVUKbZrTG2WDWfY_g9vABuRx78ULULu-Ir-kE/edit?usp=sharing”

echo “## With this script you can ##”

echo “### Manually or Automatically ###”

echo “### Modify your repos with ###”

echo “#### add-apt-repository or Repo_Mod ####”

echo “### Add a list of Repositories with ###”

echo “#### Package_Install_List ####”

echo “### Clone a list of Repositories with ###”

echo “#### Crazyflie_Repo_Cloner ####”

echo “### Link new packages into Bash with ###”

echo “#### BashRC_Linker ####”

echo “### Construct your Toolchain for Crazyflie with ####”

echo “#### Crazyflie_Toolchain_DBer ####”

echo “### Set your Udev rules for Crazyflie with ###”

echo “#### Udev_Rules ####”

echo “### And run all of them one after another with ###”

echo “#### Script_runner ####”

echo “## The only part that requires care ##”

echo “## when editing is Script_Runner ##”

echo “## All others can be edited after Part 1 ##”

echo “### if you choose to Manually edit ###”

echo “### the scripts in $HOME/BitcrazeDepends ###”

echo “### you may still use Script_Runner to ###”

echo “### provide an edited auto install. ###”

echo “### Just be sure to comment out ###”

echo “### the parts that do not apply ###”

echo “#### or comment out ####”

echo “#### the install and permission fixes in ####”

echo “#### Script_Runner and Permission_Fixer ####”

echo “### Don’t worry about messing up the scripts ###”

echo “### that This_Script adds to your system ###”

echo “### edit away and enjoy because you can ###”

echo “### re-make them all again with This_Script ###”

echo “#### Instead worry about destabilizing your ####”

echo “#### install of Linux or opening security risks ####”

echo “#### this is because you will be moving from ####”

echo “#### stable to testing or unstable by ####”

echo “#### adding repos not originally with your distribution ####”

echo “## All of which is offered free and ##”

echo “## without warranty in the hopes and ##”

echo “## intentions that it will be found useful ##”

echo “## and educational for installing and ##”

echo “## controlling the CrazyFlie Quadcopters ##”

echo “## with Android running Linux ##”

echo “## Debian Squeeze by way of ##”

echo “## Debian Kit from the App store ##”

echo “## You the reader will still have to figure out ##”

echo “### USB Host Mode and ###”

echo “### USB Drivers for ###”

echo “#### Your USB controller ####”

echo “#### Your USB Dongle ####”

echo “#### And Your USB Hub ####”

echo “## As Always happy hacking and moding ##”

echo “## and the author can be contacted though ##”

echo “## Google at Michael NA and ##”

echo “## XDA at S0AndS0 ##”

echo “## for any help or concerns ##”

{

## alert to what's about to happen

echo “###################################”

echo “This script is written for free in the hopes that it will be found useful,”

echo “use it to install all know dependencies for setting up an Android Linux”

echo “development platform for interacting with the Crazyflie Quadcopter”

echo “http://www.bitcraze.se/about/”

echo “Contact S0AndS0 though XDA or”

echo “Contact Michael NA though Google”

echo “for support with this script”

echo “###################################”

echo "You're about to destabilize your distribution";

## confirm with the user

read -r -p "Are you sure? [Y/n]" response

case "$response" in

[yY][eE][sS]|[yY])

## # if yes, then start risking changes

;;

*)

##	# Otherwise exit..

echo "Good Night"

exit

;;

esac

}

#### Next is setting some required variables

: ${USER?} ${HOME?}

echo

echo "You are $USER."

echo "Your home directory is $HOME."

echo

echo "If you are reading this message,"

echo "critical environmental variables have been set."

## more variables to come later

##### run apt-get update

sudo apt-get update

###### Make a folder to write and Install all the packages required to run the rest of the script

mkdir -p $HOME/BitcrazeDepends

## # Note when this installs you'll need to restart your lock screen and screen saver to avoid being locked out of your accounts

## Now to add the ability to add ppa’s

#### Repo Modifications

sudo cat > $HOME/BitcrazeDepends/Repo_Mod <<EOF #!/bin/bash

echo "This script will make modifications to your Repo list"

echo "after running you will be able to access the Wheeze repo"

echo "and add your own ppa repos with the add-apt-repository command"

echo "Steps to install this:1. Download a script for adding ppa repositories to debian”

wget -cO $HOME/BitcrazeDepends/add-apt-repository.sh.txt http://blog.anantshri.info/content/uploads/2010/09/add-apt-repository.sh.txt

echo "2. Save this file in /usr/sbin/"

cp $HOME/BitcrazeDepends/add-apt-repository.sh.txt /usr/sbin/add-apt-repository

echo "3. Change permissions to execute"

chmod o+x /usr/sbin/add-apt-repository

echo "4. Change ownership to root"

chown root:root /usr/sbin/add-apt-repository

echo "5. Now when ever you need to execute command type"

echo "$ sudo add-apt-repository ppa:ppa-name"

EOF

#### more Repo Modifications

### make a new repository list in the /etc/apt/ directory,

### make a new file called wheezy.list and put the path for apt-get to look for new packages

sudo cat > /etc/apt/sources.list.d/wheezy.list <<EOF

deb http://ftp.us.debian.org/debian/ wheezy main python

EOF

#### Adding Repos

sudo cat > $HOME/BitcrazeDepends/Adding_Repos <<EOF #!/bin/bash

## Now to add some ppa’s

echo “adding ppa:tortoisehg-ppa/releases to list of available repositories”

sudo add-apt-repository -y ppa:tortoisehg-ppa/releases

echo “adding ppa:iztok.jeras/ppa to list of available repositories”

sudo add-apt-repository -y ppa:iztok.jeras/ppa

echo “Updating apt-get now”

sudo apt-get update

EOF

#### Create a List of packages to install

echo "creating a list of packages to install to your system"

sudo cat > $HOME/BitcrazeDepends/Package_Install_List <<EOF #!/bin/bash

# I compiled this list from http://wiki.bitcraze.se/projects:virtualmachine:create_vm

# let me know if things need to be added or changed, please and thank you.

echo "you may run the package install list manually later to keep your system up to date,"

echo "to do so run $ sh $HOME/BitcrazeDepends/Package_Install_List from a terminal window"

echo "for now though this script will automatically take care of the first install of all packages"

sudo apt-get install -y virtualbox-guest-dkms

sudo apt-get install -y virtualbox-guest-x11

sudo apt-get install -y virtualbox-guest-utils

sudo apt-get install -y mercurial

sudo apt-get install -y sdcc

sudo apt-get install -y python2.7

sudo apt-get install -y python-usb

sudo apt-get install -y python-pygame

sudo apt-get install -y python-qt4

sudo apt-get install -y qt4-designer

sudo apt-get install -y kicad

sudo apt-get install -y build-essential

sudo apt-get install -y build-essential

sudo apt-get install -y meld

echo "you may run the package install list manually later to keep your system up to date,"

echo "to do so run $ sh $HOME/BitcrazeDepends/Package_Install_List from a terminal window"

echo "for now though this script will automatically take care of the first install of all packages"

EOF

#### Make a script to get the toolchain needed for the Crazyflie firmware

echo “Building small script to download and build toolchain for Crazyfilie firmware”

sudo cat > $HOME/BitcrazeDepends/Crazyflie_toolchain_DBer <<EOF #!/bin/bash

wget https://launchpad.net/gcc-arm-embed...m-none-eabi-4_7-2013q1-20130313-linux.tar.bz2

tar xjf gcc-arm-none-eabi-4_7-2013q1-20130313-linux.tar.bz2

mkdir -p $HOME/BitcrazeDepends/bin

mv gcc-arm-none-eabi-4_7-2013q1 $HOME/BitcrazeDepends/bin/gcc-arm-none-eabi

EOF

#### Make a script so the correct paths so your system can find the toolchain

echo “Building small script that links in the bashrc file so your system can find the toolchain that was just installed”

sudo cat > $HOME/BitcrazeDepends/BashRC_Linker <<EOF #!/bin/bash

echo -e "\nPATH=\$PATH:$HOME/BitcrazeDepends/bin/gcc-arm-none-eabi/bin" >> ~/.bashrc

source ~/.bashrc

EOF

#### Make a script to add udev rules for Crazyradio

echo “Building small script that adds udev rules for Crazyradio now”

sudo cat > $HOME/BitcrazeDepends/Udev_Rules <<EOF #!/bin/bash

sudo usermod -a -G plugdev $USER

sudo sh -c 'echo SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"1915\", ATTRS{idProduct}==\"7777\", MODE=\"0664\", GROUP=\"plugdev\" > /etc/udev/rules.d/99-crazyradio.rules'

sudo sh -c 'echo SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"1915\", ATTRS{idProduct}==\"0101\", MODE=\"0664\", GROUP=\"plugdev\" >> /etc/udev/rules.d/99-crazyradio.rules'

EOF

#### Make a script to clone repos for Crazyflie

echo “Creating a small script to clone repos for Crazyflie”

sudo cat > $HOME/BitcrazeDepends/Crazyflie_Repo_Cloner <<EOF #!/bin/bash

mkdir -p $HOME/BitcrazeDepends/projects

cd $HOME/BitcrazeDepends/projects

hg clone https://bitbucket.org/bitcraze/crazyflie-pc-client

hg clone https://bitbucket.org/bitcraze/crazyflie-firmware

hg clone https://bitbucket.org/bitcraze/crazyflie-bootloader

hg clone https://bitbucket.org/bitcraze/crazyradio-firmware

EOF

#### Make a script to run all scripts created by this script

echo "Now writing a script that will run all scripts that were written to your system"

sudo cat > $HOME/BitcrazeDepends/Script_Runner <<EOF #!/bin/bash

sh $HOME/BitcrazeDepends/Package_Install_List

sh $HOME/BitcrazeDepends/Crazyflie_Toolchain_DBer

sh $HOME/BitcrazeDepends/BashRC_Linker

sh $HOME/BitcrazeDepends/Udev_Rules

sh $HOME/BitcrazeDepends/Repo_Mod

sh $HOME/BitcrazeDepends/Adding_Repos

#### Request if user wants to clone the repo

echo "would you like to clone the Bitcraze Repo while you're at it?"

{

## confirm with the user

read -r -p "Do you want to Clone Bitcrazes Repo? [Y/n]" response

case "$response" in

[yY][eE][sS]|[yY])

## # if yes, then start risking changes

sh $HOME/BitcrazeDepends/Crazyflie_Repo_Cloner

;;

*)

##	# Otherwise exit..

echo "Good Night"

exit

;;

esac

}

EOF

#### Make a script to fix all permissions for this script

echo "Making a file to fix permissions for the rest of this script"

sudo cat > $HOME/BitcrazeDepends/Permission_Fixer <<EOF #!/bin/bash

####### Now Fixing permissions

echo "fixing permissions for running this script"

sudo chmod +x $HOME/BitcrazeDepends/Package_Install_List

sudo chmod +x $HOME/BitcrazeDepends/Crazyflie_Toolchain_DBer

sudo chmod +x $HOME/BitcrazeDepends/BashRC_Linker

sudo chmod +x $HOME/BitcrazeDepends/Udev_Rules_linker

sudo chmod +x $HOME/BitcrazeDepends/Crazyflie_Repo_Cloner

sudo chmod +x $HOME/BitcrazeDepends/Repo_Mod

sudo chmod +x $HOME/BitcrazeDepends/Adding_Repos

sudo chmod +x $HOME/BitcrazeDepends/Script_Runner

EOF

#### Fix permissions for that file so it can run

echo “Fixing the Permissions on Permission_Fixer so it can fix all other permissions”

sudo chmod +x $HOME/BitcrazeDepends/Permission_Fixer

## Checks will need to be added to ensure all has downloaded and installed before the next part, for now ask the user again if they want to continue

{

## confirm manual or auto install

echo "Part 1 complete, starting Part 2"

echo "To reiterate the variables"

echo "Your username is $USER"

echo "Your home folder is $HOME"

echo "you can now exit this script and run each individual script"

echo "from the $HOME/BitcrazeDepends directory"

echo "or let this continue in auto mode by selecting yes"

read -r -p "Would you like to continue in auto mode? [Y/n]" response

case "$response" in

[yY][eE][sS]|[yY])

#### if yes, then run Script_Runner to auto install everything

sh $HOME/BitcrazeDepends/Script_Runner

;;

*)

##	# Otherwise exit..

echo "Good Night"

exit

;;

esac

}

echo “Installation Complete?”

echo “###################################”

echo “Use the following Links to research how set up connections”

echo “to control your Crazyflie”

echo “[APP][2.1+][ROOT] Usb Host Controller 0.42”

echo “http://xdaforums.com/showthread.php?t=1468531”

echo

echo “###################################”

#############################

#############################

#########ChangeLog##########

# 06182013 First written

# 06192013 Looks good but untested for the desired purpose

# 06202013 Major restructuring of the ordering of the script

# 06202013 Edits complete; script can now be used hopefully...

#!/bin/bash

# insert "set -x" on a new line to "watch" bash work

# insert "set +x" on a new line to stop this latter on

# use the above commands to selectively see where errors are occurring.

# and or just watch it if that's what you're into.

echo “see these two sites and related material for why this script is useful or needed”

echo “http://xdaforums.com/showthread.php?t=2240397&page=10”

echo “and”

echo “http://wiki.bitcraze.se/projects:virtualmachine:create_vm“

echo “and Link to current version of this script”

echo “with full Guided Tour through all the commands used throughout”

echo “https://docs.google.com/document/d/1A64GMgcVUKbZrTG2WDWfY_g9vABuRx78ULULu-Ir-kE/edit?usp=sharing”

{

## alert to what's about to happen

echo “###################################”

echo “This script is written for free in the hopes that it will be found useful,”

echo “use it to install all know dependencies for setting up an Android Linux”

echo “development platform for interacting with the Crazyflie Quadcopter”

echo “http://www.bitcraze.se/about/”

echo “Contact S0AndS0 though XDA or”

echo “Contact Michael NA though Google”

echo “for support with this script”

echo “###################################”

echo "You're about to destabilize your distribution";

## confirm with the user

read -r -p "Are you sure? [Y/n]" response

case "$response" in

[yY][eE][sS]|[yY])

## # if yes, then start risking changes

;;

*)

##	# Otherwise exit..

echo "Good Night"

exit

;;

esac

}

###	make a new repository list in the /etc/apt/ directory, make a new file called wheezy.list and put the path for apt-get to look for new packages

sudo cat > /etc/apt/sources.list.d/wheezy.list <<EOF

deb http://ftp.us.debian.org/debian/ wheezy main python

EOF

#### Next is setting some required variables

: ${USER?} ${HOME?}

echo

echo "You are $USER."

echo "Your home directory is $HOME."

echo

echo "If you are reading this message,"

echo "critical environmental variables have been set."

## more variables to come later

##### run apt-get update

sudo apt-get update

###### Make a file/script to Install all the packages required to run the rest of the script

mkdir -p $HOME/BitcrazeDepends

## # Note when this installs you'll need to restart your lock screen and screen saver to avoid being locked out of your accounts

## Now to add the ability to add ppa’s

echo "Steps to install this:1. Download a script for adding ppa repositories to debian”

wget -cO $HOME/BitcrazeDepends/add-apt-repository.sh.txt http://blog.anantshri.info/content/uploads/2010/09/add-apt-repository.sh.txt

echo "2. Save this file in /usr/sbin/"

cp $HOME/BitcrazeDepends/add-apt-repository.sh.txt /usr/sbin/add-apt-repository

echo "3. Change permissions to execute"

chmod o+x /usr/sbin/add-apt-repository

echo "4. Change ownership to root"

chown root:root /usr/sbin/add-apt-repository

echo "5. Now when ever you need to execute command type"

echo "$ sudo add-apt-repository ppa:ppa-name"

## Now to add some ppa’s

echo “adding ppa:tortoisehg-ppa/releases to list of available repositories”

sudo add-apt-repository -y ppa:tortoisehg-ppa/releases

echo “adding ppa:iztok.jeras/ppa to list of available repositories”

sudo add-apt-repository -y ppa:iztok.jeras/ppa

echo “Updating apt-get now”

sudo apt-get update

echo "creating a list of packages to install to your system"

sudo cat > $HOME/BitcrazeDepends/Package_Install_List <<EOF #!/bin/bash

# I compiled this list from http://wiki.bitcraze.se/projects:virtualmachine:create_vm

# let me know if things need to be added or changed, please and thank you.

sudo apt-get install -y virtualbox-guest-dkms

sudo apt-get install -y virtualbox-guest-x11

sudo apt-get install -y virtualbox-guest-utils

sudo apt-get install -y mercurial

sudo apt-get install -y sdcc

sudo apt-get install -y python2.7

sudo apt-get install -y python-usb

sudo apt-get install -y python-pygame

sudo apt-get install -y python-qt4

sudo apt-get install -y qt4-designer

sudo apt-get install -y kicad

sudo apt-get install -y build-essential

sudo apt-get install -y build-essential

sudo apt-get install -y meld

EOF

####### Now to make that file executable

echo "making the package install list executable"

sudo chmod +x $HOME/BitcrazeDepends/Package_Install_List

####### Now to run the commands listed in that file.

echo "you may run the package install list manually later to keep your system up to date,"

echo "to do so run $ sh $HOME/BitcrazeDepends/Package_Install_List from a terminal window"

echo "for now though this script will automatically take care of the first install of all packages now"

sh $HOME/BitcrazeDepends/Package_Install_List

## Now to get the toolchain needed for the Crazyflie firmware

echo “Building small script to download and build toolchain for Crazyfilie firmware”

sudo cat > $HOME/BitcrazeDepends/Crazyflie_toolchain_DBer <<EOF #!/bin/bash

wget https://launchpad.net/gcc-arm-embed...m-none-eabi-4_7-2013q1-20130313-linux.tar.bz2

tar xjf gcc-arm-none-eabi-4_7-2013q1-20130313-linux.tar.bz2

mkdir -p $HOME/BitcrazeDepends/bin

mv gcc-arm-none-eabi-4_7-2013q1 $HOME/BitcrazeDepends/bin/gcc-arm-none-eabi

EOF

####### Now to make that file executable

sudo chmod +x $HOME/BitcrazeDepends/Crazyflie_toolchain_DBer

####### Now to run the commands listed in that file.

sh $HOME/BitcrazeDepends/Crazyflie_toolchain_DBer

# Now to add the correct paths so your system can find the toolchain

echo “creating another script that links in the bashrc file so your system can find the toolchain that was just installed”

sudo cat > $HOME/BitcrazeDepends/BashRC_linker <<EOF #!/bin/bash

echo -e "\nPATH=\$PATH:$HOME/BitcrazeDepends/bin/gcc-arm-none-eabi/bin" >> ~/.bashrc

source ~/.bashrc

EOF

####### Now to make that file executable

sudo chmod +x $HOME/BitcrazeDepends/BashRC_linker

####### Now to run the commands listed in that file.

sh $HOME/BitcrazeDepends/BashRC_linker

# Now to add udev rules for Crazyradio

echo “adding script to add udev rules for Crazyradio now”

sudo cat > $HOME/BitcrazeDepends/Udev_Rules <<EOF #!/bin/bash

sudo usermod -a -G plugdev $USER

sudo sh -c 'echo SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"1915\", ATTRS{idProduct}==\"7777\", MODE=\"0664\", GROUP=\"plugdev\" > /etc/udev/rules.d/99-crazyradio.rules'

sudo sh -c 'echo SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"1915\", ATTRS{idProduct}==\"0101\", MODE=\"0664\", GROUP=\"plugdev\" >> /etc/udev/rules.d/99-crazyradio.rules'

EOF

####### Now to make that file executable

sudo chmod +x $HOME/BitcrazeDepends/Udev_Rules_linker

####### Now to run the commands listed in that file.

sh $HOME/BitcrazeDepends/Udev_Rules

## Checks will need to be added to ensure all has downloaded and installed before the next part, for now ask the user again if they want to continue

echo "If you are seeing this message then part one of this script is done"

echo "Starting part two"

echo "You're about to install extras to your system";

echo "these following steps will clone all availble repos for Crazyflie Crazyradio projects”

echo “ to the projects folder under $HOME/BitcrazeDepends directory”

## confirm with the user

echo "To reiterate the variables"

echo "Your username is $USER"

echo "Your home folder is $HOME"

{

## confirm with the user

read -r -p "Are you sure? [Y/n]" response

case "$response" in

[yY][eE][sS]|[yY])

## # if yes, then start risking changes

;;

*)

##	# Otherwise exit..

echo "Good Night"

exit

;;

esac

}

echo “Creating a small script to clone repos for Crazyflie”

sudo cat > $HOME/BitcrazeDepends/Crazyflie_Repo_Cloner <<EOF #!/bin/bash

mkdir -p $HOME/BitcrazeDepends/projects

cd $HOME/BitcrazeDepends/projects

hg clone https://bitbucket.org/bitcraze/crazyflie-pc-client

hg clone https://bitbucket.org/bitcraze/crazyflie-firmware

hg clone https://bitbucket.org/bitcraze/crazyflie-bootloader

hg clone https://bitbucket.org/bitcraze/crazyradio-firmware

EOF

####### Now to make that file executable

sudo chmod +x $HOME/BitcrazeDepends/Crazyflie_Repo_Cloner

####### Now to run the commands listed in that file.

sh $HOME/BitcrazeDepends/Crazyflie_Repo_Cloner

echo “Installation Complete?”

echo “###################################”

echo “Use the following Links to research how set up connections”

echo “to control your Crazyflie”

echo “[APP][2.1+][ROOT] Usb Host Controller 0.42”

echo “http://xdaforums.com/showthread.php?t=1468531”

echo

echo “###################################”

#############################

#############################

#########ChangeLog##########

# 06182013 First written

# 06192013 Looks good but untested for the desired purpose

# 06202013 Major restructuring of the ordering of the script