Link to home
Start Free TrialLog in
Avatar of aideb
aideb

asked on

Scripted configuration of TightVNC with Start on boot

Hi,

I'm trying to develop a script that I can work into an unattended build that will configure TightVNC on Kali linux (based on Debian) and then ensure that it runs on boot

Here is what I have currently in my bash script (deploy.sh)

# Configure VNC Password
umask 0077                                        # use safe default permissions
mkdir -p "$HOME/.vnc"                             # create config directory
chmod go-rwx "$HOME/.vnc"                         # enforce safe permissions
vncpasswd -f <<<"remotecl" >"$HOME/.vnc/passwd"  # generate and write a password

# Start VNC 
/usr/bin/tightvncserver -geometry 1500x700 -depth 16

Open in new window


This is setting the password and starting the VNC server however when the machine is restarted, the service does not start back up

Can someone help me with this please
ASKER CERTIFIED SOLUTION
Avatar of Scott Silva
Scott Silva
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aideb
aideb

ASKER

Thanks Scott,

That has moved me along nicely - I used the info in your link and discovered another post

I did

sudo nano /etc/initd/vncserver

and populated this with

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

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

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

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

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

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

# The name that the VNC Desktop will have.
NAME="my-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/tightvncserver ${OPTIONS}"
;;

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

restart)
$0 stop
$0 start
;;
esac

exit 0

Open in new window


I can now start the service with

/etc/initd/vncserver start

and stop with

/etc/initd/vncserver stop


How can I get the start command to execute on boot?

Cheers
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aideb

ASKER

Great - Thanks Scott

I ran this

sudo ln -s /etc/initd/vncserver /etc/rc5.d/S08vncserver
sudo ln -s /etc/initd/vncserver /etc/rc0.d/K01vncserver

and it started on boot!

How am I best automating this so that I can add it all to my deploy.sh
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aideb

ASKER

Thanks for all your assistance to resolve this!