mirror of
https://github.com/SuperBFG7/ympd
synced 2024-12-27 03:10:26 +00:00
Dont run under uid 0
Optimize mkdebug.sh and mkrelease.sh
This commit is contained in:
parent
1f81588973
commit
7cff777d05
12
README.md
12
README.md
@ -31,13 +31,9 @@ Unix Build Instructions
|
||||
-----------------------
|
||||
|
||||
1. install dependencies. cmake and libmpdclient (dev) are available from all major distributions.
|
||||
2. create build directory ```cd /path/to/src; mkdir build; cd build```
|
||||
3. create makefile ```cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_BUILD_TYPE=RELEASE```
|
||||
4. build ```make```
|
||||
5. install ```sudo make install```
|
||||
6. change owner of /var/lib/mympd to user you will run mympd, default nobody (chown nobody /var/lib/mympd)
|
||||
7. Link your mpd music directory to ```/usr/share/mympd/htdocs/library``` and put ```folder.jpg``` files in your album directories
|
||||
8. Configure your mpd with http stream output to use the local player
|
||||
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
|
||||
|
||||
Run flags
|
||||
---------
|
||||
@ -46,7 +42,7 @@ Usage: ./mympd [OPTION]...
|
||||
|
||||
-h, --host <host> connect to mpd at host [localhost]
|
||||
-p, --port <port> connect to mpd at port [6600]
|
||||
-w, --webport [ip:]<port> listen interface/port for webserver [8080]
|
||||
-w, --webport <port> listen port for webserver [80]
|
||||
-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
|
||||
|
@ -1,4 +1,4 @@
|
||||
#/bin/bash
|
||||
#/bin/sh
|
||||
|
||||
[ -d debug ] || mkdir debug
|
||||
cd debug
|
||||
|
29
mkrelease.sh
29
mkrelease.sh
@ -1,4 +1,4 @@
|
||||
#/bin/bash
|
||||
#/bin/sh
|
||||
|
||||
if [ -f buildtools/closure-compiler.jar ]
|
||||
then
|
||||
@ -7,8 +7,10 @@ then
|
||||
[ htdocs/js/mpd.js -nt htdocs/js/mpd.min.js ] && \
|
||||
java -jar buildtools/closure-compiler.jar htdocs/js/mpd.js > htdocs/js/mpd.min.js
|
||||
else
|
||||
cp htdocs/js/player.js htdocs/js/player.min.js
|
||||
cp htdocs/js/mpd.js htdocs/js/mpd.min.js
|
||||
[ htdocs/js/player.js -nt htdocs/js/player.min.js ] && \
|
||||
cp htdocs/js/player.js htdocs/js/player.min.js
|
||||
[ htdocs/js/mpd.js -nt htdocs/js/mpd.min.js ] && \
|
||||
cp htdocs/js/mpd.js htdocs/js/mpd.min.js
|
||||
fi
|
||||
|
||||
if [ -f buildtools/closure-stylesheets.jar ]
|
||||
@ -16,13 +18,26 @@ then
|
||||
[ htdocs/css/mpd.css -nt htdocs/css/mpd.min.css ] && \
|
||||
java -jar buildtools/closure-stylesheets.jar htdocs/css/mpd.css > htdocs/css/mpd.min.css
|
||||
else
|
||||
cp htdocs/css/mpd.css htdocs/css/mpd.min.css
|
||||
[ htdocs/css/mpd.css -nt htdocs/css/mpd.min.css ] && \
|
||||
cp htdocs/css/mpd.css htdocs/css/mpd.min.css
|
||||
fi
|
||||
|
||||
[ -d release ] || mkdir release
|
||||
cd release
|
||||
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_BUILD_TYPE=RELEASE ..
|
||||
make
|
||||
make install
|
||||
sed -i -e 's/mpd\.css/mpd\.min\.css/' -e 's/mpd\.js/mpd\.min\.js/' /usr/share/mympd/htdocs/index.html
|
||||
sed -i -e 's/mpd\.css/mpd\.min\.css/' -e 's/player\.js/player\.min\.js/' /usr/share/mympd/htdocs/player.html
|
||||
sudo make install
|
||||
cd ..
|
||||
|
||||
sudo sed -i -e 's/mpd\.css/mpd\.min\.css/' -e 's/mpd\.js/mpd\.min\.js/' /usr/share/mympd/htdocs/index.html
|
||||
sudo sed -i -e 's/mpd\.css/mpd\.min\.css/' -e 's/player\.js/player\.min\.js/' /usr/share/mympd/htdocs/player.html
|
||||
|
||||
sudo chown nobody /var/lib/mympd
|
||||
|
||||
[ -d /etc/systemd/system ] && \
|
||||
sudo cp -v contrib/mympd.service /etc/systemd/system/
|
||||
|
||||
[ -d /etc/default ] && \
|
||||
sudo cp -v contrib/mympd.default /etc/default/mympd
|
||||
|
||||
echo "myMPD installed"
|
||||
|
@ -103,7 +103,7 @@ int main(int argc, char **argv)
|
||||
struct mg_connection *nc;
|
||||
unsigned int current_timer = 0, last_timer = 0;
|
||||
char *run_as_user = NULL;
|
||||
char *webport = "8080";
|
||||
char *webport = "80";
|
||||
mpd.port = 6600;
|
||||
strcpy(mpd.host, "127.0.0.1");
|
||||
streamport = 8000;
|
||||
@ -205,6 +205,11 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (getuid() == 0) {
|
||||
printf("myMPD should not be run with root privileges\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
mg_set_protocol_http_websocket(nc);
|
||||
s_http_server_opts.document_root = SRC_PATH;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user