-
-
Save elyezer/89934bc6b4d82b103aa7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash +e | |
# allow change to pass-in display argument | |
DISPLAY=$1 | |
: ${DISPLAY:=:1} | |
export DISPLAY | |
echo "=== network before $0 ===" | |
netstat -na | grep "LISTEN " | |
echo | |
echo "=== was running ===" | |
(ps -fwC Xvnc4 --no-header || ps -fwC Xvnc --no-header) && vncserver -kill ${DISPLAY} | |
sleep 1 | |
echo "=== cleanup ===" | |
XDISPLAY=X`echo $DISPLAY | cut -d : -f 2` | |
[ -f /var/tmp/Xvfb_\${DISPLAY}.pid ] && rm -f /var/tmp/Xvfb_\${DISPLAY}.pid | |
[ -f /tmp/.${XDISPLAY}-lock ] && rm -f /tmp/.${XDISPLAY}-lock | |
rm -f /tmp/.X11-unix/${XDISPLAY} | |
#kill fluxbox after run. If flux persists too long, it tends to consume 100% after a while. | |
ps ax | grep -v grep | grep fluxbox | |
flux_box_check=$? | |
if [[ $flux_box_check == 0 ]]; then | |
echo "#######################################" | |
echo "# killing fluxbox #" | |
echo "#######################################" | |
killall -9 fluxbox | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment