jcorporation / myMPD

myMPD is a standalone and mobile friendly web mpd client with a tiny footprint and advanced features.
https://jcorporation.github.io/myMPD/
GNU General Public License v3.0
418 stars 65 forks source link

[Debian] systemd unit is not created even that it should #124

Closed MichaIng closed 5 years ago

MichaIng commented 5 years ago

Describe the bug After doing a fresh install or reinstall on Debian via mkrelease.sh, the systemd unit is not created even that according to code logic it should.

To Reproduce Steps to reproduce the behavior:

  1. wget https://github.com/jcorporation/myMPD/archive/master.zip
  2. unzip master.zip
  3. cd myMPD-master
  4. ./mkrelease.sh

Expected behavior systemd unit should have been created and enabled

Actual behavior

root@VM-Stretch:/tmp/myMPD-master# l /usr/lib/systemd/system/
total 0
root@VM-Stretch:/tmp/myMPD-master# ./mkrelease.sh
Minifying javascript
Minifying stylesheets
Minifying html
Compiling and installing mympd
ASSETS_PATH: /usr/share/mympd/htdocs
++ 64 bit architecture
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/myMPD-master/release
[ 73%] Built target mympd
[ 86%] Built target mympd_coverextract
[100%] Built target test_coverextract
[ 73%] Built target mympd
[ 86%] Built target mympd_coverextract
[100%] Built target test_coverextract
Install the project...
-- Install configuration: "RELEASE"
-- Up-to-date: /usr/share/mympd/lib
-- Up-to-date: /usr/share/mympd/lib/libmympd_coverextract.so
-- Up-to-date: /usr/bin/mympd
-- Up-to-date: /etc/mympd/mympd.conf.dist
-- Up-to-date: /etc/mympd/syscmds
-- Up-to-date: /usr/share/mympd/crcert.sh
-- Up-to-date: /usr/share/mympd/mympd.service
-- Up-to-date: /usr/share/mympd/htdocs/mympd.webmanifest
-- Up-to-date: /usr/share/mympd/htdocs/robots.txt
-- Up-to-date: /usr/share/mympd/htdocs/index.html
-- Up-to-date: /usr/share/mympd/htdocs/player.html
-- Up-to-date: /usr/share/mympd/htdocs/sw.min.js
-- Up-to-date: /usr/share/mympd/htdocs/js/player.min.js
-- Up-to-date: /usr/share/mympd/htdocs/js/bootstrap-native-v4.min.js
-- Up-to-date: /usr/share/mympd/htdocs/js/mympd.min.js
-- Up-to-date: /usr/share/mympd/htdocs/js/keymap.min.js
-- Up-to-date: /usr/share/mympd/htdocs/css/bootstrap.min.css
-- Up-to-date: /usr/share/mympd/htdocs/css/mympd.min.css
-- Up-to-date: /usr/share/mympd/htdocs/assets
-- Up-to-date: /usr/share/mympd/htdocs/assets/favicon.ico
-- Up-to-date: /usr/share/mympd/htdocs/assets/coverimage-stream.png
-- Up-to-date: /usr/share/mympd/htdocs/assets/coverimage-notavailable.png
-- Up-to-date: /usr/share/mympd/htdocs/assets/coverimage-loading.png
-- Up-to-date: /usr/share/mympd/htdocs/assets/appicon-512.png
-- Up-to-date: /usr/share/mympd/htdocs/assets/appicon-192.png
-- Up-to-date: /usr/share/mympd/htdocs/assets/appicon-167.png
-- Up-to-date: /usr/share/mympd/htdocs/assets/MaterialIcons-Regular.woff2
-- Up-to-date: /var/lib/mympd/pics
-- Up-to-date: /var/lib/mympd/state
-- Up-to-date: /var/lib/mympd/covercache
-- Up-to-date: /var/lib/mympd/smartpls
-- Installing: /var/lib/mympd/smartpls/myMPDsmart-newestSongs.dist
-- Installing: /var/lib/mympd/smartpls/myMPDsmart-mostPlayed.dist
-- Installing: /var/lib/mympd/smartpls/myMPDsmart-bestRated.dist
Checking status of mympd system user and group
Installing systemd service
DEBUG: Source = /usr/share/mympd/mympd.service
Failed to enable unit: File mympd.service: No such file or directory
mympd.conf installed as mympd.conf.dist
Fixing ownership of /var/lib/mympd
Certificates already created
myMPD installed
Edit /etc/mympd/mympd.conf before starting myMPD
root@VM-Stretch:/tmp/myMPD-master# l /usr/lib/systemd/system/
total 0
root@VM-Stretch:/tmp/myMPD-master# l /usr/share/mympd/
total 16
-rwxr-xr-x 1 root root 2004 May 24 00:48 crcert.sh
drwxr-xr-x 5 root root 4096 Jun  2 17:16 htdocs
drwxr-xr-x 2 root root 4096 Jun  2 17:16 lib
-rw-r--r-- 1 root root  195 May 24 00:48 mympd.service
root@VM-Stretch:/tmp/myMPD-master# [ /usr/share/mympd/mympd.service -nt /usr/lib/systemd/system/mympd.service ] && echo 'Sourse IS newer than non-existent destination!'
Sourse IS newer than non-existent destination!

Additional context Same behavior on fresh install. As can be seen above I added some debug echo to verify that the variables are set correctly:

cat debian/postinst
...
if [ -d /etc/systemd ]
then
  echo "Installing systemd service"
  [ -d /usr/lib/systemd/system ] || mkdir -p /usr/lib/systemd/system
  echo "DEBUG: Source = ${SHAREDIR}/mympd.service"
  if [ ${SHAREDIR}/mympd.service -nt /usr/lib/systemd/system/mympd.service ]
  then
    echo 'DEBUG: Source newer than destination'
    cp ${SHAREDIR}/mympd.service /usr/lib/systemd/system/
    systemctl daemon-reload
  fi
  systemctl enable mympd
fi
...
MichaIng commented 5 years ago

Resolved with: https://github.com/jcorporation/myMPD/pull/125

MichaIng commented 5 years ago

Btw bug was introduced with: https://github.com/jcorporation/myMPD/commit/d3ee3bc6df6b225ba8da489d94c2a483a2af4ca1#diff-07e2cd25f7da0550504d107fb2cae5be #/bin/bash => #/bin/sh

Switching to bourne shell makes generally sense but it has to be taken care about slightly different behaviour 😉.

jcorporation commented 5 years ago

I merged your pull request. Thanks for your investigation.