periodically check for the internet connection. If there's no internet connection, the script performs a login to the RUB login site to active the router. After correct setup it will run forever and start automatically upon boot/reboot ofd the raspbery pi.
this is only for installing on a raspberry pi that's connected to the router/network. It doesn't work on Windows PC or any device other than raspberry pi
- pull repro into desired directory
- use nano (or similar text editor) to ediut autoLogin.py to change these lines of code:
LOGINID = "ab12345@w-hs.de" # change ab12345 with your ZA credentials
PASSWORD = "password" # change password to your actual ZA password
IPADDRESS = "" # LEAVE EMPTY unless you know what you're doingand do not change anything else (unless you know what you're doing)
3. make this run on raspberry startup (as service file)
3.1. Create a service file:
sudo nano /etc/systemd/system/autologin.service 3.2. Paste content and change /path/to/autoLogin.py to the actual path of the script:
[Unit]
Description=Auto Login Script
# if you have PiHole with unbound running,
# make sure those services are active before
# this script is launched, to make sure you
# do not run into DNS conflicts, uncomment
# these two lines:
#
# After=pihole-FTL.service unbound.service
# Wants=pihole-FTL.service unbound.service
#
# if you do not have pihole running on the
# device, leave this line uncommented:
#
After=network.target
[Service]
ExecStart=/usr/bin/python3 /path/to/autoLogin.py
User=p1
Restart=always
[Install]
WantedBy=multi-user.target
3.3 Save and Reload systemd, enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable autologin.service
sudo systemctl start autologin.serviceif you want to change your pasword, use systemctl commands to stop and start the script.
sudo systemctl stop autologin.serviceedit the autoLogin.py to change the password
sudo systemctl start autologin.service- Python:
Version 3.6or higher - Built-in Python libraries (no installation needed):
time,subprocess - External Python libraries:
requests - System utilities:
ping(usually pre-installed on most systems) - Permissions: Ability to make outgoing network connections, Permission to execute the ping command
- Ensure Python 3.6+ and pip is installed:
python3 --version
pip --version- Install
requestslibrary:
pip install requests- Verify
pingis available:
which ping