D
D
Dmitry Aitkulov2016-06-24 08:03:16
linux
Dmitry Aitkulov, 2016-06-24 08:03:16

How it is possible to implement service restart via webhook?

Good afternoon! We set the task of making a webhook in gitlab on a push event, OS centos 7, gitlab EE . The implementation was made according to this article . The webhook itself is working, the changes are being pushed. But here they also set the task of restarting the service after the changes are launched. This is where it starts. I'm trying to restart through the apache user, but an error occurs in the log
sudo: sorry, you must have a tty to run sudo
if sudo is disabled
Defaults requiretty
, then this kind of error

Failed to restart asterisk.service: Interactive authentication required.

configs:
php script without changes from the article.
bash script
#!/bin/sh
#не знаю что за строка
cd .. > /dev/null &
cd /etc/asterisk
/usr/bin/git pull
sudo /etc/rc.d/init.d/asterisk restart

line with sudoers
apache ALL=(ALL)  NOPASSWD: /etc/rc.d/init.d/asterisk restart

if you execute a bash script named apache, then it is executed, but when a request comes from apache, the error described above comes out.
What is the best way to accomplish this task? Thank you all in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aol-nnov, 2016-06-24
@Scarfase1989

add a string like
echo $USER
whoami
or something to the script to be sure which user the script is running as. then bring the settings to court.
// ehh, I rubbed my eyes. there about the lack of tty...
hello diary^W^W here it is! https://www.shell-tips.com/2014/09/08/sudo-sorry-y...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question