Raspberry setup by Asbesto

A solid setup for a raspberry sending videos / slideshow, can be rebooted / accessed by remote vpn, and make coffee.

This is for Rasp PI 3, quad core but there also some tricks for rasp pi 1 (drone)

pinout HERE: https://pinout.xyz/

Balestrini software

APPUNTI AL VOLO:

emiliano, [21.06.18 13:44]
# pip install python-uinput

# modprobe uinput

# chmod 666 /dev/uinput

Scrivi un file uinput_test.py siffatto:

import uinput
with uinput.Device([uinput.KEY_LEFTALT]) as device: 
     device.emit_click(uinput.KEY_LEFTALT)

infine

# setterm -blank 1

# sleep 90 && python uinput_test.py

Dovrebbe succedere che dopo 60 secondi lo schermo si ASTUTA
e dopo altri 30 SARRIPIGGHIA

LA SCRITTA TAPE MARK 1 sta in /etc/init.d/console-setup

IL RESTO in .bashrc di utente "pi"

la pw root e' con una d. va cambiata

Screen blanking

to be connected to a movement / proximity sensor. just some notes here

Sotto X: xset dpms force off ; sleep 5 ; xset dpms force on

Console:

setterm —blank force ; sleep 1 ; setterm —blank poke

MA STA MERDA A VOLTE NON FUNZIONA PORCO MALEDETTO DIO

Proximity sensor

3 PIN, +, data, -. CHECK PINOUT!!! https://pinout.xyz/

LOG IN / SHUTDOWN ETC

Devuan default login root, pw: toor

ssh root@10.69.1.30 

log in, and press YOU MUST PRESS CTRL-C WITHIN 5 SECONDS or the balestrini sw will start again creating some problems because it's still already running...

to turn the thing off:

poweroff

and wait for the led to become still RED with no activity at all.

HOW TO FIX IF IT DOESN'T WORK

Turn it off (see above), pull the sdcard out and fix the filesystem!

put the card into a pc with unix and do

fsck /dev/mmcblk0p1 fsck /dev/mmcblk0p2

and that's it!

Notes

serve libforms-dev

# maybe modprobe snd-pcm-oss to have /dev/dsp

#modprobe snd-aloop

apt-get install kbd

apt-get install console-data

note: aplay can't work together with rpitx / gpio output running

/etc/rc.local is executed at boot and activate swapfile if exist.

Font Configuration

This method involves editing a system file called “console-setup”. You just need to load it into your preferred text editor and tweak a few lines :

sudo nano /etc/default/console-setup

You will see the default setting.

Using the arrow keys position the cursor and change the FONTFACE and FONTSIZE lines to :

FONTFACE="Terminus"
FONTSIZE="16x32"

To apply these new settings to your command prompt without rebooting you can run the following command :

sudo /etc/init.d/console-setup restart

Program

root@devuan:~/tapemark# ls
bash_history  lofgile.txt  piam  pissb  rtty-output  rtty_ofile  slowcat    tape_mark_1.py  taperadio.wav  tappa~
bashrc        logfile.txt  pifm  rpitx  rtty_o       slo         slowcat.c  taperadio       tappa          tx.sh

# Create file to avoid rtty_ofile error (to be fixed!)
touch rtty-output
# remove old wavefile
rm taperadio.wav tr.ft 1>/dev/null 2>/dev/null
# Begin of messages
echo "ZCZC" > taperadio
# TAPE MARK 1 generation
./tape_mark_1.py >> taperadio ;
# end of message
echo "TAPE MARK 1, NANNI BALESTRINI, 1961" >> taperadio
echo "TRASFORMATORIO 2018, QSL TAPEMARK1@YANDEX.COM" >> taperadio
echo "NNNN" >> taperadio
# creating rtty raw audio file
cat taperadio ; ./rtty_ofile 1000 1450 56 taperadio
# convert raw file in 16bit 48KHz wav needed by rpitx
echo "Converting RAW into WAV..."
sox -t raw -r 8000 -e unsigned -b 8 -c 1 rtty-output -r 48000 -b 16 -c 1 taperadio.wav
# convert wav to transmission format for rpitx
echo "Generating FM transmission format file..."
./pifm taperadio.wav tr.ft
# transmitting file on 437.000 MHz FM
echo "Transmitting on 437.000 MHz FM"
./rpitx -m RF -i tr.ft -f 436990
echo Done!

