MEMBUAT AUTO STARTUP VNC SERVER di Ubuntu Server 16.04 LTS

Tuesday, May 2, 2017

MEMBUAT AUTO STARTUP VNC SERVER di Ubuntu Server 16.04 LTS


Cara membuat VNC server agar otomatis start setiap kali server usai di reboot.

1.Buat file vncserver in /etc/init.d/ directory
1
sudo nano /etc/init.d/vncserver
Kemudian copy paste atau tambahkan baris-baris berikut ini:

#!/bin/sh -e
### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: networking
# Required-Stop: networking
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO

PATH="$PATH:/usr/X11R6/bin/"

# The Username:Group that will run VNC
export USER="root"
#${RUNAS}

# The display that VNC will use
DISPLAY="1"

# Color depth (between 8 and 32)
DEPTH="16"

# The Desktop geometry to use.
#GEOMETRY="x"
#GEOMETRY="800x600"
GEOMETRY="1024x768"
#GEOMETRY="1280x1024"

# The name that the VNC Desktop will have.
NAME="your-vnc-server"

OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"

. /lib/lsb/init-functions

case "$1" in
start)
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;

stop)
log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;

restart)
$0 stop
$0 start
;;
esac

exit 0
2. Edit permission file
1
sudo chmod +x /etc/init.d/vncserver
3. Buat konfigurasi vncservers di direktori /etc
1
sudo nano /etc/vncservers.conf
lalu Tambahkan nama user anda tadi seperti ini kemudian simpan.
1
2
VNCSERVERS="1:user"
VNCSERVERARGS[1]="-geometry 1024x768"
4. Restart VNC Server
1
sudo /etc/init.d/vncserver start
atau
1
sudo /etc/init.d/vncserver restart

Tarik nafas sebentar… Selesai 🙂

0 comments :