4

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.

5
  • 1
    possible duplicate of How do you set an environment variable for all users on Fedora? Commented Oct 6, 2010 at 6:36
  • Could you tell us what is your OS? Commented Oct 6, 2010 at 6:51
  • @Casual: Linux. Commented Oct 6, 2010 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 Commented Oct 6, 2010 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. Commented Oct 6, 2010 at 7:52

1 Answer 1

2

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

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.