即使没有真正的用户,如何在我的 Linux 服务中为 Asterisk 设置环境变量? [英] How can I set environment variables in my Linux service for Asterisk even though it doesn't have a real user?
问题描述
我创建了一个作为守护进程运行的 linux 服务(并从/etc/init.d/X 启动).我需要设置一些应用程序可以访问的环境变量.
这是场景.该应用程序是一堆 Perl AGI 脚本,它们依赖于(因此需要作为)asterisk 用户运行,但 asterisk 没有 shell.理想情况下,我只是将其设置在 /home/asterisk/.bashrc 中,但 asterisk 不存在.
如何在 asterisk 用户的运行环境中为我的应用设置环境变量,以便我的应用可以使用它们?
在启动脚本 (/etc/init.d/yourdaemon
) 中设置它们,或者在该文件中添加一行看起来像:
并将环境变量放入该文件中,使用语法export VAR=value
.在类似 Red Hat 的系统上,我相信这样一个文件的正确位置是 /etc/sysconfig
.Debian/Ubuntu 似乎有 /etc/default
用于此目的.
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?
Either set them in the startup script (/etc/init.d/yourdaemon
), or put a line in that file that looks like:
. /etc/yourdaemon.env
and put the environment variables in that file, using the syntax export VAR=value
. On Red Hat-like systems, I believe the correct place for such a file is /etc/sysconfig
. Debian/Ubuntu seems to have /etc/default
for this purpose.
这篇关于即使没有真正的用户,如何在我的 Linux 服务中为 Asterisk 设置环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!