Advertisement
mrMuppet

/etc/rc.d/lms (warden)

Feb 1st, 2018
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.86 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # This script is a modified version of:
  4. # $FreeBSD: branches/RELENG_9_2_0/audio/squeezeboxserver/files/squeezeboxserver.in 302141 2012-08-05 23:19:36Z dougb $
  5.  
  6.  
  7.  
  8.  
  9. # PROVIDE: lms
  10. # REQUIRE: LOGIN
  11. # KEYWORD: shutdown
  12.  
  13. # Add the following lines to /etc/rc.conf to enable lms on startup:
  14. # lms_enable="YES"
  15.  
  16. # Optional configuration parameters:
  17. # Directory where lms writes it's logs to.
  18. # lms_logdir="/var/log/lms"
  19. #
  20. # Directory where lms stores it's cache files.
  21. # lms_cachedir="/var/db/lms/cache"
  22. #
  23. # Directory where lms stores it's configuration.
  24. # lms_prefsdir="/var/db/lms/prefs"
  25. #
  26. # Directory where lms stores the playlists. THIS NEEDS TO BE CONFIGURED THROUGH THE UI.
  27. # lms_playlistdir="/var/db/lms/playlists"
  28. #
  29. # Additional parameters, e.g. "--noimage --novideo"
  30. # lms_flags=""
  31.  
  32. #
  33. # The charset lms uses.
  34. # lms_charset="UTF-8"
  35.  
  36. #
  37. # The LC_CTYPE envvar which is necessary to get rid of the warning
  38. # """
  39. # Your locale was detected as C, you may have problems with non-Latin filenames.
  40. # Consider changing your LANG variable to the correct locale, i.e. en_US.utf8.
  41. # """
  42. # See https://forums.freenas.org/index.php?threads/logitech-media-server-for-freenas-9-2-1-1.19044/page-3#post-132872
  43. # lms_lc_ctype="en_US.UTF.8"
  44.  
  45. . /etc/rc.subr
  46.  
  47. name=lms
  48.  
  49.  
  50. rcvar=lms_enable
  51.  
  52.  
  53.  
  54. pidfile=/var/run/${name}/${name}.pid
  55. lms_user=lms
  56. lms_group=lms
  57.  
  58. load_rc_config ${name}
  59.  
  60. : ${lms_enable="NO"}
  61. : ${lms_logdir="/var/log/${name}"}
  62. : ${lms_cachedir="/var/db/${name}/cache"}
  63.  
  64.  
  65. : ${lms_prefsdir="/var/db/${name}/prefs"}
  66. : ${lms_playlistdir="/var/db/${name}/playlists"}
  67. : ${lms_flags=""}
  68. : ${lms_charset="UTF-8"}
  69. : ${lms_lc_ctype="en_US.UTF-8"}
  70.  
  71. command_interpreter=/usr/bin/perl
  72. command=/usr/local/lms/slimserver.pl
  73.  
  74.  
  75. command_args="\
  76. --daemon \
  77. --pidfile=${pidfile} \
  78. --logdir=${lms_logdir} \
  79. --cachedir=${lms_cachedir} \
  80. --prefsdir=${lms_prefsdir} \
  81. --charset=${lms_charset} \
  82. ${lms_flags}"
  83.  
  84. start_precmd="lms_start_precmd"
  85. stop_postcmd="lms_stop_postcmd"
  86.  
  87.  
  88.  
  89. lms_start_precmd()
  90. {
  91.     export LC_CTYPE="${lms_lc_ctype}"
  92.  
  93.     if [ ! -d "${pidfile%/*}" ]; then  
  94.         install -d -o ${lms_user} -g ${lms_group} ${pidfile%/*};
  95.     fi
  96.  
  97.     if [ ! -d "${lms_logdir}" ]; then
  98.         install -d -o ${lms_user} -g ${lms_group} "${lms_logdir}";
  99.     fi
  100.  
  101.  
  102.  
  103.  
  104.  
  105.     if [ ! -d "${lms_cachedir}" ]; then
  106.         install -d -o ${lms_user} -g ${lms_group} "${lms_cachedir}";
  107.     fi
  108.  
  109.  
  110.  
  111.     if [ ! -d "${lms_prefsdir}" ]; then
  112.         install -d -o ${lms_user} -g ${lms_group} "${lms_prefsdir}";
  113.     fi
  114.  
  115.  
  116.  
  117.     if [ ! -d "${lms_playlistdir}" ]; then
  118.         install -d -o ${lms_user} -g ${lms_group} "${lms_playlistdir}";
  119.     fi
  120.  
  121.  
  122.  
  123.  
  124.  
  125. }
  126.  
  127. lms_stop_postcmd()
  128. {
  129.     pids=`pgrep -u ${lms_user}`
  130.     if [ -n "${pids}" ]; then
  131.         sleep 1
  132.         kill $pids > /dev/null 2>&1
  133.     fi
  134.     pids=`pgrep -u ${lms_user}`
  135.     if [ -n "${pids}" ]; then
  136.         wait_for_pids $pids
  137.     fi
  138. }
  139.  
  140. run_rc_command "$1"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement