Install vlc as a daemon.
This commit is contained in:
parent
35f93ccba1
commit
3cfbef44ac
|
@ -10,3 +10,4 @@ automake
|
|||
libtool
|
||||
libasound2-dev
|
||||
libfftw3-dev
|
||||
vlc-nox
|
||||
|
|
|
@ -6,3 +6,7 @@ install -v -m 644 files/default.pa "${ROOTFS_DIR}/etc/pulse/"
|
|||
|
||||
cp -rf files/pivumeter "${ROOTFS_DIR}/root/"
|
||||
install -v -m 644 files/pivumeter/dependencies/etc/asound.conf "${ROOTFS_DIR}/etc/"
|
||||
install -v -m 755 files/vlcd "${ROOTFS_DIR}/etc/init.d/"
|
||||
install -v -m 755 files/bin/vlcd "${ROOTFS_DIR}/usr/bin/"
|
||||
mkdir "${ROOTFS_DIR}/etc/vlcd"
|
||||
install -v -m 644 files/default.m3u "${ROOTFS_DIR}/etc/vlcd/"
|
||||
|
|
|
@ -7,3 +7,5 @@ aclocal && libtoolize
|
|||
autoconf && automake --add-missing
|
||||
./configure && make
|
||||
make install
|
||||
systemctl daemon-reload
|
||||
systemctl enable vlcd
|
||||
|
|
51
stage2/04-pirate-radio/files/bin/vlcd
Executable file
51
stage2/04-pirate-radio/files/bin/vlcd
Executable file
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
sudo mkdir -p /var/run/vlcd
|
||||
|
||||
if [ -n $(cat /etc/passwd | grep -w "pi:") ]; then
|
||||
sudo chown pi:pi /var/run/vlcd
|
||||
if [ -f /boot/playlist.m3u ]; then
|
||||
mkdir -p /home/pi/.config/vlc
|
||||
sudo mv -f /boot/playlist.m3u /home/pi/.config/vlc/
|
||||
sudo chmod -R pi:pi /home/pi/.config/vlc/
|
||||
fi
|
||||
if [ -f /home/pi/.config/vlc/playlist.m3u ]; then
|
||||
playlist="/home/pi/.config/vlc/playlist.m3u"
|
||||
else
|
||||
playlist="/etc/vlcd/default.m3u"
|
||||
fi
|
||||
else
|
||||
playlist="/etc/vlcd/default.m3u"
|
||||
fi
|
||||
|
||||
volpref=$(grep "^alsa-gain" ~/.config/vlc/vlcrc)
|
||||
|
||||
if [ -z $volpref ]; then
|
||||
volpref="alsa-gain 0.065"
|
||||
fi
|
||||
|
||||
/usr/bin/vlc \
|
||||
--verbose 1 \
|
||||
--file-logging \
|
||||
--logfile /var/run/vlcd/vlcd.log \
|
||||
--$volpref \
|
||||
--audio-filter compressor,volnorm \
|
||||
--norm-buff-size 10 \
|
||||
--norm-max-level 80.0 \
|
||||
--norm-max-level -3 \
|
||||
--compressor-attack 50.0 \
|
||||
--compressor-release 200.0 \
|
||||
--compressor-ratio 20.0 \
|
||||
--compressor-threshold 0.0 \
|
||||
--compressor-rms-peak 0.0 \
|
||||
--compressor-knee 1.0 \
|
||||
--compressor-makeup-gain 0.0 \
|
||||
--intf dummy \
|
||||
--extraintf rc:http \
|
||||
--rc-host 0.0.0.0:9294 --rc-fake-tty \
|
||||
--http-host 0.0.0.0 --http-port 8080 --http-password raspberry \
|
||||
--no-quiet \
|
||||
--daemon \
|
||||
--pidfile /var/run/vlcd/vlcd.pid \
|
||||
$playlist
|
||||
|
14
stage2/04-pirate-radio/files/default.m3u
Normal file
14
stage2/04-pirate-radio/files/default.m3u
Normal file
|
@ -0,0 +1,14 @@
|
|||
http://relay4.slayradio.org:8200/
|
||||
http://allstream.rainwave.cc:8000/all.mp3
|
||||
http://tx.sharp-stream.com/icecast.php?i=planetrock.mp3
|
||||
http://s1.viastreaming.net:8000
|
||||
http://sc6.radiocaroline.net:8040/listen.pls
|
||||
http://sc6.radiocaroline.net:10558/listen.pls
|
||||
http://www.listenlive.eu/bbcradio2.m3u
|
||||
http://www.listenlive.eu/bbcradio4.m3u
|
||||
http://listen.181fm.com/181-uktop40_128k.mp3
|
||||
http://listen.181fm.com/181-90scountry_128k.mp3
|
||||
http://listen.181fm.com/181-oldschool_128k.mp3
|
||||
http://listen.181fm.com/181-90sdance_128k.mp3
|
||||
http://listen.181fm.com/181-chilled_128k.mp3
|
||||
http://listen.181fm.com/181-classical_128k.mp3
|
108
stage2/04-pirate-radio/files/vlcd
Executable file
108
stage2/04-pirate-radio/files/vlcd
Executable file
|
@ -0,0 +1,108 @@
|
|||
#! /bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: vlcd
|
||||
# Required-Start: $remote_fs $syslog
|
||||
# Required-Stop: $remote_fs $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Starts VLC daemon at boot time
|
||||
# Description: Manages the VLC daemon
|
||||
### END INIT INFO
|
||||
|
||||
# Do NOT "set -e"
|
||||
|
||||
# PATH should only include /usr/* if it runs after the mountnfs.sh script
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
DESC="VLC Daemon"
|
||||
NAME=vlcd
|
||||
DAEMON=/usr/bin/$NAME
|
||||
PIDFILE=/var/run/$NAME/$NAME.pid
|
||||
SCRIPTNAME=/etc/init.d/$NAME
|
||||
|
||||
# Exit if the package is not installed
|
||||
[ -x "$DAEMON" ] || exit 0
|
||||
|
||||
# Read configuration variable file if it is present
|
||||
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
||||
|
||||
# Load the VERBOSE setting and other rcS variables
|
||||
. /lib/init/vars.sh
|
||||
|
||||
# Define LSB log_* functions.
|
||||
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
|
||||
# and status_of_proc is working.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
#
|
||||
# Function that starts the daemon/service
|
||||
#
|
||||
do_start()
|
||||
{
|
||||
if [ -f "$PIDFILE" ] && kill -0 $(cat "$PIDFILE"); then
|
||||
echo 'Service already running' >&2
|
||||
return 1
|
||||
fi
|
||||
echo 'Starting...' >&2
|
||||
su -c "$DAEMON" pi
|
||||
}
|
||||
|
||||
#
|
||||
# Function that stops the daemon/service
|
||||
#
|
||||
do_stop()
|
||||
{
|
||||
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
|
||||
echo 'Service not running' >&2
|
||||
return 1
|
||||
fi
|
||||
echo 'Stopping...' >&2
|
||||
kill $(cat "$PIDFILE")
|
||||
echo 'Service stopped!' >&2
|
||||
return 0
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
|
||||
do_start
|
||||
case "$?" in
|
||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
stop)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
status)
|
||||
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
|
||||
;;
|
||||
restart|force-reload)
|
||||
log_daemon_msg "Restarting $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1)
|
||||
do_start
|
||||
case "$?" in
|
||||
0) log_end_msg 0 ;;
|
||||
1) log_end_msg 1 ;; # Old process is still running
|
||||
*) log_end_msg 1 ;; # Failed to start
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
# Failed to stop
|
||||
log_end_msg 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
|
||||
:
|
Loading…
Reference in New Issue
Block a user