Here are three operational methods we use when setting up Raspberry Pi:

This is Mandai from the development team.
Today I'd like to introduce the somewhat rough method I use when setting up a Raspberry Pi

table of contents

  1. Be able to send emails
  2. Once connected to the network, send your IP address via email
  3. Free up disk space using webdav

Be able to send emails

To install postfix on the Raspberry Pi and start up the mail server, type sudo apt-get install postfix.
This is a useful experience that will be useful later on, but it takes time to set up.

Want to be able to send emails in just a few minutes?
The quickest way to do that is to use a simple MTA called ssmtp to turn Gmail or similar into a mail server.
The configuration file is in plain text, so if you log in to the console, your email address and password are completely visible. It's a bit of a pain, but I think it's fine for personal use.

Of course, it is not installed on the servers we provide, so don't worry.
If you are using Raspbian, you can install it in one go with the apt-get command.

sudo apt-get install ssmtp

Once the installation is complete, edit the configuration file.
If you are using Gmail to send emails, /etc/ssmtp/ssmtp.conf should look something like this:

# # 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, check if you can send an email using the mail command

echo "hogehoge" | mail -s "fugafuga" [email address]

If you can send email successfully, the setup is complete

Once connected to the network, send your IP address via email

Since the Raspberry Pi does not have a display, there is no way to log in unless you know the IP address automatically obtained by DHCP.
Therefore, we will use a method whereby once the Raspberry Pi is connected to a suitable network, the IP address is notified by email.

The shell script placed directly under /etc/network/if-up.d/ will be executed when the link is up, so include the following shell script that sends the IP address at this time

# /bin/bash /sbin/ifconfig | mail -s "My network information" [email address]

It's not a very praiseworthy command, but it does meet the necessary requirements.
If our infrastructure team saw it, they'd probably be shocked and stunned.

You may want to try unplugging and plugging in the LAN cable to see if it works properly

Free up disk space using webdav

The Raspberry Pi uses an SD card as its HDD.
However, a large-capacity SD card is more expensive than the device itself.
So, although this is not really related to the purpose of this article, I will introduce a way to use cloud services as a disk 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 to.
In this example, we will create a directory called dav_box under the user directory of the pi user and mount it there.

mkdir /home/pi/dav_box

After installation, place a file in /etc/davfs2/secrets that contains the mounting URL and BOX account information

sudo vi /etc/davfs2/secrets # Add the following to the very end /home/pi/dav_box [BOX account email address] [BOX password]

If you have a bad feeling about this, you're right; the data is stored in plain text.
This is not required, so if you feel uncomfortable, you can just leave it out and enter the account information confirmation that is required every time you mount the computer.

Finally, add the webdav mount information to /etc/fstab

https://dav.box.com/dav /home/pi/dav_box davfs rw,noauto,user 0 0

At the end, he suddenly mounts her and looks smug

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 mounted, so please try it.

Now I can easily find my Raspberry Pi and I won't get lost.
To do that, there are a lot of prerequisites you need to do, such as attaching a Wi-Fi dongle and setting up a Wi-Fi account, but
there are a ton of other sites that explain this, and
I'll leave it at that, since I'm sure another member will write about it.

Have a great Raspberry Pi life everyone!

If you want to consult with a development professional

At Beyond, we combine our extensive track record, technology, and know-how in system development with OSS technology and cloud technologies such as AWS to provide contracted development of web systems with reliable quality and excellent cost performance

We also handle server-side/back-end development and proprietary API collaboration development, making full use of our technology and know-how in building and operating web system/application infrastructure for large-scale, high-load games, applications, and digital content

If you have any problems with your development project, please visit the following website

● Web system development
● Server-side development (API/DB)

If you found this article useful, please click [Like]!
0
Loading...
0 votes, average: 0.00 / 10
773
X Facebook Hatena Bookmark pocket

The person who wrote this article

About the author

Yoichi Bandai

My main job is developing web APIs for social games, but I'm also grateful to be able to do a variety of other work, including marketing.
My portrait rights within Beyond are CC0.