~mil/sxmo-tickets#539: 
active SSH connection does not stop phone from sleeping if SSHing via IPv6

I investigated how to prevent my phone from going to sleep while using SSH. Currently default_hooks/sxmo_hook_check_state_mutexes.sh checks using the following command for a running SSH session:

netstat -tn | grep ESTABLISHED | cut -d':' -f2 | grep -q '^22 '

As IPv6 addresses contain colons itself, this only works for IPv4. I would suggest to change this to the following:

netstat -tn | grep ESTABLISHED | cut -d\ -f16 | grep -q ':22$'

(or, for easier readibility, but with new dependency on preinstalled awk):

netstat -tn | grep ESTABLISHED | awk '{ print $4 }' | grep -q ':22$'

Status
RESOLVED CLOSED
Submitter
~bwildenhain
Assigned to
No-one
Submitted
2 years ago
Updated
2 years ago
Labels
No labels applied.

~earboxer 2 years ago

We already do this in master:

(similar to your last one)

ssh_connected() {
	netstat -tn | awk '
		BEGIN { status = 1 }
		$4 ~ /:22$/ { status = 0; exit }
		END { exit status }
		'
}

# active_ssh
if ssh_connected; then
	lock_suspend_mutex "SSH is connected"
else
	free_suspend_mutex "SSH is connected"
fi

~baroque0 2 years ago

Also if ssh runs on non-standard port...

~phartman REPORTED CLOSED 2 years ago

For those cases, you can edit your sxmo_hook_check_mutexes.sh.

Register here or Log in to comment, or comment via email.