V.A.M.P. how to create & source code

01) Pre install

apt-get update
apt-get install sqlite3 php5-fpm php5-curl php5-sqlite php5-cli git-core nginx-common nginx-light nginx sudo
apt-get install systemd-sysv ethtool
apt-get install net-tools dos2unix
apt-get install ntfs-3g ntfs-config openrc

if errors

#/etc/nginx/sites-available/default
# удалить стоку listen [::]:80 default_server;

apt-get install gcc automake libtool flex bison gdb dh-make

apt-get install g++ \
libmad0-dev libmpg123-dev libid3tag0-dev \
libflac-dev libvorbis-dev libopus-dev \
libadplug-dev libaudiofile-dev libsndfile1-dev libfaad-dev \
libfluidsynth-dev libgme-dev libmikmod2-dev libmodplug-dev \
libmpcdec-dev libwavpack-dev libwildmidi-dev \
libsidplay2-dev libsidutils-dev libresid-builder-dev \
libavcodec-dev libavformat-dev \
libmp3lame-dev libtwolame-dev libshine-dev \
libsamplerate0-dev libsoxr-dev \
libbz2-dev libcdio-paranoia-dev libiso9660-dev libmms-dev \
libzzip-dev \
libcurl4-gnutls-dev libyajl-dev libexpat-dev \
libasound2-dev libao-dev libjack-jackd2-dev libopenal-dev \
libpulse-dev libroar-dev libshout3-dev \
libsndio-dev \
libmpdclient-dev \
libnfs-dev libsmbclient-dev \
libupnp-dev \
libavahi-client-dev \
libsqlite3-dev \
libsystemd-dev libwrap0-dev \
libcppunit-dev xmlto \
libboost-dev \
libicu-dev

apt-get install  mpd mpg123 libshairport2 libshairport-dev

02) Users and sudo

adduser volumio
sudo adduser volumio sudo
# su - volumio
sudo adduser www-data sudo
# su - www-data

in sudoers add
# User privilege specification
root ALL=(ALL:ALL) ALL
www-data ALL=(ALL:ALL) ALL
volumio ALL=(ALL:ALL) ALL
Defaults:www-data !authenticate

03) dsd in kernel

wget http://ftp.us.debian.org/debian/pool/main/l/linux/linux-libc-dev_4.9.25-1_armhf.deb
dpkg -i linux-libc-dev_4.9.25-1_armhf.deb
check
cat /usr/include/sound/asound.h | grep DSD
#define SNDRV_PCM_FORMAT_DSD_U8 ((snd_pcm_format_t) 48) /* DSD, 1-byte samples DSD (x8) */
#define SNDRV_PCM_FORMAT_DSD_U16_LE ((snd_pcm_format_t) 49) /* DSD, 2-byte samples DSD (x16), little endian */
#define SNDRV_PCM_FORMAT_DSD_U32_LE ((snd_pcm_format_t) 50) /* DSD, 4-byte samples DSD (x32), little endian */
#define SNDRV_PCM_FORMAT_DSD_U16_BE ((snd_pcm_format_t) 51) /* DSD, 2-byte samples DSD (x16), big endian */
#define SNDRV_PCM_FORMAT_DSD_U32_BE ((snd_pcm_format_t) 52) /* DSD, 4-byte samples DSD (x32), big endian */
#define SNDRV_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_DSD_U32_BE

04) samba

apt-get install samba samba-common-bin cifs-utils autofs libexif12 minidlna djmount

05) alsa

#Change repo
#from
deb http://ftp.ua.debian.org/debian/ jessie main
deb-src http://ftp.ua.debian.org/debian/ jessie main

deb http://security.debian.org/ jessie/updates main
deb-src http://security.debian.org/ jessie/updates main

# jessie-updates, previously known as 'volatile'
deb http://ftp.ua.debian.org/debian/ jessie-updates main
deb-src http://ftp.ua.debian.org/debian/ jessie-updates main

#to

deb http://ftp.ua.debian.org/debian testing main non-free
deb-src http://ftp.ua.debian.org/debian testing main non-free

deb http://ftp.debian.org/debian/ jessie-updates main non-free
deb-src http://ftp.debian.org/debian/ jessie-updates main non-free

