daily pastebin goal
10%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          mattermost
  4. # Required-Start:    $network $syslog
  5. # Required-Stop:     $network $syslog
  6. # Default-Start:     2 3 4 5
  7. # Default-Stop:      0 1 6
  8. # Short-Description: Mattermost Group Chat
  9. # Description:       Mattermost: An open-source Slack
  10. ### END INIT INFO
  11.  
  12. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  13. DESC="Mattermost"
  14. NAME=platform
  15. MATTERMOST_ROOT=/home/admin/mattermost
  16. MATTERMOST_USER=admin
  17. DAEMON="$MATTERMOST_ROOT/bin/platform"
  18. PIDFILE="/var/run/$NAME.pid"
  19. SCRIPTNAME=/etc/init.d/$NAME
  20. CONFIGFILE="$MATTERMOST_ROOT/config/config.json"
  21.  
  22. cd $MATTERMOST_ROOT/bin
  23. . /etc/rc.d/init.d/functions
  24.  
  25. # Don't kill named during clean-up
  26. MATTERMOST_SHUTDOWN_TIMEOUT=${MATTERMOST_SHUTDOWN_TIMEOUT:-25}
  27.  
  28. check_pidfile()
  29. {
  30.         PID="`pidof "$NAME"`"
  31.         if [ -n "$PID" ] && [ "`ps -p "$PID" --no-headers -o comm`" != "$NAME" ]; then
  32.                 rm -f $PIDFILE &> /dev/null
  33.         fi
  34. }
  35.  
  36. start()
  37. {
  38.         echo -n $"Starting $NAME: "
  39.         check_pidfile
  40.         if [ -n "`pidof $NAME`" ];
  41.         then
  42.                 echo -n $"$NAME: already running"
  43.                 success
  44.                 echo
  45.                 exit 0;
  46.         fi
  47.  
  48.         daemon --pidfile "$PIDFILE" --user "$MATTERMOST_USER" --check $NAME "$DAEMON --config $CONFIGFILE >/dev/null 2>&1 &";
  49.         RETVAL=$?
  50.         if [ $RETVAL -eq 0 ];
  51.         then
  52.                 echo `pidof $NAME` > $PIDFILE
  53.                 touch /var/lock/subsys/$NAME && success || failure
  54.                 echo
  55.         else
  56.                 rm -f $PIDFILE
  57.                 rm -f /var/lock/subsys/$NAME
  58.                 exit 7;
  59.         fi
  60. }
  61.  
  62. stop()
  63. {
  64.  
  65.         echo -n $"Stopping $NAME: "
  66.         [ -n "`pidof "$NAME"`" ] && kill "`pidof "$NAME"`" >/dev/null 2>&1
  67.  
  68.         timeout=0
  69.         RETVAL=0
  70.         while `pidof "$NAME"` &>/dev/null;
  71.         do
  72.                 if [ $timeout -ge $MATTERMOST_SHUTDOWN_TIMEOUT ];
  73.                 then
  74.                         RETVAL=1
  75.                         break
  76.                 else
  77.                         sleep 2 && echo -n "."
  78.                         timeout=$((timeout+2))
  79.                 fi
  80.         done
  81.  
  82.         # remove pid files
  83.         if [ $RETVAL -eq 0 ];
  84.         then
  85.                 rm -f /var/lock/subsys/$NAME
  86.                 rm -f /var/run/$NAME.pid
  87.         fi
  88.  
  89.         if [ $RETVAL -eq 0 ];
  90.         then
  91.                 success
  92.         else
  93.                 failure
  94.                 RETVAL=1
  95.         fi
  96.         echo
  97. }
  98.  
  99. restart ()
  100. {
  101.         stop
  102.         start
  103. }
  104.  
  105. status ()
  106. {
  107.         check_pidfile
  108.         if [ -n "`pidof "$NAME"`" ];
  109.         then
  110.                 echo -n "$NAME is running..."
  111.                 success
  112.                 echo
  113.         else
  114.                 echo -n "$NAME is not running..."
  115.                 failure
  116.                 echo
  117.         fi
  118.         exit 0;
  119. }
  120.  
  121. RETVAL=0
  122.  
  123. case "$1" in
  124.   start)
  125.     start
  126.     ;;
  127.   stop)
  128.     stop
  129.     ;;
  130.   restart|force-reload)
  131.     restart
  132.     ;;
  133.   status)
  134.     status
  135.     ;;
  136.   *)
  137.     echo "Usage: $0 {start|stop|status|restart|force-reload}"
  138.     RETVAL=1
  139. esac
  140.  
  141. exit $RETVAL
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top