Instructions
The following are a series of instructions to set up your own BlueBox:
Step 1: Acquiring the Hardware
-
1. Buy a Raspberry Pi
- Go to https://www.raspberrypi.com/products/raspberry-pi-4-model-b/.
- Click Buy Now.
- Pick a model under Select a model. Note: 2GB is sufficient but 4GB or higher is recommended.
- Pick a country under Country.
- Click one of the approved retailers and purchase the Raspberry Pi.
- Depending on the retailer, search for related products to find available power supplies for the Raspberry Pi. More specifically, the Raspberry Pi4 Official USB-C 15.3W Black 5.1V 3A power supply should work.
- Browse the Internet for a Raspberry Pi 4 case that you would like to use.
- Browse the Internet for a micro SD card you would like to use. A minimum of 64 GB is recommended; however, depending on how many modules you would like to install, you likely need to increase this amount. We recommend an endurance card when possible (e.g., SanDisk High Endurance or Samsung Pro Endurance).
Step 2: Setting Up the BlueBox
-
Option 1: Installing from Image
1. Download Etcher and the BlueBox Image
- Download Etcher from https://www.balena.io/etcher/ and install it.
- Download this image (3.75 GB).
- Insert a micro SD card into your computer.
- Open Etcher.
- Click Flash from file and select the image you downloaded in step 1.
- Click Select target and select the drive of the SD card.
- Click Flash!
- When the flash has finished, remove the micro SD card and insert it into your Raspbery Pi.
- Plug in your Raspberry Pi and wait a few minutes.
- Search for the BlueBox Wi-Fi connection and select it.
- Enter bluebox/ or 10.10.10.10 in your browser URL.
-
Option 2: Installing from Scratch (Bookworm or Later)
1. Install the Raspberry Pi OS
- Download and install the Raspberry Pi Imager: https://www.raspberrypi.org/software/.
- Insert a micro SD card into your machine.
- Open the Raspberry Pi Imager application.
- Click on CHOOSE DEVICE under Raspberry Pi Device and select Raspberry Pi 4. It should be the third option.
- Click on CHOOSE OS under Operating System and select Raspberry Pi OS (other). It should be the fourth option.
- Select Raspberry Pi OS Lite (64-bit). Note: you could install the Desktop environment instead of the Lite environment, but it will take up more space on the Raspberry Pi.
- Click on CHOOSE STORAGE under Storage and select the micro SD card you inserted.
- Click NEXT.
- Click NO when asked Would you like to apply OS customisation settings?
- Confirm that you want to erase all the data on the SD card by clicking YES. Note: the writing process will take a while.
- Remove the SD card from your machine when the writing process finishes.
- Insert the micro SD card into the Raspberry Pi and power it up. You will need to connect a keyboard and external monitor to the Raspberry Pi to do the next steps.
- Select Other for the Keyboard layout, then English (US), then English (US) again.
- Use whatever you want as the username and password. I used
pi
for the username andraspberry
for the password. - When you see the prompt
raspberrypi login:
, type the credentials you used on the previous step. Note: the password won't show up as you type. - Optional: You can change the password on your Raspberry Pi by entering the following command, typing the old password, and typing the new password twice:
passwd - Connect the Raspberry Pi to the Internet
- Open the Raspberry Pi configuration tool again:
sudo raspi-config - Use the keyboard to select System Options and hit Enter.
- Select Wireless LAN and hit Enter.
- Select US for the country and hit Enter. Note: typing U will jump to the U's so you don't have to scroll through all the other countries.
- Hit Enter again to select <Ok>.
- Enter the SSID of your wireless network (e.g. CUGuest) and hit Enter.
- Enter your network password and hit Enter.
- Change the Hostname
- In the Raspberry Pi confiuration tool, use the arrow keys on your keyboard to select System Options again and hit Enter.
- Select Hostname and hit Enter.
- Hit Enter again.
- Replace raspberrypi with bluebox and hit Enter.
- Change the Keyboard Layout
- In the Raspberry Pi confiuration tool, use the keyboard to select Localisation Options and hit Enter.
- Use the keyboard to select Keyboard and hit Enter.
- Ensure that the default keyboard layout is Generic 105-key PC (intl.) and hit Enter.
- Select Other and hit Enter.
- Select English (US) and hit Enter.
- Select English (US) again and hit Enter.
- Select The default for the keyboard layout and hit Enter.
- Select No compose key and hit Enter.
- Use the default configurations for the rest.
- Enable SSH
- In the Raspberry Pi confiuration tool, use the arrow keys on your keyboard to select Interface Options.
- Select the SSH option on the list.
- Select <Yes> on the Would you like the SSH server to be enabled? prompt and hit Enter.
- Hit Enter on the The SSH server is enabled confirmation box.
- Navigate down and select Finish to save changes and close raspi-config.
- Select <No> when asked to reboot and hit Enter.
- Edit the host file so we can SSH using bluebox instead of the IP address:
sudo nano /etc/hosts - Add the information below to the end of the host file:
10.10.10.10 bluebox - Save the new configuration by typing Ctrl + X, then Y, then Enter.
- Login back into the Raspberry Pi after reboot.
- Ensure the Raspberry Pi is plugged into an ethernet connection.
- Check for updates on the Raspberry Pi. Note: this step will take a while:
sudo apt update -y
sudo apt upgrade -y - Install the Apache web server, PHP, MariaDB, SQLite, and ZipArchive with the following commands:
sudo apt install -y apache2 php php-mbstring mariadb-server mariadb-client php-mysql php-sqlite3 php-zipsudo phpenmod zip - Set Up the Wi-Fi Hotspot Run the following code to enable the Raspberry Pi as its own hotspot
- Set Up Security on the Wi-Fi Hotspot (Optional) If you want to only allow access to the network with a password, run the following as well (changing bluebox-password to the actual password you want):
- Check for the BlueBox Network Double-check that the SSID specified in the file shows up as an available wireless network. Note: you can change these settings using the user interface using
- Connect to the BlueBox Wi-Fi network (i.e., the SSID you defined in step 4 above).
- Open your terminal on a Mac or Windows Powershell/Putty on a PC and SSH into the Raspberry Pi.
ssh pi@10.10.10.10 - Enter your password when prompted (you won't see anything when typing your password).
- Connect to MariaDB:
sudo mysql -u root - Add a new bluebox account with the blue-admin password, grant all privileges to the new user, and remove the default root account:
CREATE USER 'bluebox'@'localhost' IDENTIFIED BY 'blue-admin';
GRANT ALL PRIVILEGES ON *.* TO 'bluebox'@'localhost' WITH GRANT OPTION;
DROP USER 'root'@'localhost'; - For subsequent logins to MariaDB, use the following:
sudo mysql -u bluebox -p - Enter your password when prompted.
- Create the new bluebox schema and select it for use:
CREATE SCHEMA bluebox;
USE bluebox; - Add the MariaDB tables and data:
CREATE TABLE `file` (
`filename` varchar(255) NOT NULL,
`dir` varchar(255) NOT NULL,
`ext` varchar(4) NOT NULL,
PRIMARY KEY (`filename`,`dir`)
);
CREATE TABLE `user` (
`username` varchar(100) NOT NULL PRIMARY KEY,
`password` varchar(255) NOT NULL,
`salt` varchar(255) NOT NULL,
`language` varchar(20) NOT NULL DEFAULT 'English',
`version` DOUBLE(10,2) NOT NULL
);
CREATE TABLE `module` (
`module_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`title` varchar(255) NOT NULL,
`description` text NOT NULL,
`rsync` varchar(255),
`dir` varchar(255) NOT NULL,
`url` varchar(255) NOT NULL,
`kiwix` varchar(255),
`downloaded` char(1),
`active` char(1),
`language` varchar(20) NOT NULL DEFAULT 'English',
`size` double(20,2) NOT NULL,
`version` varchar(25) NOT NULL,
`source` varchar(255)
);
CREATE TABLE `category` (
`category_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`type` varchar(255) NOT NULL,
PRIMARY KEY (`category_id`)
);
CREATE TABLE `module_category` (
`category_id` int(11) NOT NULL,
`module_id` int(11) NOT NULL,
PRIMARY KEY (`category_id`,`module_id`),
CONSTRAINT `module_category_fk1` FOREIGN KEY (`category_id`) REFERENCES `category` (`category_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `module_category_fk2` FOREIGN KEY (`module_id`) REFERENCES `module` (`module_id`) ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO user
VALUES ('bluebox', '8cb3a029f8d1f4c8dd8d09f52e367b9aecdee60f9d18d5bca709c6f2e0e0a71bd5134d28520bc7cb3fc09c91d2f0df78a6d7eb2394319931cea44e03051929d6', '29fd9a48f7aa7edbe12e7c34c5297fce4d3c6702218111960fe4ee157ad01f9fd8e8ed96fdcf974533c8f57276150076e189c7bd74f8bb978a848938e9594b88', 'English', 0); - Type
exit
and hit Enter or type Ctrl + C to exit MariaDB. - Remove the current home page:
sudo rm /var/www/html/index.html - Create the new home page:
sudo nano /var/www/html/index.php - Copy and paste the following content into the new home page:
<?php
// Initialize a file URL to the variable
$html = file_get_contents("http://bluebox.creighton.edu/modules.php?version=true");
preg_match_all('/\d\.\d*/s', $html, $version);
$version = $version[0][0];
$filename = "pi-{$version}.zip";
$url = "https://bluebox.creighton.edu/{$filename}";
// Use basename() function to return the base name of file
$siteUpdate = basename($url);
// Use file_get_contents() function to get the file from url and use file_put_contents() function to save the file by using base name
$arrContextOptions= [
"ssl" => [
"verify_peer"=> false,
"verify_peer_name"=> false,
],
];
file_put_contents($siteUpdate, file_get_contents($url, false, stream_context_create($arrContextOptions)));
// unzips all the contents of the zip folder and loads them to the server
$zip = new ZipArchive;
$zip->open($filename);
$zip->extractTo("pi");
shell_exec("cp -r ./pi/pi/* . && rm -rf pi && rm {$filename}");
header("Location: .");
exit;
?> - Edit the php.ini file to allow larger file uploads:
sudo nano /etc/php/8.2/apache2/php.ini - Note: if the previous step doesn't have any information then you will need to locate the php.ini file by adding the following to any PHP page, loading that page, and then finding the location of the php.ini file:
<?php
echo phpinfo();
?> - Search for the following lines in the file by typing Ctrl + W and pasting the following values. Then change the values from 2M/10M to 1G or something larger than the defaults:
upload_max_filesize
post_max_size - Search for the following line
;extension=sqlite3
and remove the semi-colon in front of the line. - Save the new configuration by typing Ctrl + X, then Y, then Enter.
- Change privileges of the html folder to be able to transfer files to the html directory:
sudo chmod +777 /var/www/html/ - Change ownership of the index file to be able to run it on first use:
sudo chown www-data:www-data /var/www/html/index.php - Edit the sudo user file to allow the site to reboot the Raspberry Pi when needed:
sudo nano /etc/sudoers - Add this to the end of the file:
www-data ALL = NOPASSWD: /sbin/reboot, /sbin/halt - Save the new configuration by typing Ctrl + X, then Y, then Enter.
- Restart the Raspberry Pi:
sudo reboot - Download the latest linux arm version of Kiwix Tools. Click the precompiled version link under GNU/Linux. DON'T click the big button on the right.
- Connect to the BlueBox Wi-Fi network.
- Transfer the download to the Raspberry Pi using SSH via WINSCP or FileZilla.
- Ensure the Raspberry Pi is connected to the Internet.
- Change to the directory where you transferred the file. For example, if you transferred the file to /var/www/html, you would run the following:
cd /var/www/html
- Unpack kiwix-tools in a folder:
tar -xvf kiwix-tools_linux-arm*.tar.gz
- Remove the downloaded file:
rm kiwix-tools_linux-arm*.tar.gz
- Rename and move the extracted folder to /var/kiwix:
sudo mv kiwix-tools_linux-arm* /var/kiwix
- Make sure kiwix-manage, kiwix-search, and kiwix-serve are in the /var/kiwix/ directory:
cd /var/kiwixls
- Edit the configuration file to start Kiwix on boot:
sudo nano /etc/rc.local
- Add the following just before the exit line:
sudo /var/kiwix/kiwix-serve --library /var/www/html/modules/kiwix-library.xml --port=8080 --daemon
- Save the new configuration by typing Ctrl + X, then Y, then Enter.
- Connect to the BlueBox Wi-Fi network.
- Ensure the Raspberry Pi is connected to the Internet.
- Open a browser and enter 10.10.10.10/ as the URL. The page content should download and install automatically. You should now see the BlueBox site.
- You can now download modules.
- Run the following command in terminal to grant permissions for the user interface to edit the kiwix library file:
sudo chmod 777 /var/www/html/modules/kiwix-library.xml
- If not using a wired connection, remove the wireless network you used to connect and complete the earlier steps:
nmcli con delete CUGuest
nmcli con add type wifi ifname wlan0 mode ap con-name BlueBox ssid BlueBox
nmcli con modify BlueBox wifi.band a
nmcli con modify BlueBox wifi.channel 48
nmcli con modify BlueBox ipv4.method shared ipv4.address 10.10.10.10/24
nmcli con modify BlueBox ipv6.method disabled
nmcli con up BlueBox
nmcli con modify BlueBox wifi-sec.key-mgmt wpa-psk
nmcli con modify BlueBox wifi-sec.proto rsn
nmcli con modify BlueBox wifi-sec.group ccmp
nmcli con modify BlueBox wifi-sec.pairwise ccmp
nmcli con modify BlueBox wifi-sec.psk 'bluebox-password'
sudo nmtui
.
-
Option 3: Installing from Scratch (Bulleye or Earlier)
1. Install the Raspberry Pi OS
- Download and install the Raspberry Pi Imager: https://www.raspberrypi.org/software/.
- Insert a micro SD card into your machine.
- Open the Raspberry Pi Imager application.
- Click on CHOOSE DEVICE under Raspberry Pi Device and select Raspberry Pi 4. It should be the third option.
- Click on CHOOSE OS under Operating System and select Raspberry Pi OS (other). It should be the fourth option.
- Select Raspberry Pi OS Lite (Legacy, 64-bit). Note: you could install the Desktop environment instead of the Lite environment, but it will take up more space on the Raspberry Pi.
- Click on CHOOSE STORAGE under Storage and select the micro SD card you inserted.
- Click NEXT.
- Click NO when asked Would you like to apply OS customisation settings?
- Confirm that you want to erase all the data on the SD card by clicking YES. Note: the writing process will take a while.
- Remove the SD card from your machine when the writing process finishes.
- Insert the micro SD card into the Raspberry Pi and power it up. You will need to connect a keyboard and external monitor to the Raspberry Pi to do the next steps.
- Select Other for the Keyboard layout, then English (US), then English (US) again.
- Use whatever you want as the username and password. I used
pi
for the username andraspberry
for the password. - When you see the prompt
raspberrypi login:
, type the credentials you used on the previous step. Note: the password won't show up as you type. - Optional: You can change the password on your Raspberry Pi by entering the following command, typing the old password, and typing the new password twice:
passwd - Connect the Raspberry Pi to the Internet
- Open the Raspberry Pi configuration tool again:
sudo raspi-config - Use the keyboard to select System Options and hit Enter.
- Select Wireless LAN and hit Enter.
- Select US for the country and hit Enter. Note: typing U will jump to the U's so you don't have to scroll through all the other countries.
- Hit Enter again to select <Ok>.
- Enter the SSID of your wireless network (e.g. CUGuest) and hit Enter.
- Enter your network password and hit Enter.
- Change the Hostname
- In the Raspberry Pi confiuration tool, use the arrow keys on your keyboard to select System Options again and hit Enter.
- Select Hostname and hit Enter.
- Hit Enter again.
- Replace raspberrypi with bluebox and hit Enter.
- Change the Keyboard Layout
- In the Raspberry Pi confiuration tool, use the keyboard to select Localisation Options and hit Enter.
- Use the keyboard to select Keyboard and hit Enter.
- Ensure that the default keyboard layout is Generic 105-key PC (intl.) and hit Enter.
- Select Other and hit Enter.
- Select English (US) and hit Enter.
- Select English (US) again and hit Enter.
- Select The default for the keyboard layout and hit Enter.
- Select No compose key and hit Enter.
- Use the default configurations for the rest.
- Enable SSH
- In the Raspberry Pi confiuration tool, use the arrow keys on your keyboard to select Interface Options.
- Select the SSH option on the list.
- Select <Yes> on the Would you like the SSH server to be enabled? prompt and hit Enter.
- Hit Enter on the The SSH server is enabled confirmation box.
- Navigate down and select Finish to save changes and close raspi-config.
- Select <No> when asked to reboot and hit Enter.
- Edit the host file so we can SSH using bluebox instead of the IP address:
sudo nano /etc/hosts - Add the information below to the end of the host file:
10.10.10.10 bluebox - Save the new configuration by typing Ctrl + X, then Y, then Enter.
- Login back into the Raspberry Pi after reboot.
- Ensure the Raspberry Pi is plugged into an ethernet connection.
- Check for updates on the Raspberry Pi. Note: this step will take a while:
sudo apt update -y
sudo apt upgrade -y - Install the Apache web server, PHP, MariaDB, SQLite, and ZipArchive with the following commands:
sudo apt install -y apache2 php php-mbstring mariadb-server mariadb-client php-mysql php-sqlite3 php-zipsudo phpenmod zip - Set A Static IP Address
- Edit the dhcpcd configuration file:
sudo nano /etc/dhcpcd.conf - Add the information below to the end of the configuration file to set a static IP address:
interface wlan0
static ip_address=10.10.10.10/24
nohook wpa_supplicant
denyinterfaces eth0
denyinterfaces wlan0 - Save the new configuration by typing Ctrl + X, then Y, then Enter.
- Install Hostapd
- Install hostapd to transform the Raspberry Pi's network interface card into a wireless access point software:
sudo apt install hostapd - Stop the hostapd service:
sudo service hostapd stop - Create the network name and password:
sudo nano /etc/hostapd/hostapd.conf - Add the information below to the configuration file and save it (if you have a pi 3, use g or n for hw_mode, ieee80211n instead of ieee80211ac, and 6 for g and 11 for n for the channel). Important: Make sure for the ssid that if you have multiple BlueBoxes in close proximity that you use a different ssid for each one (i.e. BlueBox-LastName or BlueBox-Location):
interface=wlan0
ssid=BlueBox
hw_mode=a
ieee80211ac=1
channel=48
macaddr_acl=0
wmm_enabled=1
auth_algs=1
ignore_broadcast_ssid=0
wpa=0 - Optional: If you want to password protect the Raspberry Pi, change
wpa=0
on the last line towpa=2
and add the following before saving your configuration (change BlueBoxPassword to what you want for the Raspberry Pi's Wi-Fi password):
wpa_passphrase=BlueBoxPassword
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP - Save the new configuration by typing Ctrl + X, then Y, then Enter.
- Edit hostapd to apply the configuration that we just made:
sudo nano /etc/default/hostapd - Find
#DAEMON_CONF
and add this on a new line below:
DAEMON_CONF="/etc/hostapd/hostapd.conf" - Save the new configuration by typing Ctrl + X, then Y, then Enter.
- Enable the wireless access point service and set it to start when your Raspberry Pi boots:
sudo systemctl unmask hostapd
sudo systemctl enable hostapd - Enable routing so devices can use the Internet of the BlueBox when it is plugged in:
sudo nano /etc/sysctl.conf - Uncomment the following line by removing the hashtag before it:
net.ipv4.ip_forward=1 - Save the new configuration by typing Ctrl + X, then Y, then Enter.
- Run this code:
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward" - Install Dnsmasq
- Install dnsmasq for Domain Name Server (DNS) caching and Dynamic Host Configuration Protocol (DHCP) server for managing the server name and connections:
sudo apt install -y dnsmasq - Stop the dnsmasq service:
sudo systemctl stop dnsmasq - Configure the DHCP and DNS services for the wireless network by backing up the default configuration file first:
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig - Create our own configuration:
sudo nano /etc/dnsmasq.conf - Add the information below to the configuration file:
interface=wlan0
dhcp-range=10.10.10.11,10.10.10.255,255.255.255.0,24h
domain=wlan
address=/bluebox.lan/10.10.10.10 - Save the new configuration by typing Ctrl + X, then Y, then Enter.
- Set Up the Firewall
- Install iptables if it doesn't already exist:
sudo apt install iptables - Add the following three firewall rules to enable routing traffic through the Raspberry Pi:
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE - Save the rules:
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat" - Edit the local file so the firewall rules are loaded at boot:
sudo nano /etc/rc.local - Add the following code before
exit 0
:
iptables-restore < /etc/iptables.ipv4.nat - Save the new configuration by typing Ctrl + X, then Y, then Enter.
- Enable the dnsmasq service (you may need to type the Raspberry Pi password several times)::
sudo systemctl enable dnsmasq
sudo systemctl start dnsmasq
sudo systemctl status dnsmasq - Check for the BlueBox Network
- Restart the Raspberry Pi:
sudo reboot - As the Raspberry Pi is booting, ensure the boot steps have [ OK ] next to them (i.e. none say failed). If anything says failed, you may need to revisit the steps and ensure you have no typos.
- Double-check that the SSID specified in the file shows up as an available wireless network.
- Connect to the BlueBox Wi-Fi network (i.e., the SSID you defined in step 4 above).
- Open your terminal on a Mac or Windows Powershell/Putty on a PC and SSH into the Raspberry Pi.
ssh pi@10.10.10.10 - Enter your password when prompted (you won't see anything when typing your password).
- Connect to MariaDB:
sudo mysql -u root - Add a new bluebox account with the blue-admin password, grant all privileges to the new user, and remove the default root account:
CREATE USER 'bluebox'@'localhost' IDENTIFIED BY 'blue-admin';
GRANT ALL PRIVILEGES ON *.* TO 'bluebox'@'localhost' WITH GRANT OPTION;
DROP USER 'root'@'localhost'; - For subsequent logins to MariaDB, use the following:
sudo mysql -u bluebox -p - Enter your password when prompted.
- Create the new bluebox schema and select it for use:
CREATE SCHEMA bluebox;
USE bluebox; - Add the MariaDB tables and data:
CREATE TABLE `file` (
`filename` varchar(255) NOT NULL,
`dir` varchar(255) NOT NULL,
`ext` varchar(4) NOT NULL,
PRIMARY KEY (`filename`,`dir`)
);
CREATE TABLE `user` (
`username` varchar(100) NOT NULL PRIMARY KEY,
`password` varchar(255) NOT NULL,
`salt` varchar(255) NOT NULL,
`language` varchar(20) NOT NULL DEFAULT 'English',
`version` DOUBLE(10,2) NOT NULL
);
CREATE TABLE `module` (
`module_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`title` varchar(255) NOT NULL,
`description` text NOT NULL,
`rsync` varchar(255),
`dir` varchar(255) NOT NULL,
`url` varchar(255) NOT NULL,
`kiwix` varchar(255),
`downloaded` char(1),
`active` char(1),
`language` varchar(20) NOT NULL DEFAULT 'English',
`size` double(20,2) NOT NULL,
`version` varchar(25) NOT NULL,
`source` varchar(255)
);
CREATE TABLE `category` (
`category_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`type` varchar(255) NOT NULL,
PRIMARY KEY (`category_id`)
);
CREATE TABLE `module_category` (
`category_id` int(11) NOT NULL,
`module_id` int(11) NOT NULL,
PRIMARY KEY (`category_id`,`module_id`),
CONSTRAINT `module_category_fk1` FOREIGN KEY (`category_id`) REFERENCES `category` (`category_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `module_category_fk2` FOREIGN KEY (`module_id`) REFERENCES `module` (`module_id`) ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO user
VALUES ('bluebox', '8cb3a029f8d1f4c8dd8d09f52e367b9aecdee60f9d18d5bca709c6f2e0e0a71bd5134d28520bc7cb3fc09c91d2f0df78a6d7eb2394319931cea44e03051929d6', '29fd9a48f7aa7edbe12e7c34c5297fce4d3c6702218111960fe4ee157ad01f9fd8e8ed96fdcf974533c8f57276150076e189c7bd74f8bb978a848938e9594b88', 'English', 0); - Type
exit
and hit Enter or type Ctrl + C to exit MariaDB. - Remove the current home page:
sudo rm /var/www/html/index.html - Create the new home page:
sudo nano /var/www/html/index.php - Copy and paste the following content into the new home page:
<?php
// Initialize a file URL to the variable
$html = file_get_contents("http://bluebox.creighton.edu/modules.php?version=true");
preg_match_all('/\d\.\d*/s', $html, $version);
$version = $version[0][0];
$filename = "pi-{$version}.zip";
$url = "https://bluebox.creighton.edu/{$filename}";
// Use basename() function to return the base name of file
$siteUpdate = basename($url);
// Use file_get_contents() function to get the file from url and use file_put_contents() function to save the file by using base name
$arrContextOptions= [
"ssl" => [
"verify_peer"=> false,
"verify_peer_name"=> false,
],
];
file_put_contents($siteUpdate, file_get_contents($url, false, stream_context_create($arrContextOptions)));
// unzips all the contents of the zip folder and loads them to the server
$zip = new ZipArchive;
$zip->open($filename);
$zip->extractTo("pi");
shell_exec("cp -r ./pi/pi/* . && rm -rf pi && rm {$filename}");
header("Location: .");
exit;
?> - Edit the php.ini file to allow larger file uploads:
sudo nano /etc/php/8.2/apache2/php.ini - Note: if the previous step doesn't have any information then you will need to locate the php.ini file by adding the following to any PHP page, loading that page, and then finding the location of the php.ini file:
<?php
echo phpinfo();
?> - Search for the following lines in the file by typing Ctrl + W and pasting the following values. Then change the values from 2M/10M to 1G or something larger than the defaults:
upload_max_filesize
post_max_size - Search for the following line
;extension=sqlite3
and remove the semi-colon in front of the line. - Save the new configuration by typing Ctrl + X, then Y, then Enter.
- Download the latest linux arm version of Kiwix Tools. Click the precompiled version link under GNU/Linux. DON'T click the big button on the right.
- Connect to the BlueBox Wi-Fi network.
- Transfer the download to the Raspberry Pi using SSH via WINSCP or FileZilla.
- Ensure the Raspberry Pi is connected to the Internet.
- Change to the directory where you transferred the file. For example, if you transferred the file to /var/www/html, you would run the following:
cd /var/www/html
- Unpack kiwix-tools in a folder:
tar -xvf kiwix-tools_linux-arm*.tar.gz
- Remove the downloaded file:
rm kiwix-tools_linux-arm*.tar.gz
- Rename and move the extracted folder to /var/kiwix:
sudo mv kiwix-tools_linux-arm* /var/kiwix
- Make sure kiwix-manage, kiwix-search, and kiwix-serve are in the /var/kiwix/ directory:
cd /var/kiwixls
- Edit the configuration file to start Kiwix on boot:
sudo nano /etc/rc.local
- Add the following just before the exit line:
sudo /var/kiwix/kiwix-serve --library /var/www/html/modules/kiwix-library.xml --port=8080 --daemon
- Save the new configuration by typing Ctrl + X, then Y, then Enter.
- Connect to the BlueBox Wi-Fi network.
- Ensure the Raspberry Pi is connected to the Internet.
- Open a browser and enter 10.10.10.10/ as the URL. The page content should download and install automatically. You should now see the BlueBox site.
- You can now download modules.
- Run the following command in terminal to grant permissions for the user interface to edit the kiwix library file:
sudo chmod 777 /var/www/html/modules/kiwix-library.xml
- If not using a wired connection, remove the wireless network you used to connect and complete the earlier steps:
nmcli con delete CUGuest