(Network-wise) Raspbery Pi that won't get lost, 3 recommendations
table of contents
This is Mandai from the development team.
This time, I would like to introduce a somewhat rough operation method that I use when setting up Raspberry Pi
There are many other sites that explain how to set up the basic Raspberry Pi, so I'll omit it here.
table of contents
- Allow to send email
- Once connected to the network, send your IP address via email
- Reserve disk space using webdav
Allow to send email
To install postfix on Raspberry Pi and start a mail server, type sudo apt-get install postfix.
I think it's a valuable experience that will come in handy later on, but it does take some time to set up.
I want to be able to send emails in just a few minutes!
In such a case, it is quick and easy to use a simple MTA called ssmtp to turn gmail etc. into a mail server.
The configuration file is in plain text, so if you log in to the console, you can see your email address and password, so it's a mediocre feature, but I think it's good for personal use.
Of course, please rest assured that it is not installed on the servers we provide.
If you use it with Raspbian, you can install it in one go using the apt-get command.
sudo apt-get install ssmtp
Once the installation is complete, edit the configuration file.
If you use gmail to send email, /etc/ssmtp/ssmtp.conf will probably have the following contents.
# # Config file for sSMTP sendmail # # The person who gets all mail for userids < 1000 # Make this empty to disable rewriting. root=[email address] # root=postmaster # The place where the mail goes. The actual machine name is required no # MX records are consulted. Commonly mailhosts are named mail.domain.com mailhub=smtp.gmail.com:587 AuthUser=[email address] AuthPass=[email address password] UseSTARTTLS=YES AuthMethod=LOGIN # Where will the mail seem to come from? rewriteDomain= # The full hostname hostname=[email address] # Are users allowed to set their own From: address? # YES - Allow the user to specify their own From: address # NO - Use the system generated From: address FromLineOverride=YES
Once the settings are complete, use the mail command to check if you can send emails.
echo "hogehoge" | mail -s "fugafuga" [email address]
If the email can be sent successfully, the settings are complete.
Once connected to the network, send your IP address via email
Since Raspberry Pi does not have a display, there is no way to log in unless you know the IP address automatically obtained using DHCP.
Therefore, once the Raspberry Pi is infiltrated into a suitable network, we will notify it by email of its IP address.
The shell script placed directly under /etc/network/if-up.d/ will be executed when the link is linked up, so at this time, insert the shell script below to send the IP address.
# /bin/bash /sbin/ifconfig | mail -s "My network information" [email address]
It's not a command that gets much praise, but it meets the necessary requirements.
If our infrastructure team saw it, it would be so sloppy that it would blow up and collapse.
You may want to try unplugging and plugging in the LAN cable to see if it works properly.
Reserve disk space using webdav
Raspberry Pi uses an SD card as an HDD.
However, a large capacity SD card will cost more than the device itself.
So, although this is not really related to the purpose of this article, I will introduce how to use cloud services as if they were disks via webdav.
I will use
a BOX that supports webdav Install the required software using apt-get.
sudo apt-get install davfs2
Once installed, create a directory to mount it to.
This time, we will create a directory called dav_box under the pi user's user directory and mount it.
mkdir /home/pi/dav_box
After installation, place a file containing the URL to mount and BOX account information in /etc/davfs2/secrets.
sudo vi /etc/davfs2/secrets # Add the following at the end /home/pi/dav_box [BOX account email address] [BOX password]
If you have a bad feeling, you're right; we store it in plain text.
This doesn't seem to be necessary, so if you don't like it, you can just leave it unconfigured and enter the account information confirmation that is required every time you mount it.
Finally, add webdav mount information to /etc/fstab.
https://dav.box.com/dav /home/pi/dav_box davfs rw,noauto,user 0 0
Finally, he slowly mounted it and looked proud.
mount /home/pi/dav_box
I don't know if it's because of the Raspberry Pi's performance, the BOX's Webdav, or both, but it's quite slow.
You can experience the slowness by running the df command while it is mounted.
Now you can always supplement your Raspberry Pi and never get lost.
There are a lot of preparations to do in order to play Doya Ring, such as attaching a wi-fi dongle and setting up a wi-fi account, but
there are many other sites that explain such things, so
I've written this far. I'll leave it out because another member might write it.
Have a nice Raspberry Pi life everyone!