diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 0000000..343970e --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,9 @@ +name: shellcheck +on: [push, pull_request] +jobs: + shellcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master diff --git a/scripts/reset_ble_stack.sh b/scripts/reset_ble_stack.sh index 53c338a..9c02615 100755 --- a/scripts/reset_ble_stack.sh +++ b/scripts/reset_ble_stack.sh @@ -2,13 +2,13 @@ set -e systemctl --user stop ble-peripheral -bluetoothctl power off &> /dev/null +bluetoothctl power off > /dev/null 2>&1 echo "Restarting bluez" # Configure sudo to allow running this without asking for a password -sudo $(realpath scripts/reset_bluez.sh) +sudo "$(realpath scripts/reset_bluez.sh)" sleep 2 echo "Powering on controller" -bluetoothctl power on &> /dev/null +bluetoothctl power on > /dev/null 2>&1 sleep 2 echo "Starting BLE service" systemctl --user start ble-peripheral diff --git a/scripts/reset_manually.sh b/scripts/reset_manually.sh index f795837..7dfbbfd 100755 --- a/scripts/reset_manually.sh +++ b/scripts/reset_manually.sh @@ -1,6 +1,6 @@ -#!/bin/sh +#!/usr/bin/env bash notify-send -t 3600000 -a ProtocolStateFuzzer -h string:x-canonical-private-synchronous:my-notification ProtocolStateFuzzer 'Device reset needed' -read -p 'PLEASE RESET THE DEVICE AND THEN PRESS ENTER TO CONTINUE...' +read -r -p 'PLEASE RESET THE DEVICE AND THEN PRESS ENTER TO CONTINUE...' notify-send -t 1 -a ProtocolStateFuzzer -h string:x-canonical-private-synchronous:my-notification ProtocolStateFuzzer 'Continuing' diff --git a/scripts/setup_venv.sh b/scripts/setup_venv.sh index d0ea4ce..abc769f 100755 --- a/scripts/setup_venv.sh +++ b/scripts/setup_venv.sh @@ -1,22 +1,24 @@ -#!/bin/bash +#!/usr/bin/env bash # This script sets up the python environment if it doesn't exist yet. # It should be sourced (i.e. called with "source scripts/setup_venv.sh") # so that the python environment will be available in the calling shell. if [ -d "venv" ]; then + # shellcheck source=/dev/null source venv/bin/activate else # Create a venv and activate it python3 -m venv venv + # shellcheck source=/dev/null source venv/bin/activate # Install dependencies from PyPi pip3 install -r requirements.txt # Install the BLESMPServer git clone https://github.com/apferscher/ble-learning.git - cd ble-learning + cd ble-learning || exit git checkout febd774109c41a6635659b8847cc766e667841dd - cd libs/smp_server + cd libs/smp_server || exit python3 setup.py install cd ../../.. rm -rf ble-learning