4

I have a pxe server which hosts a live image of Ubuntu 12.04 and I would like to enable VNC on it.

Normally I would do this with the following command:

$ gsettings set org.gnome.Vino enabled true

However, since this live OS lives in RAM it will need to do this on bootup every time. The problem is for some reason it will not work with a script in /etc/init.d/... For the life of me I cannot figure out why gsettings doesn't work in this context..

For reference this is the script I am using in /etc/init.d:

#!/bin/bash

log=/var/log/gsettings.log

#Needed for some reason.. received info from http://stackoverflow.com/questions/10374520/gsettings-with-cron
sessionfile=`find "${HOME}/.dbus/session-bus/" -type f`
export $(grep "DBUS_SESSION_BUS_ADDRESS" "${sessionfile}" | sed '/^#/d')

set_gsettings()
{
    echo "Inside set_gsettings" >> $log

    #Enable vino
    gsettings set org.gnome.Vino enabled true 2>&1 >> $log
    gsettings set org.gnome.Vino prompt-enabled false 2>&1 >> $log
}

case "$1" in
  start)
    echo "Inside IT-gsettings" >> $log
    set_gsettings
  ;;

  restart|reload|force-reload)
    /etc/init.d/IT-gsettings start
  ;;

  stop)
   :
  ;;

  *)
    log_success_msg "Usage: /etc/init.d/IT-gsettings {start|stop|restart|reload|force-reload}"
    exit 1
    ;;
esac

exit 0

In short, how can I set gsettings on startup?

DanMD
  • 287
  • 1
  • 3
  • 8
  • Is the script executable? Did you install the script using something like `update-rc.d`? – Jon Lin Aug 03 '12 at 04:35
  • Yes, I made it executable and used update-rc.d to create the symbolic links. I actually verified that the script gets executed (Inside IT-gsettings is echoed to my log file), however when I check the value of the Vino enabled key it is still false even though there was no error message... Weird huh?? – DanMD Aug 03 '12 at 16:55

1 Answers1

5

It is likely the script runs when still there is no session available.

Given it is a live CD and you have control of it, you might want to change the defaults values in the schema. For vino, you should change the default values in /usr/share/glib-2.0/schemas/org.gnome.Vino.gschema.xml.

gpoo
  • 8,408
  • 3
  • 38
  • 53