Advertisement
djazz

Wonderradio and Arch install process documentation

May 29th, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.84 KB | None | 0 0
  1. # pacman -Syu
  2. # reboot
  3.  
  4. # pacman -S sudo adduser tmux
  5. # visudo
  6. enable sudo access for wheel group
  7. Save and exit with :wq
  8. # adduser
  9. username: pi
  10. additional groups: audio video wheel
  11. # exit
  12.  
  13. Login as pi, we dont have to login as root
  14. again.
  15.  
  16. $ tmux
  17. I like using tmux when SSH'ing
  18. # hostnamectl set-hostname wonderradio
  19. # timedatectl set-timezone Region/City
  20. Install the radio:
  21.  
  22. # pacman -S nginx php-fpm mariadb icecast
  23. mpd nodejs git
  24. $ git clone https://github.com/daniel-j/wonder-radio
  25. $ cd wonder-radio/
  26. # cp nginx/nginx.conf /etc/nginx/nginx.conf
  27. # nano /etc/nginx/nginx.conf
  28. Edit the path in the file, so that it
  29. points to the wonder-radio www folder.
  30. In my case it's this path:
  31. /home/pi/wonder-radio/www
  32. Press Ctrl+X and Y to save and exit.
  33. # cp icecast/icecast.xml /etc/icecast.xml
  34. # nano /etc/icecast.xml
  35. Replace all PASSWORD with actual password.
  36. I will use "twitch".
  37. Save and exit.
  38. # systemctl enable nginx php-fpm mysqld icecast
  39. # systemctl start nginx php-fpm mysqld icecast
  40.  
  41. $ mkdir ~/.mpd/
  42. $ cp mpd/mpd.conf ~/.mpd/
  43. $ nano ~/.mpd/mpd.conf
  44. Replace PASSWORD with actual password.
  45. You can also change audio quality
  46. in this file, and the title of the stream.
  47. $ mkdir ~/music/
  48. $ nano hidden.json
  49. Put in the following content:
  50. {
  51. "mysqlUsername": "root",
  52. "mysqlPassword": "twitch",
  53. "mysqlDatabase": "wonder-radio"
  54. }
  55. $ nano hidden.php
  56. Put in the following content:
  57. <?php
  58. $mysqlHost = 'localhost';
  59. $mysqlUser = 'root';
  60. $mysqlPassword = 'twitch';
  61. $mysqlDatabase = 'wonder-radio';
  62. $mpdPassword = $mysqlPassword;
  63. $adminPass = $mysqlPassword;
  64. $localIcecastHost = '127.0.0.1';
  65. $localIcecastPort = 8000;
  66. $musicPath = "/home/pi/music/";
  67.  
  68. Let's make the MySQL database!
  69.  
  70. $ mysqladmin -u root password PASSWORD
  71. $ mysql -u root -p
  72. > create database `wonder-radio`;
  73. > exit
  74. $ mysql -u root -p "wonder-radio" < mysql/tables.sql
  75.  
  76. # nano /etc/php/php.ini
  77. Uncomment the line extension=pdo_mysql.so
  78. # systemctl restart php-fpm
  79. Make the style folder writeable for php
  80. $ chmod -R 0777 www/style/
  81.  
  82. Now our radio is running!
  83.  
  84. Now it's a good thing we have tmux!
  85. Run this command in one window:
  86.  
  87. $ mpd --verbose --no-daemon
  88.  
  89. This will start MPD, but not play any music.
  90. We need to install the mpc command to
  91. communicate with the MPD server.
  92.  
  93. Press Ctrl+B and then C to start a new
  94. window in tmux. MPD is still running.
  95.  
  96. # pacman -S mpc
  97. And now we must make some files executable.
  98. $ chmod +x mpd-queue.sh mpd-update.sh server.js
  99.  
  100. Next we must install the nodejs mysql module.
  101. $ npm install mysql
  102.  
  103. Try if the nodejs server is working:
  104. $ node server.js
  105. You should see a message saying:
  106. "Unable to queue music.. Database empty?"
  107.  
  108. Press Ctrl+C to stop the server.
  109. Let's add some music! I store my music on an
  110. external medium (an old mp3 player).
  111. The other way is to manually put files in
  112. the ~/music/ folder. I can't remember the
  113. fstab syntax so I'll just make a bash script.
  114. $ mkdir ~/sansa/
  115. # mount /dev/sda /home/pi/sansa -o rw,exec,uid=1000,gid=1000,dev
  116. Make a new tmux window and go to your home dir
  117. You should be able to browse the contents of
  118. your external drive with ls ~/sansa/
  119. I only want to add some folders to my radio,
  120. so I will use symbolic links.
  121. $ cd sansa/
  122. $ ln -s ~/music/TO FROM
  123. Check if it worked with:
  124. $ ls ~/music/ -l
  125. You should see your folders in lightblue.
  126. Let's go to the radio in the browser. We want
  127. to update the music database. Find the admin
  128. login link, and login with your password.
  129. Press "Update database".
  130.  
  131. Now we can start the nodejs server.
  132. Press Ctrl+B P to get back to the previous
  133. window.
  134. $ node server.js
  135.  
  136. Yeah right, we forgot some stuff
  137. Let's check the error.
  138. Ya, I forgot the icecast files.
  139. Derp......... well, i wrote over my local file
  140. fixed. just ignore that
  141. # cp icecast/listclients.xsl /usr/share/icecast/admin/listclients.xsl
  142. # cp icecast/info_json.xsl /usr/share/icecast/web/
  143. $ node server.js
  144.  
  145. SUCCESS
  146. Well, forgot one detail, the stream URL is
  147. wrong. Edit the file www/config.php
  148.  
  149. TODO:
  150. Automatic start of mpd, as user pi.
  151. Automatic start of the nodejs server.
  152. Mounting the storage with fstab.
  153. Tip: use systemd for starting services.
  154.  
  155. I will attempt to make it now though. :P
  156. We'll copy a sample!
  157.  
  158. I commented out the "process.title = .." line
  159. in server.js, and instead added the following
  160. at the near top of the file:
  161. process.title = "wonder-radio";
  162.  
  163. start.sh:
  164. #!/bin/sh
  165. sudo mount /dev/sda /home/pi/sansa -o rw,exec,uid=1000,gid=1000,dev
  166. mpd --no-daemon --verbose &
  167. node server.js &
  168.  
  169. /etc/systemd/system/wonder-radio@.service:
  170. [Unit]
  171. Description=Wonder-Radio
  172. After=network.target
  173.  
  174. [Service]
  175. Type=forking
  176. User=%i
  177. WorkingDirectory=/home/pi/wonder-radio/
  178. ExecStart=/home/pi/wonder-radio/start.sh
  179.  
  180. [Install]
  181. WantedBy=multi-user.target
  182.  
  183. Let's reboot!
  184. SUCCESS!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement