Installing Raspberry Pi & TPLink
28-1-15
Michael, Tom, An
BACKLINK: http://pad.constantvzw.org/p/2016-05-12-wtc-etherspace
RASPBERRY PI
connect to pc: ethernet cable
* cards are separate
-> download image, burn it
Raspbian Wheezy: https://www.raspberrypi.org/downloads/raspbian/
(larger cummunity, not the latest)
* dd
moves 'input' to 'output' (disk destroyer :-))
no need to unzip image to your computer, straight pipeline
for dd: to be safe, remove other devices connected to your laptop.
never use dd on /dev/sda (your hard disk)
The normal way with an image file is:
dd if=image.img of=/dev/YOURSDCARD bs=4M
Save disk space and time!
Use a pipeline to UNZIP and DD to the card in one step:
unzip -p raspian.zip | sudo dd of=/dev/YOURSDCARDID!!! bs=4M
When writing a rule, never use a number (e.g. SDB1)
when download done, check
$ sync
sync will wait for all writing to be finished
____ connect a screen -> needs an adapter (vga-usb)
connect keyboard + mouse
____ runs Rasberry config
1. Expand Filesystem / hit enter
Finish (using Tab) + Reboot
Login: pi
password: raspberry (in UK-Qwerty)
$ sudo raspi-config
-> brings you to first interface
4. Internationalization options
-> 3. Change keyboard layout -> Generic International -> Other -> Belgian
-> Finish
_____ plug-in ethernet cable TP-Link
$ sudo reboot
-> indicates an ip-address
$ sudo apt-get update
$ sudo apt-get upgrade
* install Chromium/IRC server
TP-LINK
in the box: gpl-license
Linksys developed router with GPL software -> had to release their source code (share-alike) which became the Open WRT project
* Download image: http://wiki.openwrt.org/toh/tp-link/tl-mr3020
or via homepage: https://openwrt.org/ -> Supported Devices -> look for TP-Link 3020
* consumes a lot of power: plug in eventually usb-cable in your laptop as well
* Install
copied from here: http://ediy.com.my/index.php/blog/item/50-flashing-openwrt-to-tp-link-tl-mr3020-3g-4g-wireless-n-router
Installing OpenWRT
- Connect TP-Link TL-MR3020 to computer.
- Open a Browser
- Enter 192.168.0.254 which is the default IP address
- Enter admin for User Name and admin for Password
- Go to Status page & check for status, this is optional. Picture below shows the status of my TL-MR3020 router, the Hardware Version is V1
- Go to System Tools and select Firmware Upgrade
- Click Browse button and choose the OpenWRT firmware that you had downloaded previously as shown in figure below
- Click on Login button to login to OpenWRT
- Make sure click on Go to password configuration to change the login password and enable SSH
Login to OpenWRT
- Restart router
- Open a browser
- Enter 192.168.1.1 (use your own router IP) and you should able to see the LUCI login screen
Configuring an OpenWRT to an existing wireless network + serve as a hotspot
===================================================================================
Starting from a vanilla openwrt.
Following [this tutorial on setting up a wireless hotspot](http://www.ediy.com.my/index.php/blog/item/110-setting-up-a-wireless-hotspot-using-tp-link-tl-mr3020-wireless-n-router), I connected my laptop to the OpenWRT using an ethernet cable, set my wireless settings to Manual 192.168.1.10 / 255.255.255.0 and cleared the gateway & DNS etc to be blank (Clearing the gateway setting is important if you don't want to interfere with your own wifi connection).
Using the web interface, I navigated to Network -> Wifi, and pressed the SCAN button to find my wifi network.
Once found, I entered a password under Wireless Security and left all other options default. (The Network setting remains on wwan (empty)).
After clicking "Save & Apply". I then tested the internet connection via the patch cable. In this case I needed to turn *off* my wifi connection and then add 192.168.1.1 as both gateway *and* DNS in my wired ethernet settings. (Without setting this, the connection was not working).
Once confirmed that this was working, I returned to the web interface, returned to Network -> Wifi and clicked ADD.
Under ESSID, I changed the default "OpenWrt" to "botnet". Ensured that the mode was set to "Access Point", and selected "lan" as the network.
After clicking "Save & Apply". I then cut off my wired connection and restarted my wifi, selecting the network "botnet". After a bit of time, it joined the network and internet was working!
NB: According to the original tutorial, what *is* important is to make sure that the OpenWRT network is not in the same subnet as the external wireless. So it might be better to use something less standard than 192.168.1.1 which may well be the subnet of a wireless network.
* password wifi (botnet): botswaller
if you want to change networks: remove first existing networks + scan to get the new one
Configuring the Raspberry PI
=============================
* Expand / reboot (raspi-config)
* Login: pi/raspberry
* sudo raspi-config to set keyboard layout to English (US). (default is UK)
* sudo raspi-config : Advanced to force audio to the headphone jack.
Used the image of 05_05_2015 (need to copy it)
OpenSSH seems to be running by default
avahi-daemon seems already to be installed (Using [.local address](http://www.howtogeek.com/167190/how-and-why-to-assign-the-.local-domain-to-your-raspberry-pi/) on the Pi.)
Network
----------
Configured a static IP address following the [Debian manual](https://wiki.debian.org/NetworkConfiguration#Configuring_the_interface_manually).
sudo nano /etc/network/interfaces
------------------------
#iface eth0 inet manual
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1
* Connected to net via cable + did an apt-get update / upgrade.
sudo nano /etc/hostname
and changed to "botnet"
From now on (restart) you should be able to reach the server at botnet.local, for instance:
ssh pi@botnet.local (password is raspberry)
SHUTTING DOWN NICELY
ssh to the pi; and then...
sudo shutdown -h now
Installing stuff
-------------------
* figlet
* links
* emacs23-nox
* espeak
* festival
* apache2
* ircd-hybrid
Personalizing the server
-------------------------
* /etc/motd
* /var/www/index.html
Settings for IRC Server
------------------------------------------
sudo nano /etc/ircd-hybrid/ircd.conf
Raised setting:
number_per_ip from 2 (default) to 50
class {
/* name: the name of the class. classes are text now */
name = "users";
/* ping time: how often a client must reply to a PING from the
* server before they are dropped.
*/
ping_time = 2 minutes;
/* number per ip: the number of users per host allowed to connect */
number_per_ip = 50;
/* max number: the maximum number of users allowed in this class */
max_number = 100;
/* sendq: the amount of data allowed in a clients queue before
* they are dropped.
*/
sendq = 100 kbytes;
};
AND (it seems important) I added the IP address:
/* listen {}: contain information about the ports ircd listens on (OLD P:) */
listen {
/* port: the specific port to listen on. if no host is specified
* before, it will listen on all available IPs.
*
* ports are seperated via a comma, a range may be specified using ".."
*/
/* port: listen on all available IPs, ports 6665 to 6669 */
host = "0.0.0.0"; # change this!
port = 6665 .. 6669;
};
Restart the irc server
sudo /etc/init.d/ircd-hybrid restart
After this I could connect with pidgin to botnet.local.
More software
-----------------
* sudo apt-get install ipython python-pip screen mplayer
* sudo pip install irc
xtras
Attaching an external USB stick for storage
---------------------------------------------
(Also nice if SD card craps out)
Formatted it ext4 (on laptop).
Created a mount point:
sudo mkdir /media/GREEN
And edited the fstab, adding a line:
### /etc/fstab
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 2
/dev/mmcblk0p2 / ext4 defaults,noatime 0 1
/dev/sda1 /media/GREEN ext4 defaults,noatime 0 0
Then edited the apache default "site" definition, to change location *and* to add a custom header + footer (readme) to the directory listings:
### /etc/apache2/sites-available/default
<VirtualHost *:80>
ServerAdmin webmaster@localhost
## CHANGED
DocumentRoot /media/GREEN/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
## CHANGED
<Directory /media/GREEN/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
# CHANGED: CUSTOM listing HEADER + FOOTER
HeaderName /include/HEADER.html
ReadmeName /include/README.html
</VirtualHost>
Auto login (shell)
----------------------
The raspi-config gives options to automatically start up the graphical shell, but you can also login via the console without starting X.
Following [this tutorial](http://raspisimon.no-ip.org/rpi_autologin.php):
sudo nano /etc/inittab
change
1:2345:respawn:/sbin/getty 115200 tty1
to
#1:2345:respawn:/sbin/getty 115200 tty1
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1
Image Viewer
--------------
fbi & fim!
Media
------------
omxplayer, aplay, mplayer ...
Starting something, and stopping it with pid
-----------
In most shells (including Bourne and C), the PID of the last subprocess you launched in the background will be stored in the special variable $!.
#!/bin/bash
./app1 &
PID=$!
# ...
kill $PID
fim
-----------
usleep '0';
reduce;
usleep '0';
reduce;
usleep '192000';
reduce;
usleep '203000';
reduce;
usleep '479000';
reduce;
usleep '0';
reduce;
usleep '566000';
magnify;
usleep '0';
reduce;
quit;
cat fimscript | fim -p robby.jpg
or
fim -p robby.jpg < fimscript
overscan
---------------
/boot/config.txt
Bigger Font
-----------------
[Tutorial](http://www.raspberrypi-spy.co.uk/2014/04/how-to-change-the-command-line-font-size/)
To see a list of available fonts: ls /usr/share/consolefonts/
setfont /usr/share/consolefonts/Lat15-TerminusBold32x16.psf.gz
sudo nano /etc/default/console-setup
and filled in:
FONTFACE="Terminus"
FONTSIZE="16x32"