initial_setup.sh 4.9KB

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 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. # typically /dev/sdb or /dev/sdc, depending upon how
  22. # many drives there are on your system
  23. MICROSD_DRIVE=$1
  24. # IP address of the router (gateway)
  25. ROUTER_IP_ADDRESS="192.168.2.1"
  26. # The fixed IP address of the Beaglebone Black on your local network
  27. BBB_FIXED_IP_ADDRESS="192.168.2.200"
  28. MICROSD_MOUNT_POINT="/media/$USER"
  29. # Downloads for the Debian installer
  30. DOWNLOAD_LINK1="https://rcn-ee.net/deb/rootfs/jessie/debian-jessie-console-armhf-2014-08-13.tar.xz"
  31. DOWNLOAD_LINK2="http://ynezz.ibawizard.net/beagleboard/jessie/debian-jessie-console-armhf-2014-08-13.tar.xz"
  32. if [ ! MICROSD_DRIVE ]; then
  33. echo 'You need to specify a drive for the connected microSD.'
  34. echo 'This can most easily be found by removing the microSD, then'
  35. echo 'running:'
  36. echo ''
  37. echo ' ls /dev/sd*'
  38. echo ''
  39. echo 'Then plugging the microSD back in and entering the same command again'
  40. exit 1
  41. fi
  42. if [ ! -b ${MICROSD_DRIVE}1 ]; then
  43. echo "The microSD drive could not be found at ${MICROSD_DRIVE}1"
  44. exit 2
  45. fi
  46. if [ ! -d ~/freedombone ]; then
  47. mkdir ~/freedombone
  48. fi
  49. cd ~/freedombone
  50. if [ ! -f ~/freedombone/debian-jessie-console-armhf-2014-08-13.tar.xz ]; then
  51. wget $DOWNLOAD_LINK1
  52. fi
  53. if [ ! -f ~/freedombone/debian-jessie-console-armhf-2014-08-13.tar.xz ]; then
  54. # try another site
  55. wget $DOWNLOAD_LINK2
  56. if [ ! -f ~/freedombone/debian-jessie-console-armhf-2014-08-13.tar.xz ]; then
  57. echo 'The Debian installer could not be downloaded'
  58. exit 3
  59. fi
  60. fi
  61. cd debian-*
  62. sudo ./setup_sdcard.sh --mmc $MICROSD_DRIVE --dtb beaglebone
  63. echo ''
  64. echo ''
  65. 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
  66. if [ ! -b ${MICROSD_DRIVE}1 ]; then
  67. echo ''
  68. echo "The microSD drive could not be found at ${MICROSD_DRIVE}1"
  69. read -p "Wait for the drive to mount then press any key... " -n1 -s
  70. if [ ! -b ${MICROSD_DRIVE}1 ]; then
  71. echo "microSD drive not found at ${MICROSD_DRIVE}1"
  72. exit 4
  73. fi
  74. fi
  75. sudo cp $MICROSD_MOUNT_POINT/BOOT/bbb-uEnv.txt $MICROSD_MOUNT_POINT/BOOT/uEnv.txt
  76. sudo sed -i '/iface eth0 inet dhcp/a\iface eth0 inet static' $MICROSD_MOUNT_POINT/rootfs/etc/network/interfaces
  77. sudo sed -i '/iface eth0 inet static/a\ dns-nameservers 213.73.91.35 85.214.20.141' $MICROSD_MOUNT_POINT/rootfs/etc/network/interfaces
  78. sudo sed -i "/iface eth0 inet static/a\ gateway $ROUTER_IP_ADDRESS" $MICROSD_MOUNT_POINT/rootfs/etc/network/interfaces
  79. sudo sed -i '/iface eth0 inet static/a\ netmask 255.255.255.0' $MICROSD_MOUNT_POINT/rootfs/etc/network/interfaces
  80. sudo sed -i "/iface eth0 inet static/a\ address $BBB_FIXED_IP_ADDRESS" $MICROSD_MOUNT_POINT/rootfs/etc/network/interfaces
  81. sudo sed -i '/iface usb0 inet static/,/ gateway 192.168.7.1/ s/^/#/' $MICROSD_MOUNT_POINT/rootfs/etc/network/interfaces
  82. sudo sed -i 's/nameserver.*/nameserver 213.73.91.35/g' $MICROSD_MOUNT_POINT/rootfs/etc/resolv.conf
  83. sudo echo 'nameserver 85.214.20.141' >> $MICROSD_MOUNT_POINT/rootfs/etc/resolv.conf
  84. sync
  85. clear
  86. echo '*** Initial microSD card setup is complete ***'
  87. echo ''
  88. echo 'The microSD card can now be removed and inserted into the Beaglebone Black.'
  89. echo 'Once the Beaglebone has booted then you can log in with:'
  90. echo ''
  91. echo " ssh debian@$BBB_FIXED_IP_ADDRESS"
  92. echo ''
  93. echo 'The password is "temppwd". You can then become the root user by typing:'
  94. echo ''
  95. echo ' su'
  96. echo ''
  97. echo 'Using the password "root". Change the root user password by typing:'
  98. echo ''
  99. echo ' passwd'
  100. echo ''
  101. echo 'Then create a user for the system with:'
  102. echo ''
  103. echo ' adduser [username]'
  104. echo ''
  105. echo 'Enter the command "exit" a couple of times to get back to your main system'
  106. echo 'then log back in as the user you just created with:'
  107. echo ''
  108. echo ' ssh [username]@$BBB_FIXED_IP_ADDRESS'
  109. echo ''
  110. echo 'and use the "su" command to become the root user again. You can then load'
  111. echo 'the freedombone main installation script with:'
  112. echo ''
  113. echo ' apt-get -y install git'
  114. echo ' git clone https://github.com/bashrc/freedombone.git'
  115. echo ' cd freedombone'
  116. echo ''
  117. echo 'Finally you can run the freedombone installer with:'
  118. echo ''
  119. echo ' ./install-freedombone.sh [domain] [username] [subdomain code] [variant]'
  120. exit 0