Skip to content

Commit

Permalink
Merge pull request #21 from jcorporation/devel
Browse files Browse the repository at this point in the history
Enable PWA Feature
  • Loading branch information
jcorporation authored Jul 16, 2018
2 parents 8bac4ed + a84d83b commit f4640a9
Show file tree
Hide file tree
Showing 25 changed files with 599 additions and 260 deletions.
18 changes: 12 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ cmake_minimum_required(VERSION 2.6)
project (mympd C)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/")
set(CPACK_PACKAGE_VERSION_MAJOR "3")
set(CPACK_PACKAGE_VERSION_MINOR "1")
set(CPACK_PACKAGE_VERSION_PATCH "1")
set(CPACK_PACKAGE_VERSION_MINOR "2")
set(CPACK_PACKAGE_VERSION_PATCH "0")

if(CMAKE_BUILD_TYPE MATCHES RELEASE)
set(ASSETS_PATH "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/htdocs")
set(DEBUG "OFF")
else()
set(ASSETS_PATH "${PROJECT_SOURCE_DIR}/htdocs")
set(DEBUG "ON")
set(CS_NDEBUG "ON")
endif()

find_package(LibMPDClient REQUIRED)
Expand All @@ -23,9 +22,13 @@ include_directories(${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR} ${LIBMPDCLIENT_I

include(CheckCSourceCompiles)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -Wextra -pedantic -D MG_DISABLE_SSL -D MG_ENABLE_IPV6 -D MG_DISABLE_MQTT -D MG_DISABLE_MQTT_BROKER -D MG_DISABLE_DNS_SERVER -D MG_DISABLE_COAP -D MG_DISABLE_HTTP_CGI -D MG_DISABLE_HTTP_SSI -D MG_DISABLE_HTTP_WEBDAV")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -Wextra -pedantic -D MG_ENABLE_SSL -D MG_ENABLE_IPV6 -D MG_DISABLE_MQTT -D MG_DISABLE_MQTT_BROKER -D MG_DISABLE_DNS_SERVER -D MG_DISABLE_COAP -D MG_DISABLE_HTTP_CGI -D MG_DISABLE_HTTP_SSI -D MG_DISABLE_HTTP_WEBDAV")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb -D_FORTIFY_SOURCE=2 -fstack-protector -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fsanitize=shift -fsanitize=integer-divide-by-zero -fsanitize=unreachable -fsanitize=vla-bound -fsanitize=null -fsanitize=return -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=bounds-strict -fsanitize=alignment -fsanitize=object-size -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=nonnull-attribute -fsanitize=returns-nonnull-attribute -fsanitize=bool -fsanitize=enum -fsanitize=vptr -static-libasan")

find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS NS_ENABLE_SSL)

