Maybe, but that’s not going to send any traffic through the mobile connection.
I would have thought that there are easier ways of ensuring that suspend does not happen i.e. disable it.
Maybe, but that’s not going to send any traffic through the mobile connection.
I would have thought that there are easier ways of ensuring that suspend does not happen i.e. disable it.
Is that what keeps the phone from going to sleep? I just figured it’d be easier on the battery.
I don’t know.
I recover automatically and it worked so far very good on my L5.
I sketched how I reused the scripts from the issue here (no calls nor sms anymore - modem/usb-hub problem): https://source.puri.sm/-/snippets/1188
Thanks!
Would anyone here be able to help me at the watch-modem.sh as a service? Right now I’m starting it manually through terminal, and just leaving it running, but I am curious if this is wasting more power than it would if this was running as a service automatically?
Thanks in advance!
This watch script seems to be doing the trick to keep the modem running. It is crazy to me though how many times it is having to do it’s job. Then I reboot, and it doesn’t need to do anything. It seems to be after coming back from standby that such a thing is necessary.
Edit: I am noticing that almost 100% of the time when I use firefox esr or vivaldi to access web client for chat platforms that the modem is resetting or dropping off. Before I do this on a fresh boot the modem is super stable. After using a web browser to access chat clients (threema, rocket chat, discord, telegram) I get nearly instant cellular drop outs, followed by nearly every minute the script restarting the service.
This is incredibly frustrating to say the least.
This is how I remember I did it:
Put the scripts into /home/purism/bin (watch-modem.sh, recover-modem.sh):
purism@pureos:~$ ls -l bin/*modem*
-rwxr-xr-x 1 root root 310 2. Jun 11:00 bin/recover-modem.sh
-rwxr-xr-x 1 purism purism 1404 2. Jun 10:56 bin/watch-modem.sh
recover-modem.sh is called as root (using sudo) - make it belong to root (like shown above) using this command:
sudo chmod 775 /home/purism/bin/recover-modem.sh; sudo chown root:root /home/purism/bin/recover-modem.sh
Edit your sudoers configuration to let purism run recover-modem.sh as root: sudo visudo /etc/sudoers.d/11_recover-modem
Copy the following into the editor and save the file:
Cmnd_Alias RECOVER_MODEM_CMD = /home/purism/bin/recover-modem.sh
User_Alias RECOVER_MODEM_GRP = purism
RECOVER_MODEM_GRP ALL=NOPASSWD: RECOVER_MODEM_CMD
Put the service file into /home/purism/.config/systemd/user/watchmodem.service
purism@pureos:~$ ls -l .config/systemd/user/watchmodem.service
-rw-r--r-- 1 purism purism 158 27. Mai 12:46 .config/systemd/user/watchmodem.service
Reload systemd config: systemctl --user daemon-reload
Enable the service: systemctl --user enable watchmodem
Check the service: systemctl --user status watchmodem
My output looks like this:
purism@pureos:~$ systemctl --user status watchmodem
● watchmodem.service - Watch Modem of Librem5
Loaded: loaded (/home/purism/.config/systemd/user/watchmodem.service; enabled; preset: enabled)
Active: active (running) since Fri 2022-09-23 12:24:38 CEST; 3 days ago
Main PID: 796 (watch-modem.sh)
Tasks: 3 (limit: 3124)
Memory: 40.4M
CPU: 2min 14.411s
CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/watchmodem.service
├─796 /bin/bash /home/purism/bin/watch-modem.sh
├─800 journalctl -f SYSLOG_IDENTIFIER=ModemManager
└─801 /bin/bash /home/purism/bin/watch-modem.sh
Sep 26 08:56:06 pureos /home/purism/bin/watch-modem.sh[15249]: found: 'QMI endpoint hangup: removed'
Sep 26 08:56:06 pureos watch-modem.sh[15252]: Playing WAVE '/home/purism/.local/share/sounds/__custom/glass.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Sep 26 08:56:17 pureos /home/purism/bin/watch-modem.sh[15386]: seems like modem recovered by itself
...
Didn’t re-install and check all the steps like written down here - so follow with care and if anything doesn’t work let me know.
I agreed to build a package of this as a temporary solution until the cause for the disconnects is found and taken care of. Will be part of bm818-tools.
If anybody installs this manually it will have to be removed when the package is ready and might be installed via dependencies. I’ll write about it in this thread so that anybody will be informed (you can watch the thread or watch the repo for the merge request that’ll come sometimes).
What does systemctl --user status watchmodem
show?
what the picture shows is what systemctl reports when running that command.
I’m not quite sure why it is doing that.
What output do you get when you run the script directly from command line by running ˋwatch-modem.shˋ (or if you need to give the path ˋ~/bin/watch-modem.shˋ?
I looked at the script again and found that there are some commands needed that might not be installed by default. The existence of those commands is checked at the beginning and the scripts exits if they do not exist. Would be the most simple explanation …
well the script runs and works. I had to source my own glass.wav and put it in the __custom directory but other than that it works. parallel.
running recover-modem.sh does give me an error
recover-modem.sh 3: [[: not found
I guess one question I have is whether I really should have been putting these in /home/purism/bin instead of /bin directly? Was that intentional?
Not saying that this is the problem but you need to be careful with that check since PATH may differ depending on the context and in particular there is an interaction between sudo
and PATH (for security reasons).
Since the multiple references to those two scripts are explicitly as /home/purism/bin/whichever.sh then, yes, the scripts are intentionally in /home/purism/bin
and that probably is a better place for something that is hopefully a temporary hack. I’m sure you could get it working if you put the scripts somewhere else and adjusted all the references.
(Edit: Having said that, I am not totally convinced that it is secure to put the recover script in /home/purism/bin
and change the ownership of the script to root
because perhaps a malicious user can move his bin
directory out of the way and replace it with a new bin
directory with a new recover script. @ChriChri ?)
Are you doing something weird and overriding which shell is in use? That might be the result of using sh
(dash
?) rather than bash
.
To comment further on that, I generally try to avoid putting my own hacky efforts in any existing system directory for executables.
O.k., we’ll have to find out why - this is probably the same reason the service doesn’t start.
Are you sure the #!/bin/bash
beginning of the script watch-modem.sh is in the file and the files mode is correct? For me it looks like this:
purism@pureos:~$ ls -l /home/purism/bin/watch-modem.sh; head -n1 /home/purism/bin/watch-modem.sh
-rwxr-xr-x 1 purism purism 1404 2. Jun 10:56 /home/purism/bin/watch-modem.sh
#!/bin/bash
I just checked my directories and they are set - let’s say - quiet liberal. I can’t remember changing the mode and even less why I should have done that. How do yours look?
purism@pureos:~$ ls -ld /home /home/purism /home/purism/bin
drwxr-xr-x 3 root root 4096 4. Sep 14:40 /home
drwxr-xr-x 38 purism purism 4096 27. Sep 09:42 /home/purism
drwxr-xr-x 2 purism purism 4096 22. Aug 20:57 /home/purism/bin
I put these inside the home directory to have them somewhere where they will not conflict with any files that might be installed by packages.
If one would choose to install the same solution as root the files would belong to /usr/local/bin or /usr/local/sbin.
My plan is to install these files as a package in a slightly improved version that respects the global setting for quiet and silent.
From the package the files will end up in /usr/bin/, /usr/sbin/ and /usr/lib/systemd/.
I’m neither. This is just a hack or prove of work. If you’re unsure about any aspect of it and you’re in need of an immediate solution (in contrast to waiting for the package) and you’re need for security is high you should adopt this hack to your needs.
so you’re probably not going to like this, but I will able to get it working by setting watch-modem.sh to root for user purism.
In other news the stability of my cellular connection is garbage as of late. Very frustrating. Has anyone else been able to work with Telekom in Germany? I’m thinking about switching to Aldi Talk, so I’d be interested in experience there as well.
You mean suid bit?
But I mean seriously how is this supposed to be useful when the friggin modem is not reliable in the slightest? It might be telekom but it is frustrating to the max.
I know what you mean and I shared your sentiment.
In practice this problem affects me not any more or extremely seldom.
But this is the reason I supposed to put all this into a package and install it by default - until the root cause is fixed.
I thought so too, but after testing it I found that much more frequent pings are needed to avoid suspend. Even 5 seconds between pings is still too much, it will suspend during those 5 seconds, then resume to do the next ping, and then the modem problem sometimes happens. I found that one ping every 2 seconds is frequent enough, then it does not try to suspend. The threshold is somewhere between 2 and 5 seconds, I did not find out more precisely than that.