Background:
I downloaded ‘DietPi_RPi-ARMv8-Bookworm.img’ for my Raspberry Pi 4 and burned it onto an SD card using Etcher on a Windows 10 machine. After a successful write, I can see the SD card mounted as a ‘boot’ drive with a collection of files, including ‘dietpi-wifi.txt’. I edited the ‘dietpi-wifi.txt’ file and provided my WiFi’s SSID and password. Pi is running headless without keyboard or anything attached.
Problem:
However, after inserting the SD card into my Raspberry Pi, and powering it on, the Raspberry Pi does connect to the WiFi, but I am unable to determine its IP address. I am in a corporate environment and can not run WiFi Scanner tools. I tried SSHing using hostname, ‘dietpi’, as set in the ‘dietpi.txt’ file but to no avail although both are connected to same WiFi.
Desired Solution:
I want to execute the following commands right after the Raspberry Pi boots up and connects to my WiFi so that i get notified about the local WLAN IP address of the Raspberry Pi.
you have a screen attached? Maybe a keyboard as well?
Otherwise you could use the automatic install process and execute your script at the end of the setup. Executing a script before login is not really intended.
Pi is running headless without keyboard attached. How can I set it up without SSHing and configuring it? Honestly i am looking for a solution that involves tinkering with the files present on my SD card.
Right after flashing the image, you can adjust various settings within dietpi.txt. This needs to happen before first initial boot as these AUTO install settings are applied only once
Yes, but how can i login without the IP address of raspberry pi? I have set AUTO_SETUP_AUTOMATED=1 but I guess I need to login first and then automatic installation of software begin along with running of my custom script.
Sorry I am noob to this. All I want is that when I put SD after burning image to my PI and power it on, it connects to Wi-Fi and let me know its IP address. Then I can SSH using IP address provided and install software and configure dietpi manually.
No, using AUTO_SETUP_AUTOMATED=1 will start whole process automatically without any user input.
Your case is special as you don’t know the IP withing your environment. Therefore, I recommend, to use the fully automatic install process first to get the system up and running. Having a screen attached should show the install process.
Another option you could think of is
This will automatically perform a user login on next reboot (after setup finished) and will show a banner like this
─────────────────────────────────────────────────────
DietPi v8.20.1 : 11:50 - Fri 08/11/23
─────────────────────────────────────────────────────
- Device model : NanoPi R5S/R5C (aarch64)
- Uptime : up 2 hours, 21 minutes
- CPU temp : 37 °C / 98 °F : Cool runnings
- LAN IP : 192.168.x.x (eth0)
─────────────────────────────────────────────────────
hi dear @Joulinar
i was looking at this Raspbian Firstboot and realised that this is what i was looking for. This solution is for raspbian os. Can we do the same for dietpi? or any easy method to do it on dietpi?
Note/Disclosure: I have also opened a feature request at github.
We already have scripts that can be executed at the first initial boot. But they are executed before the network is online, which was not helpful in your case.
none of the solution worked. unfortunately, not even the one I was looking at i.e., firstboot.sh method. I have tried systemd, init.d, cron etc but these tricks do not work on first boot. Yes, they all do work perfectly if I set them up after first login through SSH. For now, I guess there is no easy solution to my problem.
Yes, this worked. After setting the flag to 1, I inserted the SD card into my Raspberry Pi and waited for the specified duration mentioned below. This allowed the automated setup to complete, and it executed my script (Automation_Custom_Script.sh) as expected.
Wait Times
Raspberry Pi 0W v 1.1 512 MB RAM (2017) _________ Wait time: 15 minutes.
Raspberry Pi 3 Model B+ 1GB RAM (2017) __________ Wait time: 5 minutes.
Raspberry Pi 4 Model B - 4GB RAM (2018) __________ Wait time: 5 minutes.