Automatic login for devuan raspberry (drone)

Note: devuan (drone) has only root account by default. so this is for root.

Edit /etc/inittab

Comment out the following line in inittab

1:2345:respawn:/sbin/getty 115200 tty1

Add the following line just below the commented line

1:2345:respawn:/bin/login -f root tty1 </dev/tty1 >/dev/tty1 2>&1

This will run the login program with root user and without any authentication

BEWARE, THAT'S ROOT.

Console blanking disable (drone)

Consoleblank is a kernel parameter. In order to be permanently set, it needs to be defined on the kernel command line.

sudo nano /boot/cmdline.txt

Add consoleblank=0 to turn screen blanking off completely, or edit it to set the number of seconds of inactivity before the console will blank. Note the kernel command line must be a single line of text.

note on slow boot / no network for 5 minutes (drone)

If there's ntpd installed and you have the wrong network gw, it will hang for 5 minutes. This block you from ssh!

So remove the gw from /etc/network/interfaces and/or remove openntpd package.

Force fsck at boot

Edit /etc/default/rcS accordingly, there's an option for that: FSCKFIX=yes

KBD locales etc.

apt-get install kbd

apt-get install console-data

loadkeys it

Howto about video / slideshow

A script generate the video list to go on play, reading that dir /home/pi/video and creating a new list every X minutes or at every reboot.

so every added video will be added to the playlist.

To play only a particular video you must remove all others.

TODO ASBESTO, notepad

* ffprobe doesn't exist because DEBIAN SHIT, it was named avprobe. so dur.sh didn't worked. so listamp4.sh didn't generate any list. PORCODIO! changing ffprobe in avprobe inside dur.sh fixed everything.

MILANO / DRONE Features

IDEAS

questo sia necessario)

ACCESSING THE SHIT

USER pi, PW vivabasaglia. Root pw is "ciaras".

System boots and launch /home/pi/shells/start.sh - from there, everything starts.

Automagic check for network up/down

Every 2 minutes this piece of shit check for network and eventually put it on again.

It's in background with "sleep 120" because here NO crontab due to the RO fs.

while (true); do
 x=`ping -c2 google.com 2>&1 | grep unknown`
 if [ ! "$x" = "" ]; then
    echo `date` >> /home/pi/netcheck.log
    echo "Line is down. restarting..." >> /home/pi/netcheck.log
    service networking restart
    echo "done" >>/home/pi/netcheck.log
 fi
sleep 120
done

This script is named netcheck, in /usr/local/sbinand starts from /etc/rc.local:

# into rc.local
nohup /usr/local/sbin/netcheck &

Hostname with last IP number in it

The script is "ultimo" in /usr/local/sbin/ultimo:

#
# in base all'ultimo numero dell'IP del wifi, crea /etc/hostname.
#
IP=`ifconfig wlan0 | grep addr: | sed 's/.*inet *//; s/ .*//'`
cn=$(awk -F. '$0=$4' <<< $IP)
echo "raspami"$cn > /etc/hostname

and start from /etc/rc.local:

# change /etc/hostname adding last IP number from wifi
/usr/local/sbin/ultimo &

VPN

We use Voyager's vpn :)

VPN install on rasp

sudo apt-get install openvpn

next, copy the .conf file already prepared with all certs etc. (ex. for rasp number 50 use 50.conf)

after that

openvpn ./50.conf

or copy 50.conf into /etc/openvpn/client.conf

and launch from /etc/rc.local

service openvpn start

VPN on our computers

Same shit but using our personal certs.

