Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # pacman -Syu
- # reboot
- # pacman -S sudo adduser tmux
- # visudo
- enable sudo access for wheel group
- Save and exit with :wq
- # adduser
- username: pi
- additional groups: audio video wheel
- # exit
- Login as pi, we dont have to login as root
- again.
- $ tmux
- I like using tmux when SSH'ing
- # hostnamectl set-hostname wonderradio
- # timedatectl set-timezone Region/City
- Install the radio:
- # pacman -S nginx php-fpm mariadb icecast
- mpd nodejs git
- $ git clone https://github.com/daniel-j/wonder-radio
- $ cd wonder-radio/
- # cp nginx/nginx.conf /etc/nginx/nginx.conf
- # nano /etc/nginx/nginx.conf
- Edit the path in the file, so that it
- points to the wonder-radio www folder.
- In my case it's this path:
- /home/pi/wonder-radio/www
- Press Ctrl+X and Y to save and exit.
- # cp icecast/icecast.xml /etc/icecast.xml
- # nano /etc/icecast.xml
- Replace all PASSWORD with actual password.
- I will use "twitch".
- Save and exit.
- # systemctl enable nginx php-fpm mysqld icecast
- # systemctl start nginx php-fpm mysqld icecast
- $ mkdir ~/.mpd/
- $ cp mpd/mpd.conf ~/.mpd/
- $ nano ~/.mpd/mpd.conf
- Replace PASSWORD with actual password.
- You can also change audio quality
- in this file, and the title of the stream.
- $ mkdir ~/music/
- $ nano hidden.json
- Put in the following content:
- {
- "mysqlUsername": "root",
- "mysqlPassword": "twitch",
- "mysqlDatabase": "wonder-radio"
- }
- $ nano hidden.php
- Put in the following content:
- <?php
- $mysqlHost = 'localhost';
- $mysqlUser = 'root';
- $mysqlPassword = 'twitch';
- $mysqlDatabase = 'wonder-radio';
- $mpdPassword = $mysqlPassword;
- $adminPass = $mysqlPassword;
- $localIcecastHost = '127.0.0.1';
- $localIcecastPort = 8000;
- $musicPath = "/home/pi/music/";
- Let's make the MySQL database!
- $ mysqladmin -u root password PASSWORD
- $ mysql -u root -p
- > create database `wonder-radio`;
- > exit
- $ mysql -u root -p "wonder-radio" < mysql/tables.sql
- # nano /etc/php/php.ini
- Uncomment the line extension=pdo_mysql.so
- # systemctl restart php-fpm
- Make the style folder writeable for php
- $ chmod -R 0777 www/style/
- Now our radio is running!
- Now it's a good thing we have tmux!
- Run this command in one window:
- $ mpd --verbose --no-daemon
- This will start MPD, but not play any music.
- We need to install the mpc command to
- communicate with the MPD server.
- Press Ctrl+B and then C to start a new
- window in tmux. MPD is still running.
- # pacman -S mpc
- And now we must make some files executable.
- $ chmod +x mpd-queue.sh mpd-update.sh server.js
- Next we must install the nodejs mysql module.
- $ npm install mysql
- Try if the nodejs server is working:
- $ node server.js
- You should see a message saying:
- "Unable to queue music.. Database empty?"
- Press Ctrl+C to stop the server.
- Let's add some music! I store my music on an
- external medium (an old mp3 player).
- The other way is to manually put files in
- the ~/music/ folder. I can't remember the
- fstab syntax so I'll just make a bash script.
- $ mkdir ~/sansa/
- # mount /dev/sda /home/pi/sansa -o rw,exec,uid=1000,gid=1000,dev
- Make a new tmux window and go to your home dir
- You should be able to browse the contents of
- your external drive with ls ~/sansa/
- I only want to add some folders to my radio,
- so I will use symbolic links.
- $ cd sansa/
- $ ln -s ~/music/TO FROM
- Check if it worked with:
- $ ls ~/music/ -l
- You should see your folders in lightblue.
- Let's go to the radio in the browser. We want
- to update the music database. Find the admin
- login link, and login with your password.
- Press "Update database".
- Now we can start the nodejs server.
- Press Ctrl+B P to get back to the previous
- window.
- $ node server.js
- Yeah right, we forgot some stuff
- Let's check the error.
- Ya, I forgot the icecast files.
- Derp......... well, i wrote over my local file
- fixed. just ignore that
- # cp icecast/listclients.xsl /usr/share/icecast/admin/listclients.xsl
- # cp icecast/info_json.xsl /usr/share/icecast/web/
- $ node server.js
- SUCCESS
- Well, forgot one detail, the stream URL is
- wrong. Edit the file www/config.php
- TODO:
- Automatic start of mpd, as user pi.
- Automatic start of the nodejs server.
- Mounting the storage with fstab.
- Tip: use systemd for starting services.
- I will attempt to make it now though. :P
- We'll copy a sample!
- I commented out the "process.title = .." line
- in server.js, and instead added the following
- at the near top of the file:
- process.title = "wonder-radio";
- start.sh:
- #!/bin/sh
- sudo mount /dev/sda /home/pi/sansa -o rw,exec,uid=1000,gid=1000,dev
- mpd --no-daemon --verbose &
- node server.js &
- /etc/systemd/system/wonder-radio@.service:
- [Unit]
- Description=Wonder-Radio
- After=network.target
- [Service]
- Type=forking
- User=%i
- WorkingDirectory=/home/pi/wonder-radio/
- ExecStart=/home/pi/wonder-radio/start.sh
- [Install]
- WantedBy=multi-user.target
- Let's reboot!
- SUCCESS!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement