From 97a6d959025d2fa648ab3a847d657b33cf44d67e Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 1 Feb 2019 22:26:22 +0000 Subject: [PATCH] start_service.sh: Apparently sudo doesn't quit - and stays as a wrapper process.Solve this by disowning after sudo & avoid showing the password in the sudo process arguments by preserving the environment when sudoing. --- rhinoreminds.service | 2 +- start_service.sh | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/rhinoreminds.service b/rhinoreminds.service index cc5a1f4..8c2ab47 100644 --- a/rhinoreminds.service +++ b/rhinoreminds.service @@ -9,7 +9,7 @@ StartLimitBurst=5 [Service] Type=forking -PIDFile=/run/rhinoreminds.pid +PIDFile=/run/rhinoreminds/rhinoreminds.pid # We change our own user User=root WorkingDirectory=/srv/kraggwapple diff --git a/start_service.sh b/start_service.sh index b8d9c98..c2c64d6 100755 --- a/start_service.sh +++ b/start_service.sh @@ -6,7 +6,10 @@ source .xmpp_credentials; # Execute & disown # We pass the environment variables explicitly here, as then we don't accidentally pass something private. # Better to be safe than sorry - defence in depth! -sudo -u username_here XMPP_JID="${XMPP_JID}" XMPP_PASSWORD="${XMPP_PASSWORD}" /usr/bin/mono RhinoReminds.exe --domain starbeamrainbowlabs.com -echo "$!" >/run/rhinoreminds.pid; -disown; +export XMPP_JID; +export XMPP_PASSWORD; +# Create the pidfile directory +mkdir /run/rhinoreminds; chmod 0700 /run/rhinoreminds; chown rhinoreminds:rhinoreminds /run/rhinoreminds; + +sudo -E -u rhinoreminds bash -c '/usr/bin/mono ../bin/RhinoReminds.exe --domain starbeamrainbowlabs.com --avatar avatar.png & echo "$!" >/run/rhinoreminds/rhinoreminds.pid; disown'