2019-05-09
In the last post, we bought the hardware, installed a minimal Raspbian OS, and set it up as a Synergy client. This time we'll improve the system's usability in terms of network settings and performance.
Using the lxsession reference page
, we can see what we need to do.
First, create a file called showIP.sh
in /home/pi
#!/bin/bash
rm /home/pi/Desktop/*.IP
touch "/home/pi/Desktop/$(hostname -I).IP"
Allow anyone to execute this script by running:
chmod +x /home/pi/showIP.sh
Then edit the auto-start file to display the IP on your X desktop:
sudo vim /etc/xdg/lxsession/LXDE-pi/autostart
and add @/home/pi/showIP.sh
to the end of the file.
Showing the IP on the desktop will allow you to access the machine without a hostname. This is important later, as we will optimize system load by disabling avahi-daemon
.
You will need to add a post-up line in your /etc/network/interfaces
to update the IP:
post-up /home/pi/showIP.sh
Install a SMTP mail utility:
sudo apt-get install ssmtp
Next, ensure you have a GMail password that does not contain spaces.
You can send the PI's IP to an email once ssmtp.conf
is configured properly:
{
echo To: [email protected]
echo From: [email protected]
echo Subject: RPi0 IP change
echo
echo "IP changed to $(hostname -I) at $(date)"
} | ssmtp [email protected]
I've added this command to the showIP.sh
script on my own RPi0.
We recommend a brief skim of this simple guide on how to set up your client / host to use SSH keys instead of entering a password for every SSH connection. Doing this minimizes the risk of exposing your Pi's password and also the amount of typing required to gain SSH access.
After completing, we can use Ansible to automate re-initializing the Synergy client on the Pi. Consolidating all these steps:
sudo ~/initSynergy.sh <SYNERGY-HOST-IP>
Into a single Ansible playbook: initSynergy.yml
which can be run with
ANSIBLE_PIPELINING=True ansible-playbook initSynergy.yml -i hosts --extra-vars "hostIP=$(getSynergyHostIP.sh)"
It is important to kill memory hogs and high CPU background services as well as anything you are not / will not be using when running Raspbian. Any savings in those areas will have significant impact on your daily user experience.
systemctl disable bluetooth
systemctl stop bluetooth
raspberrypi.local
) via Bonjour / Zeroconf.systemctl disable avahi-daemon
systemctl stop avahi-daemon
Removing this has the largest impact on CPU load on the lower spec Raspberry Pi models. You can expect an idle CPU usage reduction from 30% down to ~1%.
systemctl disable triggerhappy
systemctl stop triggerhappy
In the final post of the series, we'll look at lightweight replacements for common desktop apps that you can run on your new Raspbian installation.
Cohesive.dev provide comprehensive software, operating environment, and network configuration audits. We can help you keep your computing resources working smoothly, and reliably.