Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > Your Distro > Redhat / Fedora Linux Help > how to get user environment into /sbin/service

Forgot Password?
 Redhat / Fedora Linux Help   Help and discussion related to Redhat and Fedora Linux.

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds


Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 07-03-2009   #1 (permalink)
Just Joined!
 
Join Date: Jul 2009
Posts: 5
Angry how to get user environment into /sbin/service

please can anyone help.

i need to get root user environment when run e.g. "/sbin/service myapp start"

i have tried to include these lines in /etc/init.d/myapp:

. /etc/profile
. /root/.bash_profile

but i still cannot get the environment as logged on as root, verified by set.

i am using rhel 4.8

thanks
zcw
zcwlinux is offline  


Reply With Quote
Old 07-03-2009   #2 (permalink)
Linux Newbie
 
Join Date: Mar 2009
Posts: 133
The problem is you can't access /root/.bash_profile because the permissions on the /root directory doesn't allow non-root users to access it.

You could change the permisions on the /root directory so non-root users has access it but strongly not adviced.

The thing to do would be take the parts of .bash_profile that non-root users need and place it in another script somewhere that anyone can access it and execute that.
lomcevak is online now   Reply With Quote
Old 07-03-2009   #3 (permalink)
Just Joined!
 
Join Date: Jul 2009
Posts: 5
but "/sbin/service myapp start" is run by root, so it should have access to /root/*
zcwlinux is offline   Reply With Quote
Old 07-03-2009   #4 (permalink)
Linux Guru
 
Rubberman's Avatar
 
Join Date: Apr 2009
Location: I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
Posts: 2,540
You can write a script that sources /root/.bash_profile and then executes /sbin/service. You still need to be root to do this.
__________________
Sometimes, real fast is almost as good as real time.
Rubberman is offline   Reply With Quote
Old 07-03-2009   #5 (permalink)
Just Joined!
 
Join Date: Jul 2009
Posts: 5
but i think that /sbin/service runs on empty environment? if i set up environment first, then run /sbin/service, it may reset to empty, but worth trying. thanks. ideally we want to keep using /sbin/service.

Quote:
Originally Posted by Rubberman View Post
You can write a script that sources /root/.bash_profile and then executes /sbin/service. You still need to be root to do this.
zcwlinux is offline   Reply With Quote
Old 07-03-2009   #6 (permalink)
Linux Guru
 
Rubberman's Avatar
 
Join Date: Apr 2009
Location: I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
Posts: 2,540
Quote:
Originally Posted by zcwlinux View Post
but i think that /sbin/service runs on empty environment? if i set up environment first, then run /sbin/service, it may reset to empty, but worth trying. thanks. ideally we want to keep using /sbin/service.
Well, it is a script itself that executes another script for the named service in turn. You might want to look at it in detail to see why you are losing your environment.
__________________
Sometimes, real fast is almost as good as real time.
Rubberman is offline   Reply With Quote
Old 07-03-2009   #7 (permalink)
Just Joined!
 
Join Date: Jul 2009
Posts: 5
en, i think that i may need to expand my problem description a little bit. it is grails/spring we used in our website, which is served by tomcat has this problem. Without this bit of grails/spring, tomcat works fine and can be started/stopped using /sbin/service. once this grails/spring is included, we can only start tomcat using any of the following:

/etc/init.d/tomcat start
/etc/rc5.d/S80tomcat start
$CATALINA_HOME/bin/startup.sh

but "/sbin/service tomcat start" does not work and most importantly, tomcat will not start on reboot. even if i put $CATALINA_HOME/bin/startup.sh in /etc/rc.local, tomcat still cannot start on reboot.

Obviously, i have posted in tomcat and grails user groups, but no clue.
zcwlinux is offline   Reply With Quote
Old 07-03-2009   #8 (permalink)
Linux Guru
 
Rubberman's Avatar
 
Join Date: Apr 2009
Location: I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
Posts: 2,540
Thanks for the expansion of the situation. It's the "little" details like this that can save everyone a lot of time and effort giving you the wrong advice...
__________________
Sometimes, real fast is almost as good as real time.
Rubberman is offline   Reply With Quote
Old 07-03-2009   #9 (permalink)
Just Joined!
 
Join Date: Jul 2009
Posts: 5
hi

your inputa are very useful. i think that the problem is the environment. if i gave all the details it not likely i will have any suggestions.

thank very much i will try ut your suggestions wehn i can play with the server.
zcwlinux is offline   Reply With Quote
Old 07-03-2009   #10 (permalink)
Linux Guru
 
Rubberman's Avatar
 
Join Date: Apr 2009
Location: I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
Posts: 2,540
Quote:
Originally Posted by zcwlinux View Post
your inputa are very useful. i think that the problem is the environment. if i gave all the details it not likely i will have any suggestions.
Or, you might just find that there is someone on the forums that has had a similar experience and knows what to do to fix it... I just hate spending my valuable time going down dead-ends because the originator of the thread left out important information like you did.
__________________
Sometimes, real fast is almost as good as real time.
Rubberman is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 11:36 AM.






© 2000 - 2009 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.0 RC2