Debian / etc / init.d / script not working?

I use BeagleBone Black, which runs Debian (the latest version, which I think the link is provided on the BeagleBone website), and I recently installed Java on it. Every time I download the board, I have to install 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 configure java at startup, and then run some java program. So I wrote the script "helium_startup.sh" and placed 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 have not written a program that I would like to run here, but I think I can place a line to start it right after these two lines, right? Then I use update-rc.d to create 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 the warning does not affect anything? I checked / etc / rc 5.d to make sure 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 there seemed to be links for each of the runlevels. Then I reboot Beaglebone (I tried to do this by โ€œrebootingโ€, disconnecting and pressing the power button) and try to check the java version:

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

And he fails. I'm new to Debian (and Linux in general), and this is my first time using BeagleBone Black, I'm not sure what the problem is. I also tried putting 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

+1
source share
1 answer

You cannot set the environment variable (PATH) permanently in an init script. The appropriate place would be the script in /etc/profile.d

0
source

Source: https://habr.com/ru/post/983316/


All Articles