-
-
Save JeremyOttley/e9eed1ddae62314ec8e99d4c862805a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
clear | |
username=$(whoami) | |
interface=`ip route show | cut -d ' ' -f 3 | head -1` | |
interface=$(ip route show | awk '{print $NF}' | tail -1) | |
echo "What is the full path of the directory containing your music?" | |
read -e -p "> " music_dir | |
if test -n "$(pgrep pulseaudio)"; | |
then | |
AUDIO=' | |
audio_output { | |
type "pulse" | |
name "Pulseaudio" | |
} | |
' | |
else | |
echo "No PulseAudio seems to be used, using autodetection instead" | |
AUDIO="" | |
fi | |
cat <<EOF | |
Ready to write config file. | |
This will delete and re-create directory "$HOME/.mpd" | |
EOF | |
read -p "Continue? (y/n) " yn | |
DO_CONFIG= | |
case $yn in | |
[Yy]*) DO_CONFIG=yes ;; | |
[Nn]*) exit;; | |
*) echo "Please answer yes or no."; exit;; | |
esac | |
if test x$DO_CONFIG = xyes; | |
then | |
rm -fr $HOME/.mpd | |
mkdir -p $HOME/.mpd/playlists | |
touch $HOME/.mpd/log | |
cat > $HOME/.mpd/mpd.conf <<EOF | |
music_directory "$music_dir" | |
db_file "$HOME/.mpd/database" | |
log_file "$HOME/.mpd/log" | |
pid_file "$HOME/.mpd/pid" | |
state_file "$HOME/.mpd/state" | |
playlist_directory "$HOME/.mpd/playlists" | |
log_level "default" | |
#password "password@read,add,control,admin" | |
#default_permissions "read,add,control,admin" | |
#user "$username" | |
#bind_to_address "$interface" | |
bind_to_address "127.0.0.1" | |
bind_to_address "$HOME/.mpd/socket" | |
port "6600" | |
gapless_mp3_playback "yes" | |
auto_update "yes" | |
#auto_update_depth "3" | |
input { | |
plugin "curl" | |
proxy "proxy.isp.com:8000" | |
proxy_user "user" | |
proxy_password "password" | |
} | |
$AUDIO | |
#audio_output { | |
# type "alsa" | |
# name "Alsa output" | |
# device "hw:0,0" | |
# format "44100:16:2" | |
# mixer_type "hardware" | |
# mixer_device "default" | |
# mixer_control "PCM" | |
# mixer_index "0" | |
#} | |
#audio_output { | |
# type "httpd" | |
# name "Internet Stream" | |
# encoder "lame" | |
# port "8000" | |
# bind_to_address "192.168.1.13" | |
# quality "5.0" | |
# bitrate "128" | |
# format "44100:16:1" | |
# max_clients "3" | |
#} | |
#audio_output { | |
# type "recorder" | |
# name "My recorder" | |
# encoder "vorbis" | |
# path "/home/carnager/stream.ogg" | |
# quality "7.0" # do not define if bitrate is defined | |
# bitrate "128" # do not define if quality is defined | |
# format "44100:16:1" | |
#} | |
replaygain "album" | |
replaygain_preamp "0" | |
#volume_normalization "no" | |
#audio_buffer_size "2048" | |
#buffer_before_play "10%" | |
#connection_timeout "60" | |
#max_connections "10" | |
#max_playlist_length "16384" | |
#max_command_list_size "2048" | |
#max_output_buffer_size "8192" | |
#filesystem_charset "UTF-8" | |
#id3v1_encoding "ISO-8859-1" | |
EOF | |
clear | |
cat <<EOF | |
EOF | |
echo "Trying to create systemd custom settings" | |
echo "Root previlegs needed..." | |
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" | |
echo "Setup complete" | |
echo " " | |
echo "If you want mpd to start at boot, run:" | |
echo ""systemctl enable mpd"" | |
echo " " | |
echo "Otherwise simply run "mpd" as user now." | |
else | |
echo "No config written, aborting" | |
exit | |
fi | |
## make the directory where you want to store the script | |
mkdir /tmp/mpd-configure | |
## change to that directory | |
cd /tmp/mpd-configure | |
## download and unpack the script and other files needed | |
wget https://lacocina.nl/mpd-configure -O - | tar --strip-components=1 -zxf - | |
## run the script | |
bash mpd-configure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment