2018-09-06 22:10:40 +00:00
|
|
|
#/bin/bash
|
|
|
|
|
2018-09-17 17:31:45 +00:00
|
|
|
echo "Checking status of mympd system user and group"
|
2018-09-06 22:10:40 +00:00
|
|
|
getent group mympd > /dev/null
|
2018-09-12 20:30:24 +00:00
|
|
|
[ "$?" = "2" ] && groupadd -r mympd
|
2018-09-06 22:10:40 +00:00
|
|
|
getent passwd mympd > /dev/null
|
2018-09-16 21:22:36 +00:00
|
|
|
[ "$?" = "2" ] && useradd -r mympd -g mympd -d /var/lib/mympd -s /usr/sbin/nologin
|
2018-09-06 22:10:40 +00:00
|
|
|
|
2018-09-20 20:13:04 +00:00
|
|
|
if ! [ $(stat -c '%U:%G' /var/lib/mympd/) = 'mympd:mympd' ]
|
2018-09-17 17:31:45 +00:00
|
|
|
then
|
|
|
|
echo "Fixing ownership of /var/lib/mympd"
|
|
|
|
chown -R mympd.mympd /var/lib/mympd
|
|
|
|
fi
|
2018-09-06 22:10:40 +00:00
|
|
|
|
|
|
|
echo "Trying to link musicdir to library"
|
|
|
|
if [ -f /etc/mpd.conf ]
|
|
|
|
then
|
|
|
|
LIBRARY=$(grep ^music_directory /etc/mpd.conf | awk {'print $2'} | sed -e 's/"//g')
|
|
|
|
[ "$LIBRARY" != "" ] && [ ! -e /usr/share/mympd/htdocs/library ] && ln -s "$LIBRARY" /usr/share/mympd/htdocs/library
|
|
|
|
else
|
|
|
|
echo "/etc/mpd.conf not found, you must link your music_directory manually to /usr/share/mympd/htdocs/library"
|
|
|
|
fi
|
|
|
|
|
2018-09-20 20:13:04 +00:00
|
|
|
echo "Linking pics directory"
|
|
|
|
[ -e /usr/share/mympd/htdocs/pics ] || ln -s /var/lib/mympd/pics /usr/share/mympd/htdocs/
|
|
|
|
|
|
|
|
if [ -d /etc/systemd ]
|
2018-09-06 22:10:40 +00:00
|
|
|
then
|
|
|
|
echo "Installing systemd service"
|
2018-09-20 20:13:04 +00:00
|
|
|
[ -d /usr/lib/systemd/system ] || mkdir -p /usr/lib/systemd/system
|
2018-09-06 22:10:40 +00:00
|
|
|
if [ contrib/mympd.service -nt /usr/lib/systemd/system/mympd.service ]
|
|
|
|
then
|
|
|
|
cp contrib/mympd.service /usr/lib/systemd/system/
|
2018-09-17 17:53:10 +00:00
|
|
|
systemctl daemon-reload
|
2018-09-06 22:10:40 +00:00
|
|
|
fi
|
2018-09-17 17:53:10 +00:00
|
|
|
systemctl enable mympd
|
2018-09-06 22:10:40 +00:00
|
|
|
fi
|
|
|
|
|
2018-09-17 17:31:45 +00:00
|
|
|
# move config into place unless already existing
|
|
|
|
if [ ! -f /etc/mympd/mympd.conf ]
|
|
|
|
then
|
|
|
|
mv /etc/mympd/mympd.conf.dist /etc/mympd/mympd.conf
|
|
|
|
else
|
|
|
|
echo "mympd.conf installed as mympd.conf.dist"
|
|
|
|
fi
|
|
|
|
|
2018-09-06 22:10:40 +00:00
|
|
|
if [ -d /etc/mympd/ssl ]
|
|
|
|
then
|
|
|
|
echo "Certificates already created"
|
|
|
|
else
|
|
|
|
echo "Creating certificates"
|
2018-09-16 21:22:36 +00:00
|
|
|
sudo /usr/share/mympd/crcert.sh
|
2018-09-06 22:10:40 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "myMPD installed"
|
|
|
|
echo "Edit /etc/mympd/mympd.conf before starting myMPD"
|