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
  Slarm64 on PinePhone [Unofficial Slackware ARM - 64 bit] acid andy 40 37,283 12-28-2024, 12:19 AM
Last Post: mara
  Office applications for the Pinephone Peter Gamma 2 829 09-05-2024, 09:22 AM
Last Post: Peter Gamma
  Struggle to install LibreOffice on the PinePhone Peter Gamma 50 40,176 07-26-2024, 10:35 PM
Last Post: Peter Gamma
  Why does Pine64 sabotage office on the Pinephone? Peter Gamma 5 1,609 07-04-2024, 07:34 AM
Last Post: Kevin Kofler
  Which word processor to choose for the Pinephone? Peter Gamma 16 7,004 06-22-2024, 07:28 AM
Last Post: Peter Gamma
  Samba share on the Pinephone? Peter Gamma 0 803 06-16-2024, 10:26 PM
Last Post: Peter Gamma
  Possible Free Backup Carrier for PinePhone PineFone 0 747 06-13-2024, 03:45 PM
Last Post: PineFone
  Using Signal on PinePhone in mid-2023? dante404 47 27,009 05-03-2024, 02:19 AM
Last Post: dragonhospital
Wink PINEPHONE not booting Touchwood 2 1,542 02-23-2024, 07:27 AM
Last Post: Touchwood
  Slack on PinePhone Adam Seline 5 7,022 12-20-2023, 07:20 AM
Last Post: nickolas

Forum Jump:


Users browsing this thread: 1 Guest(s)