#!/bin/bash # This script will set up the .mpd folder in the home directory # and the mpd.conf configuration file in the /etc/ directory. # Check if the script is running with root privileges (required for /etc/) if [ "$EUID" -ne 0 ]; then echo "Please run this script with sudo: sudo $0" exit 1 fi # Find the actual home directory of the user who invoked sudo REAL_HOME=$(eval echo "~$SUDO_USER") echo "" echo "Checking for existence of $REAL_HOME/.mpd ..." if [[ -d "$REAL_HOME/.mpd" ]]; then echo "$REAL_HOME/.mpd found" echo "" echo "Checking for existence of $REAL_HOME/.mpd/playlists" if [[ -d "$REAL_HOME/.mpd/playlists" ]]; then echo "$REAL_HOME/.mpd/playlists found" else echo "$REAL_HOME/.mpd/playlists not found" echo "creating $REAL_HOME/.mpd/playlists" mkdir -pv "$REAL_HOME/.mpd/playlists" chown -R "$SUDO_USER:" "$REAL_HOME/.mpd" fi else echo "$REAL_HOME/.mpd not found" echo "creating $REAL_HOME/.mpd and $REAL_HOME/.mpd/playlists" mkdir -pv "$REAL_HOME/.mpd/playlists" chown -R "$SUDO_USER:" "$REAL_HOME/.mpd" fi echo "" echo "Checking for existence of /etc/mpd.conf ..." if [[ -f /etc/mpd.conf ]]; then echo "/etc/mpd.conf found" else echo "/etc/mpd.conf not found" echo "creating /etc/mpd.conf" cp -v /usr/doc/mpd-@PKGVER@/mpdconf.example /etc/mpd.conf # Since the config is in /etc, we replace '~/music' with the user's absolute path sed -i "s|~/music|$REAL_HOME/Music|" /etc/mpd.conf echo "Music directory set to $REAL_HOME/Music" fi echo "" echo "MPD configuration was set up. Please run:" echo "mpd /etc/mpd.conf" echo "to start the daemon using the configuration file in /etc/." echo "You can change settings by editing your /etc/mpd.conf file." echo ""