mirror of
https://github.com/SuperBFG7/ympd
synced 2024-12-26 02:50:26 +00:00
85 lines
3.3 KiB
Plaintext
Executable File
85 lines
3.3 KiB
Plaintext
Executable File
#/bin/bash
|
|
|
|
echo "Checking status of mympd system user and group"
|
|
getent group mympd > /dev/null
|
|
[ "$?" = "2" ] && groupadd -r mympd
|
|
getent passwd mympd > /dev/null
|
|
[ "$?" = "2" ] && useradd -r mympd -g mympd -d /var/lib/mympd -s /usr/sbin/nologin
|
|
|
|
|
|
|
|
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
|
|
|
|
echo "Linking pics directory"
|
|
[ -e /usr/share/mympd/htdocs/pics ] || ln -s /var/lib/mympd/pics /usr/share/mympd/htdocs/
|
|
|
|
if [ -d /etc/systemd ]
|
|
then
|
|
echo "Installing systemd service"
|
|
[ -d /usr/lib/systemd/system ] || mkdir -p /usr/lib/systemd/system
|
|
if [ contrib/mympd.service -nt /usr/lib/systemd/system/mympd.service ]
|
|
then
|
|
cp contrib/mympd.service /usr/lib/systemd/system/
|
|
systemctl daemon-reload
|
|
fi
|
|
systemctl enable mympd
|
|
fi
|
|
|
|
# move smartpls into place unless already existing
|
|
for PLDIST in /var/lib/mympd/smartpls/*.dist
|
|
do
|
|
if [ -f "$PLDIST" ]
|
|
then
|
|
PLS=$(basename $PLDIST .dist)
|
|
if [ -f /var/lib/mympd/smartpls/$PLS ]
|
|
then
|
|
rm $PLDIST
|
|
else
|
|
mv -v $PLDIST /var/lib/mympd/smartpls/$PLS
|
|
fi
|
|
fi
|
|
done
|
|
|
|
# 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
|
|
|
|
#default state files
|
|
[ -f /var/lib/mympd/state/jukeboxMode ] || echo -n "0" > /var/lib/mympd/state/jukeboxMode
|
|
[ -f /var/lib/mympd/state/jukeboxPlaylist ] || echo -n "Database" > /var/lib/mympd/state/jukeboxPlaylist
|
|
[ -f /var/lib/mympd/state/jukeboxQueueLength ] || echo -n "1" > /var/lib/mympd/state/jukeboxQueueLength
|
|
[ -f /var/lib/mympd/state/notificationPage ] || echo -n "true" > /var/lib/mympd/state/notificationPage
|
|
[ -f /var/lib/mympd/state/notificationWeb ] || echo -n "false" > /var/lib/mympd/state/notificationWeb
|
|
[ -f /var/lib/mympd/state/colsBrowseDatabase ] || echo -n '["Track","Title","Duration"]' > /var/lib/mympd/state/colsBrowseDatabase
|
|
[ -f /var/lib/mympd/state/colsBrowseFilesystem ] || echo -n '["Type","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsBrowseFilesystem
|
|
[ -f /var/lib/mympd/state/colsPlayback ] || echo -n '["Artist","Album","Genre"]' > /var/lib/mympd/state/colsPlayback
|
|
[ -f /var/lib/mympd/state/colsBrowsePlaylistsDetail ] || echo -n '["Pos","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsBrowsePlaylistsDetail
|
|
[ -f /var/lib/mympd/state/colsQueueCurrent ] || echo -n '["Pos","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsQueueCurrent
|
|
[ -f /var/lib/mympd/state/colsQueueLastPlayed ] || echo -n '["Pos","Title","Artist","Album","LastPlayed"]' > /var/lib/mympd/state/colsQueueLastPlayed
|
|
[ -f /var/lib/mympd/state/colsSearch ] || echo -n '["Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsSearch
|
|
|
|
echo "Fixing ownership of /var/lib/mympd"
|
|
chown -R mympd.mympd /var/lib/mympd
|
|
|
|
if [ -d /etc/mympd/ssl ]
|
|
then
|
|
echo "Certificates already created"
|
|
else
|
|
echo "Creating certificates"
|
|
/usr/share/mympd/crcert.sh
|
|
fi
|
|
|
|
echo "myMPD installed"
|
|
echo "Edit /etc/mympd/mympd.conf before starting myMPD"
|