deb http://security.debian.org/ jessie/updates main non-free
deb-src http://security.debian.org/ jessie/updates main non-free

apt-get update
apt-get install libasound2 alsa-tools

grep VERSION_STR /usr/include/alsa/version.h

root@bananapipro:~# grep VERSION_STR /usr/include/alsa/version.h
#define SND_LIB_VERSION_STR "1.1.0"

apt-cache show libasound2
Package: libasound2
Status: install ok installed
Priority: optional
Section: libs
Installed-Size: 800
Maintainer: Debian ALSA Maintainers <pkg-alsa-devel@lists.alioth.debian.org>
Architecture: armhf
Multi-Arch: same
Source: alsa-lib
Version: 1.1.0-1

06)Compile MPD (for  ver 19.*)

wget http://www.musicpd.org/download/mpd/stable/mpd-0.19.14.tar.xz
tar xvJf mpd-0.19.14.tar.xz
cd mpd-0.19.14/
wget https://raw.githubusercontent.com/lintweaker/mpd-dsd-019/master/0001-Add-native-DSD-support-to-MPD-0.19.14.patch
patch -p1 < 0001-Add-native-DSD-support-to-MPD-0.19.14.patch
sh autogen.sh
./configure --enable-alsa --enable-id3 --enable-sqlite --enable-audiofile --enable-flac --enable-cdio-paranoia --enable-lsr --disable-oss --disable-pulse --disable-jack --disable-ipv6 --disable-openal --disable-roar --disable-shout --disable-inotify --disable-bzip2 --disable-nfs
make -j3
systemctl stop mpd.socket && /etc/init.d/mpd stop && mv /usr/bin/mpd /usr/bin/mpd_old
make install
nano /etc/init.d/mpd
DAEMON=/usr/local/bin/mpd
chmod 777 /etc/init.d/mpd
strip /usr/local/bin/mpd
ln -s /usr/local/bin/mpd /usr/bin/mpd
ln -s /etc/mpd.conf /usr/local/etc/mpd.conf (важно для последних патчей)
/etc/init.d/mpd start
/etc/init.d/php5-fpm restart
Check 
mpd --version

07) Compile volumio
sudo rm -R /var/www
sudo git clone https://github.com/volumio/Volumio-WebUI.git /var/www
sudo chmod -R 777 /var/www/
sudo mkdir /mnt/NAS
sudo mkdir /mnt/USB
mkdir /mnt/UPNP
sudo chmod -R 777 /mnt/NAS
sudo chmod -R 777 /mnt/USB
sudo chmod -R 777 /mnt/UPNP
cd /var/lib/mpd/music
sudo ln -s /mnt/NAS /var/lib/mpd/music/NAS
sudo ln -s /mnt/USB /var/lib/mpd/music/USB
sudo ln -s /mnt/UPNP /var/lib/mpd/music/UPNP
chmod -R 777 /var/lib/mpd/
chmod -R 777 /mnt/
mkdir /var/lib/mpd/music/WEBRADIO
chmod 777 -R /var/lib/mpd/music/WEBRADIO

#remove boot
sudo rm -R /var/www/_OS_SETTINGS/boot
sudo cp -var /var/www/_OS_SETTINGS/etc /
sudo cp -var /var/www/_OS_SETTINGS/home /

service nginx restart && service php5-fpm restart

08)Tweaks
#Buttons, mpc
apt-get install mpc acpi-support-base

nano /etc/acpi/powerbtn-acpi-support.sh
/sbin/shutdown -hP now "Power button pressed"
chmod +x /etc/acpi/powerbtn-acpi-support.sh

nano /etc/acpi/events/powerbtn-acpi-support
event=button/power
action=/etc/acpi/powerbtn-acpi-support.sh

#Ban codec
nano /etc/modprobe.d/fbdev-blacklist.conf
blacklist sun4i_codec

#Swap
swapoff -a

09) Change host
cd /etc
chmod 777 hosts
chmod 777 hostname

09) Boot
apt-get install sysv-rc-conf
Удаляю блютуз
q - exit

 

10)shairport
git clone https://github.com/albertz/shairport.git shairport
cd shairport
make
make install
apt-get install shairport-sync

10.1)upmpdcli
/etc/apt/sources.list.d/upmpdcli.list and add the following lines:

deb http://www.lesbonscomptes.com/upmpdcli/downloads/debian/ unstable main
deb-src http://www.lesbonscomptes.com/upmpdcli/downloads/debian/ unstable main
apt-get update
apt-get install upmpdcli
chmod 777 dhclient.conf minidlna.conf upmpdcli.conf fake-hwclock.data resolv.conf mpd.conf sysctl.conf

del swap /var
chmod 755 /var/cache/samba/msg

11) cue
/var/www/inc/player_lib.php
if ($fileext == 'm3u' OR $fileext == 'cue' OR $fileext == 'pls' OR strpos($path, '/') === false) {

12) poweroff

systemctl enable mpd.service
/etc/init.d/autofs stop
mkdir disk_01 disk_02 disk_03 disk_04 disk_05 disk_06 disk_07 disk_08 disk_09
chmod -R 777 disk_01 disk_02 disk_03 disk_04 disk_05 disk_06 disk_07 disk_08 disk_09

ln -s .autofs/cdrom cdrom
# ln -s .autofs/floppy floppy
# ln -s .autofs/usb1 usb1
# ln -s .autofs/usb2 usb2
# ln -s .autofs/usb3 usb3
# ln -s .autofs/usb4 usb4

disk_02 -fstype=auto,umask=000 :/dev/sdb2
disk_03 -fstype=auto,umask=000 :/dev/sdb3
disk_04 -fstype=auto,umask=000 :/dev/sdc1
disk_05 -fstype=auto,umask=000 :/dev/sdc2
disk_06 -fstype=auto,umask=000 :/dev/sdc3
disk_07 -fstype=auto,umask=000 :/dev/sdd1
disk_08 -fstype=auto,umask=000 :/dev/sdd2
disk_09 -fstype=auto,umask=000 :/dev/sdd3

echo "Installing Upmpdcli"
wget http://repo.volumio.org/Packages/Upmpdcli/arm/upmpdcli_1.1.3-1_armhf.deb
wget http://repo.volumio.org/Packages/Upmpdcli/arm/libupnpp2_0.14.1-1_armhf.deb
wget http://repo.volumio.org/Packages/Upmpdcli/arm/libupnp6_1.6.19.jfd3-1_armhf.deb
dpkg -i libupnpp2_0.14.1-1_armhf.deb
dpkg -i libupnp6_1.6.19.jfd3-1_armhf.deb
dpkg -i upmpdcli_1.1.3-1_armhf.deb
rm /upmpdcli_1.1.3-1_armhf.deb
rm /libupnp6_1.6.19.jfd3-1_armhf.deb
rm /libupnpp2_0.14.1-1_armhf.deb

apt-get install upmpdcli libupnpp4 libupnp6 ( for v.a.mp pc)

chown -R volumio:volumio /volumio
chown volumio:volumio /etc/os-release
chmod 777 /etc/os-release

echo "volumio ALL=(ALL) NOPASSWD: /sbin/poweroff,/sbin/shutdown,/sbin/reboot,/sbin/halt,/bin/systemctl,/usr/bin/apt-get,/usr/sbin/update-rc.d,/usr/bin/gpio,/bin/mount,/bin/umount/,/sbin/iwconfig,/sbin/iwlist,/sbin/ifconfig,/usr/bin/killall,/bin/ip,/usr/sbin/service,/etc/init.d/netplug,/bin/journalctl,/bin/chmod,/sbin/ethtool,/usr/sbin/alsactl" >> /etc/sudoers

update-rc.d mpd remove
systemctl enable mpd.service

usermod -a -G audio volumio
usermod -a -G audio mpd

wget http://repo.volumio.org/Volumio2/Binaries/shairport-sync_arm.tar.gz
tar xf shairport-sync_arm.tar.gz
(copy to player)

for vamp pc
rm /usr/local/bin/shairport-sync
touch /usr/local/bin/shairport-sync
ln -s /usr/bin/shairport-sync /usr/local/bin/shairport-sync

