Debian /etc/init.d/ script not running?
Asked Answered
P

1

1

I'm using a BeagleBone Black that runs Debian (the latest version that the BeagleBone website provides a link for, I believe) and I recently installed Java on it. Every time I boot the board I must set the PATH for Java again as shown below.

root@beaglebone:/etc/init.d# java -version
-bash: java: command not found
root@beaglebone:/etc/init.d# export PATH=$PATH:/bin/jdk1.7.0_60/bin
root@beaglebone:/etc/init.d# export JAVA_HOME=/bin/jdk1.7.0_60
root@beaglebone:/etc/init.d# java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) Client VM (build 24.60-b09, mixed mode)
root@beaglebone:/etc/init.d# 

I wanted to write a script to set up java during start-up and then run some java program. So I wrote a script "helium_startup.sh" and put it in init.d, the script looks like this:

export PATH=$PATH:/bin/jdk1.7.0_60/bin
export JAVA_HOME=/bin/jdk1.7.0_60

I haven't wrote the program that I would like to run here yet, but I think I could place a line to run it right after these two lines, right? Then I use update-rc.d to create the links:

root@beaglebone:/etc/init.d# update-rc.d helium_startup.sh defaults
update-rc.d: using dependency based boot sequencing
insserv: warning: script 'helium_startup.sh' missing LSB tags and overrides

I believe that the warning doesn't affect anything? I checked /etc/rc5.d to verify that one of the links was made:

root@beaglebone:~# cd /etc/rc5.d
root@beaglebone:/etc/rc5.d# ls
README              S01sudo               S03loadcpufreq   S04wicd
S01boot_scripts.sh  S01xrdp               S03rsync         S05saned
S01bootlogs         S02apache2            S03ssh           S06rc.local
S01capemgr.sh       S03acpid              S03udhcpd        S06rmnologin
S01hostapd          S03cron               S04avahi-daemon
S01motd             S03dbus               S04cpufrequtils
S01rsyslog          S03helium_startup.sh  S04lightdm

And, the links do appear to be made for each of the run levels. Then I reboot the Beaglebone (I've tried doing it by "reboot", unplugging it, and pressing power button) and attempt to check the version of java:

root@beaglebone:/etc/rc5.d# java -version
-bash: java: command not found

And it fails. I'm new to Debian (and Linux in general) and this is my first time using the BeagleBone Black, I'm not sure what the issue is. I also tried putting the 2 lines to set the PATH for java in /etc/rc.local, and that didn't work either.

Any help would be greatly appreciated.

-Brandon

Preponderant answered 25/1, 2015 at 20:31 Comment(0)
R
0

You can't set an environment variable (PATH) permanently in an init script. The appropriate place would be a script in /etc/profile.d

Robby answered 25/1, 2015 at 22:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.