Bash script for automatic login to sapienza wireless captive portal
| Dependency | Arch | Debian 7 / Ubuntu |
|---|---|---|
| GNU bash | bash | bash |
| curl | curl | curl |
| iwgetid | wireless_tools | wireless-tools |
CPAL_USER="yourusername" CPAL_PASS="yourpassword" swcp-autologin.shYou can install the script as a system command
sudo cp swcp-autologin.sh /usr/local/bin/swcp-autologin
sudo chmod +x /usr/local/bin/swcp-autologin
To run swcp-autologin as daemon you need to follow the system wide installation procedure and then choose one of the integration method:
Thanks to cron it's possible to automatically launch the script at specific time intervals
edit your user crons with crontab -e and add the following line:
* * * * * env CPAL_USER="" CPAL_PASS="" PATH="$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" swcp-autologin >> /tmp/swcp-autologin.log 2>&1
remember to fill in the CPAL_USER and CPAL_PASS variables
you will find the daemon log at /tmp/swcp-autologin.log
This installation method provide a configurable timed daemon that will keep you logged in.
write your username and password in /etc/swcp-autologin.conf:
CPAL_USER="yourusername"
CPAL_PASS="yourpassword"It's recommanded to make it readable only:
sudo chmod 660 /etc/swcp-autologin.conf
Now we need to copy systemd files:
sudo cp systemd/swcp-autologin.* /etc/systemd/system/
# Perform login:
sudo systemctl start swcp-autologin.service
# Start daemon ( this will keep you logged in )
sudo systemctl start swcp-autologin.timer
# Stop daemon
sudo systemctl stop swcp-autologin.timer
# Enable daemon automatic startup:
sudo systemctl enable swcp-autologin.timer
# Disable daemon automatic startup:
sudo systemctl disable swcp-autologin.timer
# Show logs
sudo journalctl -fb -u swcp-autologin