Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. #!/bin/sh
  2. set -e
  3.  
  4. case "$1" in
  5. configure)
  6.  
  7. [ -f "/etc/default/timidity" ] && . /etc/default/timidity
  8.  
  9. # Sane defaults, needed for when the user has messed with /etc/default/timidity:
  10.  
  11. [ -z "$SERVER_HOME" ] && SERVER_HOME=/etc/timidity
  12. [ -z "$SERVER_USER" ] && SERVER_USER=timidity
  13. [ -z "$SERVER_NAME" ] && SERVER_NAME="TiMidity++ MIDI sequencer service"
  14. [ -z "$SERVER_GROUP" ] && SERVER_GROUP=timidity
  15.  
  16. # Groups that the user will be added to, if undefined, then none.
  17. [ -z "$ADDGROUP" ] && ADDGROUP=audio
  18.  
  19. # create user to avoid running server as root
  20. # 1. create group if not existing
  21. if ! getent group | grep -q "^$SERVER_GROUP:" ; then
  22. echo -n "Adding group $SERVER_GROUP.."
  23. addgroup --quiet --system $SERVER_GROUP 2>/dev/null ||true
  24. echo "..done"
  25. fi
  26. # 2. create user if not existing
  27. if ! getent passwd | grep -q "^$SERVER_USER:"; then
  28. echo -n "Adding system user $SERVER_USER.."
  29. adduser --quiet \
  30. --system \
  31. --ingroup $SERVER_GROUP \
  32. --no-create-home \
  33. --disabled-password \
  34. $SERVER_USER 2>/dev/null || true
  35. echo "..done"
  36. fi
  37. # 3. adjust passwd entry
  38. usermod -c "$SERVER_NAME" \
  39. -d $SERVER_HOME \
  40. -g $SERVER_GROUP \
  41. $SERVER_USER 2> /dev/null || true
  42. # 4. Add the user to the ADDGROUP group
  43. if test -n $ADDGROUP
  44. then
  45. if ! groups $SERVER_USER | cut -d: -f2 | \
  46. grep -qw $ADDGROUP; then
  47. adduser $SERVER_USER $ADDGROUP
  48. fi
  49. fi
  50. ;;
  51. esac
  52.  
  53. rm -f /etc/timidity/timidity.daemon
  54.  
  55. # make sure we really stop, because packaging system doesn't
  56. # understand what we're trying to do with migration to timidity-daemon
  57. [ -f "/etc/init.d/timidity" ] && if which invoke-rc.d >/dev/null 2>&1; then
  58. invoke-rc.d timidity stop
  59. else
  60. /etc/init.d/timidity stop
  61. fi
  62.  
  63. # Automatically added by dh_installinit
  64. if [ -x "/etc/init.d/timidity" ]; then
  65. update-rc.d timidity defaults 99 01 >/dev/null
  66. if [ -n "$2" ]; then
  67. _dh_action=restart
  68. else
  69. _dh_action=start
  70. fi
  71. if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
  72. invoke-rc.d timidity $_dh_action || exit $?
  73. else
  74. /etc/init.d/timidity $_dh_action || exit $?
  75. fi
  76. fi
  77. # End automatically added section
  78.  
  79.  
  80. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement