Skip to content

Commit

Permalink
systemd: correct init system detection for systems that don't have /p…
Browse files Browse the repository at this point in the history
…roc/1/comm
  • Loading branch information
jjallaire committed May 5, 2015
1 parent ba06f32 commit 8251698
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package/linux/debian-control/postinst.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ sudo rstudio-server force-suspend-all

# check lsb release and init system
LSB_RELEASE=`lsb_release --id --short`
INIT_SYSTEM=`cat /proc/1/comm`
INIT_SYSTEM=`cat /proc/1/comm 2>/dev/null`

# add apparmor profile (but don't for systemd as this borks up process management)
if test $LSB_RELEASE = "Ubuntu" && test -d /etc/apparmor.d/ && ! test $INIT_SYSTEM = "systemd"
Expand All @@ -51,7 +51,7 @@ then
fi

# add systemd, upstart, or init.d script and start the server
if test $INIT_SYSTEM = "systemd"
if test "$INIT_SYSTEM" = "systemd"
then
sudo systemctl stop rstudio-server.service 2>/dev/null
sudo systemctl disable rstudio-server.service 2>/dev/null
Expand Down
4 changes: 2 additions & 2 deletions package/linux/debian-control/postrm.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ sudo rm -rf /tmp/rstudio-rsession
sudo rm -rf /tmp/rstudio-rserver

# stop and remove service under systemd
INIT_SYSTEM=`cat /proc/1/comm`
if test $INIT_SYSTEM = "systemd"
INIT_SYSTEM=`cat /proc/1/comm 2>/dev/null`
if test "$INIT_SYSTEM" = "systemd"
then
sudo systemctl stop rstudio-server.service 2>/dev/null
sudo systemctl disable rstudio-server.service 2>/dev/null
Expand Down
4 changes: 2 additions & 2 deletions package/linux/rpm-script/postinst.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ then
fi

# add systemd, upstart, or init.d script and start the server
INIT_SYSTEM=`cat /proc/1/comm`
if test $INIT_SYSTEM = "systemd"
INIT_SYSTEM=`cat /proc/1/comm 2>/dev/null`
if test "$INIT_SYSTEM" = "systemd"
then
# remove any previously existing init.d based scheme
service rstudio-server stop 2>/dev/null
Expand Down
4 changes: 2 additions & 2 deletions package/linux/rpm-script/postrm.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ then
rm -rf /tmp/rstudio-rserver

# stop and remove service under systemd
INIT_SYSTEM=`cat /proc/1/comm`
if test $INIT_SYSTEM = "systemd"
INIT_SYSTEM=`cat /proc/1/comm 2>/dev/null`
if test "$INIT_SYSTEM" = "systemd"
then
systemctl stop rstudio-server.service 2>/dev/null
systemctl disable rstudio-server.service 2>/dev/null
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/server/extras/admin/rstudio-server.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/sh

daemonCmd() {
INIT_SYSTEM=`cat /proc/1/comm`
if test $INIT_SYSTEM = "systemd"
INIT_SYSTEM=`cat /proc/1/comm 2>/dev/null`
if test "$INIT_SYSTEM" = "systemd"
then
eval "systemctl $1 rstudio-server.service"
elif test -e /etc/init/rstudio-server.conf
Expand Down

0 comments on commit 8251698

Please sign in to comment.