hyx0329 / openstick-failsafe-guard

a bunch of systemd services for MSM8916 devices running debian
20 stars 5 forks source link

Failsafe systemd service for OpenStick

This repo has evolved into a collection of tool scripts/services to help playing with MSM8916 sticks. Some are fail-safe services to regain access to the device, the others may be utilities to help the system runs better.

how to create deb packages

Just run (on a system with dpkg-deb, fakeroot, gnumake)

make all-deb

then you'll find the packages at the root of the repo.

Main features and usages

openstick-startup-diagnose

WARNING: If you set up a CUSTOM AP, the SCRIPT will assume that the device is ONLINE! So please remember your AP's password!

usage

apt install -y gawk  # required
cp openstick-gc-guard.service openstick-gc-guard.timer /etc/systemd/system/
cp openstick-gc-guard.sh /usr/sbin/
chmod +x /usr/sbin/openstick-gc-guard.sh
systemctl enable openstick-gc-guard.timer

reset button monitor

Monitor the reset button and trigger relevant actions. The defined action will be excuted directly(in posix shell). If you decide to modify the action to "exit 0", it will exit.

usage

apt install -y bsdmainutils bc  # required: hexdump, bc(calculator)
cp openstick-button-monitor.service /etc/systemd/system/
cp openstick-button-monitor.sh /usr/sbin/
systemctl enable --now openstick-button-monitor.service

You might want to edit the environment variables through systemd to define your button behavior. Defaults to do nothing except logging. Long-press behavior changed to activate the failsafe access point.

With supported kernel, the led will on while the button is pressed, until the long-press time threshold has been exceeded.

openstick-gc-startup

Test and enable USB gadget mode if USB is not connected or connected to a host machine. Predefined action is to enable RNDIS and ADB interface.

usage

Enable the service and edit the Environment in the service unit script.

openstick-sim-changer

Switch sim card according to the configuration at startup, for UFI001/UFI003 series. ~~This also ensures the sim card is fully powered up so ModemManager don't need to be restarted after boot up.~~ That's a complicated issue.

Note that I'm not aware of any method to reload the sim card info without a reboot, so I created this service to switch the sim cards before ModemManager initialize the modem.

usage

Enable the service and edit the Environment in the service unit script.

Others

Not useful for most users, as they are intended to help a new installation setup.

Notes

How to modify the environment variables in systemd service

see https://serverfault.com/questions/413397/how-to-set-environment-variable-in-systemd-service

TODOs