Một mục mã nguồn mở trong kho dữ liệu GitHub của TopGit: schollz/raspberry-pi-turnkey, 857 sao, Python. How to make a Raspberry Pi image that can be deployed anywhere and assigned to a WiFi network without SSH :ok_hand:
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Have you ever wanted to setup a Raspberry Pi without having to SSH or attach a keyboard to add your WiFi credentials? This is particularly useful when you are making a Raspberry Pi that needs to be deployed somewhere where supplying the credentials via SSH or attaching a keyboard isn't an option. Or it could be useful if you take your Pi to a friend's house and they don't have ethernet cables or extra keyboards+monitors to put your friend's WiFi credentials onto the Pi. With this image base you don't ever need to modify a wpa_supplicant with SSH/terminal/PiBakery again!
You can follow the instructions below to create a turnkey image, or you can just download my latest one at raspberry-pi-turnkey.schollz.com/2018-06-25-turnkey-1.3.zip (v1.3.0, 982MB) and follow the typical flashing instructions.
Usage
Once you boot the Pi with this image, wait about 10 minutes for the Pi to reformat the drive and start up the web server. Then you will see a WiFi AP named "ConnectToConnect" (password same). Connect to it and your browser should automatically redirect you to a sign-in page. If not, navigate to 192.168.4.1 where you'll see a login form.
When the WiFi credentials are entered onto the login form, the Pi will modify its internal wpa_supplicant to conform to them so that it will be connected to the net. The Pi will then reboot itself using those WiFi credentials. If the credentials are not correct, then the Pi will reboot back into the AP mode to allow you to re-enter them again.
Once connected, you can recieve a message with the LAN IP for your Pi at https://snaptext.live (the specific URL will be given to you when you enter in the credentials to the form).
Note: The Raspberry Pi is not a fast computer. When you see the AP and connect to it, it may take up to a minute for the page at 192.168.4.1 to appear. Also, if you enter the wrong WiFi credentials, it will have to reboot twice to reset the Pi to allow you to enter the credentials again. So try to enter them right the first time!
How does it work?
When the Pi starts up it runs a Python script, startup.py. This script first checks if the Pi is online (by looking for an SSID in iwconfig wlan0). If the Pi is online, the script sets the status as "connected" (saved to disk in status.json).
If the Pi is not online, it will check the status. The initial status is "disconnected". When "disconnected" the Pi will uncomment the configuration files for hostapd and dnsmasq. The access point configuration is nearly identical to as outlined in this tutorial. Then the Pi sets the status as "hostapd" and reboots itself.
When the status is "hostapd" then the script will bind to port 80 and serve a web form at 192.168.4.1. Once you connect to the AP this web form will be available and it will recieve input. Once the server recieves input, it sets the credentials in wpa_supplicant.conf and comments out the configuration file for hostapd and dnsmasq so that the AP doesn't interfere, and then reboots. When it reboots it will see if it gets online and set the status as "connected" or "disconnected". Then it repeats the steps above (i.e. doing nothing if connected, or restarting the AP if disconnected).
Instructions to create image
The following are the step-by-step instructions for how I create the turnkey image. If you don't want to download the image I created above (I don't blame you), then follow these to make one exactly the same.
These instructions assume you are using Ubuntu. You can use Windows/OS X for most of these steps, except step #4 which requires resizing.
1. Flash Raspbian Stretch Lite
Starting from version Raspbian Stretch Lite version 2017-11-29.
Add pi to the sudoers, so that you can run sudo commands without having to be root (so that all the paths to your programs are unchanged).
$ sudo visudo
Then add this line:
pi ALL=(ALL:ALL) ALL
(Sidenote: I save an image intermediate.img at this point so its easy to go back)
Startup server on boot
Open up the rc.local
$ sudo nano /etc/rc.local
And add the following line before exit 0:
su pi -c '/usr/bin/sudo /usr/bin/python3 /home/pi/raspberry-pi-turnkey/startup.py &'
Shutdown the pi
Shutdown the Raspberry Pi and do not start it up until after you write the image. Otherwise the unique ID that is generated will be the same for all the images.
$ sudo shutdown now
3. Resize Raspberry Pi SD image
If you don't want to resize the image, you can just write the entire image file to your computer and use that from here on. If you do want to resize (especially useful if you are installing on a 16GB card and want to flash onto a smaller card), follow these instructions.
Put the newly made image into Ubuntu and do
$ xhost +local:
$ sudo gparted-pkexec
Right click on the SD card image and do "Unmount". Then right click on the image and do "Resize/Move" and change the size to 2400.
Then you can copy the image to your computer using the following command
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/schollz/raspberry-pi-turnkey là nguồn chính thức.
schollz/raspberry-pi-turnkey có bao nhiêu sao?
schollz/raspberry-pi-turnkey có 857 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/schollz/raspberry-pi-turnkey. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
schollz/raspberry-pi-turnkey có những chủ đề gì?
GitHub topics của schollz/raspberry-pi-turnkey: "instructions", "raspberry-pi", "raspbian", "wifi-hotspot". TopGit xếp repo vào nhóm mã nguồn mở.
schollz/raspberry-pi-turnkey còn đang phát triển không?
Commit gần nhất trên schollz/raspberry-pi-turnkey là 3.9 năm trước (theo timestamp GitHub). Repo có 89 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
schollz/raspberry-pi-turnkey viết bằng ngôn ngữ gì?
schollz/raspberry-pi-turnkey chủ yếu viết bằng Python. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về raspberry-pi-turnkey?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về raspberry-pi-turnkey.