| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | #!/bin/bash
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-16 15:55:47 +00:00
										 |  |  | #kpartx -a asdfsadf.img | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-16 15:55:47 +00:00
										 |  |  | ##dd if=/dev/zero bs=1M count=200 >>2016-02-26-raspbian-jessie-lite.img | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #mount root partition | 
					
						
							| 
									
										
										
										
											2016-03-16 15:55:47 +00:00
										 |  |  | ##mount -o loop,offset=67108864 2016-02-26-raspbian-jessie-lite.img mnt/ | 
					
						
							|  |  |  | ##resize2fs /dev/loop0 | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | #mount boot partition | 
					
						
							| 
									
										
										
										
											2016-03-16 15:55:47 +00:00
										 |  |  | ##mount -o loop,offset=4194304 2016-02-26-raspbian-jessie-lite.img mnt/boot/ | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-16 15:55:47 +00:00
										 |  |  | chroot mnt/ apt-get update | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #update firmware | 
					
						
							| 
									
										
										
										
											2016-03-16 15:55:47 +00:00
										 |  |  | chroot mnt/ apt-get -y install rpi-update | 
					
						
							|  |  |  | chroot mnt/ rpi-update | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | #wifi | 
					
						
							| 
									
										
										
										
											2016-03-16 15:55:47 +00:00
										 |  |  | chroot mnt/ apt-get install -y hostapd isc-dhcp-server | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | #troubleshooting | 
					
						
							| 
									
										
										
										
											2016-03-16 16:13:07 +00:00
										 |  |  | chroot mnt/ apt-get install -y tcpdump | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | #wifi startup | 
					
						
							| 
									
										
										
										
											2016-03-16 16:13:07 +00:00
										 |  |  | chroot mnt/ systemctl enable isc-dhcp-server | 
					
						
							| 
									
										
										
										
											2016-03-16 14:37:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | #disable ntpd autostart | 
					
						
							| 
									
										
										
										
											2016-03-16 16:13:07 +00:00
										 |  |  | chroot mnt/ systemctl disable ntp | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #root key | 
					
						
							|  |  |  | cp -f root mnt/etc/ssh/authorized_keys/root | 
					
						
							|  |  |  | chown root.root mnt/etc/ssh/authorized_keys/root | 
					
						
							|  |  |  | chmod 644 mnt/etc/ssh/authorized_keys/root | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-13 20:12:41 +00:00
										 |  |  | #motd | 
					
						
							|  |  |  | cp -f motd mnt/etc/motd | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | #dhcpd config | 
					
						
							|  |  |  | cp -f dhcpd.conf mnt/etc/dhcp/dhcpd.conf | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #hostapd config | 
					
						
							|  |  |  | cp -f hostapd.conf mnt/etc/hostapd/hostapd.conf | 
					
						
							| 
									
										
										
										
											2016-03-16 15:55:47 +00:00
										 |  |  | cp -f hostapd-edimax.conf mnt/etc/hostapd/hostapd-edimax.conf | 
					
						
							| 
									
										
										
										
											2016-04-01 23:42:54 +00:00
										 |  |  | #hostapd manager script | 
					
						
							| 
									
										
										
										
											2016-04-08 23:17:54 +00:00
										 |  |  | cp -f hostapd_manager.sh mnt/usr/sbin/hostapd_manager.sh | 
					
						
							|  |  |  | chmod 755 mnt/usr/sbin/hostapd_manager.sh | 
					
						
							| 
									
										
										
										
											2016-03-16 14:37:19 +00:00
										 |  |  | #hostapd | 
					
						
							|  |  |  | cp -f hostapd-edimax mnt/usr/sbin/hostapd-edimax | 
					
						
							| 
									
										
										
										
											2016-03-16 15:32:22 +00:00
										 |  |  | chmod 755 mnt/usr/sbin/hostapd-edimax | 
					
						
							|  |  |  | #remove hostapd startup scripts | 
					
						
							|  |  |  | rm -f mnt/etc/rc*.d/*hostapd mnt/etc/network/if-pre-up.d/hostapd mnt/etc/network/if-post-down.d/hostapd mnt/etc/init.d/hostapd mnt/etc/default/hostapd | 
					
						
							|  |  |  | #interface config | 
					
						
							|  |  |  | cp -f interfaces mnt/etc/network/interfaces | 
					
						
							|  |  |  | #custom hostapd start script | 
					
						
							| 
									
										
										
										
											2016-03-16 15:37:56 +00:00
										 |  |  | cp stratux-wifi.sh mnt/usr/sbin/ | 
					
						
							|  |  |  | chmod 755 mnt/usr/sbin/stratux-wifi.sh | 
					
						
							| 
									
										
										
										
											2016-07-14 19:50:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-01 01:13:35 +00:00
										 |  |  | #SDR Serial Script | 
					
						
							|  |  |  | cp -f sdr-tool.sh mnt/usr/sbin/sdr-tool.sh | 
					
						
							|  |  |  | chmod 755 mnt/usr/sbin/sdr-tool.sh | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-20 09:36:45 +00:00
										 |  |  | #ping udev | 
					
						
							|  |  |  | cp -f 99-uavionix.rules mnt/etc/udev/rules.d | 
					
						
							| 
									
										
										
										
											2016-07-14 19:50:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-21 16:11:54 +00:00
										 |  |  | #fan/temp control script | 
					
						
							| 
									
										
										
										
											2017-05-13 14:24:12 +00:00
										 |  |  | #remove old script | 
					
						
							|  |  |  | rm -rf mnt/usr/bin/fancontrol.py | 
					
						
							|  |  |  | #install new program | 
					
						
							|  |  |  | cp ../fancontrol mnt/usr/bin | 
					
						
							|  |  |  | chmod 755 mnt/usr/bin/fancontrol | 
					
						
							|  |  |  | chroot mnt/ /usr/bin/fancontrol remove | 
					
						
							|  |  |  | chroot mnt/ /usr/bin/fancontrol install | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-16 15:32:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | #isc-dhcp-server config | 
					
						
							|  |  |  | cp -f isc-dhcp-server mnt/etc/default/isc-dhcp-server | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #sshd config | 
					
						
							|  |  |  | cp -f sshd_config mnt/etc/ssh/sshd_config | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-17 21:13:30 +00:00
										 |  |  | #udev config | 
					
						
							|  |  |  | cp -f 10-stratux.rules mnt/etc/udev/rules.d | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | #stratux files | 
					
						
							|  |  |  | cp -f ../libdump978.so mnt/usr/lib/libdump978.so | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-16 16:13:07 +00:00
										 |  |  | #go1.5.1 setup | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | cp -rf /root/go mnt/root/ | 
					
						
							| 
									
										
										
										
											2016-03-21 17:42:10 +00:00
										 |  |  | cp -f bashrc.txt mnt/root/.bashrc | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-08 16:03:18 +00:00
										 |  |  | #debug aliases | 
					
						
							| 
									
										
										
										
											2016-04-11 21:25:09 +00:00
										 |  |  | cp -f stxAliases.txt mnt/root/.stxAliases | 
					
						
							| 
									
										
										
										
											2016-04-08 16:03:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | #rtl-sdr setup | 
					
						
							| 
									
										
										
										
											2016-03-21 17:38:12 +00:00
										 |  |  | cp -f rtl-sdr-blacklist.conf mnt/etc/modprobe.d/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-16 16:13:07 +00:00
										 |  |  | chroot mnt/ apt-get install -y git cmake libusb-1.0-0.dev build-essential | 
					
						
							|  |  |  | rm -rf mnt/root/librtlsdr | 
					
						
							|  |  |  | git clone https://github.com/jpoirier/librtlsdr mnt/root/librtlsdr | 
					
						
							|  |  |  | mkdir -p mnt/root/librtlsdr/build | 
					
						
							|  |  |  | #FIXME | 
					
						
							|  |  |  | chroot mnt/ 'cd /root/librtlsdr/build && cmake ../ && make && make install && ldconfig' | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #stratux setup | 
					
						
							|  |  |  | cd /root | 
					
						
							|  |  |  | apt-get install -y mercurial | 
					
						
							|  |  |  | apt-get install -y build-essential | 
					
						
							|  |  |  | rm -rf stratux | 
					
						
							|  |  |  | git clone https://github.com/cyoung/stratux --recursive | 
					
						
							|  |  |  | cd stratux | 
					
						
							|  |  |  | make | 
					
						
							| 
									
										
										
										
											2016-03-16 16:13:07 +00:00
										 |  |  | make install | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #system tweaks | 
					
						
							| 
									
										
										
										
											2016-03-21 18:48:38 +00:00
										 |  |  | cp -f modules.txt mnt/etc/modules | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #kalibrate-rtl | 
					
						
							|  |  |  | cd /root | 
					
						
							| 
									
										
										
										
											2016-03-21 19:58:48 +00:00
										 |  |  | rm -rf kalibrate-rtl | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | git clone https://github.com/steve-m/kalibrate-rtl | 
					
						
							|  |  |  | cd kalibrate-rtl | 
					
						
							| 
									
										
										
										
											2016-03-21 19:58:48 +00:00
										 |  |  | apt-get install -y autoconf fftw3 fftw3-dev libtool | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | ./bootstrap | 
					
						
							|  |  |  | ./configure | 
					
						
							|  |  |  | make | 
					
						
							|  |  |  | make install | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #disable serial console | 
					
						
							| 
									
										
										
										
											2016-07-15 15:49:51 +00:00
										 |  |  | sed -i /boot/cmdline.txt -e "s/console=ttyAMA0,[0-9]\+ //" | 
					
						
							| 
									
										
										
										
											2016-03-15 03:28:14 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #Set the keyboard layout to US. | 
					
						
							|  |  |  | sed -i /etc/default/keyboard -e "/^XKBLAYOUT/s/\".*\"/\"us\"/" | 
					
						
							| 
									
										
										
										
											2016-03-17 20:55:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #boot settings | 
					
						
							| 
									
										
										
										
											2016-03-21 17:05:42 +00:00
										 |  |  | cp -f config.txt mnt/boot/ | 
					
						
							| 
									
										
										
										
											2016-06-22 02:58:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-09 18:25:06 +00:00
										 |  |  | #external OLED screen | 
					
						
							| 
									
										
										
										
											2016-09-11 21:24:01 +00:00
										 |  |  | apt-get install -y libjpeg-dev i2c-tools python-smbus python-pip python-dev python-pil python-daemon screen | 
					
						
							| 
									
										
										
										
											2016-09-12 18:43:56 +00:00
										 |  |  | #for fancontrol.py: | 
					
						
							|  |  |  | pip install wiringpi | 
					
						
							| 
									
										
										
										
											2016-09-11 22:49:01 +00:00
										 |  |  | cd /root | 
					
						
							| 
									
										
										
										
											2016-09-11 20:58:37 +00:00
										 |  |  | git clone https://github.com/rm-hull/ssd1306 | 
					
						
							| 
									
										
										
										
											2017-03-28 21:18:53 +00:00
										 |  |  | cd ssd1306 | 
					
						
							|  |  |  | # Force an older version of ssd1306, since recent changes have caused a lot of compatibility issues. | 
					
						
							|  |  |  | git reset --hard 232fc801b0b8bd551290e26a13122c42d628fd39 | 
					
						
							|  |  |  | python setup.py install | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-11 20:58:37 +00:00
										 |  |  | cp /root/stratux/test/screen/screen.py /usr/bin/stratux-screen.py | 
					
						
							|  |  |  | mkdir -p /etc/stratux-screen/ | 
					
						
							|  |  |  | cp -f /root/stratux/test/screen/stratux-logo-64x64.bmp /etc/stratux-screen/stratux-logo-64x64.bmp | 
					
						
							|  |  |  | cp -f /root/stratux/test/screen/CnC_Red_Alert.ttf /etc/stratux-screen/CnC_Red_Alert.ttf | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-11 21:06:06 +00:00
										 |  |  | #startup scripts | 
					
						
							| 
									
										
										
										
											2016-09-11 22:49:01 +00:00
										 |  |  | cp -f ../__lib__systemd__system__stratux.service mnt/lib/systemd/system/stratux.service | 
					
						
							|  |  |  | cp -f ../__root__stratux-pre-start.sh mnt/root/stratux-pre-start.sh | 
					
						
							| 
									
										
										
										
											2016-09-12 18:43:56 +00:00
										 |  |  | cp -f rc.local mnt/etc/rc.local | 
					
						
							| 
									
										
										
										
											2017-02-02 15:44:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #dhcpcd causes first boot hanging. | 
					
						
							|  |  |  | chroot mnt/ systemctl disable dhcpcd | 
					
						
							| 
									
										
										
										
											2017-02-15 07:37:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #disable hciuart - interferes with ttyAMA0 as a serial port. | 
					
						
							|  |  |  | chroot mnt/ systemctl disable hciuart | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-13 14:24:12 +00:00
										 |  |  | #clean up for release images. | 
					
						
							|  |  |  | rm -rf mnt/root/stratux mnt/root/go |