tor_dongle_setup.sh 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #!/bin/bash
  2. # This script installs the Debian image to the microSD card, and should
  3. # be run on your laptop/desktop with the microSD card plugged in.
  4. # License
  5. # =======
  6. #
  7. # Copyright (C) 2014-2015 Bob Mottram <bob@robotics.uk.to>
  8. #
  9. # This program is free software: you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation, either version 3 of the License, or
  12. # (at your option) any later version.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU General Public License
  20. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. # Version number of this script
  22. VERSION="1.00"
  23. # typically /dev/sdb or /dev/sdc, depending upon how
  24. # many drives there are on your system
  25. MICROSD_DRIVE=$1
  26. # IP address of the router (gateway)
  27. ROUTER_IP_ADDRESS="192.168.1.254"
  28. # The fixed IP address of the Beaglebone Black on your local network
  29. BBB_FIXED_IP_ADDRESS="192.168.7.2"
  30. MICROSD_MOUNT_POINT="/media/$USER"
  31. DEBIAN_FILE_NAME="debian-jessie-console-armhf-2014-08-13"
  32. # Downloads for the Debian installer
  33. DOWNLOAD_LINK1="https://rcn-ee.net/deb/rootfs/jessie/$DEBIAN_FILE_NAME.tar.xz"
  34. DOWNLOAD_LINK2="http://ynezz.ibawizard.net/beagleboard/jessie/$DEBIAN_FILE_NAME.tar.xz"
  35. if [ ! MICROSD_DRIVE ]; then
  36. echo 'You need to specify a drive for the connected microSD.'
  37. echo 'This can most easily be found by removing the microSD, then'
  38. echo 'running:'
  39. echo ''
  40. echo ' ls /dev/sd*'
  41. echo ''
  42. echo 'Then plugging the microSD back in and entering the same command again'
  43. exit 1
  44. fi
  45. if [ ! -b ${MICROSD_DRIVE}1 ]; then
  46. echo "The microSD drive could not be found at ${MICROSD_DRIVE}1"
  47. exit 2
  48. fi
  49. if [ ! -d ~/freedombone ]; then
  50. mkdir ~/freedombone
  51. fi
  52. cd ~/freedombone
  53. if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.tar.xz ]; then
  54. wget $DOWNLOAD_LINK1
  55. fi
  56. if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.tar.xz ]; then
  57. # try another site
  58. wget $DOWNLOAD_LINK2
  59. if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.tar.xz ]; then
  60. echo 'The Debian installer could not be downloaded'
  61. exit 3
  62. fi
  63. fi
  64. echo 'Extracting files...'
  65. tar xJf $DEBIAN_FILE_NAME.tar.xz
  66. if [ ! -d ~/freedombone/$DEBIAN_FILE_NAME ]; then
  67. echo "Couldn't extract files"
  68. exit 4
  69. fi
  70. cd $DEBIAN_FILE_NAME
  71. sudo ./setup_sdcard.sh --mmc $MICROSD_DRIVE --dtb beaglebone
  72. echo ''
  73. echo ''
  74. read -p "Eject the microSD card, re-insert it and wait a minute for it to mount, then press any key to continue... " -n1 -s
  75. if [ ! -b ${MICROSD_DRIVE}1 ]; then
  76. echo ''
  77. echo "The microSD drive could not be found at ${MICROSD_DRIVE}1"
  78. read -p "Wait for the drive to mount then press any key... " -n1 -s
  79. if [ ! -b ${MICROSD_DRIVE}1 ]; then
  80. echo "microSD drive not found at ${MICROSD_DRIVE}1"
  81. exit 5
  82. fi
  83. fi
  84. sudo cp $MICROSD_MOUNT_POINT/BOOT/bbb-uEnv.txt $MICROSD_MOUNT_POINT/BOOT/uEnv.txt
  85. sudo sed -i 's/nameserver.*/nameserver 213.73.91.35/g' $MICROSD_MOUNT_POINT/rootfs/etc/resolv.conf
  86. sudo sed -i '/nameserver 213.73.91.35/a\nameserver 85.214.20.141' $MICROSD_MOUNT_POINT/rootfs/etc/resolv.conf
  87. clear
  88. echo '*** Initial microSD card setup is complete ***'
  89. echo ''
  90. echo 'The microSD card can now be removed and inserted into the Beaglebone Black.'
  91. echo 'Once the Beaglebone has booted then you can log in with:'
  92. echo ''
  93. echo " ssh debian@$BBB_FIXED_IP_ADDRESS"
  94. echo ''
  95. echo 'The password is "temppwd". You can then become the root user by typing:'
  96. echo ''
  97. echo ' su'
  98. echo ''
  99. echo 'Using the password "root". Change the root user password by typing:'
  100. echo ''
  101. echo ' passwd'
  102. echo ''
  103. echo 'Then create a user for the system with:'
  104. echo ''
  105. echo ' adduser [username]'
  106. echo ''
  107. echo 'Enter the command "exit" a couple of times to get back to your main system'
  108. echo 'then log back in as the user you just created with:'
  109. echo ''
  110. echo ' ssh [username]@$BBB_FIXED_IP_ADDRESS'
  111. echo ''
  112. echo 'and use the "su" command to become the root user again. You can then load'
  113. echo 'the freedombone main installation script with:'
  114. echo ''
  115. echo ' apt-get -y install git'
  116. echo ' git clone https://github.com/bashrc/freedombone.git'
  117. echo ' cd freedombone'
  118. echo ''
  119. echo 'Finally you can run the freedombone installer with:'
  120. echo ''
  121. echo ' ./install-freedombone.sh [domain] [username] 0 tordongle'
  122. exit 0