1
0
mirror of https://github.com/SuperBFG7/ympd synced 2024-11-05 22:36:16 +00:00
ympd/mkrelease.sh

90 lines
3.5 KiB
Bash
Raw Normal View History

#/bin/sh
java=$(which java 2> /dev/null)
if [ -f dist/buildtools/closure-compiler.jar ] && [ "$java" != "" ]
then
2018-07-11 00:01:04 +00:00
echo "Minifying javascript"
[ htdocs/js/player.js -nt dist/htdocs/js/player.min.js ] && \
java -jar dist/buildtools/closure-compiler.jar htdocs/js/player.js > dist/htdocs/js/player.min.js
[ htdocs/js/mympd.js -nt dist/htdocs/js/mympd.min.js ] && \
java -jar dist/buildtools/closure-compiler.jar htdocs/js/mympd.js > dist/htdocs/js/mympd.min.js
[ htdocs/sw.js -nt dist/htdocs/sw.min.js ] && \
java -jar dist/buildtools/closure-compiler.jar htdocs/sw.js > dist/htdocs/sw.min.js
2018-06-21 21:56:39 +00:00
else
2018-08-01 09:01:34 +00:00
echo "dist/buildtools/closure-compiler.jar not found, using non-minified files"
[ htdocs/js/player.js -nt dist/htdocs/js/player.min.js ] && \
cp htdocs/js/player.js dist/htdocs/js/player.min.js
[ htdocs/js/mympd.js -nt dist/htdocs/js/mympd.min.js ] && \
cp htdocs/js/mympd.js dist/htdocs/js/mympd.min.js
[ htdocs/sw.js -nt dist/htdocs/sw.min.js ] && \
cp htdocs/sw.js dist/htdocs/sw.min.js
fi
2018-07-11 00:01:04 +00:00
2018-07-31 16:15:08 +00:00
if [ -f dist/buildtools/closure-stylesheets.jar ] && [ "$java" != "" ]
2018-07-11 00:01:04 +00:00
then
echo "Minifying stylesheets"
[ htdocs/css/mympd.css -nt dist/htdocs/css/mympd.min.css ] && \
java -jar dist/buildtools/closure-stylesheets.jar --allow-unrecognized-properties htdocs/css/mympd.css > dist/htdocs/css/mympd.min.css
2018-06-21 21:56:39 +00:00
else
2018-08-01 09:01:34 +00:00
echo "dist/buildtools/closure-stylesheets.jar not found, using non-minified files"
[ htdocs/css/mympd.css -nt dist/htdocs/css/mympd.min.css ] && \
cp htdocs/css/mympd.css dist/htdocs/css/mympd.min.css
fi
echo "Replacing javascript and stylesheets with minified files"
sed -e 's/mympd\.css/mympd\.min\.css/' -e 's/mympd\.js/mympd\.min\.js/' htdocs/index.html > dist/htdocs/index.html
sed -e 's/mympd\.css/mympd\.min\.css/' -e 's/player\.js/player\.min\.js/' htdocs/player.html > dist/htdocs/player.html
sed -i -e 's/mympd\.css/mympd\.min\.css/' -e 's/mympd\.js/mympd\.min\.js/' -e 's/player\.js/player\.min\.js/' dist/htdocs/sw.min.js
sed -i -e 's/\/sw\.js/\/sw\.min\.js/' dist/htdocs/js/mympd.min.js
echo "Minifying html"
perl -i -pe 's/^\s*//gm; s/\s*$//gm' dist/htdocs/index.html
perl -i -pe 's/^\s*//gm; s/\s*$//gm' dist/htdocs/player.html
2018-07-11 00:01:04 +00:00
echo "Compiling and installing mympd"
[ -d release ] || mkdir release
cd release
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_BUILD_TYPE=RELEASE ..
make
sudo make install
cd ..
2018-07-11 00:01:04 +00:00
echo "Fixing ownership of /var/lib/mympd"
2018-09-04 20:07:30 +00:00
getent group mympd > /dev/null
2018-09-06 22:10:40 +00:00
[ "$?" = "2" ] && sudo groupadd mympd
2018-09-04 20:07:30 +00:00
getent passwd mympd > /dev/null
2018-09-06 22:10:40 +00:00
[ "$?" = "2" ] && sudo useradd mympd -g mympd
2018-09-04 20:07:30 +00:00
sudo chown -R mympd.mympd /var/lib/mympd
2018-07-11 00:01:04 +00:00
echo "Trying to link musicdir to library"
if [ -f /etc/mpd.conf ]
then
2018-09-04 19:36:04 +00:00
LIBRARY=$(sudo grep ^music_directory /etc/mpd.conf | awk {'print $2'} | sed -e 's/"//g')
2018-08-15 13:05:46 +00:00
[ "$LIBRARY" != "" ] && [ ! -e /usr/share/mympd/htdocs/library ] && sudo ln -s "$LIBRARY" /usr/share/mympd/htdocs/library
2018-07-11 00:01:04 +00:00
else
2018-08-21 22:02:22 +00:00
echo "/etc/mpd.conf not found, you must link your music_directory manually to /usr/share/mympd/htdocs/library"
2018-07-11 00:01:04 +00:00
fi
echo "Installing systemd service"
2018-09-04 19:36:04 +00:00
if [ -d /usr/lib/systemd/ ]
2018-07-11 00:01:04 +00:00
then
2018-09-04 19:36:04 +00:00
[ -d /usr/lib/systemd/system ] || sudo mkdir /usr/lib/systemd/system
if [ contrib/mympd.service -nt /usr/lib/systemd/system/mympd.service ]
2018-07-11 00:01:04 +00:00
then
2018-09-04 19:36:04 +00:00
sudo cp contrib/mympd.service /usr/lib/systemd/system/
2018-08-15 13:05:46 +00:00
sudo systemctl daemon-reload
2018-07-11 00:01:04 +00:00
fi
2018-08-15 13:05:46 +00:00
sudo systemctl enable mympd
2018-07-11 00:01:04 +00:00
fi
2018-07-11 00:01:04 +00:00
if [ -d /etc/mympd/ssl ]
then
echo "Certificates already created"
else
echo "Creating certificates"
2018-08-27 23:11:43 +00:00
sudo contrib/crcert.sh
2018-07-11 00:01:04 +00:00
fi
echo "myMPD installed"
2018-08-21 22:02:22 +00:00
echo "Edit /etc/mympd/mympd.conf before starting myMPD"