小编CT.*_*CT.的帖子

如何让这个守护进程/init 以非 root 用户身份运行?

我有一个 init 脚本来启动一个守护进程。问题是它以 root 身份运行。我希望它以名为“deploy”的用户身份运行。Ubuntu 12.04

#! /bin/sh

# File: /etc/init.d/unicorn

### BEGIN INIT INFO
# Provides:          unicorn
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the unicorn web server
# Description:       starts unicorn
### END INIT INFO

DAEMON=/usr/local/bin/unicorn_rails
DAEMON_OPTS="-c /var/www/current/config/unicorn.rb -D"
NAME=unicorn
DESC="Unicorn"
PID=/var/www/current/shared/pid/unicorn.pid

case "$1" in
  start)
    echo -n "Starting $DESC: "
    $DAEMON $DAEMON_OPTS
    echo "$NAME."
    ;;
  *)
    echo "Usage: …
Run Code Online (Sandbox Code Playgroud)

ubuntu init-script not-root-user

23
推荐指数
1
解决办法
5万
查看次数

我可以在 shell 脚本中刷新我的 shell 吗?

我正在尝试设置一个脚本,该脚本以最小的 CentOS 6 安装开始并为 Ruby 开发提供它。

#!/bin/bash

# Add PostgreSQL Repo
rpm -i http://yum.postgresql.org/9.1/redhat/rhel-6-x86_64/pgdg-redhat91-9.1-5.noarch.rpm

# Add NginX Repo
echo '[nginx]' > /etc/yum.repos.d/nginx.repo
echo 'name=nginx repo' >> /etc/yum.repos.d/nginx.repo
echo 'baseurl=http://nginx.org/packages/centos/6/$basearch/' >> /etc/yum.repos.d/nginx.repo
echo 'gpgcheck=0' >> /etc/yum.repos.d/nginx.repo
echo 'enabled=1' >> /etc/yum.repos.d/nginx.repo

# Update
yum update -y

# Install NginX, PostgreSQL, and Ruby Dependencies
yum install -y nginx postgresql91-server postgresql91-contrib gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison piconv-devel sqlite-devel git-core

# PostgreSQL Post Install
service …
Run Code Online (Sandbox Code Playgroud)

shell bash centos ruby

5
推荐指数
1
解决办法
4744
查看次数

标签 统计

bash ×1

centos ×1

init-script ×1

not-root-user ×1

ruby ×1

shell ×1

ubuntu ×1