Skip to content
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

Add a start_detached command #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ and notifications when users attach/detach.
Use `wemux start` to start a wemux server, chmod /tmp/wemux-wemux to 1777 so
that other users may connect to it, and attach to it. If a wemux server
already exists, it will attach to it instead.
#### wemux start_detached
Use `wemux start_detached` to start a wemux server and stay detached from it.
This does nothing if a server is already running.
#### wemux attach
Use `wemux attach` to attach to an existing wemux server.
#### wemux stop
Expand Down Expand Up @@ -328,4 +331,4 @@ and notifications when users attach/detach.

Please note that this does not ensure a logged in user will not be able to exit
tmux and access their shell. If the user is not trusted, you must perform any
security measures one would normally perform for a remote user.
security measures one would normally perform for a remote user.
51 changes: 31 additions & 20 deletions wemux
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,18 @@ host_mode() {
chmod 1777 $socket
echo "wemux server started on '$server'."
fi
# reattach
}

start_attached_server() {
start_server
reattach
}

start_detached_server() {
start_server
}

# Reattach to the wemux server.
reattach() {
if session_exists; then
Expand Down Expand Up @@ -368,6 +377,7 @@ host_mode() {
echo "To host a wemux server please use one of the following:"
echo ""
echo " [s] start: Start the wemux server/attach to an existing wemux server."
echo " [sd] start_detached: Start the wemux server and stay detached."
echo " [a] attach: Attach to an existing wemux server."
echo " [k] stop: Kill the wemux server '$server', delete its socket."
echo ""
Expand All @@ -393,28 +403,29 @@ host_mode() {
# Host mode command handling:
# If no command given, call start server.
if [ -z "$1" ]; then
announce_connection "host" start_server
announce_connection "host" start_attached_server
else
case "$1" in
start|s) announce_connection "host" start_server;;
attach|a) announce_connection "host" reattach;;
stop|st) shift; stop_server "$@";;
kill|k) shift; stop_server "$@";;
help|h) display_host_commands;;
join|j) shift; change_server "$@";;
name|n) shift; change_server "$@";;
reset|d) change_server "$default_server_name";;
list|l) list_active_servers;;
users|u) list_users;;
kick) kick_user $2;;
status_users) status_users;;
display_users) display_users;;
version|v) display_version;;
conf*|c) $editor /usr/local/etc/wemux.conf;;
*) if ! $wemux "$@"; then
echo "To see a list of wemux commands enter 'wemux help'"
exit 127
fi;;
start|s) announce_connection "host" start_attached_server;;
start_detached|sd) announce_connection "host" start_detached_server;;
attach|a) announce_connection "host" reattach;;
stop|st) shift; stop_server "$@";;
kill|k) shift; stop_server "$@";;
help|h) display_host_commands;;
join|j) shift; change_server "$@";;
name|n) shift; change_server "$@";;
reset|d) change_server "$default_server_name";;
list|l) list_active_servers;;
users|u) list_users;;
kick) kick_user $2;;
status_users) status_users;;
display_users) display_users;;
version|v) display_version;;
conf*|c) $editor /usr/local/etc/wemux.conf;;
*) if ! $wemux "$@"; then
echo "To see a list of wemux commands enter 'wemux help'"
exit 127
fi;;
esac
fi
}
Expand Down