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

This is Mandai from the development team.
Today,a Raspberry PiI'd like to share a somewhat rough and ready method I use when setting up

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 a Raspberry Pi and set up a mail server, you type `sudo apt-get install postfix`.
While this is a valuable experience that will be useful later, the setup process is quite time-consuming.

Want to send emails in just a few minutes?
The quickest way to do that is to use a simple MTA called ssmtp and turn Gmail or another email server into your own.
The configuration file is in plain text, meaning your email address and password are completely exposed if you log into the console – it's a bit of a tricky system, but I think it's fine for personal use.

Of course, rest assured that it is not installed on the servers we provide.
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, you'll need to edit the configuration file.
If you're using Gmail to send emails, the /etc/ssmtp/ssmtp.conf file 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 doesn't have a display, there's no way to log in unless you know the IP address it automatically obtains via DHCP.
Therefore, we'll use a method where we place the Raspberry Pi on a suitable network and then notify the user of its IP address via 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 exactly a commendable command, but it does meet the necessary requirements.
If our infrastructure team saw it, they'd probably foam at the mouth and collapse from the sheer sloppiness.

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 hard drive.
However, high-capacity SD cards can be more expensive than the Raspberry Pi itself.
Therefore, although it's not directly related to the main topic of this article, I'll introduce a method to use a cloud service as a disk via WebDAV.
, which supports WebDAVBOXwe'll use

Install the required software using apt-get

sudo apt-get install davfs2

Once installed, create the directory to mount to.
In this example, we'll 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 had a bad feeling about this, you're absolutely right; the data is saved in plain text.
This doesn't seem to be mandatory, and if you find it repulsive, you can simply choose not to set it, or you can enter your account information, which is required every time you mount.

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'm not sure if it's due to the Raspberry Pi's performance, the BOX's WebDAV, or both, but it's quite slow.
You can experience the slowness firsthand by running the `df` command while it's mounted, so please do.

Now I can always find my Raspberry Pi and it won't get lost anymore.
To show it off, there are various preparations to be made beforehand, such as attaching a Wi-Fi dongle and setting up a Wi-Fi account, but
there are tons of other websites that explain that, and
if I write this much, another member might write it, so I'll omit the details.

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 helpful,please give it a "Like"!
0
Loading...
0 votes, average: 0.00 / 10
846
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 thankfully I'm also given the opportunity to work on various other tasks, including marketing.
My image rights within Beyond are treated as CC0.