### Monitor Dataplicity Mass Installation Log Source: https://docs.dataplicity.com/docs/install-dataplicity-on-many-devices This command displays the contents of the mass installation log file in real-time, allowing you to monitor the installation process and identify any errors. The `-F` option ensures that the output updates as new lines are added to the file, which is useful for debugging live installations. ```bash tail -F /var/log/mass-install-dp.log ``` -------------------------------- ### Install NGINX Web Server on Raspberry Pi Source: https://docs.dataplicity.com/docs/host-a-website-from-your-pi This command installs the NGINX web server on your Raspberry Pi. NGINX is a popular, lightweight web server. The installation process is initiated via the terminal, and NGINX is expected to start automatically upon completion. ```bash sudo apt install -y nginx ``` -------------------------------- ### Dataplicity Mass Installation Script Source: https://docs.dataplicity.com/docs/install-dataplicity-on-many-devices This shell script automates the installation of Dataplicity on a Raspberry Pi. It configures the device's hostname using its serial number, waits for network connectivity, checks for existing Dataplicity installations, downloads and registers the device, and then self-deletes upon successful completion. Users must replace 'EXAMPLE123' with their actual Dataplicity installer ID. ```Shell #!/bin/sh ACCT_ID="EXAMPLE123" INSTALL_URL="https://www.dataplicity.com/$ACCT_ID.py | sudo python" LOG_FILE="/var/log/mass-install-dp.log" #Wait maximum 30 seconds on network connectivity before giving up limit=30 retry=0 #Don't bother to run when lo is configured if [ "$IFACE" = lo ]; then exit 0 fi #Only run from ifup if [ "$MODE" != start ]; then exit 0 fi if [ ! -e /opt/dataplicity/mass-install-hostname ]; then echo "Configuring hostname..." >> $LOG_FILE 2>&1 procinfo=$(cat /proc/cpuinfo | grep Serial) rpi_serial=$(echo $procinfo | tr " " "\n" | tail -1) if [ -z $rpi_serial ]; then echo "Raspberry Pi serial number not found" >> $LOG_FILE 2>&1 else echo $rpi_serial | sudo tee /etc/hostname sudo sed -i '$d' /etc/hosts printf "127.0.0.1\t$rpi_serial\n" | sudo tee --append /etc/hosts sudo mkdir /opt/dataplicity sudo touch /opt/dataplicity/mass-install-hostname echo "Rebooting..." >> $LOG_FILE 2>&1 sudo reboot fi fi if [ ! -e /opt/dataplicity/tuxtunnel/auth ]; then echo $IFACE >> $LOG_FILE 2>&1 until ping -c 1 www.google.com > /dev/null ; do sleep 1 retry=$(($retry+1)) if [ $retry -eq $limit ]; then echo "Interface not connected and limit reached..." >> $LOG_FILE exit 0 fi done echo "Dataplicity will now be installed..." >> $LOG_FILE 2>&1 /bin/sh -c "curl -k $INSTALL_URL" >> $LOG_FILE 2>&1 #Self deletion (cleanup) /bin/sh -c "sudo rm /etc/network/if-up.d/mass-install-dp /opt/dataplicity/mass-install-hostname" fi ``` -------------------------------- ### Create Dataplicity Mass Installer Script File Source: https://docs.dataplicity.com/docs/install-dataplicity-on-many-devices This command uses the 'nano' text editor to create or open the 'mass-install-dp' file within the '/etc/network/if-up.d/' directory. This directory is designated for scripts that execute automatically when a network interface becomes active ('up'). ```Shell sudo nano /etc/network/if-up.d/mass-install-dp ``` -------------------------------- ### Dataplicity Textfield Action Configuration Example Source: https://docs.dataplicity.com/docs/custom-actions An example configuration file entry demonstrating how to set up a `textfield` action. It specifies the polling interval and the path to the `get` script for retrieving text. ```INI [textfield:Text Field] poll:4 get:~dataplicity/actions/hddtemp/get.sh ``` -------------------------------- ### Start Hawkeye Live Streaming Session Source: https://docs.dataplicity.com/docs/stream-live-video-from-your-pi Execute this shell command to initiate the Hawkeye live video streaming session. This command should be run after the automated installer has successfully completed its setup. ```Shell sudo /opt/webcam_streamer/start ``` -------------------------------- ### View Dataplicity Agent Installation Log Source: https://docs.dataplicity.com/docs/troubleshooting This command allows users to view the installation log file for the Dataplicity agent. It is useful for troubleshooting issues encountered during the initial setup process, providing insights into potential installation failures. ```bash less /var/log/dpinstall.log ``` -------------------------------- ### Install Dataplicity on DietPi Source: https://docs.dataplicity.com/docs/installation-on-different-oss Steps to install Dataplicity on DietPi, covering user creation, adding the user to sudoers, installing Python, and running the Dataplicity installation script via curl. ```bash # mkdir home # useradd pi -m -s /bin/bash # passwd pi raspberry raspberry # adduser pi sudo # su pi $ sudo apt-get install -y python $ curl https://www.dataplicity.com/.py | python ``` -------------------------------- ### Install Dataplicity on CentOS Source: https://docs.dataplicity.com/docs/installation-on-different-oss Guide for installing Dataplicity on CentOS, including supervisor installation using yum, running the Dataplicity script, and configuring systemd services for supervisor. ```bash yum install supervisor -y mkdir -p /etc/supervisor/conf.d/ curl https://www.dataplicity.com/xxxxxx.py | sudo python systemctl start supervisord systemctl enable supervisord echo >> /etc/supervisord.conf cat /etc/supervisor/conf.d/tuxtunnel.conf >> /etc/supervisord.conf supervisorctl reread supervisorctl update ``` -------------------------------- ### Dataplicity Slider Action Configuration Example Source: https://docs.dataplicity.com/docs/custom-actions An example configuration file entry demonstrating how to set up a `slider` action. It specifies the minimum and maximum values, and paths to the `set` and `get` scripts. ```INI [slider:Slider] min:-15 max:15 set:~dataplicity/actions/air/set.sh get:~dataplicity/actions/air/get.sh ``` -------------------------------- ### Install Dataplicity on Manjaro and Arch Linux Source: https://docs.dataplicity.com/docs/installation-on-different-oss Guide for installing Dataplicity on Manjaro and Arch Linux, including supervisor installation using pacman, running the Dataplicity script, and configuring systemd services for supervisor. ```bash $ su root root # pacman -S supervisor # mkdir -p /etc/supervisor/conf.d/ # curl https://www.dataplicity.com/.py | python # systemctl start supervisord # systemctl enable supervisord # echo >> /etc/supervisord.conf # cat /etc/supervisor/conf.d/tuxtunnel.conf >> /etc/supervisord.conf # supervisorctl reread # supervisorctl update ``` -------------------------------- ### Install Dataplicity on Fedora Source: https://docs.dataplicity.com/docs/installation-on-different-oss Instructions for installing Dataplicity on Fedora, covering supervisor installation using dnf, running the Dataplicity script, and configuring systemd services for supervisor. ```bash $ sudo su # dnf install supervisor # mkdir -p /etc/supervisor/conf.d/ # curl https://www.dataplicity.com/.py | python # systemctl start supervisord # systemctl enable supervisord # echo >> /etc/supervisord.conf # cat /etc/supervisor/conf.d/tuxtunnel.conf >> /etc/supervisord.conf # supervisorctl reread # supervisorctl update ``` -------------------------------- ### Install Dataplicity on Alpine Linux Source: https://docs.dataplicity.com/docs/installation-on-different-oss Instructions for setting up Dataplicity on Alpine Linux, including installing supervisor, curl, bash, sudo, creating a dataplicity user, symlinking python, and configuring supervisor for the service. ```bash apk add supervisor curl bash sudo adduser dataplicity -s /bin/bash -D ln -s /usr/bin/python3.9 /usr/bin/python mkdir /var/log/supervisor mkdir -p /etc/supervisor/conf.d curl -s https://www.dataplicity.com/?v=0.5.6 | sudo python cat /etc/supervisor/conf.d/tuxtunnel.conf >> /etc/supervisord.conf /etc/init.d/supervisord start || supervisord ``` -------------------------------- ### Install ScoutRealtime Gem Source: https://docs.dataplicity.com/docs/remotely-monitor-your-pi After Ruby is installed, use the 'gem' package manager to install the 'scout_realtime' gem, which provides the web-based system monitoring tool. ```Shell sudo gem install scout_realtime ``` -------------------------------- ### Install tmux Source: https://docs.dataplicity.com/docs/run-your-scripts-in-background First, install the tmux utility on your system using the apt package manager. ```bash sudo apt install -y tmux ``` -------------------------------- ### Set Execute Permissions for Installer Script Source: https://docs.dataplicity.com/docs/install-dataplicity-on-many-devices This command changes the file permissions of the 'mass-install-dp' script, making it executable. The '755' permission set grants read, write, and execute permissions to the owner, and read and execute permissions to the group and others. ```Shell sudo chmod 755 /etc/network/if-up.d/mass-install-dp ``` -------------------------------- ### Start VNC Session on Raspberry Pi Source: https://docs.dataplicity.com/docs/remotely-access-pi-desktop After installation, this command initiates a VNC server session. The first time it runs, it prompts the user to set a VNC access password for remote connections. ```Shell sudo /opt/remote_desktop/start ``` -------------------------------- ### Install Dataplicity on Kali Linux Source: https://docs.dataplicity.com/docs/installation-on-different-oss Simple steps to install Dataplicity on Kali Linux, involving installing curl using apt-get and then executing the Dataplicity installation script. ```bash $ sudo apt-get install -y curl curl https://www.dataplicity.com/.py | python ``` -------------------------------- ### Install HTOP Package on Raspberry Pi Source: https://docs.dataplicity.com/docs/htop-whats-running-on-your-pi This command installs the HTOP package on your Raspberry Pi using the apt package manager. The '-y' flag automatically confirms the installation. ```Bash sudo apt install -y htop ``` -------------------------------- ### Display All Porthole CLI Commands Source: https://docs.dataplicity.com/docs/command-line-interface This command displays a comprehensive list of all available commands for the Porthole CLI tool. It includes descriptions and usage instructions for each command, serving as the primary help interface for users. ```CLI porthole ``` -------------------------------- ### Run HTOP on Raspberry Pi Source: https://docs.dataplicity.com/docs/htop-whats-running-on-your-pi After installation, execute this command to launch the HTOP utility and view your Raspberry Pi's CPU and memory usage. ```Bash sudo htop ``` -------------------------------- ### Example Usage of Get-PortholeDeviceStatus PowerShell Cmdlet Source: https://docs.dataplicity.com/docs/porthole-powershell This example shows the output of the Get-PortholeDeviceStatus cmdlet, listing devices with their names, IDs, and online/offline status. This helps in quickly assessing the connectivity of multiple devices. ```PowerShell Get-PortholeDeviceStatus ``` -------------------------------- ### Install Telnet Client on Raspberry Pi Source: https://docs.dataplicity.com/docs/play-a-star-wars-movie This snippet provides the command to install the telnet client on your Raspberry Pi, which is a prerequisite for playing the Star Wars ASCII movie. It uses the `apt` package manager for installation. ```Shell sudo apt install -y telnet ``` -------------------------------- ### Start Filebrowser Service on Raspberry Pi Source: https://docs.dataplicity.com/docs/manage-files-with-wormhole After Filebrowser has been successfully installed, this command initiates the Filebrowser application. Once started, Filebrowser becomes accessible for remote file management via Dataplicity Wormhole. ```Shell sudo /opt/file_browser/start ``` -------------------------------- ### Install httpie for REST API Interaction Source: https://docs.dataplicity.com/docs/control-gpios-using-rest-api This command installs `httpie`, a command-line HTTP client, on Ubuntu. It's used for easily interacting with REST APIs from the terminal. ```Shell sudo apt install -y httpie ``` -------------------------------- ### Install eSpeak Text-to-Speech Utility on Raspberry Pi Source: https://docs.dataplicity.com/docs/make-your-pi-speak Install the `espeak` text-to-speech program on your Raspberry Pi using apt. This will download and install the necessary packages. ```bash sudo apt install -y espeak ``` -------------------------------- ### Example Usage of Get-PortholeDevices PowerShell Cmdlet Source: https://docs.dataplicity.com/docs/porthole-powershell This example demonstrates the output of the Get-PortholeDevices cmdlet, showing a list of registered devices with their respective details like DeviceName, DeviceId, DeviceStatus, MachineType, and AgentVersion. This helps in understanding the structure of the returned device information. ```PowerShell Get-PortholeDevices ``` -------------------------------- ### Install Falcon Framework for Python Source: https://docs.dataplicity.com/docs/control-gpios-using-rest-api This command installs the Falcon web framework for Python using pip3. Falcon is a minimalist API framework used for building REST APIs. ```Shell sudo pip3 install falcon ``` -------------------------------- ### Dataplicity Custom Actions configuration for LEDs (Configuration) Source: https://docs.dataplicity.com/docs/custom-actions-gpio Defines custom actions for controlling Red and Green LEDs within the Dataplicity system. It maps 'on', 'off', and 'get' commands to specific script paths for each LED, enabling remote control via Dataplicity. ```Configuration [section:Control LEDs] [onoff:Red LED] on:/home/dataplicity/actions/on-off/leds/control-state red on off:/home/dataplicity/actions/on-off/leds/control-state red off get:/home/dataplicity/actions/on-off/leds/get-state red [onoff:Green LED] on:/home/dataplicity/actions/on-off/leds/control-state green on off:/home/dataplicity/actions/on-off/leds/control-state green off get:/home/dataplicity/actions/on-off/leds/get-state green ``` -------------------------------- ### Clone SD Card Image with dd on Linux Source: https://docs.dataplicity.com/docs/install-dataplicity-on-many-devices This command uses the 'dd' utility to create an image file from an SD card. 'if=/dev/sdb' specifies the input file (the SD card device), and 'of=/home/$USER' specifies the output file path where the image will be saved in the current user's home directory. ```Shell sudo dd if=/dev/sdb of=/home/$USER ``` -------------------------------- ### Install Ruby Programming Language Source: https://docs.dataplicity.com/docs/remotely-monitor-your-pi Before installing ScoutRealtime, which is a Ruby Gem, you need to install the Ruby programming language package on your Raspberry Pi. ```Shell sudo apt install -y ruby ``` -------------------------------- ### Example Usage of Invoke-PortholeCommand PowerShell Cmdlet Source: https://docs.dataplicity.com/docs/porthole-powershell This example demonstrates using Invoke-PortholeCommand to execute 'cat /proc/cpuinfo | grep Hardware' on a remote device. It shows how to pass the device ID and the command, and illustrates the `StandardOutput` returned by the cmdlet. ```PowerShell Invoke-PortholeCommand -Device 12345678-1234-1234-1234-123456789000 ^ "cat /proc/cpuinfo| grep Hardware" ``` -------------------------------- ### Install VNC on Raspberry Pi via cURL Source: https://docs.dataplicity.com/docs/remotely-access-pi-desktop This command downloads and executes an automated installer script from GitHub, setting up VNC on the Raspberry Pi. It requires an active internet connection and sudo privileges. ```cURL curl -s https://raw.githubusercontent.com/wildfoundry/specialprojects-public/remote-desktop/install.bash | sudo bash ``` -------------------------------- ### Identify SD Card Device on Linux Source: https://docs.dataplicity.com/docs/install-dataplicity-on-many-devices This command lists information about all block devices, including hard drives and SD cards, connected to the system. It is used to identify the device name (e.g., /dev/sdb) corresponding to the inserted SD card, typically by comparing sizes. ```Shell sudo lsblk ``` -------------------------------- ### Bash script to get LED state (Bash) Source: https://docs.dataplicity.com/docs/custom-actions-gpio A Bash script designed to retrieve the current state of a specified LED (red or green) by reading its corresponding GPIO pin value. It includes validation for user permissions and input arguments, providing error messages for invalid usage or uninitialized LEDs. ```Bash #!/bin/bash # # DESCRIPTION: # This is a Custom Actions program that gets the state in which the LEDs are in. # # PRE-REQUISITES: # For this script to work the "dataplicity" user has to be added # to "gpio" group. This can be done from sudo account such as "pi" # with the use of the following command: # "sudo usermod -a -G gpio dataplicity" # # Check if "dataplicity" user is in "gpio" group grep gpio /etc/group | grep dataplicity > /dev/null if [[ $? -eq 1 ]]; then echo "Can't run script, Please add \"dataplicity\" user to \"gpio\" group." exit 1 fi # Enforce user to supply one argument if [[ $# -ne 1 ]]; then echo "[$0] Incorrect amount of arguments, 1 required." echo "Argument 1 must be: \"red\" or \"green\"." exit 1 fi # Check if LED_PIN argument is correct case $1 in red) LED_PIN=23 ;; green) LED_PIN=24 ;; *) echo "[$0] Incorrect argument - \"red\" or \"green\" expected." exit 1 ;; esac # Check if LED GPIO pin was previously initialized ls /sys/class/gpio/ | grep gpio$LED_PIN > /dev/null # If not initialized return error, else return current state if [[ $? -eq 1 ]]; then echo "[[[ReturnError:LED Not Initialized]]]" else echo "[[[ReturnOK:$(cat /sys/class/gpio/gpio$LED_PIN/value)]]]" fi ``` -------------------------------- ### Install Hawkeye Webcam Streamer using cURL Source: https://docs.dataplicity.com/docs/stream-live-video-from-your-pi This command uses cURL to download and execute an automated Lua installer for Hawkeye. Before proceeding, ensure your Raspberry Pi is connected to the internet, has a USB webcam, Dataplicity installed, and you are logged in as the 'pi' user with port 80 free. ```cURL curl https://raw.githubusercontent.com/wildfoundry/specialprojects-public/webcam-streamer/install_webcamstreamer.lua | sudo lua ``` -------------------------------- ### Example Usage of Restart-PortholeDevice PowerShell Cmdlet Source: https://docs.dataplicity.com/docs/porthole-powershell This example demonstrates using Restart-PortholeDevice to initiate a remote reboot of a device by providing its unique device ID. The output 'True' indicates the command was successfully issued. ```PowerShell Restart-PortholeDevice -Device 12345678-1234-1234-1234-123456789000 ``` -------------------------------- ### Dataplicity option Action API Definition Source: https://docs.dataplicity.com/docs/custom-actions Defines the 'option' Action, a multiple-choice menu, including its methods ('get', 'set', 'options'), their parameter requirements, and expected return formats. It also provides an example configuration file entry. ```APIDOC option Action: Description: Creates a multiple choice menu. Use Cases: Fan speed control, Dimmer switch. Methods: get: Description: Script run to determine initial status. Parameter: script (path to executable) Returns: "[[[ReturnError:]]]" or "[[[ReturnOK:<1 or 0>]]]" set: Description: Script executes a user defined action based on selected option. Parameter: script (path to executable) options: Description: Defines the choices for the multiple-choice menu. Parameter: multiple comma separated strings (choices) Configuration Example: [option:Multiple Choice] options:option 1, Option 2, Option 3, Option 4 get:~dataplicity/actions/fan/get.sh set:~dataplicity/actions/fan/set.sh ``` -------------------------------- ### View Dataplicity Agent Runtime Log Source: https://docs.dataplicity.com/docs/troubleshooting This command displays the runtime log file for the Dataplicity agent. It's essential for diagnosing connectivity problems or unusual behavior after the agent has been installed, with the '+G' argument ensuring the view starts at the end of the file. ```bash less +G /var/log/dataplicity.log ``` -------------------------------- ### Create Dataplicity action directory (Shell) Source: https://docs.dataplicity.com/docs/custom-actions-gpio Creates the required directory structure for storing Dataplicity Custom Action scripts, specifically for LED control. The '-p' flag ensures parent directories are created if they don't exist. ```Shell mkdir -p /home/dataplicity/actions/on-off/leds ``` -------------------------------- ### Create Dataplicity Custom Action Shell Script Source: https://docs.dataplicity.com/docs/hello-world This shell script, designed for Dataplicity custom actions, creates a marker file named 'custom_actions_are_working' in the user's home directory. It also outputs '[[[ReturnOK]]]' to the console, which Dataplicity interprets as a successful execution signal. This serves as a fundamental example to verify the functionality of custom actions. ```Shell #!/bin/bash touch ~/custom_actions_are_working echo "[[[ReturnOK]]]" ``` -------------------------------- ### Switch to sudo-able user (Shell) Source: https://docs.dataplicity.com/docs/custom-actions-gpio Allows switching to a sudo-able user account (e.g., 'pi') to perform privileged operations required for system configuration. ```Shell su pi ``` -------------------------------- ### Dataplicity onoff Action API Definition Source: https://docs.dataplicity.com/docs/custom-actions Defines the 'onoff' Action, a bi-state slider, including its methods ('get', 'on', 'off'), their script parameter requirements, and expected return formats. It also provides an example configuration file entry. ```APIDOC onoff Action: Description: Creates a bi-state slider (enabled/disabled). Use Cases: GPIOs, LEDs, Switches, Home automation, Raspberry Pi OS system services. Methods: get: Description: Script run to determine initial status. Parameter: script (path to executable) Returns: "[[[ReturnError:]]]" or "[[[ReturnOK:<1 or 0>]]]" on: Description: Script called when adjusted from Off to On. Parameter: script (path to executable) Returns: "[[[ReturnOK]]]" off: Description: Script called when adjusted from On to Off. Parameter: script (path to executable) Returns: "[[[ReturnOK]]]" Configuration Example: [onoff:Off/On] on:~dataplicity/actions/on-off/on.sh off:~dataplicity/actions/on-off/off.sh get:~dataplicity/actions/on-off/get.sh ``` -------------------------------- ### Dataplicity percentage Action API Definition Source: https://docs.dataplicity.com/docs/custom-actions Defines the 'percentage' Action, a graphical bar for percentage values, including its methods ('get', 'poll'), their parameter requirements, and expected return formats. It also provides an example configuration file entry. ```APIDOC percentage Action: Description: Creates a graphical bar to represent a percentage value. Use Cases: Disk space monitoring, Long running file download progress, Tank water level, Tracking progress of a long running task, Show battery consumption. Methods: get: Description: Script run to determine initial status. Parameter: script (path to executable) Returns: "[[[ReturnError:]]]" or "[[[ReturnOK:<1 or 0>]]]" poll: Description: Sets the refresh interval for the percentage value. Parameter: integer (seconds between refreshes) Configuration Example: [percentage:Progress Bar] get:~dataplicity/actions/diskPercent/get.sh poll:2.5 ``` -------------------------------- ### Execute sudo commands after user switch Source: https://docs.dataplicity.com/docs/superuser Once you have successfully switched to a privileged user account (e.g., 'pi' user) and entered the correct password, you can then use the `sudo` command as normal to perform administrative tasks or install software on your device. ```Shell sudo cat /etc/shadow ``` -------------------------------- ### Install Filebrowser on Raspberry Pi Source: https://docs.dataplicity.com/docs/manage-files-with-wormhole This command uses cURL to download and execute an automated installer script for Filebrowser on a Raspberry Pi. It prepares the environment for remote file management, ensuring the Pi is connected to the internet and Dataplicity is installed. ```cURL curl https://raw.githubusercontent.com/wildfoundry/specialprojects-public/file-browser/install_filebrowser.lua | sudo lua ``` -------------------------------- ### Example Usage of Invoke-PortholeDeviceTerminal PowerShell Cmdlet Source: https://docs.dataplicity.com/docs/porthole-powershell This example demonstrates using Invoke-PortholeDeviceTerminal to open a terminal session to a remote device by providing its unique device ID. This allows direct interactive access to the remote system. ```PowerShell Invoke-PortholeDeviceTerminal -Device 12345678-1234-1234-1234-123456789000 ``` -------------------------------- ### Test eSpeak Text-to-Speech Functionality Source: https://docs.dataplicity.com/docs/make-your-pi-speak After installing eSpeak, test its functionality by having your Raspberry Pi say 'Hello' through the configured audio output. ```bash sudo espeak "Hello" ``` -------------------------------- ### Run Python LED REST API Application Source: https://docs.dataplicity.com/docs/control-gpios-using-rest-api This command executes the Python LED REST controller script. It starts the Falcon web server, making the LED control API accessible. ```Shell sudo python3 led-rest-controller.py ``` -------------------------------- ### Access API Help Endpoint with httpie Source: https://docs.dataplicity.com/docs/control-gpios-using-rest-api This command uses `httpie` to send a GET request to the root endpoint of the LED REST API. It retrieves and displays the API's help page. ```Shell http GET https://ABCD-EFGH-1234-device.dataplicity.io/ ``` -------------------------------- ### Example Dataplicity Wormhole URL Source: https://docs.dataplicity.com/docs/control-gpios-using-rest-api This HTML snippet shows an example of a Dataplicity Wormhole URL. This unique URL provides remote access to the Raspberry Pi's web server. ```HTML https://ABCD-EFGH-1234-device.dataplicity.io/ ``` -------------------------------- ### Construct Base Wormhole URL for Remote Access Source: https://docs.dataplicity.com/docs/remotely-access-pi-desktop This example shows the base URL format for accessing a device's unique wormhole. This URL serves as the foundation for constructing the full VNC access link. ```HTML https://ABCD-EFGH-1234-device.dataplicity.io/ ``` -------------------------------- ### Execute Commands on Multiple Porthole Devices (Batch Script) Source: https://docs.dataplicity.com/docs/command-line-interface This Windows batch script iterates through a predefined list of device IDs and executes the 'ls /home/pi' command on each. It demonstrates how to automate command execution across multiple Porthole-managed devices, leveraging batch scripting for efficiency. ```Batch Script for %x in ( 11111111-1111-1111-1111-111111111111 22222222-2222-2222-2222-222222222222 ) do ( porthole devices:command %x ls /home/pi ) ``` -------------------------------- ### Get Green LED State with httpie Source: https://docs.dataplicity.com/docs/control-gpios-using-rest-api This command sends a GET request to the `/green` endpoint of the LED API using `httpie`. It retrieves the current state (ON/OFF) of the green LED. ```Shell http GET https://ABCD-EFGH-1234-device.dataplicity.io/green ``` -------------------------------- ### Echo Success Message for Custom Action Source: https://docs.dataplicity.com/docs/custom-actions-gpio This shell command is used to output a specific string, '[[[ReturnOK]]]', which often serves as an indicator of successful execution for a custom action within the Dataplicity system. ```Shell echo "[[[ReturnOK]]]" ``` -------------------------------- ### List Porthole Forwarded Devices Source: https://docs.dataplicity.com/docs/command-line-interface This command lists all devices that currently have port forwards assigned through the Porthole system. It provides an overview of active forwarding configurations, mirroring the information available in the graphical interface. ```CLI porthole forwards ``` -------------------------------- ### Construct VNC Access URL for Remote Desktop Source: https://docs.dataplicity.com/docs/remotely-access-pi-desktop This example demonstrates how to append the VNC-specific path (/vnc.html) to the base wormhole URL, enabling direct browser access to the VNC web interface. ```HTML https://ABCD-EFGH-1234-device.dataplicity.io/vnc.html ``` -------------------------------- ### Add Dataplicity user to GPIO group (Shell) Source: https://docs.dataplicity.com/docs/custom-actions-gpio Adds the 'dataplicity' user to the 'gpio' system group, granting necessary permissions for Dataplicity Custom Actions to interact with GPIOs. ```Shell sudo usermod -a -G gpio dataplicity ``` -------------------------------- ### Execute 'htop' Command on Porthole Device Source: https://docs.dataplicity.com/docs/command-line-interface This command executes the 'htop' command on a specified remote device, providing a real-time interactive process viewer. It illustrates the ability to run more complex, interactive commands on remote devices through the Porthole CLI. ```CLI porthole devices:command 11111111-1111-1111-1111-111111111111 htop ``` -------------------------------- ### Set Executable Permissions for Dataplicity Action Scripts Source: https://docs.dataplicity.com/docs/custom-actions-gpio This command sets file permissions to 755 (read, write, execute for owner; read, execute for group and others) on all files within the specified directory. This is crucial for ensuring that custom action scripts, such as those controlling LEDs, are executable by the system. ```Shell chmod 755 /home/dataplicity/actions/on-off/leds/* ``` -------------------------------- ### Bash script to control LED state (Bash) Source: https://docs.dataplicity.com/docs/custom-actions-gpio A Bash script for controlling the on/off state of a specified LED (red or green) by manipulating its GPIO pin. It handles GPIO initialization if needed and includes robust checks for user permissions and correct input arguments. ```Bash #!/bin/bash # # DESCRIPTION: # This is a Custom Actions program that controls LEDs. # # PRE-REQUISITES: # For this script to work the "dataplicity" user has to be added # to "gpio" group. This can be done from sudo account such as "pi" # with the use of the following command: # "sudo usermod -a -G gpio dataplicity" # # Check if "dataplicity" user is in "gpio" group grep gpio /etc/group | grep dataplicity > /dev/null if [[ $? -eq 1 ]]; then echo "Can't run script, Please add \"dataplicity\" user to \"gpio\" group." exit 1 fi # Enforce user to supply two arguments if [[ $# -ne 2 ]]; then echo "[$0] Incorrect amount of arguments, 2 required." echo "Argument 1 must be: \"red\" or \"green\"." echo "Argument 2 must be: \"on\" or \"off\"." exit 1 fi # Check if LED_PIN argument is correct case $1 in red) LED_PIN=23 ;; green) LED_PIN=24 ;; *) echo "[$0] Incorrect argument ($1) - \"red\" or \"green\" expected." exit 1 ;; esac # Check if CONTROL argument is correct case $2 in on) CONTROL=1 ;; off) CONTROL=0 ;; *) echo "[$0] Incorrect argument ($2) - \"on\" or \"off\" expected." exit 1 ;; esac # Check if LED GPIO pin was previously initialized ls /sys/class/gpio/ | grep gpio$LED_PIN > /dev/null # Initialize, if not previously initialized if [[ $? -eq 1 ]]; then echo "$LED_PIN" > /sys/class/gpio/export sleep 0.5 fi # Switch LED ON or OFF echo "out" > /sys/class/gpio/gpio$LED_PIN/direction echo "$CONTROL" > /sys/class/gpio/gpio$LED_PIN/value ``` -------------------------------- ### View Porthole Account Details Source: https://docs.dataplicity.com/docs/command-line-interface This command retrieves and displays information about the currently logged-in user account within the Porthole system. It confirms the user's identity and provides details such as the associated email address. ```CLI porthole account ``` -------------------------------- ### Enable UFW Firewall Source: https://docs.dataplicity.com/docs/securing-wormhole-enabled-web-servers These commands install and enable the Uncomplicated Firewall (UFW) on a Linux system. UFW provides a user-friendly interface for managing iptables, allowing administrators to easily configure network security rules and restrict incoming connections to enhance system protection. ```bash sudo apt install -y ufw sudo ufw enable ``` -------------------------------- ### ActionMethod Script Exit Code Example Source: https://docs.dataplicity.com/docs/custom-actions Demonstrates how an ActionMethod script can return a non-zero exit code to indicate a failure or specific status, as interpreted by the Dataplicity system. ```shell exit 5 ``` -------------------------------- ### Curl SSL Certificate Problem Error Message Example Source: https://docs.dataplicity.com/docs/troubleshooting An example of an SSL certificate error message encountered during a curl operation, indicating issues with certificate verification or trust chain. ```Text % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 curl: (60) SSL certificate problem: unable to get local issuer certificate More details here: http://curl.haxx.net/docs/sslcerts.html curl performs SSL certificate verification by default, using a "bundle" of Certificate Authority (CA) public keys (CA certs). If the default bundle file isn't adequate, you can specify an alternate file using the --cacert option. If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL). If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option. ``` -------------------------------- ### Example Device-Generated Tags Script (Shell) Source: https://docs.dataplicity.com/docs/device-management-at-scale This shell script demonstrates how to output custom tags, one per line, that the Dataplicity Agent will pick up. The output should contain only one alphanumeric string per line, without spaces, though underscores are permitted. ```Shell #!/bin/sh echo "NAME_GRUNTMASTER" echo "MODEL_6000" echo "VERSION_1_0_0" ``` -------------------------------- ### Play Star Wars ASCII Movie via Telnet Source: https://docs.dataplicity.com/docs/play-a-star-wars-movie This command initiates the Star Wars ASCII movie playback by connecting to a specific telnet server. Once executed, it provides a long, text-based movie experience. This requires a telnet client to be installed on your system. ```Shell telnet towel.blinkenlights.nl ``` -------------------------------- ### Enable SSH on Raspberry Pi Source: https://docs.dataplicity.com/docs/redirect-tcp-ports-over-the-internet These commands are used to enable and start the SSH service on a Raspberry Pi running Raspbian. They also ensure that the SSH host keys are regenerated, which is important for security and unique identification of the device. ```Shell sudo systemctl enable ssh sudo systemctl start ssh sudo systemctl enable regenerate_ssh_host_keys.service sudo systemctl start regenerate_ssh_host_keys.service ``` -------------------------------- ### Restart Dataplicity Agent (Shell) Source: https://docs.dataplicity.com/docs/custom-actions-gpio Restarts all services managed by Supervisor, including the Dataplicity Agent, to ensure new permissions or configuration changes take effect. ```Shell sudo supervisorctl restart all ``` -------------------------------- ### Input Parameters for Invoke-PortholeCommand PowerShell Cmdlet Source: https://docs.dataplicity.com/docs/porthole-powershell This section describes the input parameters required by the Invoke-PortholeCommand cmdlet. It details the 'Device' parameter (Unique Device API ID) and the 'Command' parameter (Remote command to execute), along with their descriptions and examples. ```APIDOC Device: Unique Device API ID for the device. Command: Remote command to execute. Example: "cat /proc/cpuinfo" ``` -------------------------------- ### View Dataplicity Logs with Debug Information Source: https://docs.dataplicity.com/docs/troubleshooting Displays the Dataplicity agent's log file, allowing users to review all log entries, including newly enabled debug messages, starting from the end of the file. ```Bash less +G /var/log/dataplicity.log ``` -------------------------------- ### Python Falcon LED REST API Controller Source: https://docs.dataplicity.com/docs/control-gpios-using-rest-api This Python script implements a REST API using the Falcon framework to control green and red LEDs connected to a Raspberry Pi's GPIO pins. It defines routes for a help page, and for getting/setting the state of green and red LEDs via HTTP GET and PUT requests. ```Python from wsgiref.simple_server import make_server import falcon import json import RPi.GPIO as GPIO LEDS = {"green": 16, "red": 18} GPIO.setmode(GPIO.BOARD) GPIO.setup(LEDS["green"], GPIO.OUT) GPIO.setup(LEDS["red"], GPIO.OUT) def get_led_state(led_colour): return json.dumps({ 'active' : GPIO.input(LEDS[led_colour]), }) def set_led_state(led_colour, led_new_state): state = {'off': 0, 'on': 1} if not led_new_state in state: return json.dumps({ 'result' : 'error - incorrect state option supplied' }) else: GPIO.output(LEDS[led_colour], state[led_new_state]) return json.dumps({ 'result' : 'success' }) class helpPageResource: def on_get(self, req, resp): resp.content_type = falcon.MEDIA_TEXT resp.text = ('Hello! To interact with this API please use GET and PUT requests on:\n\n' + req.url + '\n\n' 'Available colours:\n' ' /green, /red\n' 'Available PUT operations on the above colours:\n' ' Change of state: active=' ) class LedGreenResource: def on_get(self, req, resp): resp.text = get_led_state('green') def on_put(self, req, resp): change = json.loads(req.bounded_stream.read()) resp.text = set_led_state('green', change['active']) class LedRedResource: def on_get(self, req, resp): resp.text = get_led_state('red') def on_put(self, req, resp): change = json.loads(req.bounded_stream.read()) resp.text = set_led_state('red', change['active']) app = falcon.App() help_page = helpPageResource() led_green = LedGreenResource() led_red = LedRedResource() app.add_route('/', help_page) app.add_route('/green', led_green) app.add_route('/red', led_red ) if __name__ == '__main__': with make_server('', 80, app) as httpd: print('Serving REST LED controller on Wormhole...') httpd.serve_forever() ``` -------------------------------- ### Define Dataplicity Custom Action Configuration Source: https://docs.dataplicity.com/docs/hello-world This configuration snippet defines a custom action within Dataplicity. It sets up a 'Hello world' section and an action titled 'Click to see CA working' that executes a specified shell script. This file enables the custom action functionality within the Dataplicity system. ```Configuration [section:Hello world] [action:Click to see CA working] do:/home/dataplicity/actions/hello_world/hello_world_script.sh ``` -------------------------------- ### Disable VNC Remote Desktop Service (Uninstall Step) Source: https://docs.dataplicity.com/docs/remotely-access-pi-desktop This command disables the remote_desktop service, preventing it from automatically starting on future system reboots as part of the uninstallation process. ```Shell sudo systemctl disable remote_desktop ``` -------------------------------- ### Reinstall pip to Resolve Python Module Errors Source: https://docs.dataplicity.com/docs/troubleshooting Commands to completely remove and then reinstall pip, addressing 'ImportError: No module named packaging.version' which indicates a corrupted pip installation. ```Bash sudo su root ``` ```Bash apt-get purge -y python-pip ``` ```Bash wget https://bootstrap.pypa.io/get-pip.py ``` ```Bash python ./get-pip.py ``` ```Bash apt-get install python-pip ``` -------------------------------- ### Execute 'ls' Command on Porthole Device Source: https://docs.dataplicity.com/docs/command-line-interface This command allows executing the 'ls' command directly on a specified remote device connected via Porthole. It demonstrates the capability to run arbitrary shell commands on managed devices to inspect their file systems. ```CLI porthole devices:command 11111111-1111-1111-1111-111111111111 ls ``` -------------------------------- ### Slack Incoming Webhook App Directory URL Source: https://docs.dataplicity.com/docs/device-status-notifications This URL directs users to the Slack App Directory to install the Incoming Webhooks application. This application is essential for setting up device notifications to be sent to a designated Slack channel. ```Text https://.slack.com/apps/A0F7XDUAZ-incoming-webhooks ``` -------------------------------- ### Resolve SSL Certificate Errors on Debian/Ubuntu Source: https://docs.dataplicity.com/docs/troubleshooting A series of commands to install necessary tools, fetch and save Dataplicity's SSL certificate, copy it to the system's SSL directory, and update the CA certificates to resolve SSL verification issues. ```Bash sudo apt-get install gnutls-bin ca-certificates -y ``` ```Bash gnutls-cli --print-cert dataplicity.com /tmp/dataplicitycert.crt ``` ```Bash echo | openssl s_client -connect dataplicity.com:443 2>&1 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /tmp/dataplicitycert.crt ``` ```Bash sudo cp /tmp/dataplicitycert.crt /etc/ssl/dataplicitycert.crt ``` ```Bash sudo update-ca-certificates ``` -------------------------------- ### Dataplicity action Action API Definition Source: https://docs.dataplicity.com/docs/custom-actions Defines the 'action' Action, a general-purpose script execution trigger, including its method ('do'), parameter requirements, and expected return formats. It also provides an example configuration file entry. ```APIDOC action Action: Description: Executes a script that does not fit under a more specific Action. Use Cases: Running scripts (including longer running scripts), Arbitrary actions triggered by a 'button press'. Methods: do: Description: Script run after user clicks the Action. Parameter: script (path to executable) Returns: "[[[ReturnError]]]" or "[[[ReturnOK]]]" Configuration Example: [action:Action Click] do:~dataplicity/actions/sayHello/do.sh ``` -------------------------------- ### Access Nginx Website via Wormhole URL Source: https://docs.dataplicity.com/docs/host-a-website-from-your-pi This code snippet provides an example of a Wormhole URL. This unique URL is generated by Dataplicity for each device and allows direct access to web services, such as an Nginx server, running on the Raspberry Pi from any web browser. The 'ABCD-EFGH-1234' part is a placeholder for the device's unique identifier. ```HTML https://ABCD-EFGH-1234-device.dataplicity.io/ ``` -------------------------------- ### Dataplicity Textfield Action API Definition Source: https://docs.dataplicity.com/docs/custom-actions Defines the methods and parameters for the `textfield` action in Dataplicity, used for displaying text. It includes a `get` method for initial text and a `poll` method for refresh intervals. ```APIDOC textfield Action: get: description: Script to determine the initial text displayed. parameters: script: Path to a script. returns: "[[[ReturnError:]]]" or "[[[ReturnOK:<1 or 0>]]]" poll: description: Sets the refresh interval for the textfield. parameters: interval: Integer value (seconds) for refresh rate. ``` -------------------------------- ### Launch Raspberry Pi Configuration Utility Source: https://docs.dataplicity.com/docs/get-pi-connected-to-the-internet This command opens the `raspi-config` utility, which provides a user-friendly interface for configuring various aspects of your Raspberry Pi, including network settings like WiFi. It's the easiest way to set up wireless connectivity. ```bash sudo raspi-config ```