| 1 | #!/bin/sh -x |
| 2 | isNaturalNumber(){ |
| 3 | case "$1" in |
| 4 | ''|*[!0-9]*) return 1;; |
| 5 | *) return 0;; |
| 6 | esac |
| 7 | } |
| 8 | |
| 9 | sudo systemctl start xrdp |
| 10 | # XXX: Is there a better way to get the port number other than by parsing the |
| 11 | # configuration file? |
| 12 | port=$(sed -n '/^port=[0123456789]/{s/port=//p;q;}' /etc/xrdp/xrdp.ini) |
| 13 | if ! isNaturalNumber "$port"; then |
| 14 | exit 1 |
| 15 | fi |
| 16 | |
| 17 | timeout 2s xvfb-run -l xfreerdp /v:localhost:"$port" /p: /u: /d: /cert:tofu |
| 18 | if test $? != 124; then |
| 19 | 2>&1 printf "%s\n" "Xfreerdp exited before the timeout, it has likely " \ |
| 20 | "failed to connect. The test has therefore failed." |
| 21 | exit 2 |
| 22 | fi |