VNC server/client install and usage

A teamviewer-like piece of shit, very handy!

VNC installation on raspberry

Look https://www.raspberrypi.org/documentation/remote-access/vnc/

sudo apt-get install tightvncserver

and launch tightvncserver to configure it, here you give a password that you will need to access.

in ~/shells/start.sh I added

vncserver :1 &

VNC installation on our computers

sudo apt-get install xtightvncviewer

so just launch

vncviewer 172.16.66.9:1

put the pw and desktop appears. END OF SHIT

Installazione ansible, e modo d'uso

*TODO - TODO - e' stato fatto ma e' da documentare.*

E CMQ FANCULO ANSIBLE PORCODIO

Ansible recipe to configure all raspberry

that's is /home/pi/pi.yml

WARNING, SPACES ARE PART OF THE SYNTAX. IF YOU MOVE THEM, NOTHING WILL WORK. YAML IS A FUCKING PIECE OF SHIT.

---
- hosts: pi
  remote_user: pi
  sudo: yes
  tasks:

  # netcheck
  #
  # files to be added
  #
  - copy: src=/usr/local/sbin/netcheck dest=/usr/local/sbin/netcheck owner=root group=staff mode=0755 
  - copy: src=/usr/local/sbin/ultimo dest=/usr/local/sbin/ultimo owner=root group=root mode=0755
  - copy: src=/etc/modprobe.d/8192cu.conf dest=/etc/modprobe.d/8192cu.conf owner=root group=root mode=0644
  - copy: src=/etc/rc.altrirasp  dest=/etc/rc.local owner=root group=root mode=0755

  #
  # Line to be added in /etc/rc.local
  # 
  # - lineinfile: dest=/etc/rc.local state=absent regexp="exit 0"
  # - lineinfile: dest=/etc/rc.local line="nohup /usr/local/sbin/netcheck &"
  # - lineinfile: dest=/etc/rc.local line="exit 0" 

  #
  # Stuff to install/remove
  #
  # - name: nmap installation
  #   apt: name=nmap state=present

  - name: reboot
    command: /sbin/reboot

WARNING, SPACES ARE PART OF THE SYNTAX. IF YOU MOVE THEM, NOTHING WILL WORK. YAML IS A FUCKING PIECE OF SHIT.

LAUNCH with:

ansible-playbook --ask-pass ./pi.yml

For a single ip, ex. il 10.0.1.77, use

ansible-playbook --ask-pass -l 10.0.1.77 ./pi.yml

IP must be configured into /etc/ansible/hosts, as follow:

# This is the default ansible 'hosts' file.
#
# It should live in /etc/ansible/hosts
#
#   - Comments begin with the '#' character
#   - Blank lines are ignored
#   - Groups of hosts are delimited by [header] elements
#   - You can enter hostnames or ip addresses
#   - A hostname/ip can be a member of multiple groups

# Ex 1: Ungrouped hosts, specify before any group headers.

[pi]
10.0.1.[51:99]  ansible_ssh_user=pi
# 192.168.1.249

Disk settings

I made the sdcard as a 4GB one, also if is 32gb. To copy it:

dd if=/dev/sdb of=milano2.img bs=4096 count=1048576

Now it is as follow:

pi@raspami1 ~ $ cat /etc/fstab
proc            /proc           proc    defaults          0       0
/dev/mmcblk0p1  /boot           vfat    defaults,ro                0       2
/dev/mmcblk0p2  /               ext4    defaults,rw,noatime        0       1
/dev/mmcblk0p3  /home           ext4    rw,nosuid,nodev,relatime,data=ordered 0 0
tmpfs           /tmp            tmpfs   defaults          0       0

(parted) print all                                                        
Model: SD SL32G (sd/mmc)
Disk /dev/mmcblk0: 31.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      4194kB  62.9MB  58.7MB  primary  fat16
 2      62.9MB  2943MB  2880MB  primary  ext4
 3      2943MB  4277MB  1334MB  primary  ext4

