Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

I created a simple script to install RompR on a Raspberry Pi running Raspbian #46

#1

I've run this successfully twice now. It's pretty crude, and requires you run this as pi from the root of your home drive.

You will need to create 3 files at the root of the pi user's home drive:

install.sh
php_append.txt
rompr

Contents of each file:

install.sh

#!/bin/bash

# Rompr install script  This script is alpha quality at best.  It will work with Raspbian from 10/10/2020 that' fully patched.
# I tried to script all the steps needed to from the RompR web page.
# This script is INSECURE.  It uses a lot of sudo commands and assumes you'll run it as the pi user.
 
#Install nginx web server, php and other needed coponents
if [ ! -d "/home/pi/backup-rompr" ] 
then
    mkdir /home/pi/backup-rompr 
fi

sudo apt install -y nginx php-curl php-sqlite3 php-gd php-json php-xml php-mbstring php-fpm imagemagick

# Add connection timeout to the end of your mpd configuration file
cp /etc/mpd.conf ~/backup-rompr
sudo echo 'connection_timeout     "120"' >> /etc/mpd.conf

# Switch to the web root directory
cd /var/www

# Copy RompR down using git
sudo apt install -y git
sudo git clone https://github.com/fatg3erman/RompR.git

# Create needed prefs and albumart directories
sudo mkdir /var/www/RompR/albumart
sudo mkdir /var/www/RompR/prefs

# change permissions on the RompR directory, so the Nginx web server has access to it.
sudo chown -R www-data /var/www/RompR
sudo chgrp -R www-data /var/www/RompR

# Read the hostname into a variable
host=$(hostname)

# Update default nginx config as per RompR documentation
cp /etc/nginx/sites-available/default ~/backup-rompr
sudo sed -i 's/ default_server;/;/' /etc/nginx/sites-available/default

# Add your Raspberry Pi's hostname into the rompr config file
sudo sed -i "s/hostname.of.your.computer/$host/" ~/rompr

# Copy the RompR config file into the nginx config directory and change it's permissions to match the other files in that directory
sudo cp ~/rompr /etc/nginx/sites-available
sudo chmod 644 /etc/nginx/sites-available/rompr

# Enable the RompR config
sudo ln -s /etc/nginx/sites-available/rompr /etc/nginx/sites-enabled/rompr

# Update php.ini with required settings
cp /etc/php/7.3/fpm/php.ini ~/backup-rompr
sudo cat ~/php_append.txt >> /etc/php/7.3/fpm/php.ini

# Enable php-fpm daemon and nginx
sudo systemctl enable php7.3-fpm
sudo systemctl enable nginx

# Restart php and nginx
sudo systemctl restart php7.3-fpm
sudo systemctl restart nginx

echo "Install is complete.  You should be able to access your music server by pointing a browser at http://$host/RompR"

rompr

server {

    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www;
    index index.php index.html index.htm;

    server_name hostname.of.your.computer;

    client_max_body_size 256M;

    # This section can be copied into an existing default setup
    location /RompR/ {
        allow all;
        index index.php;
        location ~ \.php {
                try_files $uri index.php =404;
                fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $request_filename;
                include /etc/nginx/fastcgi_params;
                fastcgi_read_timeout 1800;
        }
        error_page 404 = /404.php;
        try_files $uri $uri/ =404;
        location ~ /albumart/* {
                expires -1s;
        }
    }
}

php_append.txt

llow_url_fopen = On
memory_limit = 128M
max_execution_time = 1800
post_max_size = 256M
upload_max_filesize = 10M
max_file_uploads = 200

Just run ./install.sh and you should have a working RompR server when all is done.

I welcome any and all constructive criticisms on how to do it better. I am not a professional developer. I'm just a Linux geek.

  • replies 1
  • views 1.7K
  • likes 0
apastuszak · Author
#2

Ok, upon further testing, this script is totally not going to work. I did some major cleanup, and got it down one script file with no extra files.

This is for Raspberry Pi OS that is fully patched as of 10/17/2020.

#!/bin/bash

# Rompr install script  This script is alpha quality at best.  It will work with Raspbian from 10/10/2020 that' fully patched.
# I tried to script all the steps needed to from the RompR web page.
# This script is INSECURE.  It uses a lot of sudo commands and assumes you'll run it as the pi user.

#Install nginx web server, php and other needed coponents
sudo apt install -y nginx php-curl php-sqlite3 php-gd php-json php-xml php-mbstring php-fpm imagemagick

# Add connection timeout to the end of your mpd configuration file

echo -e '\nconnection_timeout     "120"\n' | sudo tee -a /etc/mpd.conf
sudo systemctl restart mpd

# Switch to the web root directory
cd /var/www

# Copy RompR down using git
sudo apt install -y git
sudo git clone https://github.com/fatg3erman/RompR.git

# Create needed prefs and albumart directories
sudo mkdir /var/www/RompR/albumart
sudo mkdir /var/www/RompR/prefs

# change permissions on the RompR directory, so the Nginx web server has access to it.
sudo chown -R www-data /var/www/RompR
sudo chgrp -R www-data /var/www/RompR

# Read the hostname into a variable
host=$(hostname)

# Update default nginx config as per RompR documentation
sudo sed -i 's/ default_server;/;/' /etc/nginx/sites-available/default

#Create RompR config file
echo -e "server {\n\n    listen 80 default_server;\n    listen [::]:80 default_server;\n\n    root /var/www;\n    index index.php index.html index.htm;\n\n    server_name hostname.of.your.computer;\n\n    client_max_body_size 256M;\n\n    # This section can be copied into an existing default setup\n    location /RompR/ {\n        allow all;\n        index index.php;\n        location ~ \.php {\n                try_files \$uri index.php =404;\n                fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;\n                fastcgi_index index.php;\n                fastcgi_param SCRIPT_FILENAME \$request_filename;\n                include /etc/nginx/fastcgi_params;\n                fastcgi_read_timeout 1800;\n        }\n        error_page 404 = /404.php;\n        try_files \$uri \$uri/ =404;\n        location ~ /albumart/* {\n                expires -1s;\n        }\n    }\n}\n" > /home/pi/rompr

# Add your Raspberry Pi's hostname into the rompr config file
sudo sed -i "s/hostname.of.your.computer/$host/" ~/rompr

# Copy the RompR config file into the nginx config directory and change it's permissions to match the other files in that directory
sudo cp ~/rompr /etc/nginx/sites-available
sudo chmod 644 /etc/nginx/sites-available/rompr

# Enable the RompR config
sudo ln -s /etc/nginx/sites-available/rompr /etc/nginx/sites-enabled/rompr

# Update php.ini with required settings
echo -e "allow_url_fopen = On\nmemory_limit = 128M\nmax_execution_time = 1800\npost_max_size = 256M\nupload_max_filesize = 10M\nmax_file_uploads = 200\n" | sudo tee -a /etc/php/7.3/fpm/php.ini

\# Enable php-fpm daemon and nginx
sudo systemctl enable php7.3-fpm
sudo systemctl enable nginx

# Restart php and nginx
sudo systemctl restart php7.3-fpm
sudo systemctl restart nginx

echo "Install is complete.  You should be able to access your music server by pointing a browser at http://$host/RompR"