Untitled

 avatar
unknown
plain_text
a year ago
1.1 kB
8
Indexable
#!/bin/bash

if (($# > 2))
then
    echo "Usage:"
    echo "raat-connect          - List all vnc servers"
    echo "raat-connect [port]     - Connect to a vnc server on given port"
    exit 1
fi

ports=($(ss -lptn | grep Xvnc | awk '{split($4, a, ":"); print a[2]}'))

if (($# == 0))
then
    if [ ${#ports[@]} -eq 0 ]; then
            echo "There are no active vnc sessions"
    else
            echo "There are active sessions on ports:"
            for port in "${ports[@]}"; do
                echo "    - $port"
            done
    fi
else
    echo "${ports[*]} ||| $1"
    if [[ ${ports[*]} =~ "$1" ]]; then
        vncviewer 0.0.0.0:$1 &
    else
        echo "There is no active session on port $1"
    fi    
fi


------



#!/bin/bash

if (($# != 3))
then
    echo "Usage: raat-server [vnc password] [rfb port] [geometry]"
    exit 1
fi

display=$(($2-5900))


mkdir -p ~/.vnc && touch ~/.vnc/$2.passwd
echo $1 | vncpasswd -f > ~/.vnc/$2.passwd
setsid Xvnc -AlwaysShared -geometry $3 -rfbauth ~/.vnc/$2.passwd :$display &
DISPLAY=:$display setsid startlxde &
vncviewer -passwd ~/.vnc/$2.passwd  0.0.0.0:$2
Editor is loading...
Leave a Comment