Latest firmware for PinePhone modem!
(05-06-2022, 01:29 PM)robthebold Wrote: I wonder if there's anything I can do script-wise that can periodically check on cellular connectivity and alert me that I should reboot the phone. I'll post if I find anything useful on that.

Sorry for reviving a dead thread, but I could not see your profile to pm you and I saw that your account seems to still be active.

Here is a script that you can put in either your user or the root's crontab depending on if you want your phone to reboot automatically upon a modem crash.

Here is the ugly script that I use to do that and I adapted it with notify-send if you would rather have notifications instead of a cold reboot.

Notes
- this assumes a non systemd distro (I am not familiar with systemd) (iirc, you use postmarketos)
- It is not php code, it is only the text editor that puts that title

Desktop notification on modem crash (non automatic reboot)
0. Create the directory `/opt/sbin/`

Code:
# mkdir -p /otp/sbin


1. Put this script in `/opt/sbin/modem-check`


PHP Code:
#!/bin/sh
export LANG="en_US.UTF-8"
MODEM_STATE=`nmcli device|grep cdc-wdm0|head -n1|xargs|cut -f3 -d' '`
MODEM_STATE_CONNECTED="connected"

if [ "$MODEM_STATE!= "$MODEM_STATE_CONNECTED]; then
        notify
-send "Modem crashed. Reboot in order to bring it back online."
fi 


2.1 Open the crontab for your user (not root, not through sudo)

PHP Code:
crontab -


2.2 Add the following line at the bottom of your crontab

PHP Code:
*/30    *      *      *      *      /opt/sbin/modem-check 


2.3 Save it and quit

3. Enable crond

PHP Code:
# rc-update add crond 


4. Start crontab monitoring without rebooting

PHP Code:
# rc-service crond start 


Automatic reboot on modem crash
If you want to reboot your phone automatically (Be careful, as you could experience data loss if you are using the phone while the phone reboots)

0. Create the directory `/opt/sbin/`

PHP Code:
# mkdir /otp/sbin 


1. Put the script code in `/opt/sbin/modem-check`


PHP Code:
#!/bin/sh
export LANG="en_US.UTF-8"
MODEM_STATE=`nmcli device|grep cdc-wdm0|head -n1|xargs|cut -f3 -d' '`
MODEM_STATE_CONNECTED="connected"
LOG="/var/log/modem-check-crash"

if [ "$MODEM_STATE!= "$MODEM_STATE_CONNECTED]; then
        
echo "`date '+%Y-%m-%d %T'`: modem crashed, rebooting." >> "$LOG"
        reboot
fi 


2.1 Open the crontab for the root user

PHP Code:
# crontab -e 


2.2 Add the following line at the bottom of the root's crontab

PHP Code:
*/30    *      *      *      *      /opt/sbin/modem-check 


2.3 Save it and quit

3. Enable crond

PHP Code:
# rc-update add crond 


4. Start crontab monitoring without rebooting

PHP Code:
# rc-service crond start 
  Reply


Messages In This Thread
RE: Latest firmware for PinePhone modem! - by bacydentir85 - 02-02-2025, 08:47 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Fedora + Phosh for PinePhone njha 75 201,160 12-23-2025, 09:12 PM
Last Post: shanehill@mail.com
  Difficulty with openSUSE Tumbleweed Install PinePhone Beta danm1988 0 231 11-17-2025, 07:49 AM
Last Post: danm1988
  Movuan distribution for PinePhone merom 5 4,963 07-27-2025, 05:01 PM
Last Post: merom
  baremetal via Zig on PinePhone - JumpDrive help please WhiteHexagon 1 3,223 07-07-2025, 10:33 AM
Last Post: WhiteHexagon
  Slarm64 on PinePhone [Unofficial Slackware ARM - 64 bit] acid andy 40 56,036 12-28-2024, 12:19 AM
Last Post: mara
  Office applications for the Pinephone Peter Gamma 2 4,442 09-05-2024, 09:22 AM
Last Post: Peter Gamma
  Struggle to install LibreOffice on the PinePhone Peter Gamma 50 61,498 07-26-2024, 10:35 PM
Last Post: Peter Gamma
  Why does Pine64 sabotage office on the Pinephone? Peter Gamma 5 5,815 07-04-2024, 07:34 AM
Last Post: Kevin Kofler
  Which word processor to choose for the Pinephone? Peter Gamma 16 15,679 06-22-2024, 07:28 AM
Last Post: Peter Gamma
  Samba share on the Pinephone? Peter Gamma 0 3,909 06-16-2024, 10:26 PM
Last Post: Peter Gamma

Forum Jump:


Users browsing this thread: 1 Guest(s)