服务器 Gind.cn

服务器问题集锦,包括 Linux(Ubuntu, Centos,Debian等)和Windows Server服务器

以非root用户身份运行init.d启动脚本(PostgreSQL相关)

我目前在RHEL6系统上从源代码安装PostgreSQL。 我通常一直在遵循官方文件的指导( http://www.postgresql.org/docs/9.4/static/installation.html )。 不幸的是,通过init.d /启动脚本没有太多的信息。 这是我目前正在挣扎的: OOB启动脚本( https://github.com/postgres/postgres/blob/master/contrib/start-scripts/linux )会被复制到/etc/init.d/postgres并稍作修改以反映我的环境(例如前缀,数据path等); 文件由root拥有,拥有755个权限 以root身份执行以下命令以确保在启动时执行:chkconfig –add postgresql; chkconfig postgresql on; 作为根,脚本运行没有问题(例如/etc/init.d/postgresql状态) 但是,脚本在作为postgres用户(configuration为运行PostgreSQL的用户)执行时会返回密码提示, 这种体验与PostgreSQL函数的打包版本(即RPM)有很大的不同。 我能够以root身份和postgres身份执行脚本: [root@ulvjived80 ~]# /etc/init.d/postgresql-9.4 status postgresql-9.4 is stopped [postgres@ulvjived80 ~]$ /etc/init.d/postgresql-9.4 status postgresql-9.4 is stopped 我在网上做了不less的search,我发现的最引用的解决scheme涉及到在/ etc / sudoers文件中允许相关用户的命令/脚本。 但是,RPM似乎没有这样做。 我们使用的商业应用程序的行为也是相同的,即启动脚本可以由root用户和相关的非root用户执行。 有什么想法可以模仿RPMsfunction吗? 谢谢!