File: dr_init

package info (click to toggle)
draai 20260114-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,148 kB
  • sloc: sh: 952; perl: 415; makefile: 30
file content (75 lines) | stat: -rwxr-xr-x 1,936 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh

# This file is maintained at http://git.mdcc.cx/draai

# Copyright: © 2021, 2025 Joost van Baal-Ilić
# This script is in the public domain.

#
# running mpd as a user (not as a system daemon) with minimal configuration,
#   and starting draai
#
# alternatively, one can achieve this using systemd.
# see also /usr/share/doc/mpd/README.Debian.
#

# FIXME
# exit with error in case mpd.conf does not define an audio_output like:
#
# cat <<EOT >>/etc/mpd.conf
# audio_output {
#        type            "pulse"
#        name            "My Pulse Output"
# }
# EOT

if test ! -e $HOME/.mpdconf
then
    if grep -v '^#' /etc/mpd.conf | grep user
    then
        cat >&2 <<EOT
/etc/mpd.conf specifies the user MPD will run as.  Do not use this option if
you start MPD as an unprivileged user.  Please comment out the line starting
with 'user' and rerun this script.
EOT
        exit 1
    fi

    ln -s /etc/mpd.conf $HOME/.mpdconf
fi

#drwxrwxr-x 5 mpd     audio    4096 31. окт. у 21:33 /var/lib/mpd/
#drwxr-xr-x 2 root    root     4096  3. јун. у 01:48 /var/lib/mpd/music/
#drwxr-xr-x 2 mpd     audio    4096  3. јун. у 01:48 /var/lib/mpd/playlists/
#-rw-r--r-- 1 joostvb joostvb  1484 31. окт. у 21:33 /var/lib/mpd/state
#-rw-r--r-- 1 mpd     audio   12288 21. јул. у 16:21 /var/lib/mpd/sticker.sql
#-rw-r--r-- 1 mpd     audio     242 21. јул. у 16:21 /var/lib/mpd/tag_cache


#
# _very_ crude hack: we use sudo in order to bang permissions into our
# preferences
#

echo >&2 dr_init: warning: chmod-ing /var/lib/mpd and /run/mpd/

test -w /var/lib/mpd || sudo chmod g+w /var/lib/mpd
for f in state sticker.sql tag_cache
do
     test -w /var/lib/mpd/$f || rm /var/lib/mpd/$f
done
# FIXME might also want to deal with music/ and playlists/ here

sudo chmod g+w /run/mpd/
( mpd --no-daemon --stderr 2>&1 | logger ) &



# hack
sleep 2

# joostvb preferences
mpc consume
mpc crossfade 2

exec draai init