2

Whole day I'm facing a startup script problem.

What I'm looking for is a way to run a single script at boot/before login that will configure my machine and run proper services. (Single script for all users would be cool - easy maintenance)

simple script "/machineSetup.sh"

#LC_NUMERIC - Specifies the decimal delimiter
export LC_NUMERIC="en_US.UTF-8"
#-------------------------------------------------------------------
#add custom aliases path 
export PATH=$PATH:/home/user/aliases
#-------------------------------------------------------------------
#run backburnerServer (tool to control remote computing) run process
/usr/discreet/backburner/backburnerServer &
#-------------------------------------------------------------------
#run x11vnc run process 
/usr/bin/x11vnc &

I'm on Ubuntu14.04. I already did tests with /etc/rc.local no luck at all. I tried /etc/profile.d/machineSetup.sh but it works only after login.

Would be cool if you can give me any hints. Is it possible at all to store configuration inside single file Thanks in advance for suggestions!

  • What is your purpose for starting x11vnc? Are you actually trying to provide remote VNC access to the display manager / login prompt, or do you really just want x11vnc to relay an established user session (i.e. 'desktop sharing')? Either way, "boot time" is not the place to do that. – steeldriver Mar 14 '16 at 19:04
  • Well , are we talking about starting this script for GUI or command line ? If we're talking both, you might want to add a check of whether or not this script is already been running , in order to avoid running it multiple times, if you choose to go through .profile route. Second thing, it may run in /etc/rc.local, but it runs as root, without any connection to GUI. So I am doubting it would be altering anyting . I would suggest you use /etc/lightdm/lightdm.conf to link this with GUI and also avoid spawning multiple instances – Sergiy Kolodyazhnyy Mar 14 '16 at 19:16
  • @steeldriver That's what i'm trying to do. I need to start backburnerServer without need to provide login info. – bolek Mar 14 '16 at 19:23
  • This one worked for me http://askubuntu.com/questions/243044/why-isnt-rc-local-executed – bolek Mar 18 '16 at 12:06
3

You may start any script from

/etc/rc.local

Better you create an upstart .conf file. These are stored in

/etc/init/*.conf

As an example, here are the contents of the file /etc/init/hostname.conf:

#
# This task is run on startup to set the system hostname from     /etc/hostname,
# falling back to "localhost" if that file is not readable or is empty     and
# no hostname has yet been set.

description     "set system hostname"

start on startup

task
exec hostname -b -F /etc/hostname

Another solution is using the crontab feature @reboot, find out more about crontab here

0

Declaration environment variables is generally done in ~/.profile, so you can just add these lines to the end of that file. I'm not sure if this answers your question, but if you are okay with the script executing at login, you should try adding the script to your Startup Applications. Just open the dash, enter Startup Applications, and click Add. Enter whatever name you like, and in the Command field browse to your script. Then click Add, and you are done.

  • Thanks! Sure, but it works only after login. So it doesn't work for me. – bolek Mar 14 '16 at 18:49
0

When calling from rc.local you need to have a executable shell script:

sudo -i

vi /machineSetup.sh

Content:

#!/bin/bash
#LC_NUMERIC - Specifies the decimal delimiter
export LC_NUMERIC="en_US.UTF-8"
#-------------------------------------------------------------------
#add custom aliases path 
export PATH=$PATH:/home/user/aliases
#-------------------------------------------------------------------
#run backburnerServer (tool to control remote computing) run process
/usr/discreet/backburner/backburnerServer &
#-------------------------------------------------------------------
#run x11vnc run process 
/usr/bin/x11vnc &

Make it executable:

chmod 0755 vi /machineSetup.sh
  • I tried. No luck on ubuntu 14.04. It works ok on 12 (also before login) but on 14.04 i cannot force backburnerServer to start before login, same settings just different ubuntu version. On 14.04 backburnerServer starts right after I login – bolek Mar 14 '16 at 19:36
0

I don't know why I didn't think of this earlier. All you have to do is open /etc/rc.local in a text editor, and paste the contents of your script inside the file, before the line exit 0. I know that this works for a fact, as I make my laptop autokill Bluetooth at startup.

  • Thanks! but please check commentu under cmks answer. – bolek Mar 15 '16 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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