You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
692 B
32 lines
692 B
3 years ago
|
#!/bin/bash
|
||
|
|
||
|
set -e
|
||
|
set -f
|
||
|
set -u
|
||
|
set -o pipefail
|
||
|
|
||
|
_safe_param_stdin() {
|
||
|
tr -d '$`<>"%;)(&+'"'"
|
||
|
}
|
||
|
|
||
|
_main_server_watcher(){
|
||
|
inotifywait --event close_write --format '%f' --monitor "$dir" | \
|
||
|
while read -r line
|
||
|
do
|
||
|
# TODO: validate IP/hostname
|
||
|
local target
|
||
3 years ago
|
target="$(head -n 1 "$dir/$line" | _safe_param_stdin)"
|
||
3 years ago
|
test -n "$target"
|
||
3 years ago
|
# log how xpra is run into ~/.xsession-errors*
|
||
|
( set -x ; xpra attach tcp://"$target":4648 ) &
|
||
|
# XXX TODO: this fails for now, fix permissions and try to avoid 777
|
||
|
# or maybe clean up old files by systemd-tmpfiles
|
||
|
#unlink "$dir/$line"
|
||
3 years ago
|
done
|
||
|
}
|
||
|
|
||
|
if [ "${SOURCED:-0}" != 1 ]; then
|
||
|
readonly dir='/var/spool/doskast'
|
||
|
_main_server_watcher "$@"
|
||
|
fi
|