Browse Source

Initial microSD setup script

Bob Mottram 10 years ago
parent
commit
3a5bafb0df
2 changed files with 121 additions and 3 deletions
  1. 118
    0
      initial_setup.sh
  2. 3
    3
      install-freedombone.sh

+ 118
- 0
initial_setup.sh View File

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

+ 3
- 3
install-freedombone.sh View File

@@ -34,15 +34,15 @@
34 34
 # Summary
35 35
 # =======
36 36
 #
37
+# This script is intended to be run on the target device, which
38
+# is typically a Beaglebone Black.
39
+#
37 40
 # To be able to run this script you need to get to a condition
38 41
 # where you have Debian Jessie installed, with at least one
39 42
 # unprivileged user account and at least one subdomain created on
40 43
 # https://freedns.afraid.org/. If you're not installing on a
41 44
 # Beaglebone Black then set the variable INSTALLING_ON_BBB to "no"
42 45
 #
43
-# This script is intended to be run on the target device, which
44
-# is typically a Beaglebone Black.
45
-#
46 46
 # Note on dynamic dns
47 47
 # ===================
48 48
 #