HowTo Setup the Raspberry

Installation of Rasbian

First thing Todo is to prepare the SD Card for raspbian jessie OS

Download the latest raspian image from:

After Download verify the Checksum of your Image and compare it with the SHA-1 Checksum on the Download Page.

shasum ~/Downloads/2017-06-21-raspbian-jessie-lite.zip
unzip ~/Downloads/2017-06-21-raspbian-jessie-lite.zip

After you verified and unziped the Image you can write the Image to an SD Card with the following Command:

sudo dd bs=4M if=2017-06-21-raspbian-jessie-lite.img of=/dev/mmcblk0
sudo sync

If its done place the SD Card in your Rasberry PI connect all cables including the HDMI Cable and check if its booting.

The Default login is pi / raspberry

Enable ipv6 on Raspberry

Open the file /etc/modules and add ipv6 to the last line. Then reboot.

Activate the Hardware Watchdog:

The BCM2708 support an Hardware Watchdog for using it you need a Module and a Watchdog Daemon

Load the following Kernel Module and install the watchdog progamm

sudo modprobe bcm2708_wdog
echo "bcm2708_wdog" | sudo tee -a /etc/modules
sudo apt-get install watchdog

Open the file: sudo nano /etc/watchdog.conf

watchdog-device        = /dev/watchdog
max-load-1             = 24

These values will hopefully never reboot your machine during normal use (if your machine is really hung, the loadavg will go much higher than 25)

sudo /etc/init.d/watchdog restart

Installation of Packages

If the Raspberry boots install the following usefull packages:

sudo apt-get install mediatomb sqlite cryptsetup cryptmount git samba
samba-common-bin screen ndpmon libxslt1-dev libxslt1.1 lighttpd php5-common
php5-cgi php5 ruby mc bc mtr tcpdump nmap netcat iperf nethogs iptraf ntp
ntpdate fake-hwclock wpasupplicant wireless-tools

Configuration of WiFi

Install wifi Packages if necessarry:

sudo apt-get install wpasupplicant wireless-tools

Search for your Wifi ESSID:

sudo iwlist wlan0 scan
sudo iwlist wlan0 scan | grep ESSID

Edit the Network interface Configuration

sudo nano /etc/network/interfaces
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ap-scan 1
wpa-scan-ssid 1
wpa-ssid "YOUR_NETWORK"
wpa-psk "YOUR_PASSPHRASE"
sudo service networking restart

Check your Wifi

Configuration of lighttpd

first create a www folder in your home Directory:

mkdir /home/pi/www

then copy the following example configuraion to /etc/lighttpd/lighttpd.conf

server.modules = (
    "mod_access",
    "mod_alias",
    "mod_compress",
    "mod_redirect",
    \#"mod_rewrite",
)

server.document-root        = "/home/pi/www"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"
server.port                 = 80

index-file.names            = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny                     = ( "~", ".inc", ".svn", ".git" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir          = "/var/cache/lighttpd/compress/"
compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )

\# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

copy /var/www/index.lighttpd.html to /home/pi/www

Start the lighttpd Server with:

sudo /etc/init.d/lighttpd start

lighttpd rights for www directory

sudo chown -R pi:www-data ~/www/
sudo chmod -R 775 ~/www/

Configuration of Crontab to perform some regular tasks

Edit the crontab to start every hour a Script for regular tasks

crontab -e
0 0 * * * $HOME/raspberry/cronscript.sh
0 * * * * $HOME/www/production/Scripte/send_mail_if_pid_done.sh echo_all_test_related_pids
0 * * * * $HOME/www/production/Scripte/online_ping_check.sh www.google.de 80
0 0 * * * $HOME/www/production/Scripte/most_used_commands.sh
0 * * * * $HOME/www/production/Scripte/print_reachable_ipv6_host_in_network.sh ipv6_multicast_to_all_nodes eth0
0 * * * * $HOME/www/production/Scripte/print_reachable_ipv6_host_in_network.sh amount_of_nodes_in_network eth0
0 0 * * * $HOME/raspberry/IP_adresse_mailen.py
*/15 * * * * $HOME/Scripte/update-godaddy.sh

The cert_renewal cronjob is for the root user:

@monthly  /home/pi/raspberry/cert_renewal.sh

Make the cronscript executeable:

chmod +x chronscript.sh

Forwarding of X Window of Rasperry PI

ssh -X pi@raspberry
lxpanel &

Raspberry Pi as DNS-Cache

install pdns:

sudo apt-get install pdnsd

configure pdns:

vim /etc/pdnsd.conf
perm_cache=8192; // Cache-Size in Kilobyte (8 Megabyte)
cache_dir="/var/cache/pdnsd"; // Cache-Directory
server_ip = 0.0.0.0; // IP, auf der gelauscht wird: 0.0.0.0 bedeute auf allen IPs

in /etc/network/interfaces add the following DNS Servers:

dns-nameservers 192.168.3.1 2620:0:ccc::2 2620:0:ccd::2 2001:4860:4860::8888 2001:4860:4860::8844 208.67.222.222 208.67.220.220 85.214.20.141 213.73.91.35 85.214.73.63

start pdns as deamon:

sudo vim /etc/default/pdnsd
START_DAEMON=yes
sudo /etc/init.d/pdnsd  start

Check the Status:

sudo /etc/init.d/pdnsd status

Raspberry Pi as Transmission Torrent Box

sudo apt-get install transmission-daemon
mkdir /media/data/
mkdir /media/data/progress
mkdir /media/data/completed
mkdir /media/data/torrents
sudo usermod -a -G debian-transmission pi

setting groups and the rights for the folders

sudo chgrp debian-transmission /media/data/progress
sudo chgrp debian-transmission /media/data/completed
sudo chgrp debian-transmission /media/data/torrents
sudo chmod 770 /media/data/progress
sudo chmod 770 /media/data/completed
sudo chmod 770 /media/data/torrents

add user pi to the debian-transmission group

sudo adduser pi debian-transmission

Stop the transmission service

sudo service transmission-daemon stop

change startup user for transmission, change user name to your username: USER=pi

sudo chown pi -R /var/lib/transmission-daemon/info/
sudo nano /etc/init.d/transmission-daemon

change owner rights to transmission configuration files to your user

sudo chown pi -R /var/lib/transmission-daemon/info/
sudo chown pi -R /media/data/progress
sudo chown pi -R /media/data/completed
sudo chown pi -R /media/data/torrents/
sudo chown pi -R /var/lib/transmission-daemon/info/settings.json
sudo chown debian-transmission:debian-transmission /var/lib/transmission-daemon/info/settings.json

start Transmission again

sudo service transmission-daemon start
sudo nano /etc/transmission-daemon/settings.json
  1. Find rpc-username and rpc-password, change the values. This is supposed to be different from your Raspbian username.
  2. Find rpc-whitelist and add the IP addresses of your other computers there (computers you plan to access Transmission from). For my case, I simply add 192.168.3.*
  3. Find download-dir and change it into /media/data/completed or whatever the name of the folder you have prepared before.
  4. Find incomplete-dir and change it into /media/data/progress or whatever the name of the folder you have prepared before.
  5. Find watch-dir and change it into /media/data//torrentwatch or whatever the name of the folder you have prepared before.

Save the settings.json file and force transmission-daemon to load it:

sudo service transmission-daemon reload

Links:

Last generation on 2024-10-06 00:00:55.


© 2024 Oliver Graute ⋅ hosted on a Raspberry PI ⋅ EmailMastodonTwitterGithubStackoverflowFlickr