Guest User

Untitled

a guest
Sep 25th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.12 KB | None | 0 0
  1. #!/bin/bash
  2. clear
  3. username=$(whoami)
  4. interface=`ip route show | cut -d ' ' -f 3 | head -1`
  5. interface=$(ip route show | awk '{print $NF}' | tail -1)
  6. echo "What is the full path of the directory containing your music?"
  7. read -e -p "> " music_dir
  8.  
  9. if test -n "$(pgrep pulseaudio)";
  10. then
  11. AUDIO='
  12. audio_output {
  13. type "pulse"
  14. name "Pulseaudio"
  15. }
  16. '
  17. else
  18. echo "No PulseAudio seems to be used, using autodetection instead"
  19. AUDIO=""
  20. fi
  21.  
  22. cat <<EOF
  23.  
  24.  
  25. Ready to write config file.
  26. This will delete and re-create directory "$HOME/.mpd"
  27.  
  28. EOF
  29. read -p "Continue? (y/n) " yn
  30.  
  31. DO_CONFIG=
  32. case $yn in
  33. [Yy]*) DO_CONFIG=yes ;;
  34. [Nn]*) exit;;
  35. *) echo "Please answer yes or no."; exit;;
  36. esac
  37.  
  38. if test x$DO_CONFIG = xyes;
  39. then
  40. rm -fr $HOME/.mpd
  41. mkdir -p $HOME/.mpd/playlists
  42. touch $HOME/.mpd/log
  43. cat > $HOME/.mpd/mpd.conf <<EOF
  44. music_directory "$music_dir"
  45. db_file "$HOME/.mpd/database"
  46. log_file "$HOME/.mpd/log"
  47. pid_file "$HOME/.mpd/pid"
  48. state_file "$HOME/.mpd/state"
  49. playlist_directory "$HOME/.mpd/playlists"
  50. log_level "default"
  51. #password "password@read,add,control,admin"
  52. #default_permissions "read,add,control,admin"
  53. #user "$username"
  54. #bind_to_address "$interface"
  55. bind_to_address "127.0.0.1"
  56. bind_to_address "$HOME/.mpd/socket"
  57. port "6600"
  58. gapless_mp3_playback "yes"
  59. auto_update "yes"
  60. #auto_update_depth "3"
  61.  
  62. input {
  63. plugin "curl"
  64. proxy "proxy.isp.com:8000"
  65. proxy_user "user"
  66. proxy_password "password"
  67. }
  68. $AUDIO
  69. #audio_output {
  70. # type "alsa"
  71. # name "Alsa output"
  72. # device "hw:0,0"
  73. # format "44100:16:2"
  74. # mixer_type "hardware"
  75. # mixer_device "default"
  76. # mixer_control "PCM"
  77. # mixer_index "0"
  78. #}
  79. #audio_output {
  80. # type "httpd"
  81. # name "Internet Stream"
  82. # encoder "lame"
  83. # port "8000"
  84. # bind_to_address "192.168.1.13"
  85. # quality "5.0"
  86. # bitrate "128"
  87. # format "44100:16:1"
  88. # max_clients "3"
  89. #}
  90.  
  91. #audio_output {
  92. # type "recorder"
  93. # name "My recorder"
  94. # encoder "vorbis"
  95. # path "/home/carnager/stream.ogg"
  96. # quality "7.0" # do not define if bitrate is defined
  97. # bitrate "128" # do not define if quality is defined
  98. # format "44100:16:1"
  99. #}
  100.  
  101. replaygain "album"
  102. replaygain_preamp "0"
  103. #volume_normalization "no"
  104. #audio_buffer_size "2048"
  105. #buffer_before_play "10%"
  106. #connection_timeout "60"
  107. #max_connections "10"
  108. #max_playlist_length "16384"
  109. #max_command_list_size "2048"
  110. #max_output_buffer_size "8192"
  111. #filesystem_charset "UTF-8"
  112. #id3v1_encoding "ISO-8859-1"
  113. EOF
  114. clear
  115. cat <<EOF
  116.  
  117. EOF
  118. echo "Trying to create systemd custom settings"
  119. echo "Root previlegs needed..."
  120. export username="$(whoami)"; su -c "mkdir /etc/systemd/system/mpd.service.d && echo -e \"[Service]\nUser=$username\nPAMName=system-local-login\" > /etc/systemd/system/mpd.service.d/mpd.conf"
  121. echo "Setup complete"
  122. echo " "
  123. echo "If you want mpd to start at boot, run:"
  124. echo ""systemctl enable mpd""
  125. echo " "
  126. echo "Otherwise simply run "mpd" as user now."
  127.  
  128. else
  129. echo "No config written, aborting"
  130. exit
  131. fi
  132.  
Add Comment
Please, Sign In to add comment