First time posting here:
In brief:
What I need is for some guidance to write a script that will start an ad-hoc wifi network when my machine goes from ac to battery power and then stop it when ac power is restored. Is it possible?
Detailed version and why would i want such a thing:
I have an older 3rd gen i7 laptop running Ubuntu server. It has a few structural issues but hardware wise it’s in good shape so I made a server out of it. That and it only draws 20w idle.
It’s running nextcloud, plex, openvpn, ssh and qbittorrent 24/7.
Yesterday we had a blackout that lasted a few hours and I had the idea that it would be useful that when this happens and the battery kicks in, everyone in the house could still watch all the movies I have stored on their phones/tablets/etc. So I need a script that kicks in when ac power cuts off to start an ad-hoc network on the wifi card (not being used, the server is hooked by gigabit ethernet) so everyone could access plex, and when power is restored the script turns the network off. All the content I have on the plex server is legal and consists of mostly Indi-Portuguese movies I collected over the years. Having the ad-hoc network always on could work but I really wish to avoid it to keep power usage as low as possible, keep extra wifi channels free and for aesthetic reasons.
The battery itself can last up to 8hrs at idle with the lid closed (12 cell) and will auto power on when power is restored if the battery gets drained.
Any help is welcomed. Thanks for your time.