set(SOURCES
src/mympd.c
src/mpd_client.c
Expand All @@ -34,16 +37,19 @@ set(SOURCES
)

add_executable(mympd ${SOURCES})
target_link_libraries(mympd ${LIBMPDCLIENT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(mympd ${LIBMPDCLIENT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${OPENSSL_LIBRARIES})

install(TARGETS mympd DESTINATION bin)
install(FILES mympd.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1)
install(FILES contrib/mympd.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1)
install(FILES htdocs/mympd.webmanifest DESTINATION share/${PROJECT_NAME}/htdocs/)
install(FILES htdocs/index.html DESTINATION share/${PROJECT_NAME}/htdocs/)
install(FILES htdocs/player.html DESTINATION share/${PROJECT_NAME}/htdocs/)
install(FILES htdocs/sw.min.js DESTINATION share/${PROJECT_NAME}/htdocs/)
install(FILES htdocs/js/player.min.js DESTINATION share/${PROJECT_NAME}/htdocs/js/)
install(FILES htdocs/js/bootstrap-native-v4.min.js DESTINATION share/${PROJECT_NAME}/htdocs/js/)
install(FILES htdocs/js/mpd.min.js DESTINATION share/${PROJECT_NAME}/htdocs/js/)
install(FILES htdocs/css/bootstrap.min.css DESTINATION share/${PROJECT_NAME}/htdocs/css/)
install(FILES htdocs/css/mpd.min.css DESTINATION share/${PROJECT_NAME}/htdocs/css/)
install(DIRECTORY htdocs/assets DESTINATION share/${PROJECT_NAME}/htdocs)
install(DIRECTORY DESTINATION /var/lib/${PROJECT_NAME}/)
install(FILES contrib/options DESTINATION /etc/${PROJECT_NAME}/)
50 changes: 40 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
myMPD
====
=====

myMPD is a lightweight MPD web client that runs without a dedicated webserver or interpreter.
It's tuned for minimal resource usage and requires only very litte dependencies.
myMPD is a fork of ympd.
myMPD is a fork of ympd (https://github.com/notandy/ympd).

This fork provides a reworked ui based on Bootstrap 4 and a modernized backend.

Design principles:
- Keep it small and simple
- Uses only mpd as source of truth
- Mobile first UI
- Keep security in mind

Featurelist:
- Browse mpd database by artist
- Browse filesystem and playlists
- Queue management
- Advanced search
- Progressiv Web App enabled
- Local coverart support

myMPD is work in progress. Bugreportes and feature requests are very welcome. Please use the issues function from github (https://github.com/jcorporation/myMPD/issues).
Planed functions are managed in a github project (https://github.com/jcorporation/myMPD/projects/1).

![image](https://jcgames.de/stuff/myMPD/screenshots.gif)

UI Components
-------------
- Bootstrap 4: https://getbootstrap.com/
- Material Design Icons: https://material.io/tools/icons/?style=baseline
- Material Design Icons: https://material.io/tools/icons/
- Bootstrap Native: http://thednp.github.io/bootstrap.native/

Backend
Expand All @@ -24,32 +41,45 @@ Dependencies
------------
- libmpdclient 2: http://www.musicpd.org/libs/libmpdclient/
- cmake 2.6: http://cmake.org/
- OpenSSL: https://www.openssl.org/

Unix Build Instructions
-----------------------

1. install dependencies. cmake and libmpdclient (dev) are available from all major distributions.
2. build and install it ```cd /path/to/src; ./mkrelease.sh```
3. Link your mpd music directory to ```/usr/share/mympd/htdocs/library``` and put ```folder.jpg``` files in your album directories
4. Configure your mpd with http stream output to use the local player
1. Install dependencies: cmake, libmpdclient (dev) and OpenSSL (dev) are available from all major distributions.
2. Build and install: ```cd /path/to/src; ./mkrelease.sh```.
3. Link your mpd music directory to ```/usr/share/mympd/htdocs/library``` and put ```folder.jpg``` files in your album directories (mkrelease.sh tries to do this for you).
4. Configure your mpd with http stream output to use the local player.

Run flags
---------
```
Usage: ./mympd [OPTION]...
-h, --host <host> connect to mpd at host [localhost]
-p, --port <port> connect to mpd at port [6600]
-h, --mpdhost <host> connect to mpd at host [localhost]
-p, --mpdport <port> connect to mpd at port [6600]
-m, --mpdpass <password> specifies the password to use when connecting to mpd
-w, --webport <port> listen port for webserver [80]
-S, --ssl enable ssl
-W, --sslport <port> listen port for ssl webserver [443]
-C, --sslcert <filename> filename for ssl certificate [/etc/mympd/ssl/server.pem]
-K, --sslkey <filename> filename for ssl key [/etc/mympd/ssl/server.key]
-s, --streamport <port> connect to mpd http stream at port [8000]
-u, --user <username> drop priviliges to user after socket bind
-m, --mpdpass <password> specifies the password to use when connecting to mpd
-i, --coverimage <filename> filename for coverimage [folder.jpg]
-t, --statefile <filename> filename for mympd state [/var/lib/mympd/mympd.state]
-v, --version get version
--help this help
```

SSL
---

1. Create ca and certificate ```/path/to/src/contrib/crcert.sh``` (mkrelease.sh do this for you).
2. Start myMPD with ```-S``` (use default certificate under ```/etc/mympd/ssl/```).
3. Import ```/etc/mympd/ssl/ca/ca.pem``` in your browser to trust the certificate.
4. myMPD redirects http requests to https, ensure that myMPD hostname is resolvable.

Copyright
---------
ympd: 2013-2014 <[email protected]>
Expand Down
100 changes: 100 additions & 0 deletions contrib/crcert.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/bin/sh

if [ -d /etc/mympd/ssl ]
then
echo "SSL directory exists, to recreate certificates: \"rm -r /etc/mympd/ssl\""
exit 1
fi

mkdir -p /etc/mympd/ssl/ca/certs
cd /etc/mympd/ssl/ca

echo '01' > serial
touch index.txt
touch index.txt.attr

echo "Creating ca"

cat > ca.cnf << EOL
[req]
distinguished_name = root_ca_distinguished_name
x509_extensions = root_ca_extensions
prompt = no
[root_ca_distinguished_name]
O = myMPD
CN = myMPD_CA
[root_ca_extensions]
basicConstraints = CA:true
[ ca ]
default_ca = mympd_ca
[mympd_ca]
dir = /etc/mympd/ssl/ca
database = /etc/mympd/ssl/ca/index.txt
new_certs_dir = /etc/mympd/ssl/ca/certs/
serial = /etc/mympd/ssl/ca/serial
copy_extensions = copy
policy = local_ca_policy
x509_extensions = local_ca_extensions
default_md = sha256
[ local_ca_policy ]
commonName = supplied
organizationName = supplied
[ local_ca_extensions ]
basicConstraints = CA:false
EOL

openssl req -new -x509 -newkey rsa:2048 -sha256 -days 3650 -nodes -config ca.cnf \
-keyout ca.key -out ca.pem

HOSTNAME=$(hostname)
FQDN=$(hostname -f)
IP=$(getent hosts $HOSTNAME | awk {'print $1'})

cd /etc/mympd/ssl
echo "Creating cert:"
echo "\t$HOSTNAME"
echo "\t$FQDN"
echo "\t$IP"

cat > req.cnf << EOL
[req]
distinguished_name = req_distinguished_name
req_extensions = v3_req
prompt = no
[req_distinguished_name]
O = myMPD
CN = $FQDN
[v3_req]
basicConstraints = CA:FALSE
keyUsage = digitalSignature, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1 = $HOSTNAME
DNS.2 = $FQDN
DNS.3 = localhost
IP.1 = $IP
IP.2 = 127.0.0.1
EOL

openssl req -new -sha256 -newkey rsa:2048 -days 3650 -nodes -config req.cnf \
-keyout server.key -out server.csr \
-extensions v3_req

echo "Sign cert with ca"
openssl ca -in server.csr -cert ca/ca.pem -keyfile ca/ca.key -config ca/ca.cnf \
-out server.pem -days 3650 -batch

rm server.csr
rm ca/ca.cnf
rm req.cnf
24 changes: 18 additions & 6 deletions mympd.1 → contrib/mympd.1
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,36 @@ myMPD is a fork of ympd.

.SH OPTIONS
.TP
\fB\-h\fR, \fB\-\-host HOST\fR
\fB\-h\fR, \fB\-\-mpdhost HOST\fR
connect to mpd at host, defaults to localhost
.TP
\fB\-p\fR, \fB\-\-port PORT\fR
\fB\-p\fR, \fB\-\-mpdport PORT\fR
connect to mpd at port, defaults to 6600
.TP
\fB\-m\fR, \fB\-\-mpdpass PASSWORD\fR
specifies the password to use when connecting to mpd
.TP
\fB\-w\fR, \fB\-\-webport PORT\fR
specifies the port for the webserver to listen to, defaults to 8080
listen interface/port for webserver [80]
.TP
\fB\-S\fR, \fB\-\-ssl\fR
enable ssl
.TP
\fB\-W\fR, \fB\-\-sslport PORT\fR
listen interface/port for ssl webserver [443]
.TP
\fB\-C\fR, \fB\-\-sslcert FILENAME\fR
filename for ssl certificate [/etc/mympd/ssl/server.pem]
.TP
\fB\-K\fR, \fB\-\-sslkey FILENAME\fR
filename for ssl key [/etc/mympd/ssl/server.key]
.TP
\fB-s\fR, \fB\-\-streamport PORT
connect to mpd http stream at port [8000]
.TP
\fB\-u\fR, \fB\-\-user USERNAME\fR
drop privileges to the provided username after socket binding
.TP
\fB\-m\fR, \fB\-\-mpdpass PASSWORD\fR
specifies the password to use when connecting to mpd
.TP
\fB-i\fR, \fB\-\-coverimage FILENAME\fR
filename for coverimage [folder.jpg]
.TP
Expand Down
8 changes: 0 additions & 8 deletions contrib/mympd.default

This file was deleted.

11 changes: 2 additions & 9 deletions contrib/mympd.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,8 @@ Description=myMPD server daemon
Requires=network.target local-fs.target

[Service]
Environment=MPD_HOST=localhost
Environment=MPD_PORT=6600
Environment=MPD_PASSWORD=
Environment=WEB_PORT=80
Environment=MYMPD_USER=nobody
Environment=COVERIMAGE=--coverimage folder.jpg
Environment=STATEFILE=--statefile /var/lib/mympd/mympd.state
EnvironmentFile=/etc/default/mympd
ExecStart=/usr/bin/mympd --user $MYMPD_USER --webport $WEB_PORT --host $MPD_HOST --port $MPD_PORT $COVERIMAGE $STATEFILE
EnvironmentFile=/etc/mympd/options
ExecStart=/usr/bin/mympd --user $MYMPD_USER --webport $WEB_PORT --mpdhost $MPD_HOST --mpdport $MPD_PORT $MPD_PASSWORD $COVERIMAGE $STATEFILE $SSL
Type=simple

[Install]
Expand Down
9 changes: 9 additions & 0 deletions contrib/options
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#myMPD startup options
MPD_HOST=localhost
MPD_PORT=6600
#MPD_PASSWORD=--mpdpass PASSWORD
WEB_PORT=80
#SSL=-S -W 443 -C /etc/mympd/ssl/server.pem -K /etc/mympd/ssl/server.key
MYMPD_USER=nobody
COVERIMAGE=--coverimage folder.jpg
STATEFILE=--statefile /var/lib/mympd/mympd.state
Binary file added htdocs/assets/appicon-167.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added htdocs/assets/appicon-192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added htdocs/assets/appicon-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed htdocs/assets/appicon.png
Binary file not shown.
Binary file modified htdocs/assets/favicon.ico
Binary file not shown.
4 changes: 0 additions & 4 deletions htdocs/css/mpd.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ button {
min-width: 50px;
}

#search {
width: 200px;
}

.card {
min-height:350px;
}
Expand Down
2 changes: 1 addition & 1 deletion htdocs/css/mpd.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f4640a9

Please sign in to comment.