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?

2
  • Is the script executable? Did you install the script using something like update-rc.d?
    – Jon Lin
    Aug 3, 2012 at 4: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 3, 2012 at 16:55

1 Answer 1

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.