-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
xrdpctl
executable file
·35 lines (32 loc) · 950 Bytes
/
xrdpctl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
if [ "${1}x" = "x" ]; then
echo "Syntax: $0 [list|kill]"
exit 0
fi
if [ "${1}x" = "listx" ]; then
loginctl --no-pager --no-legend | awk '{print $1}' | while read a; do
loginctl session-status --no-pager --no-legend $a -n0 |grep Leader: |grep xrdp >/dev/null
if [ $? = 0 ]; then
#echo -n "$a "
loginctl session-status --no-pager --no-legend $a -n0 |sed -n '1,/Unit:/p'
fi
done
exit 0
fi
if [ "${1}x" = "killx" ]; then
if [ "${2}x" = "x" ]; then
s=$((loginctl --no-pager --no-legend | awk '{print $1}' | while read a; do
loginctl session-status --no-pager --no-legend $a -n0 |grep Leader: |grep xrdp >/dev/null
if [ $? = 0 ]; then
#echo -n "$a "
loginctl session-status --no-pager --no-legend $a -n0 |head -1
fi
done) | iselect -af | awk '{print $1}')
loginctl terminate-session $s
exit 0
fi
if [ "${2}x" != "x" ]; then
loginctl terminate-session $2
exit 0
fi
fi