Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sshuttle
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pub
sshuttle
Commits
1dbf2163
Unverified
Commit
1dbf2163
authored
Oct 18, 2020
by
Brian May
Committed by
GitHub
Oct 18, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #543 from skuhl/sdnotify-doc
sdnotify.py documentation
parents
c1cc3911
52558174
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
sdnotify.py
sshuttle/sdnotify.py
+17
-0
No files found.
sshuttle/sdnotify.py
View file @
1dbf2163
"""When sshuttle is run via a systemd service file, we can communicate
to systemd about the status of the sshuttle process. In particular, we
can send READY status to tell systemd that sshuttle has completed
startup and send STOPPING to indicate that sshuttle is beginning
shutdown.
For details, see:
https://www.freedesktop.org/software/systemd/man/sd_notify.html
"""
import
socket
import
os
...
...
@@ -5,6 +15,7 @@ from sshuttle.helpers import debug1
def
_notify
(
message
):
"""Send a notification message to systemd."""
addr
=
os
.
environ
.
get
(
"NOTIFY_SOCKET"
,
None
)
if
not
addr
or
len
(
addr
)
==
1
or
addr
[
0
]
not
in
(
'/'
,
'@'
):
...
...
@@ -31,16 +42,22 @@ def _notify(message):
def
send
(
*
messages
):
"""Send multiple messages to systemd."""
return
_notify
(
b
'
\n
'
.
join
(
messages
))
def
ready
():
"""Constructs a message that is appropriate to send upon completion of
sshuttle startup."""
return
b
"READY=1"
def
stop
():
"""Constructs a message that is appropriate to send when sshuttle is
beginning to shutdown."""
return
b
"STOPPING=1"
def
status
(
message
):
"""Constructs a status message to be sent to systemd."""
return
b
"STATUS=
%
s"
%
message
.
encode
(
'utf8'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment