Kaynağa Gözat

Script for tor dongle creation

Bob Mottram 10 yıl önce
ebeveyn
işleme
62a2d0693a
1 değiştirilmiş dosya ile 139 ekleme ve 0 silme
  1. 139
    0
      tor_dongle_setup.sh

+ 139
- 0
tor_dongle_setup.sh Dosyayı Görüntüle

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