echo "Disabling IPV6"
echo "#disable ipv6" | tee -a /etc/sysctl.conf
echo "net.ipv6.conf.all.disable_ipv6 = 1" | tee -a /etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" | tee -a /etc/sysctl.conf
echo "net.ipv6.conf.lo.disable_ipv6 = 1" | tee -a /etc/sysctl.conf

https://github.com/volumio/Build/blob/master/scripts/volumioconfig.sh

echo "Setting RT Priority to Audio Group"
echo '@audio - rtprio 99
@audio - memlock unlimited' >> /etc/security/limits.conf

echo "Tuning LAN"
echo 'fs.inotify.max_user_watches = 524288' >> /etc/sysctl.conf

rc-update add autofs default
touch /usr/bin/minidlnad
ln -s /usr/sbin/minidlnad /usr/bin/minidlnad

GRUB_CMDLINE_LINUX_DEFAULT="quiet clocksource=hpet threadirqs"
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
sudo grub-mkconfig -o /boot/grub/grub.cfg

apt-get install rtirq-init
https://habrahabr.ru/company/xakep/blog/203598/
http://forum.ixbt.com/topic.cgi?id=76:11338:18#18 - тест латенси

policy: fifo: loadavg: 0.88 0.53 0.26 1/241 2746

T: 0 ( 2691) P:99 I:1000 C: 134042 Min: 5 Act: 259 Avg: 573 Max: 2058623
T: 1 ( 2692) P:99 I:1500 C: 92397 Min: 5 Act: 405 Avg: 700 Max: 61170
T: 2 ( 2693) P:99 I:2000 C: 70261 Min: 4 Act:43863 Avg: 808 Max: 1431333
T: 3 ( 2694) P:99 I:2500 C: 56622 Min: 4 Act: 286 Avg: 917 Max: 190748
sudo ./cyclictest -a -t -n -p99

 

delllogs bash

#!/bin/bash
cd /var/log/
for file in /var/log/lastlog /var/log/syslog /var/log/kern.log /var/log/dmesg /var/log/dpkg.log /var/log/php5-fpm.log /var/log/php_errors.log /var/log/messages /var/log/daemon.log /var/log/utmp /var/log/wtmp /var/log/mpd/mpd.log /var/log/nginx/access.log /var/log/nginx/error.log /var/log/nginx/db.log /var/log/nginx/command.log /var/log/mpd/mpd.log /var/log/samba/log.smbd /var/log/samba/log.nmbd /var/log/auth.log ; do
unlink $file
ln -s /dev/null $file
done

kernel update

apt-get update
apt-get install libncurses-dev
apt-get install kernel-package
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.18.7.tar.xz
tar -xpJf linux-4.18.7.tar.xz
ln -s linux-4.18.7 linux
cd linux
wget https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/4.18/patch-4.18.7-rt5.patch.gz
gzip -d patch-4.18.7-rt5.patch.gz
patch -p1 < patch-4.18.7-rt5.patch
make oldconfig
make-kpkg clean
make menuconfig
CONCURENCY_LEVEL=5 fakeroot make-kpkg --initrd --revision=00 kernel_image kernel_headers

 

https://github.com/norrest/volumio.git

http://digitall.in.ua/mpd.tar.bz2

install mpd new (ver 0.20.*)

apt-get update
apt-get install automake
apt-get -y --force-yes install libupnp-dev
wget http://www.musicpd.org/download/mpd/0.20/mpd-0.20.19.tar.xz
tar xvJf mpd-0.20.19.tar.xz
cd mpd-0.20.19
patch -p1 < mpd-0.20.18-rtopt20180414.patch
autoreconf -f
./configure --enable-rtopt --enable-alsa --enable-id3 --enable-sqlite --enable-audiofile --enable-flac --enable-cdio-paranoia --enable-lsr --disable-oss --disable-pulse --disable-jack --disable-ipv6 --disable-openal --disable-roar --disable-shout --disable-inotify --disable-bzip2 --disable-nfs --disable-sndio
make -j3
systemctl stop mpd.socket && /etc/init.d/mpd stop && mv /usr/bin/mpd /usr/bin/mpd_old && systemctl stop mpd.socket

tar -cvjf mpd-0.20.15.tar.bz2 *

 

