Na partycji boot trzeba zrobić plik o nazwie ssh
by aktywować łączenie się przez ssh
I wrzucić plik wpa_supplicant.conf
z ustawieniami wifi:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=PL
network={
ssid="nazwa"
psk="hasło"
}
Kopia zapasowa karty SD: Win32 Disk Imager
bo adresie mac Pi
arp -a | findstr b8-27-eb
albo po adresie anteny wifi
arp -a | findstr 00-13-ef-40-09-27
- Uruchomienie skryptu (shh, passwd, apt update/upgrade)
cd ./raspbian-manual ./setup.ps1
- raspi-config
sudo raspi-config
- Strefa czasowa
- Włączenie interfejsów GPIO
- update
- reboot, by wdrożyć zmiany
sudo reboot
Tworzenie
python3 -m venv "/home/pi/nazwaProjektu/venv"
# or
python3 -m venv ./venv
Aktywacja linux:
source nazwaProjektu/venv/bin/activate
Aktywacja Windows:
# In cmd.exe
nazwaProjektu\venv\Scripts\activate.bat
# In PowerShell
nazwaProjektu\venv\Scripts\Activate.ps1
Dezaktywacja:
deactivate
Poniżej jest dosyć prosta instrukcja, a tu jest inny bardziej kompleksowy poradnik
-
Determine your Raspberry PI's current IP v4 address if you don't already know it.
The easiest way to do this is by using the hostname -I command at the command prompt.
If you know its hostname, you can also ping the Pi from a different computer on the network.hostname -I
-
Get your router's IP address if you don't already know it.
The easiest way to do this is to use the command ip r and take the address that appears after "default via."ip r
-
Get the IP address of your DNS (domain name server) by enter the command below.
This may or may not be the same as your router's IP.grep "nameserver" /etc/resolv.conf
-
Open /etc/dhcpcd.conf for editing in nano.
nano /etc/dhcpcd.conf
-
Add the following lines to the bottom of the file.
If such lines already exist and are not commented out, remove them.Replace the comments in brackets in the box below with the correct information.
Interface will be either wlan0 for Wi-Fi or eth0 for Ethernet.interface [INTERFACE] static_routers=[ROUTER IP] static domain_name_servers=[DNS IP] static ip_address=[STATIC IP ADDRESS YOU WANT]/24
In our case, it looked like this.
interface wlan0 static_routers=192.168.0.1 static domain_name_servers=62.179.1.61 62.179.1.63 static ip_address=192.168.0.48/24
You may wish to substitute "inform" for "static" on the last line.
Using inform means that the Raspberry Pi will attempt to get the IP address you requested,
but if it's not available, it will choose another. If you use static, it will have no IP v4 address at all if the requested one is in use. -
Save the file and reboot.
Add to /etc/network/interfaces
this fragment:
auto lo
iface lo inet loopback
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
If you have Network-Manager installed:
To disable the MAC address randomization create the file
/etc/NetworkManager/conf.d/100-disable-wifi-mac-randomization.conf
with the content:
[connection]
wifi.mac-address-randomization=1
[device]
wifi.scan-rand-mac-address=no
-
Stwórz plik
nazwa-projektu.service
[Unit] Description=nazwaProjektu After=network.target [Service] #EnvironmentFile=/etc/environment ExecStart=/home/pi/nazwaProjektu/venv/bin/python -u /home/pi/nazwaProjektu/run.py WorkingDirectory=/home/pi/nazwaProjektu StandardOutput=inherit StandardError=inherit Restart=always [Install] WantedBy=multi-user.target
-
Copy service file
nazwa-projektu.service
file into/etc/systemd/system
as root, for example:sudo cp /home/pi/nazwaProjektu/nazwa-projektu.service /etc/systemd/system/nazwa-projektu.service \ && sudo systemctl daemon-reload
-
Test deamon
sudo systemctl start nazwa-projektu.service
-
When you are happy with the process of the app, you can have it start automatically on reboot by using this command:
sudo systemctl enable nazwa-projektu.service
Freeze packages
pip freeze | grep -v "pkg-resources" > requirements.txt
status
sudo systemctl status <service-name>.service
Logs:
journalctl -u <service-name>
Logs for the current boot:
journalctl -b -u <service-name>