8

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!

bolek
  • 91

4 Answers4

5

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

cmks
  • 1,914
1

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.

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
cmks
  • 1,914
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.