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 # unlink music dir
echo "unlinking musicdir to library" echo "unlinking musicdir to library"
if [ -f /etc/mpd.conf ] [ -e /usr/share/mympd/htdocs/library ] && rm -v /usr/share/mympd/htdocs/library
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
# remove mympd user and group # remove mympd user and group
getent passwd mympd > /dev/null getent passwd mympd > /dev/null

View File

@ -54,7 +54,10 @@ if [ -d /usr/lib/systemd/ ]
then then
[ -d /usr/lib/systemd/system ] || sudo mkdir /usr/lib/systemd/system [ -d /usr/lib/systemd/system ] || sudo mkdir /usr/lib/systemd/system
cp /usr/share/mympd/mympd.service /usr/lib/systemd/system/ cp /usr/share/mympd/mympd.service /usr/lib/systemd/system/
systemctl daemon-reload
systemctl enable mympd
fi fi
if [ -f /etc/mpd.conf ] if [ -f /etc/mpd.conf ]
then then
LIBRARY=$(grep ^music_directory /etc/mpd.conf | awk {'print $2'} | sed -e 's/"//g') LIBRARY=$(grep ^music_directory /etc/mpd.conf | awk {'print $2'} | sed -e 's/"//g')
@ -71,8 +74,19 @@ fi
/usr/share/mympd/crcert.sh /usr/share/mympd/crcert.sh
%postun %postun
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 rm -v -fr /var/lib/mympd
rm -v -f /usr/lib/systemd/system/mympd.service [ -e /usr/share/mympd/htdocs/library ] && rm -v /usr/share/mympd/htdocs/library
rmdir -v /usr/share/{mympd/htdocs/,mympd/} rmdir -v /usr/share/{mympd/htdocs/,mympd/}
getent passwd mympd > /dev/null 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 ] if [ contrib/mympd.service -nt /usr/lib/systemd/system/mympd.service ]
then then
cp contrib/mympd.service /usr/lib/systemd/system/ cp contrib/mympd.service /usr/lib/systemd/system/
systemctl daemon-reload
fi fi
systemctl enable mympd
fi fi
# move config into place unless already existing # move config into place unless already existing

14
debian/postrm vendored
View File

@ -1,5 +1,17 @@
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 rm -v -fr /var/lib/mympd
rm -v -f /usr/lib/systemd/system/mympd.service
[ -e /usr/share/mympd/htdocs/library ] && rm -v /usr/share/mympd/htdocs/library
rmdir -v /usr/share/{mympd/htdocs/,mympd/} rmdir -v /usr/share/{mympd/htdocs/,mympd/}
getent passwd mympd > /dev/null getent passwd mympd > /dev/null