Проблема с созданием исполняемого файла как службы

Основываясь на ответе Джайлза, я придумал такую реализацию его предложения:

Во-первых, создайте этот файл скрипта:

#!/bin/bash
echo "Defaults !tty_tickets" >> $1
exit 0

Во-вторых, включите его в основной скрипт, рядом с началом:

sudo grep -i "Defaults !tty_tickets" /etc/sudoers 
if [ $? -ne 0 ] ; then
    sudo chmod a+x $SRCDIR/install_scripts/no_tty_tickets.sh
    sudo -E EDITOR=$SRCDIR/install_scripts/no_tty_tickets.sh su -c visudo
fi

Он правильно редактирует /etc/sudoers. Вот результат:

#
# This file MUST be edited with the 'visudo' command as root.
#
...

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

Defaults !tty_tickets

Это работает и дает мне полное решение.

3
10.03.2019, 14:34
1 ответ

I also setup the initial settings.json file in the same folder. It worked out fine, so to get it as a service...

В сервисе systemd установите WorkingDirectory.

9
27.01.2020, 21:10

Теги

Похожие вопросы