#apt-get update
apt-get -y --force-yes install libupnp-dev
------------------------------ For 0.19 с DSD native
sqlite3 /var/www/db/player.db 'delete from cfg_mpd where id = 83'
sqlite3 /var/www/db/player.db 'delete from cfg_mpd where id = 84'
sqlite3 /var/www/db/player.db 'delete from cfg_mpd where id = 85'
sqlite3 /var/www/db/player.db 'delete from cfg_mpd where id = 48'
sqlite3 /var/www/db/player.db 'update cfg_mpd set id = "84" where id = "86"'
sqlite3 /var/www/db/player.db "INSERT INTO "cfg_mpd" VALUES(83,'optional_alsa_output_parameters','priority','__FIFO from 80 to 99__','Set the priority of audio output','FIFO:90','FIFO:90','')"
------------------------------ For 0.19 с DSD native + RTIME
sqlite3 /var/www/db/player.db 'delete from cfg_mpd where id = 83'
sqlite3 /var/www/db/player.db 'delete from cfg_mpd where id = 84'
sqlite3 /var/www/db/player.db 'delete from cfg_mpd where id = 85'
sqlite3 /var/www/db/player.db 'delete from cfg_mpd where id = 86'
sqlite3 /var/www/db/player.db 'update cfg_mpd set id = "84" where id = "87"'
sqlite3 /var/www/db/player.db "INSERT INTO "cfg_mpd" VALUES(83,'optional_alsa_output_parameters','priority','__FIFO from 80 to 99__','Set the priority of audio output','FIFO:90','FIFO:90','')"

mkdir mpd-0.20.6
tar -xvf mpd-0.20.6.tar.gz -C ./mpd-0.20.6
cd ./mpd-0.20.6
systemctl stop mpd.socket && /etc/init.d/mpd stop && mv /usr/bin/mpd /usr/bin/mpd_old && systemctl stop mpd.socket

#autoreconf -f -i
#./configure --enable-rtopt --enable-alsa --enable-id3 --enable-sqlite --enable-audiofile --enable-flac --enable-cdio-paranoia --enable-lsr --disable-oss --disable-pulse --disable-jack --disable-ipv6 --disable-openal --disable-roar --disable-shout --disable-inotify --disable-bzip2 --disable-nfs
#make -j3
make install
chmod 777 /etc/init.d/mpd
strip /usr/local/bin/mpd
ln -s /usr/local/bin/mpd /usr/bin/mpd
cd ..
mkdir db
tar -xvf db.tar -C ./db
sudo cp -pfR ./db/var /
sudo cp -pfR ./db/etc /
chmod -R 777 /var/www
chmod 777 /etc/mpd.conf
mpd -V

 

shairport

#! /bin/sh
apt-get -y install avahi-daemon avahi-autoipd libnss-mdns avahi-utils libconfig-dev
ln -s /usr/local/bin/shairport-sync /usr/bin/shairport-sync
getent group shairport-sync &>/dev/null || sudo groupadd -r shairport-sync >/dev/null
getent passwd shairport-sync &> /dev/null || sudo useradd -r -M -g shairport-sync -s /usr/bin/nologin -G audio shairport-sync >/dev/null
sudo chmod 777 /usr/local/bin/shairport-sync
sudo chmod 777 /etc/shairport-sync.conf

sound stat and usb

#! /bin/sh
print «Content-Type: text/html\n\n«;
cat /proc/asound/* | grep USB
cat /proc/asound/* | grep speed
cat /proc/asound/card*/* | grep Status
cat /proc/asound/card*/pcm*p/* | grep id
cat /proc/asound/card*/pcm*p/sub*/* | grep access
cat /proc/asound/card*/pcm*p/sub*/* | grep DSD
cat /proc/asound/card*/pcm*p/sub*/* | grep state
cat /proc/asound/card*/pcm*p/sub*/* | grep rate
echo «MPD STATUS:«
service mpd status | grep Ac
echo «USB DEVICES:«
lsusb | grep -v Linux

fix bug for lan lost and remove video

sed -i 's/disp.screen0_output_mode=1920x1080p60/monitor=none net.ifnames=0 biosdevname=0/' /boot/boot.cmd
mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr

more space for hdd

sudo tune2fs -m 0 /dev/sda1