Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have created a linux service that runs as a deamon (and gets started from /etc/init.d/X). I need to set some environment variables that can be accessed by the application.

Here's the scenario. The application is a bunch of Perl AGI scripts that depend on (and therefore need to run as) asterisk user but asterisk doesn't have a shell. Ideally I'd just set this in /home/asterisk/.bashrc but that doesn't exist for asterisk.

How can I set environment variables for my app in the asterisk user's running environment so that my app can use them?

Update: Changed the title to show am using Debian.

share|improve this question
1  
    
Could you tell us what is your OS? –  Casual Coder Oct 6 '10 at 6:51
    
@Casual: Linux. –  Ignacio Vazquez-Abrams Oct 6 '10 at 6:51
    
Ok. I was asking domino. Your answer is related to Fedora. Maybe domino is using different distribution where init scripts are not configured in /etc/sysconfig –  Casual Coder Oct 6 '10 at 6:59
    
@Casual - I am using debian. @Ignacio - thanks for the link it helped me know what to look for, for a debian distro. Found the answer and posted it below. –  domino Oct 6 '10 at 7:52

1 Answer 1

up vote 1 down vote accepted

Found the solution. For debian distro creating the file /etc/default/myservice and then adding the environment variables using the syntax export VAR=value

then sourcing the file from /etc/init.d/myservice using

[ -r /etc/default/myservice ] && . /etc/default/myservice solved the problem

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.