...
This script setup-pib.sh can be found in this repository: https://github.com/pib-rocks/pib-backend/blob/main/setup/setup-pib.sh
It’s assumed that the user running this script has “pib“ as a username and the operating system is Ubuntu 22.04.2 LTS. Before running the script, the user name used on this device must be set in the DEFAULT_USER variable. The default user is "pib".
Here is the description of some variables being used in the script:
TMP_DIR - the directory where the archives with Cerebra, phpLiteAdmin, and the database initialization script will be saved. It’s /home/user/setup_tmp/ by default.
ROS_WORKSPACE - the directory where the ROS2 node for the camera will be installed and the scripts for starting ROS and Cerebra (ros_cerebra_boot.sh) and the camera (ros_camera_boot.sh) as well. It’s /home/user/ros2_ws/ by default.
PHPLITEADMIN_INSTALLATION_DIR - the directory where the phpLiteAdmin is being installed. It’s /var/www/phpliteadmin by default.
DATABASE_DIR - the directory where the database is being initialized. It’s /home/user/pib_data by default.
DEFAULT_NGINX_HTML_DIR - the directory where Cerebra will be unzipped. It’s etc/nginx/html by default.
…_URL variables contain links to download all necessary files and packages.
…_FILE and …_ZIP variables describe the filenames to save the downloaded resources.
To make the script executable run in the terminal the following command:
Code Block |
---|
sudo chmod 755 setup-pib.sh |
To run the script type the following:
Code Block |
---|
./setup-pib.sh |
As soon as the script is completely executed, the system will automatically reboot.the latest Raspberry Pi OS.
What the script does:
Req # | What is done | How to test this requirement |
---|---|---|
1 | The username of the user running the script is printed to console like “Hello “+$USERNAME+”! You are now setting up pibs software…” | Run the setup-testscript and make an assertion in the script for the line in the created logfile provided by the testscript. Will be automated in the future and part of the testscript |
2 | Check if username is “pib”. If yes: continue. If no: Ask “It is strongly recommended to run this script as user ‘pib’, but your username is '“+$USERNAME+”. Do you want to continue anyways? (y/n): “ If yes: continue if no: abort the script with the message “Aborting installation, no changes were done. Please re-run the script as user ‘pib’…” | At the moment it must be tested manually. Create VM and create a new user on it. Change user context to new user and run setup-script. An additional testscript will be created and testing this via an assertion in the testscript. |
3 | Ask for admin password and enable the script to run with admin/root privileges | Must be tested manually as sudo and password is technically not possible through a shh-pseudo-shell in a virtual machine Current workaround in the testscript is to make a sudo-command with a chmod right before executing the setup-pib.sh. So the sudo-context and password is saved for a certain amount of time and the setup-script will be running in a sudo-context without prompting for the password. |
4 | Cerebra is installed | Going to “http://localhost” or “http://<IP>” in chromium opens the Cerebra UI |
5 | The database is available | Going in Cerebra to “Programs” shows a default program. Without database the complete right component is empty. |
6 | BrickV is installed | BrickV can be opened in the menu (Programs->BrickV) |
7 | The animated eyes are installed on the desktop | Animated gif is on the desktop |
8 | A link to Cerebra is available on the desktop | Shortcut is on the desktop |
TODO: check this for validity:
To check if ROS successfully started, execute the command:
...
In this case, the output will be simpler:
...
To stop Cerebra:
Code Block |
---|
sudo systemctl stop nginx |
To stop ROS (assuming that ROS is running on port 9090):
Code Block |
---|
sudo kill -9 `lsof -t -i:9090` |
To start Cerebra again:
Code Block | ||
---|---|---|
| ||
sudo systemctl start nginx |
And to start ROS again:
Code Block | ||
---|---|---|
| ||
ros2 launch rosbridge_server rosbridge_websocket_launch.xml |
Be aware that with the last command, ROS will lock your terminal by starting for writing its logs there. And if you take control over the terminal back by clicking “ctrl+C” it will cause ROS to stop. Therefore the best way to start ROS again is to reboot the system.
Deploy script
These scripts are intended to install new versions of the Cerebra application.
This script deploy_cerebra.sh can be found here:
Jira Legacy | ||||||
---|---|---|---|---|---|---|
|
While the script is running, an archive with a new version of Cerebra is being downloaded from Pib.Rocks (https://pib.rocks/wp-content/uploads/pib_data/cerebra-latest.zip) and then installed on the target device.
The script runs directly on the target device.
The script should be executable as well. To make it executable run in terminal the following command:
Code Block |
---|
sudo chmod 755 deploy_cerebra.sh |
To run the script type the following:
...