Skip to content

Instantly share code, notes, and snippets.

@metalefty
Last active April 8, 2019 03:29
Show Gist options
  • Save metalefty/2672c26ae0cb36f7a4bc100650c83a15 to your computer and use it in GitHub Desktop.
Save metalefty/2672c26ae0cb36f7a4bc100650c83a15 to your computer and use it in GitHub Desktop.
Clean up remained xrdp socket files
#!/bin/sh
SOCKDIR=/tmp/.xrdp
SESSIONS=$(cd ${SOCKDIR} ; ls -1 xrdp_* | sed -e 's|[^0-9]||g' | sort -u)
for i in ${SESSIONS}
do
if [ ! -S ${SOCKDIR}/xrdp_display_${i} ]
then
(
cd ${SOCKDIR}
rm -f xrdp_chansrv_audio_in_socket_${i} \
xrdp_chansrv_audio_out_socket_${i} \
xrdp_chansrv_socket_${i} \
xrdpapi_${i}
)
fi
done
@metalefty
Copy link
Author

The SESSIONS line can be written like this.

# space after first "("
SESSIONS=$( (cd ${SOCKDIR} ; ls -1 xrdp_*) | sed -e 's|[^0-9]||g' | sort -u)
# actually "( )" surrounding ls and cd is not necessary 
SESSIONS=$(cd ${SOCKDIR} ; ls -1 xrdp_* | sed -e 's|[^0-9]||g' | sort -u)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment