Skip to content

Add example of an OpenBSD daemon #440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions examples/openbsd_service
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/ksh

daemon="/usr/local/bin/ssh-chat"
daemon_logger="daemon.info"
daemon_flags="--verbose --bind ':PORT' --identity PRIVATE_KEY --admin=ADMIN_FILE --motd=MOTD_FILE"
daemon_user="USER"

. /etc/rc.d/rc.subr

rc_bg=YES
rc_reload=NO

rc_cmd $1

# 1. Copy this file to `/etc/rc.d` and make sure it's executable.
# $ cp ssh-chat/examples/openbsd_service /etc/rc.d/ssh_chat
# $ chmod +x /etc/rc.d/ssh_chat
#
# 2. Point the variable `daemon` to the executable, e.g., /usr/local/bin/ssh-chat
# $ ln -s ~/ssh-chat/ssh-chat /usr/local/bin/ssh-chat
#
# 3. Modify the values in daemon_flags and daemon_user based on your liking.
# Alternatively, you can delete that line and set the flags using rcctl instead:
# $ rcctl set ssh_chat flags --verbose --bind [...] --identity [...]
#
# 4. Create the user that will run this service (see `man useradd` or `man adduser`)
# $ useradd -m chat
#
# 5. Enable and start the service
# $ rcctl enable ssh_chat
# $ rcctl start ssh_chat
#
# 6. Check the logs in `/var/log/daemon`