initial_setup.sh 4.2KB

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