- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我想以 storm_deployer
用户身份执行我的脚本 /sbin/service storm start
。为此,我创建了一个用户 storm_deployer
并将其添加到 /etc/sudoers
hornet_deployer ALL=(ALL) NOPASSWD:/sbin/service
并在 /etc/init.d
中创建此脚本 storm
#!/bin/bash
#===================================================================================
#FILE: storm
#USAGE: storm [start] [stop] [status]
#DESCRIPTION: storm start, stop, restart service
#
#OPTIONS:
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
#
#AUTHOR: Valter Henrique, valter.silva@company.com
#COMPANY: company
#VERSION: 1.0
#CREATED: 03.27.13
#REVISION: 03.27.13
#===================================================================================
#
# chkconfig: 345 90 12
# description: storm start, stop, restart service
# processname: storm
#
# Get function from functions library
. /etc/init.d/functions
folder=/company/storm/bin #folder to the application
service="storm" #name of the service
startup=$folder/run.sh
shutdown=$folder/stop.sh
deployer=storm_deployer
process="63987524-22fc-4674-8896-11230716bc62"
#=== FUNCTION ================================================================
#
#NAME: start
# DESCRIPTION: Start the service storm
# PARAMETER 1: ---
#===============================================================================
start() {
#----------------------------------------------------------------------
# getting the process PID
#----------------------------------------------------------------------
pid_process=`ps -ef | grep $process | grep -v grep |awk -F' ' '{ print $2 }'`;
if [ $pid_process ]; then
echo "#######################"
echo "$service is running!"
echo "Stop then first!"
echo "#######################"
else
action $"Starting $service: " su - $deployer -c $startup
RETVAL=$?
fi
}
#=== FUNCTION ================================================================
#
#NAME: stop
# DESCRIPTION: Stop the service storm
# PARAMETER 1: ---
#===============================================================================
stop() {
#----------------------------------------------------------------------
# getting the process PID
#----------------------------------------------------------------------
pid_process=`ps -ef | grep $process | grep -v grep |awk -F' ' '{ print $2 }'`;
if [ $pid_process ]; then
action $"Stopping $service: " su - $deployer -c $shutdown
RETVAL=$?
else
echo "#######################"
echo "$service is not running"
echo "#######################"
fi
}
#=== FUNCTION ================================================================
#
# NAME: status
# DESCRIPTION: Status of the service
# PARAMETER 1: ---
#===============================================================================
status() {
#----------------------------------------------------------------------
# getting the process PID
#----------------------------------------------------------------------
pid_process=`ps -ef | grep $process | grep -v grep |awk -F' ' '{ print $2 }'`;
if [ $pid_process ]; then
echo "#######################"
echo "$service is RUNNING"
echo "#######################"
else
echo "#######################"
echo "$service is NOT RUNNING"
echo "#######################"
fi
}
#----------------------------------------------------------------------
# Main Logic
#----------------------------------------------------------------------
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart|reload|condrestart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
所以我使用 sudo su storm_deployer
以用户 storm_deployer
身份登录并运行 /sbin/service hornet start
但每次都不断询问密码运行此服务。
更新
我的/et/sudoers
## Sudoers allows particular users to run various commands as
## the root user, without needing the root password.
##
## Examples are provided at the bottom of the file for collections
## of related commands, which can then be delegated out to particular
## users or groups.
##
## This file must be edited with the 'visudo' command.
## Host Aliases
## Groups of machines. You may prefer to use hostnames (perhap using
## wildcards for entire domains) or IP addresses instead.
# Host_Alias FILESERVERS = fs1, fs2
# Host_Alias MAILSERVERS = smtp, smtp2
## User Aliases
## These aren't often necessary, as you can use regular groups
## (ie, from files, LDAP, NIS, etc) in this file - just use %groupname
## rather than USERALIAS
# User_Alias ADMINS = jsmith, mikem
## Command Aliases
## These are groups of related commands...
## Networking
#Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables, /usr/bin/rfcomm, /usr/bin/wvdial, /sbin/iwconfig, /sbin/mii-tool
## Installation and management of software
#Cmnd_Alias SOFTWARE = /bin/rpm, /usr/bin/up2date, /usr/bin/yum
## Services
#Cmnd_Alias SERVICES = /sbin/service, /sbin/chkconfig
## Updating the locate database
#Cmnd_Alias LOCATE = /usr/bin/updatedb
## Storage
#Cmnd_Alias STORAGE = /sbin/fdisk, /sbin/sfdisk, /sbin/parted, /sbin/partprobe, /bin/mount, /bin/umount
## Delegating permissions
#Cmnd_Alias DELEGATING = /usr/sbin/visudo, /bin/chown, /bin/chmod, /bin/chgrp
## Processes
#Cmnd_Alias PROCESSES = /bin/nice, /bin/kill, /usr/bin/kill, /usr/bin/killall
## Drivers
#Cmnd_Alias DRIVERS = /sbin/modprobe
# Defaults specification
#
# Disable "ssh hostname sudo <cmd>", because it will show the password in clear.
# You have to run "ssh -t hostname sudo <cmd>".
#
#Defaults requiretty
#
# Refuse to run if unable to disable echo on the tty. This setting should also be
# changed in order to be able to use sudo without a tty. See requiretty above.
#
Defaults !visiblepw
Defaults env_reset
Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR \
LS_COLORS MAIL PS1 PS2 QTDIR USERNAME \
LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION \
LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC \
LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS \
_XKB_CHARSET XAUTHORITY"
## Next comes the main part: which users can run what software on
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
## user MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
User_Alias SUPERADMIN = %superadmin
SUPERADMIN ALL=(ALL) NOPASSWD: ALL
hornet_deployer ALL=(ALL) NOPASSWD:/sbin/service
## Allows members of the 'sys' group to run networking, software,
## service management apps and more.
# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS
## Allows people in group wheel to run all commands
# %wheel ALL=(ALL) ALL
## Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL
## Allows members of the users group to mount and unmount the
## cdrom as root
# %users ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom
## Allows members of the users group to shutdown this system
# %users localhost=/sbin/shutdown -h now
nagios ALL=(ALL) NOPASSWD:/bin/touch, /bin/rm
User_Alias SUPERSUDOERS = %supersudoers
SUPERSUDOERS ALL=NOPASSWD:/usr/sbin/tcpdump,/sbin/service,/usr/bin/kill,/usr/bin/killall,/usr/bin/iptraf
~
最佳答案
sudoers 文件中的这一行:
hornet_deployer ALL=(ALL) NOPASSWD:/sbin/service
它是在所有其他组/用户之后还是像这样(介于两者之间)?
root ALL=(ALL:ALL) ALL
hornet_deployer ALL=(ALL) NOPASSWD:/sbin/service
%admin ALL=(ALL) ALL
%sudo ALL=(ALL:ALL) ALL
关于linux - 如何以特定用户身份启动/停止/重启服务并记录此操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15683293/
我有一个 UWP 应用程序(在 Windows/Microsoft Store 中发布),我正在进行新的更新,我在我的应用程序中使用了 Template10,它具有深色和浅色主题,并且在 Window
我是 spring batch 的新手,有一些关于暂停/恢复的问题。看了spring batch的文档,好像没有内置的pause或者resume功能。但是,我从主站点找到了这个用例: http://d
我正在编写一个网络服务并有以下观察结果:即使我只是将一个文本文件添加到存储 web 服务引用的所有 dll 的目录 (bin),appdomain 也会刷新。 这会导致存储在字典(在其中一个 dll
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 6 年前。 Improve this qu
Hadoop 1.0.3 工作 36 小时后说: INFO mapred.JobClient: map 42% reduce 0% mapred.JobClient: Job Failed
我使用 AVAssetWriter 将视频录制到文件中。所以我为此创建了类。 link to gist 然后在项目的某处我推送记录并开始录制视频。 func start() { assetWriter
我想要一个在后台运行的 python 脚本(无限循环)。 def main(): # inizialize and start threads [...] try:
我在重新启动 Activity 时感到困惑。我有两个功能可以很好地完成同一任务。请指导我哪个最好,为什么? public void restart() { Intent
重启sidekiq的正确方法是什么。它似乎在我启动它时缓存了我的 worker 代码,所以每次我对我的 worker 进行更改时我都需要重新启动它。我正在使用 Ctrl/C 执行此操作,但该过程需要很
我在我的 Android 模拟器上安装了新字体。说明说我必须重新启动设备。我尝试使用“关机”按钮,但它只显示“正在关机”并且什么也不做。即使我去 adb shell 并运行“重启”它也会挂起。 任何想
启动操作 ? 1
关闭 service nginx stop systemctl stop nginx 启动 service nginx start systemctl start n
正在学习Linux中。。。一边学一边记录着。。所有观点只是个人观点 Linux有个文件 /etc/inittab 复制代码 代码如下:
如果我运行 systemctl restart kubelet它会影响其他正在运行的节点吗?它会停止集群吗?你能预见任何影响吗? 任何帮助,将不胜感激! 最佳答案 在回答之前,小声明:重启不是由于对
嗯,问题是我有一个在 MATE 上完美运行的 Abyssus Razer,但是 在 Debian、Elementary、OpenSUSE 和其他平台上,默认 设置 super 慢。 我用 解决了这个问
我在 Ubuntu 16.04 上安装了 NGINX 并编辑了我的配置。 当我想用 sudo service nginx restart 重新启动时我得到错误: Job for nginx.servi
我已经在我的 Ubuntu 上安装了 Gearman Job Server(又名 Gearmand)1.0.6: Distributor ID: Ubuntu Description: Ubun
我有一个 WiX Burn使用 ManagedBootstrapperApplicationHost 的自定义安装程序。安装必备 Microsoft Windows Installer 之一后4.5
我已经使用 brew install mosquitto 在我的 mac 上安装了蚊子代理. 通常我不会给出任何命令来启动 mosquitto 服务器。当我打开我的 mac 时它会自动启动。 我已经使
我有一个带有 2 个容器的 pod test-1495806908-xn5jn。我想重新启动其中一个名为 container-test 的项目。是否可以重新启动 Pod 中的单个容器以及如何重新启动?
我是一名优秀的程序员,十分优秀!