root@raspami1:/home/pi# mount
/dev/root on / type ext4 (rw,noatime,data=ordered)
devtmpfs on /dev type devtmpfs (rw,relatime,size=470368k,nr_inodes=117592,mode=755)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=94936k,mode=755)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=189860k)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
/dev/mmcblk0p1 on /boot type vfat (ro,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
/dev/mmcblk0p3 on /home type ext4 (rw,nosuid,nodev,relatime,data=ordered)
tmpfs on /tmp type tmpfs (rw,relatime)
root@raspami1:/home/pi# 

root@raspami1:/home/pi# df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs          2.6G  2.0G  467M  82% /
/dev/root       2.6G  2.0G  467M  82% /
devtmpfs        460M     0  460M   0% /dev
tmpfs            93M  264K   93M   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           186M     0  186M   0% /run/shm
/dev/mmcblk0p1   56M   15M   42M  26% /boot
/dev/mmcblk0p3  1.2G  129M  1.1G  12% /home
tmpfs           464M   12K  464M   1% /tmp

Using gparted you can resize it as you need.

ACCESS / NETWORK

Ethernet: eth0, 172.16.0.50 fixed.

Login: user pi, pw vivabasaglia. sudo give root. pw root: ciaras

Wifi: wlan0 10.0.1.50 and up, gw 10.0.0.1

WARNING

in /etc/network/interfaces SET JUST ONE GW, OTHERWHISE 2nd network card (wlan0) won't start!

LOOK BELOW.

Make our distro compatible for arm 7 -> arm 8

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get install raspberrypi-ui-mods

sudo halt

and reboot.

BLACK SCREEN AT BOOT AVOIDING messages and logos

Edit /boot/cmdline.txt

boot log:

 console=tty3 

instead of tty1

NO: better have logs to understand if it's booting or not. I left only loglevel=3 & logo.nologo

Fuck the logo: add at the end

wtf.jpg

Actually /boot/cmdline.txt is like that:

 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait loglevel=3 logo.nologo

lxde startup and HOW THEY'RE SON OF BITCHES

THOSE RASPBIAN BASTARDS CHANGED LXDE in LXDE-pi INTO ~/.config/lxsession so autostart didn't worked.

ASSHOLES

http://www.raspberrypi-spy.co.uk/2014/05/how-to-autostart-apps-in-rasbian-lxde-desktop/

It's from there that I launch ~/shells/start.sh ;)

WIFI dongle

https://github.com/lwfinger/rtl8188eu

From here you download the zip file, inside is the fucking firmware.

The .bin goes in /lib/firmware/rtlwifi

Next you need the correct driver according to the kernel: https://www.raspberrypi.org/forums/viewtopic.php?p=462982

For our kernel, Linux raspami1 3.18.7-v7+ #755 SMP PREEMPT Thu Feb 12 17:20:48 GMT 2015 armv7l GNU/Linux

the correct firmware is

3.18.7-v7+ #755, #756 - 8188eu-v7-20150212.tar.gz

So, from root:

wget https://dl.dropboxusercontent.com/u/80256631/8188eu-v7-20150212.tar.gz
tar xzf 8188eu-v7-20150212.tar.gz
./install.sh

and reboot!

Old notes

wget https://dl.dropboxusercontent.com/u/80256631/8188eu-20140307.tar.gz //make sure you use the correct dropbox url for your Raspberry version
tar -zxvf 8188eu-20140307.tar.gz
sudo cp rtl8188eufw.bin /lib/firmware/rtlwifi //not needed anymore if your operating system is above 3.10.33+
sudo install -p -m 644 8188eu.ko /lib/modules/3.10.33+/kernel/drivers/net/wireless
sudo insmod /lib/modules/3.10.33+/kernel/drivers/net/wireless/8188eu.ko
sudo depmod -a
sudo reboot

WIFI Scanner

Get rid of LXDE background, putting a black background

Remove from background, and put it black. You do it from X. After that, from desktop options, remove trash icon, so now you have to just kill the panel.

Killing the panel

Kill lxpanel. If you need it again, relaunch with lxpanel --profile LXDE-pi : launch directly ~/shells/panel.sh

BLANK SCREEN disabling

xset -dpms  
xset s noblank  
xset s off 

it's into ~/shells/start.sh

solve SLOW SSH

One workaround is to edit /etc/sshd_config on the sshd server machine, not your ssh client machine to set "UseDNS" to "no". (From the way you originally wrote your question, it sounded like you may have edited that file on your client, which wouldn't make a difference.)

Another solution would be to have your ISP (or whatever institution is responsible for your publicly-routable IP addresses) fix their reverse-DNS record for your IP address on their DNS name servers that are authoritative for the reverse-DNS records for that block of IP addresses. In other words, "make it so people can find your host name based on your IP address, and make sure the hostname they find maps back to your IP address". 7 mins · Unlike · 1

Set into ssh config: UseDNS no

HIDE X cursor after some seconds of inactivity

sudo apt-get install unclutter
unclutter -display :0 -noevents -grab

Automagic wifi connection

Our wifi:

Edimax EW-7811Un 150Mbps 11n Wi-Fi USB Adapter, Nano Size Lets You Plug it and Forget it, Ideal for Raspberry Pi, Supports Windows, Mac OS, Linux

IDEAL this DICK!!!

http://www.amazon.com/gp/product/B003MTTJOY/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B003MTTJOY&linkCode=as2&tag=rapihq-20&linkId=7QAXDGG72H4EWYFB

https://www.raspberrypi.org/forums/viewtopic.php?f=31&t=7471

GET RID OF POWERSAVING on wifi dongles!!!

With "lsmod" we see we have this driver:

8192cu                528365  0 

Create /etc/modprobe.d/8192cu.conf with:

# Disable power saving, FFS!
options 8192cu rtw_power_mgnt=0 rtw_enusbss=1 rtw_ips_mode=1

and reboot / reload driver.

Network configuration

Put this in etc/network/interfaces

# ultima config testata, funziona, tira su tutto
auto lo
iface lo inet loopback

up eth0
allow-hotplug
iface eth0 inet static
        address 172.16.0.50 # ogni schedino col suo IP ovviamente
        netmask 255.255.0.0
        # non usarlo! gateway 10.10.1.1
        # nota: un solo gw per le interfacce 
        # altrimenti non sale la rete wifi!

auto wlan0
allow-hotplug
iface wlan0 inet static
        address 10.0.1.50
        netmask 255.0.0.0
        broadcast 10.255.255.255
        gateway 10.0.0.1
        dns-nameservers 8.8.8.8  8.8.4.4 
        wpa-ssid KIP01
        wpa-psk vivabasaglia

and REMOVE /etc/wpa_supplicant/wpa_supplicant.conf

SLIDESHOW

apt-get install feh
feh --recursive --randomize --auto-zoom -D 20 -F ./slideshow/

-D delay, -F fullscreen. GIF not supported!

LIGHT problem in raspberry PI 2

U16 is sensible to light. Cover it!.

http://www.pcpro.co.uk/components/1000375/why-a-camera-flash-will-reboot-your-raspberry-pi-2

Sistema in READ ONLY?

NICE TO DO.

Only /boot for now is read only, /tmp is in tmpfs ramdisk, with some /var links. So crontab is volatile.

MAYBE we can put crontab symlinks on /boot so we can have a fixed crontab to be modified into /boot.

HDMI port always ON

WE NEED THIS Because if we don't have hdmi active, the raspberry switches itself on the crappy video out connector.

Add these two lines to */boot/config.txt* and reboot Raspbmc:

hdmi_force_hotplug=1
hdmi_drive=2

SDCARD duplication

image is milano2.img

Asbesto


CategoryMuseo

Museo/RaspberrySetup (last edited 2019-01-03 17:17:41 by asbesto)