2018-09-13 21:56:07 +00:00
|
|
|
post_install() {
|
|
|
|
post_upgrade;
|
|
|
|
}
|
|
|
|
|
|
|
|
post_upgrade() {
|
|
|
|
# create mympd user, group if not already existing
|
|
|
|
echo "INFO: Checking status of mympd system user and group"
|
|
|
|
getent group mympd > /dev/null
|
|
|
|
[ "$?" = "2" ] && groupadd --system mympd
|
|
|
|
getent passwd mympd > /dev/null
|
|
|
|
[ "$?" = "2" ] && useradd --system -d /var/lib/mympd -s /usr/sbin/nologin -g mympd mympd
|
|
|
|
|
|
|
|
# link music directory to mympd if not already exising
|
|
|
|
echo "INFO: 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 musicdir 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/
|
|
|
|
|
2018-09-13 21:56:07 +00:00
|
|
|
# install systemd service
|
|
|
|
echo "INFO: Installing systemd service"
|
|
|
|
if [ -d /etc/systemd/system ]
|
|
|
|
then
|
|
|
|
echo "INFO: reloading systemd"
|
|
|
|
systemctl daemon-reload
|
|
|
|
if [ ! -f /etc/systemd/system/multi-user.target.wants/mympd.service ]
|
|
|
|
then
|
|
|
|
echo "INFO: enabling mympd.service"
|
|
|
|
systemctl enable mympd
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# create ssl certificates unless already existing
|
|
|
|
if [ -d /etc/mympd/ssl ]
|
|
|
|
then
|
|
|
|
echo "INFO: Certificates already created"
|
|
|
|
else
|
|
|
|
echo "INFO: Creating certificates"
|
|
|
|
/usr/share/mympd/crcert.sh
|
|
|
|
fi
|
|
|
|
|
2018-10-01 19:12:59 +00:00
|
|
|
# move smartpls into place unless already existing
|
|
|
|
for PLDIST in /var/lib/mympd/smartpls/*.dist
|
|
|
|
do
|
2018-10-01 21:11:14 +00:00
|
|
|
if [ -f "$PLDIST" ]
|
2018-10-01 19:12:59 +00:00
|
|
|
then
|
2018-10-01 21:11:14 +00:00
|
|
|
PLS=$(basename $PLDIST .dist)
|
|
|
|
if [ -f /var/lib/mympd/smartpls/$PLS ]
|
|
|
|
then
|
|
|
|
rm $PLDIST
|
|
|
|
else
|
|
|
|
mv -v $PLDIST /var/lib/mympd/smartpls/$PLS
|
|
|
|
fi
|
2018-10-01 19:12:59 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2018-10-07 21:34:54 +00:00
|
|
|
#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
|
2019-01-19 00:20:05 +00:00
|
|
|
[ -f /var/lib/mympd/state/autoPlay ] || echo -n "false" > /var/lib/mympd/state/autoPlay
|
2018-10-07 21:34:54 +00:00
|
|
|
[ -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
|
2018-11-04 18:34:46 +00:00
|
|
|
[ -f /var/lib/mympd/state/colsBrowseDatabase ] || echo -n '["Track","Title","Duration"]' > /var/lib/mympd/state/colsBrowseDatabase
|
2018-11-04 23:24:47 +00:00
|
|
|
[ -f /var/lib/mympd/state/colsPlayback ] || echo -n '["Artist","Album","Genre"]' > /var/lib/mympd/state/colsPlayback
|
2018-10-22 20:03:45 +00:00
|
|
|
[ -f /var/lib/mympd/state/colsBrowseFilesystem ] || echo -n '["Type","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsBrowseFilesystem
|
2018-10-22 22:20:57 +00:00
|
|
|
[ -f /var/lib/mympd/state/colsBrowsePlaylistsDetail ] || echo -n '["Pos","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsBrowsePlaylistsDetail
|
2018-11-14 23:14:47 +00:00
|
|
|
[ -f /var/lib/mympd/state/colsQueueCurrent ] || echo -n '["Pos","Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsQueueCurrent
|
2018-10-22 20:03:45 +00:00
|
|
|
[ -f /var/lib/mympd/state/colsSearch ] || echo -n '["Title","Artist","Album","Duration"]' > /var/lib/mympd/state/colsSearch
|
2018-11-14 23:14:47 +00:00
|
|
|
[ -f /var/lib/mympd/state/colsQueueLastPlayed ] || echo -n '["Pos","Title","Artist","Album","LastPlayed"]' > /var/lib/mympd/state/colsQueueLastPlayed
|
2018-10-07 21:34:54 +00:00
|
|
|
|
|
|
|
# fix ownership of /var/lib/mympd
|
|
|
|
echo "INFO: Fixing ownership of /var/lib/mympd"
|
|
|
|
chown -R mympd.mympd /var/lib/mympd
|
|
|
|
|
2018-09-13 21:56:07 +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 -e "\e[93mWARNING\e[0m: \e[1mmympd.conf \e[0minstalled as \e[1mmympd.conf.dist\e[0m"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# installation complete
|
|
|
|
echo -e "\e[93mWARNING\e[0m: Edit \e[1m/etc/mympd/mympd.conf \e[0mbefore starting myMPD"
|
|
|
|
}
|
|
|
|
|
|
|
|
post_remove() {
|
|
|
|
# stop and remove systemd service
|
|
|
|
systemctl daemon-reload
|
|
|
|
if `systemctl is-active --quiet mympd`
|
|
|
|
then
|
|
|
|
echo "stopping mympd.service" && systemctl stop mympd
|
|
|
|
fi
|
|
|
|
echo "disabling mympd.service" && systemctl disable mympd
|
|
|
|
|
|
|
|
# backup config
|
|
|
|
if [ -f /etc/mympd/mympd.conf ]
|
|
|
|
then
|
|
|
|
mv /etc/mympd/mympd.conf /etc/mympd/mympd.conf.pacsave
|
|
|
|
echo -e "\e[93mINFO\e[0m: /etc/mympd/mympd.conf backed up to /etc/mympd/mympd.conf.pacsave"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# remove leftover directories
|
2018-09-20 20:13:04 +00:00
|
|
|
rm -v -f /usr/share/mympd/htdocs/pics
|
|
|
|
rm -v -f /usr/share/mympd/htdocs/library
|
|
|
|
rmdir -v /usr/share/mympd/htdocs/
|
|
|
|
rmdir -v /usr/share/mympd/
|
2018-09-13 21:56:07 +00:00
|
|
|
}
|