¿Cómo iniciar scripts que necesitan root utilizando un servicio systemd?

¿Cómo iniciar scripts que necesitan root utilizando un servicio systemd?

Estoy intentando iniciar un par de cosas al inicio en CentOS, pero encuentro algunos problemas que no sé cómo resolver.

Aquí está mi archivo.service:

[Unit]
Description="Boot Jenkins slave and SonarQube server"
After=network.target

[Service]
Type=simple
ExecStart=/var/boot.sh
User=root
Group=root

[Install]
WantedBy=default.target

Después de systemctl daemon-reloady systemctl enable my.service, systemctl start my.serviceen realidad nada parece suceder/funcionar.

La salida de systemctl status my.servicees:

$ systemctl status my.service 
● startup.service - "Boot Jenkins slave and SonarQube server"
   Loaded: loaded (/etc/systemd/system/my.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Wed 2017-04-26 19:49:31 IDT; 1min 41s ago
  Process: 988 ExecStart=/var/boot.sh (code=exited, status=0/SUCCESS)
 Main PID: 988 (code=exited, status=0/SUCCESS)

Apr 26 19:49:00 build-1 systemd[1]: Started "Boot Jenkins slave and SonarQube server".
Apr 26 19:49:00 build-1 systemd[1]: Starting "Boot Jenkins slave and SonarQube server"...
Apr 26 19:49:00 build-1 boot.sh[988]: Starting SonarQube...
Apr 26 19:49:01 build-1 boot.sh[988]: Started SonarQube.

Supuestamente, las cosas deberían haber funcionado, pero no es así...
Sin embargo, si ejecuto manualmente boot.sh, funcionan.

su ...
./boot.sh

boot.sh es:

#!/bin/bash

nohup java -jar /var/jenkins/slave.jar -jnlpUrl https://***.jnlp -secret **** &
/var/sonarqube-6.3/bin/linux-x86-64/sonar.sh start

Tenga en cuenta que SonarQube requiere root.
¿Qué estoy haciendo mal?

Actualizar:registros de cat /var/log/messages | grep SonarQube:

Apr 26 20:58:53 build-1 systemd: Started "Boot Jenkis slave and SonarQube server".
Apr 26 20:58:53 build-1 systemd: Starting "Boot Jenkis slave and SonarQube server"...
Apr 26 20:58:53 build-1 boot.sh: Starting SonarQube...
Apr 26 20:58:53 build-1 boot.sh: Started SonarQube.

Respuesta1

Para SonarQube terminé siguiendo esto:https://devopscube.com/setup-and-configure-sonarqube-on-linux/, que indica cómo agregar SonarQube como servicio... que, curiosamente, era bastante más simple que el enfoque systemd.

Para el primer comando del archivo, todavía es un tema abierto...

información relacionada