0

Here is the full rc.local

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

touch /home/jack/test.txt
bash /home/jack/Scripts/select_wallpaper.sh

exit 0

When executing the script manually no problem occures and everything works fine. I have tried to put the test command touch into the rc.local but nothing happens!? I have checked the sysv-rc-conf and it is enabled! What am I missing??

Here is the content of my /etc/init.d/rc.local:

 #! /bin/sh
### BEGIN INIT INFO
# Provides:          rc.local
# Required-Start:    $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: Run /etc/rc.local if it exist
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin

. /lib/init/vars.sh
. /lib/lsb/init-functions

do_start() {
    if [ -x /etc/rc.local ]; then
        [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)"
    /etc/rc.local
    ES=$?
    [ "$VERBOSE" != no ] && log_end_msg $ES
    return $ES
fi
}

echo $1 > /home/jack/test.txt

case "$1" in
start)
do_start
    ;;
restart|reload|force-reload)
    echo "Error: argument '$1' not supported" >&2
    exit 3
    ;;
stop)
    ;;
*)
    echo "Usage: $0 start|stop" >&2
    exit 3
    ;;
esac

I inserted the line echo $1 > /home/dan/test.txt myself but nothing is written there!? When I execute it like sudo /etc/init.d/rc.local start everything works fine just not when booting the system!?

wasp256
  • 787
  • 1
  • 9
  • 27
  • `/home/../test.sh` is the same as `/test.sh`. And in the second example you have three dots, is it a typo? Which user are you using to run the command? Is `/etc/rc.local` executable? – Rmano Oct 13 '14 at 19:18
  • the `bash` command has nothing to do with `touch` and the dots are just supposed to show a long path – wasp256 Oct 13 '14 at 19:20
  • 1
    Ok --- so without more detailed (and complete) information it will be very difficult to answer... `ls -l /etc/rc.local` and its content could help. – Rmano Oct 13 '14 at 19:22
  • possible duplicate of [Why doesn't rc.local run all my commands, and what can I do about it?](http://askubuntu.com/questions/239600/why-doesnt-rc-local-run-all-my-commands-and-what-can-i-do-about-it) – αғsнιη Oct 13 '14 at 19:28
  • @Rmano I updated the whole file – wasp256 Oct 13 '14 at 19:29
  • @KasiyA I don't think so since none of my commands are executed!? – wasp256 Oct 13 '14 at 19:29
  • A) check if `/etc/rc.local` has the `x` flag set. B) if `select_wallpaper.sh` is doing something related to the graphic environment, it can't work; the graphic system is not yet up when `rc.local` is run. – Rmano Oct 13 '14 at 19:31
  • bug reported https://bugs.launchpad.net/ubuntu/+source/sysvinit/+bug/882254 – αғsнιη Oct 13 '14 at 19:33
  • A) Yes the x flag is set for all B) no the script does nothing with the graphic environment! THE COMMAND `touch` is not executed as well!! – wasp256 Oct 13 '14 at 20:00
  • In order to test your script use `sudo /etc/init.d/rc.local start` this will run rc.local as root and with restricted environment like during system startup, and you should see if there are errors. – Lety Oct 13 '14 at 22:17
  • I tried the command and it worked fine, the file got generated and the script was executed! – wasp256 Oct 14 '14 at 06:30
  • Did you check if in `/etc/rc2.d` folder exists link to `/etc/init.d/rc.local`? – Lety Oct 14 '14 at 23:31
  • I haved checked it please see my edit of the orginal post – wasp256 Oct 15 '14 at 12:30
  • Is your home folder encrypted? – muru Oct 15 '14 at 13:18
  • Yes it is encrypted! And the `/` and `/home/jack/` folders are on different partitions I guess thats the problem!? Is there a workaround on this? – wasp256 Oct 15 '14 at 13:22

1 Answers1

1

I put the script in the Startup Applications and it works now fine

wasp256
  • 787
  • 1
  • 9
  • 27