So I recently got a CyberPower UPS, and set up PowerPanel Business with it. I liked the software except for that it didn't have the option to run a script on bootup after a power failure. So I pretty much changed the shutdown script of PowerPanel so that it runs this Python script (set of scripts, rather) that do this:
On shutdown, creates a file in its program directory.
On startup, checks to see if the file exists. If it does exist, run a script that the user configured (Could be a bash script or any other kind of script, the one I used was just an SH script)
When that's done, delete the file so the cycle can repeat.
That way I can do some special things on wakeup from a power fail, like waking other servers on LAN and such. Plus it was a neat little project to fiddle with Python for.
I'm a complete noob at programming, I only know python and enough Linux commands to get around, so I was wondering if you guys could give me some pointers? I put the project on GitHub (if I did anything really dumb putting it on GitHub, forgive me, I've never used GitHub before so I did the best I could). On my github look in the setup folder, thats an auto installer script for it that I wrote this afternoon. It does everything for you except adding the startup part, but it tells you how to do it and what file to add, so its pretty easy.
What do you guys think? What dumb mistakes did I make? How can I improve? (Also, is this actually something people would use, or is it kinda silly to have? I could add things to make deployment to lots of servers easier if people are actually interested, but I mostly did it as a little project to help myself out and test my python skills.)
I've only got the auto installer there right now, but I'm in the process of uploading more stuff including the full program directory, but I gotta finish up some other things before I do that.
Nice man. Everyone's first project they fully write is usually something they are extremely proud of. I am not too familiar with python, but I looked at the files and understand how it works. I am trying to think of how this would be useful, but I am guessing that if you configured it to execute another script on startup if the previous file existed, then you could pull out the text into a db where the data could be centrally stored and used for reporting purposes?
My first program/code snippet that I wrote was on login, it would record the username, IP address, MAC, and date time and write the info to SQL. I used it to track people logging in and was easier for me to find the computer where they were logged into. (Did not want to use 3rd party software.)
Another cool project I did, was use exchange API to scan incoming messages, and the count of messages in each public folder. Scanned the incomming messages against a list of words and if that email was flagged, then a copy was sent to another email account, and reviewed.
Thanks for the kind words! My use case for it was to use Wake On LAN after a blackout, since I've got some PCs that don't have the "turn on as soon as you get AC power" option in the BIOS. But I suppose you could also have it write time info and UPS status info to an SQL database. I really need to figure out how to "trick" PowerPanel Business Edition into spitting out individual UPS variables so I can log them in Zabbix, but I haven't gotten around to that yet.