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

Fix: dont't remove user/group on uninstall

Fix: moved pics directory to /var/lib/mympd
This commit is contained in:
jcorporation 2018-09-20 21:13:04 +01:00
parent 77be445fc1
commit 82029ce39d
6 changed files with 31 additions and 47 deletions

View File

@ -54,5 +54,4 @@ install(FILES dist/htdocs/js/mympd.min.js DESTINATION share/${PROJECT_NAME}/htdo
install(FILES dist/htdocs/css/bootstrap.min.css DESTINATION share/${PROJECT_NAME}/htdocs/css/) install(FILES dist/htdocs/css/bootstrap.min.css DESTINATION share/${PROJECT_NAME}/htdocs/css/)
install(FILES dist/htdocs/css/mympd.min.css DESTINATION share/${PROJECT_NAME}/htdocs/css/) install(FILES dist/htdocs/css/mympd.min.css DESTINATION share/${PROJECT_NAME}/htdocs/css/)
install(DIRECTORY htdocs/assets DESTINATION share/${PROJECT_NAME}/htdocs) install(DIRECTORY htdocs/assets DESTINATION share/${PROJECT_NAME}/htdocs)
install(DIRECTORY DESTINATION share/${PROJECT_NAME}/htdocs/pics) install(DIRECTORY DESTINATION ../var/lib/${PROJECT_NAME}/pics)
install(DIRECTORY DESTINATION ../var/lib/${PROJECT_NAME}/)

View File

@ -27,6 +27,9 @@ post_upgrade() {
echo "/etc/mpd.conf not found, you must link your musicdir manually to /usr/share/mympd/htdocs/library" echo "/etc/mpd.conf not found, you must link your musicdir manually to /usr/share/mympd/htdocs/library"
fi fi
echo "Linking pics directory"
[ -e /usr/share/mympd/htdocs/pics ] || ln -s /var/lib/mympd/pics /usr/share/mympd/htdocs/
# install systemd service # install systemd service
echo "INFO: Installing systemd service" echo "INFO: Installing systemd service"
if [ -d /etc/systemd/system ] if [ -d /etc/systemd/system ]
@ -77,18 +80,9 @@ post_remove() {
echo -e "\e[93mINFO\e[0m: /etc/mympd/mympd.conf backed up to /etc/mympd/mympd.conf.pacsave" echo -e "\e[93mINFO\e[0m: /etc/mympd/mympd.conf backed up to /etc/mympd/mympd.conf.pacsave"
fi fi
# unlink music dir
echo "unlinking musicdir to library"
[ -e /usr/share/mympd/htdocs/library ] && rm -v /usr/share/mympd/htdocs/library
# remove mympd user and group
getent passwd mympd > /dev/null
echo -e "\e[93mWARNING\e[0m: Removing \e[1mmympd \e[0muser and group!"
[ "$?" != "2" ] && userdel -r mympd
getent group mympd > /dev/null
[ "$?" != "2" ] && groupdel mympd
# remove leftover directories # remove leftover directories
rmdir -v /usr/share/{mympd/htdocs/,mympd/} 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/
} }

View File

@ -50,8 +50,7 @@ then
chown -R mympd.mympd /var/lib/mympd chown -R mympd.mympd /var/lib/mympd
fi fi
SYSTEMCTL=$(which systemctl > /dev/null 2>&1) if [ -d /etc/systemd ]
if [ "$?" == "0" ]
then then
[ -d /usr/lib/systemd/system ] || sudo mkdir -p /usr/lib/systemd/system [ -d /usr/lib/systemd/system ] || sudo mkdir -p /usr/lib/systemd/system
cp /usr/share/mympd/mympd.service /usr/lib/systemd/system/ cp /usr/share/mympd/mympd.service /usr/lib/systemd/system/
@ -65,6 +64,8 @@ then
[ "$LIBRARY" != "" ] && [ ! -e /usr/share/mympd/htdocs/library ] && ln -s "$LIBRARY" /usr/share/mympd/htdocs/library [ "$LIBRARY" != "" ] && [ ! -e /usr/share/mympd/htdocs/library ] && ln -s "$LIBRARY" /usr/share/mympd/htdocs/library
fi fi
[ -e /usr/share/mympd/htdocs/pics ] || ln -s /var/lib/mympd/pics /usr/share/mympd/htdocs/
if [ ! -f /etc/mympd/mympd.conf ] if [ ! -f /etc/mympd/mympd.conf ]
then then
mv /etc/mympd/mympd.conf.dist /etc/mympd/mympd.conf mv /etc/mympd/mympd.conf.dist /etc/mympd/mympd.conf
@ -75,8 +76,10 @@ fi
/usr/share/mympd/crcert.sh /usr/share/mympd/crcert.sh
%postun %postun
if [ -f /usr/lib/systemd/system/mympd.service ] if [ "$1" = "0" ]
then then
if [ -f /usr/lib/systemd/system/mympd.service ]
then
if `systemctl is-active --quiet mympd` if `systemctl is-active --quiet mympd`
then then
echo "stopping mympd.service" && systemctl stop mympd echo "stopping mympd.service" && systemctl stop mympd
@ -84,19 +87,11 @@ then
echo "disabling mympd.service" && systemctl disable mympd echo "disabling mympd.service" && systemctl disable mympd
rm -v -f /usr/lib/systemd/system/mympd.service rm -v -f /usr/lib/systemd/system/mympd.service
systemctl daemon-reload systemctl daemon-reload
fi
rm -v -f /usr/share/mympd/htdocs/pics
rm -v -f /usr/share/mympd/htdocs/library
fi 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
echo "Removing mympd user and group"
[ "$?" != "2" ] && userdel -r mympd
getent group mympd > /dev/null
[ "$?" != "2" ] && groupdel mympd
%files %files
%defattr(-,root,root,-) %defattr(-,root,root,-)
%doc README.md LICENSE %doc README.md LICENSE

9
debian/postinst vendored
View File

@ -6,7 +6,7 @@ getent group mympd > /dev/null
getent passwd mympd > /dev/null getent passwd mympd > /dev/null
[ "$?" = "2" ] && useradd -r mympd -g mympd -d /var/lib/mympd -s /usr/sbin/nologin [ "$?" = "2" ] && useradd -r mympd -g mympd -d /var/lib/mympd -s /usr/sbin/nologin
if ! [ $(stat -c '%U:%G' /var/lib/mympd/) == 'mympd:mympd' ] if ! [ $(stat -c '%U:%G' /var/lib/mympd/) = 'mympd:mympd' ]
then then
echo "Fixing ownership of /var/lib/mympd" echo "Fixing ownership of /var/lib/mympd"
chown -R mympd.mympd /var/lib/mympd chown -R mympd.mympd /var/lib/mympd
@ -21,10 +21,13 @@ else
echo "/etc/mpd.conf not found, you must link your music_directory manually to /usr/share/mympd/htdocs/library" echo "/etc/mpd.conf not found, you must link your music_directory manually to /usr/share/mympd/htdocs/library"
fi fi
if [ -d /usr/lib/systemd/ ] 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 then
echo "Installing systemd service" echo "Installing systemd service"
[ -d /usr/lib/systemd/system ] || mkdir /usr/lib/systemd/system [ -d /usr/lib/systemd/system ] || mkdir -p /usr/lib/systemd/system
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/

12
debian/postrm vendored
View File

@ -9,13 +9,5 @@ then
systemctl daemon-reload systemctl daemon-reload
fi fi
rm -v -fr /var/lib/mympd rm -v -f /usr/share/mympd/htdocs/pics
rm -v -f /usr/share/mympd/htdocs/library
[ -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
echo "Removing mympd user and group"
[ "$?" != "2" ] && userdel -r mympd
getent group mympd > /dev/null
[ "$?" != "2" ] && groupdel mympd

1
debian/rules vendored
View File

@ -16,6 +16,7 @@ binary-arch:
cd $(BUILDDIR); cmake -P cmake_install.cmake cd $(BUILDDIR); cmake -P cmake_install.cmake
mkdir debian/tmp/DEBIAN mkdir debian/tmp/DEBIAN
cp debian/postinst debian/tmp/DEBIAN cp debian/postinst debian/tmp/DEBIAN
cp debian/postrm debian/tmp/DEBIAN
dpkg-gencontrol -pmympd dpkg-gencontrol -pmympd
dpkg --build debian/tmp .. dpkg --build debian/tmp ..