1
0
mirror of https://github.com/SuperBFG7/ympd synced 2024-11-05 14:26:16 +00:00

Fix: remove systemd service on uninstall

This commit is contained in:
jcorporation 2018-09-17 18:53:10 +01:00
parent 4c5bb30c8c
commit ebb6a607e9
4 changed files with 31 additions and 9 deletions

View File

@ -79,13 +79,7 @@ post_remove() {
# unlink music dir
echo "unlinking 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 ] && rm /usr/share/mympd/htdocs/library
else
echo -e "\e[93mWARNING\e[0m: /etc/mpd.conf not found, you must unlink your musicdir manually from \e[1m/usr/share/mympd/htdocs/library\e[0m"
fi
[ -e /usr/share/mympd/htdocs/library ] && rm -v /usr/share/mympd/htdocs/library
# remove mympd user and group
getent passwd mympd > /dev/null

View File

@ -54,7 +54,10 @@ if [ -d /usr/lib/systemd/ ]
then
[ -d /usr/lib/systemd/system ] || sudo mkdir /usr/lib/systemd/system
cp /usr/share/mympd/mympd.service /usr/lib/systemd/system/
systemctl daemon-reload
systemctl enable mympd
fi
if [ -f /etc/mpd.conf ]
then
LIBRARY=$(grep ^music_directory /etc/mpd.conf | awk {'print $2'} | sed -e 's/"//g')
@ -71,8 +74,19 @@ fi
/usr/share/mympd/crcert.sh
%postun
rm -v -fr /var/lib/mympd
if [ -f /usr/lib/systemd/system/mympd.service ]
then
if `systemctl is-active --quiet mympd`
then
echo "stopping mympd.service" && systemctl stop mympd
fi
echo "disabling mympd.service" && systemctl disable mympd
rm -v -f /usr/lib/systemd/system/mympd.service
systemctl daemon-reload
fi
rm -v -fr /var/lib/mympd
[ -e /usr/share/mympd/htdocs/library ] && rm -v /usr/share/mympd/htdocs/library
rmdir -v /usr/share/{mympd/htdocs/,mympd/}
getent passwd mympd > /dev/null

2
debian/postinst vendored
View File

@ -28,7 +28,9 @@ then
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 config into place unless already existing

14
debian/postrm vendored
View File

@ -1,5 +1,17 @@
rm -v -fr /var/lib/mympd
if [ -f /usr/lib/systemd/system/mympd.service ]
then
if `systemctl is-active --quiet mympd`
then
echo "stopping mympd.service" && systemctl stop mympd
fi
echo "disabling mympd.service" && systemctl disable mympd
rm -v -f /usr/lib/systemd/system/mympd.service
systemctl daemon-reload
fi
rm -v -fr /var/lib/mympd
[ -e /usr/share/mympd/htdocs/library ] && rm -v /usr/share/mympd/htdocs/library
rmdir -v /usr/share/{mympd/htdocs/,mympd/}
getent passwd mympd > /dev/null