Updating the guest wifi settings is a hassle, so I'm going to automate this task.
--When you run the script, Slack will be issued a QR code with wireless LAN configuration information. --Reading the QR code issued to slack with an iPhone or Android device suggests a wireless LAN connection.
In terms of images, let's do this.
See the code I wrote on Github
Select app in slack and add bot
Give the bot a name
Get a Token for the bot (this token will be set later)
rice_cooker.py(8th to 13th lines)
# Please Write Your Wi-Fi Setting & Slack Token & Font Path
CONPANY_NAME = 'GUEST'
ENCRYPTION_METHOD = 'WPA'
SLACK_TOKEN = ''
SLACK_CHANNEL = 'freewifi-dev'
FONT_PATH = '/usr/share/fonts/dejavu/DejaVuSans.ttf'
Enter the following items.
Run with python3 rice_cooker.py
Check the QR code, SSID and password on slack
Start up your iPhone and read the QR code
You will be prompted to connect to the network, so tap Connect
Make sure you are connected to a wireless LAN
You have been successfully connected!
Originally, after this process, there was code to connect to the AP with SSH and add and remove wireless LAN settings (SSID, Password). I thought I would implement it with Ansible or Netmiko, but the wireless LAN terminal I was using was an Aruba product, and I couldn't use them, so I supported it with Python's expect. If motivation remains, I will write about network setting automation with expect.
--Pillow's Image.width may not be processed correctly, so I replaced the processing with Image.size [0] and made the tea muddy.
--Reference for password creation -Generate password for text with python --Issuance of QR code -Generate and save QR code image with Python, Pillow, qrcode --Image generation and combination -Add margins to the top, bottom, left and right of the image with Python, Pillow and resize -Paste another image to an image with Python, Pillow -Edit images and insert text in Python -How to use Python's image processing library Pillow (PIL) --Notification function to slack -How to upload images to Slack with Python - Docs » Reference » Image Module - slack - api chat.postMessage - slack - api files.upload
Recommended Posts