Advertisement
TylerB

test

Jun 7th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.44 KB | None | 0 0
  1. #--------MINECRAFT/CRAFTBUKKIT start-stop-status script
  2. #--------package maintained at blog.heatdfw.com
  3.  
  4. DAEMON_USER="`echo ${SYNOPKG_PKGNAME} | awk {'print tolower($_)'}`"
  5. DAEMON_ID="${SYNOPKG_PKGNAME} daemon user"
  6. ENGINE_SCRIPT="/var/packages/${SYNOPKG_PKGNAME}/scripts/launcher.sh"
  7. DAEMON_USER_SHORT=`echo ${DAEMON_USER} | cut -c 1-8`
  8.  
  9. daemon_status ()
  10. {
  11.     ps -efa | grep "minecraft" > /dev/null
  12. }
  13.  
  14. case $1 in
  15.   start)
  16.     DAEMON_HOME="`cat /etc/passwd | grep "${DAEMON_ID}" | cut -f6 -d':'`"
  17.    
  18.     #set the current timezone for Java so that log timestamps are accurate
  19.     #we need to use the modern timezone names so that Java can figure out DST
  20.     SYNO_TZ=`cat /etc/synoinfo.conf | grep timezone | cut -f2 -d'"'`
  21.     SYNO_TZ=`grep "^${SYNO_TZ}" /usr/share/zoneinfo/Timezone/tzname | sed -e "s/^.*= //"`
  22.     grep "^export TZ" ${DAEMON_HOME}/.profile > /dev/null \
  23.      && sed -i "s%^export TZ=.*$%export TZ='${SYNO_TZ}'%" ${DAEMON_HOME}/.profile \
  24.      || echo export TZ=\'${SYNO_TZ}\' >> ${DAEMON_HOME}/.profile
  25.    
  26.    su - ${DAEMON_USER} -s /bin/sh -c "${ENGINE_SCRIPT} start ${DAEMON_USER} ${SYNOPKG_PKGDEST} &"
  27.    exit 0
  28.  ;;
  29.  
  30.  stop)
  31.    su - ${DAEMON_USER} -s /bin/sh -c "${ENGINE_SCRIPT} stop ${DAEMON_USER} ${SYNOPKG_PKGDEST}"
  32.    exit 0
  33.  ;;
  34.  
  35.  status)
  36.    if daemon_status ; then
  37.      exit 0
  38.    else
  39.      exit 1
  40.    fi
  41.  ;;
  42.  
  43.  log)
  44.    echo "${SYNOPKG_PKGDEST}/logs/latest.log"
  45.    exit 0
  46.  ;;
  47. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement