mirror of
https://github.com/SuperBFG7/ympd
synced 2025-01-12 10:20:34 +00:00
Fix: packaging improvrements - unified postinst scripts, added postrm hooks
Fix: don't override mympd.conf
This commit is contained in:
parent
7cffc5ecc6
commit
1b9dde8059
@ -43,7 +43,7 @@ install(TARGETS mympd DESTINATION bin)
|
||||
install(FILES contrib/mympd.1 DESTINATION share/man/man1)
|
||||
install(PROGRAMS contrib/crcert.sh DESTINATION share/${PROJECT_NAME}/)
|
||||
install(FILES contrib/mympd.service DESTINATION share/${PROJECT_NAME}/)
|
||||
install(FILES contrib/mympd.conf DESTINATION ../etc/${PROJECT_NAME}/)
|
||||
install(FILES contrib/mympd.conf.dist DESTINATION ../etc/${PROJECT_NAME}/)
|
||||
install(FILES htdocs/mympd.webmanifest DESTINATION share/${PROJECT_NAME}/htdocs/)
|
||||
install(FILES dist/htdocs/index.html DESTINATION share/${PROJECT_NAME}/htdocs/)
|
||||
install(FILES dist/htdocs/player.html DESTINATION share/${PROJECT_NAME}/htdocs/)
|
||||
|
3
PKGBUILD
3
PKGBUILD
@ -77,9 +77,6 @@ package() {
|
||||
cd "${srcdir}/${_pkgname}-${pkgver}/release"
|
||||
make DESTDIR="$pkgdir/" install
|
||||
|
||||
### DON'T OVERWRITE CURRENT CONFIG ###
|
||||
mv "${pkgdir}/etc/mympd/mympd.conf" "${pkgdir}/etc/mympd/mympd.conf.dist"
|
||||
|
||||
install -Dm644 "${srcdir}/${_pkgname}-${pkgver}/contrib/mympd.service" "$pkgdir/usr/lib/systemd/system/mympd.service"
|
||||
/usr/share/mympd/crcert.sh
|
||||
}
|
||||
|
@ -49,15 +49,10 @@ post_upgrade() {
|
||||
/usr/share/mympd/crcert.sh
|
||||
fi
|
||||
|
||||
# disable ssl by default on mympd.conf.dist (chrome hates localhost.localdomain)
|
||||
echo "INFO: Disabling SSL by default in dist config"
|
||||
sed '/^ssl = true/c ssl = false' -i "/etc/mympd/mympd.conf.dist"
|
||||
|
||||
# move config into place unless already existing
|
||||
if [ ! -f /etc/mympd/mympd.conf ]
|
||||
then
|
||||
mv /etc/mympd/mympd.conf.dist /etc/mympd/mympd.conf
|
||||
echo -e "\e[93mWARNING\e[0m: \e[1mSSL Disabled by default! You must enable SSL in /etc/mympd/mympd.conf if you wish to use SSL\e[0m"
|
||||
else
|
||||
echo -e "\e[93mWARNING\e[0m: \e[1mmympd.conf \e[0minstalled as \e[1mmympd.conf.dist\e[0m"
|
||||
fi
|
||||
|
@ -38,10 +38,18 @@ cd release
|
||||
make install DESTDIR=%{buildroot}
|
||||
|
||||
%post
|
||||
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
|
||||
|
||||
if ! [ $(stat -c '%U:%G' /var/lib/mympd/) == 'mympd:mympd' ]
|
||||
then
|
||||
echo "Fixing ownership of /var/lib/mympd"
|
||||
chown -R mympd.mympd /var/lib/mympd
|
||||
fi
|
||||
|
||||
if [ -d /usr/lib/systemd/ ]
|
||||
then
|
||||
[ -d /usr/lib/systemd/system ] || sudo mkdir /usr/lib/systemd/system
|
||||
@ -52,9 +60,28 @@ 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
|
||||
fi
|
||||
chown -R mympd /var/lib/mympd
|
||||
|
||||
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
|
||||
|
||||
/usr/share/mympd/crcert.sh
|
||||
|
||||
%postun
|
||||
rm -v -fr /var/lib/mympd
|
||||
rm -v -f /usr/lib/systemd/system/mympd.service
|
||||
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
|
||||
%defattr(-,root,root,-)
|
||||
%doc README.md LICENSE
|
||||
|
@ -1,8 +0,0 @@
|
||||
#!/bin/sh
|
||||
rm -r /etc/mympd
|
||||
rm -r /var/lib/mympd
|
||||
rm -r /usr/share/mympd
|
||||
rm -f /usr/lib/systemd/system/mympd.service
|
||||
|
||||
userdel mympd
|
||||
groupdel mympd
|
16
debian/postinst
vendored
16
debian/postinst
vendored
@ -1,12 +1,16 @@
|
||||
#/bin/bash
|
||||
|
||||
echo "Fixing ownership of /var/lib/mympd"
|
||||
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
|
||||
|
||||
chown -R mympd.mympd /var/lib/mympd
|
||||
if ! [ $(stat -c '%U:%G' /var/lib/mympd/) == 'mympd:mympd' ]
|
||||
then
|
||||
echo "Fixing ownership of /var/lib/mympd"
|
||||
chown -R mympd.mympd /var/lib/mympd
|
||||
fi
|
||||
|
||||
echo "Trying to link musicdir to library"
|
||||
if [ -f /etc/mpd.conf ]
|
||||
@ -27,6 +31,14 @@ then
|
||||
fi
|
||||
fi
|
||||
|
||||
# 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
|
||||
|
||||
if [ -d /etc/mympd/ssl ]
|
||||
then
|
||||
echo "Certificates already created"
|
||||
|
9
debian/postrm
vendored
Normal file
9
debian/postrm
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
rm -v -fr /var/lib/mympd
|
||||
rm -v -f /usr/lib/systemd/system/mympd.service
|
||||
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
|
39
mkrelease.sh
39
mkrelease.sh
@ -49,41 +49,4 @@ make
|
||||
sudo make install
|
||||
cd ..
|
||||
|
||||
echo "Fixing ownership of /var/lib/mympd"
|
||||
getent group mympd > /dev/null
|
||||
[ "$?" = "2" ] && sudo groupadd -r mympd
|
||||
getent passwd mympd > /dev/null
|
||||
[ "$?" = "2" ] && sudo useradd -r mympd -g mympd -d /var/lib/mympd -s /usr/sbin/nologin
|
||||
sudo chown -R mympd.mympd /var/lib/mympd
|
||||
|
||||
echo "Trying to link musicdir to library"
|
||||
if [ -f /etc/mpd.conf ]
|
||||
then
|
||||
LIBRARY=$(sudo grep ^music_directory /etc/mpd.conf | awk {'print $2'} | sed -e 's/"//g')
|
||||
[ "$LIBRARY" != "" ] && [ ! -e /usr/share/mympd/htdocs/library ] && sudo 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 "Installing systemd service"
|
||||
if [ -d /usr/lib/systemd/ ]
|
||||
then
|
||||
[ -d /usr/lib/systemd/system ] || sudo mkdir /usr/lib/systemd/system
|
||||
if [ contrib/mympd.service -nt /usr/lib/systemd/system/mympd.service ]
|
||||
then
|
||||
sudo cp contrib/mympd.service /usr/lib/systemd/system/
|
||||
sudo systemctl daemon-reload
|
||||
fi
|
||||
sudo systemctl enable mympd
|
||||
fi
|
||||
|
||||
if [ -d /etc/mympd/ssl ]
|
||||
then
|
||||
echo "Certificates already created"
|
||||
else
|
||||
echo "Creating certificates"
|
||||
sudo /usr/share/mympd/crcert.sh
|
||||
fi
|
||||
|
||||
echo "myMPD installed"
|
||||
echo "Edit /etc/mympd/mympd.conf before starting myMPD"
|
||||
debian/postinst
|
||||
|
Loading…
Reference in New Issue
Block a user