Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
on:
- push
- pull_request

name: "Shellcheck"
permissions: {}

jobs:
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
severity: warning
16 changes: 16 additions & 0 deletions .github/workflows/shfmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: shfmt
on:
- pull_request
- push
jobs:
sh-checker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run the sh-checker
uses: luizm/action-sh-checker@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
sh_checker_shellcheck_disable: true
sh_checker_comment: true
33 changes: 0 additions & 33 deletions Blink.ino

This file was deleted.

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Mirte Install Scripts
Scripts that are ran during creation of the image and on the Mirte itself.

## Stylecheck
- [shfmt](https://github.com/mvdan/sh): styling (whitespace) of all shell scripts
- [ShellCheck](https://github.com/koalaman/shellcheck): static analysis to find (possible) bugs. Only errors and warnings are enabled

Check & format using their command line tools or vscode plugins. Or check the GitHub workflows with (act)[https://github.com/nektos/act].
157 changes: 78 additions & 79 deletions blink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,103 +7,102 @@ OPI2=$(grep "Orange Pi Zero 2" /proc/device-tree/model)
RPI=$(grep -a "Raspberry" /proc/device-tree/model)

if [ "$RPI" ]; then
echo none > /sys/class/leds/ACT/trigger
echo none > /sys/class/leds/PWR/trigger
echo none >/sys/class/leds/ACT/trigger
echo none >/sys/class/leds/PWR/trigger
fi

red_on() {
if [ "$OPI" ]; then
echo 'default-on' > /sys/class/leds/orangepi\:red\:status/trigger
elif [ "$OPI2" ]; then
echo '255' > /sys/class/leds/orangepi\:red\:power/brightness
elif [ "$RPI" ]; then
echo 1 > /sys/class/leds/PWR/brightness
fi
if [ "$OPI" ]; then
echo 'default-on' >/sys/class/leds/orangepi\:red\:status/trigger
elif [ "$OPI2" ]; then
echo '255' >/sys/class/leds/orangepi\:red\:power/brightness
elif [ "$RPI" ]; then
echo 1 >/sys/class/leds/PWR/brightness
fi
}
red_off() {
if [ "$OPI" ]; then
echo 'none' > /sys/class/leds/orangepi\:red\:status/trigger
elif [ "$OPI2" ]; then
echo '0' > /sys/class/leds/orangepi\:red\:power/brightness
elif [ "$RPI" ]; then
echo '0' > /sys/class/leds/PWR/brightness
fi
if [ "$OPI" ]; then
echo 'none' >/sys/class/leds/orangepi\:red\:status/trigger
elif [ "$OPI2" ]; then
echo '0' >/sys/class/leds/orangepi\:red\:power/brightness
elif [ "$RPI" ]; then
echo '0' >/sys/class/leds/PWR/brightness
fi
}

green_on() {
if [ "$OPI" ]; then
echo 'default-on' > /sys/class/leds/orangepi\:green\:pwr/trigger
elif [ "$OPI2" ]; then
echo '255' > /sys/class/leds/orangepi\:green\:status/brightness
elif [ "$RPI" ]; then
echo 1 > /sys/class/leds/ACT/brightness
fi
if [ "$OPI" ]; then
echo 'default-on' >/sys/class/leds/orangepi\:green\:pwr/trigger
elif [ "$OPI2" ]; then
echo '255' >/sys/class/leds/orangepi\:green\:status/brightness
elif [ "$RPI" ]; then
echo 1 >/sys/class/leds/ACT/brightness
fi
}

green_off() {
if [ "$OPI" ]; then
echo 'none' > /sys/class/leds/orangepi\:green\:pwr/trigger
elif [ "$OPI2" ]; then
echo '0' > /sys/class/leds/orangepi\:green\:status/brightness
elif [ "$RPI" ]; then
echo 0 > /sys/class/leds/ACT/brightness
fi
if [ "$OPI" ]; then
echo 'none' >/sys/class/leds/orangepi\:green\:pwr/trigger
elif [ "$OPI2" ]; then
echo '0' >/sys/class/leds/orangepi\:green\:status/brightness
elif [ "$RPI" ]; then
echo 0 >/sys/class/leds/ACT/brightness
fi
}

if ! [ "$OPI" ]; then

echo "Blinking"
echo "$VALUE"
echo "Blinking"
echo "$VALUE"

for (( repeat=0; repeat<5; repeat++ )); do
# Start sequence with fast blinking both
for (( i=0; i<10; i++ )); do
FAST=$(echo "scale=2; $BLINK_SPEED/20" | bc)
green_on
red_on
sleep "$FAST"
green_off
red_off
sleep "$FAST"
done
sleep $BLINK_SPEED
for ((repeat = 0; repeat < 5; repeat++)); do
# Start sequence with fast blinking both
for ((i = 0; i < 10; i++)); do
FAST=$(echo "scale=2; $BLINK_SPEED/20" | bc)
green_on
red_on
sleep "$FAST"
green_off
red_off
sleep "$FAST"
done
sleep $BLINK_SPEED

for (( i=0; i<${#VALUE}; i++ )); do
# Next character
green_on
sleep $BLINK_SPEED
green_off
sleep $BLINK_SPEED
for ((i = 0; i < ${#VALUE}; i++)); do
# Next character
green_on
sleep $BLINK_SPEED
green_off
sleep $BLINK_SPEED

if [ "${VALUE:i:1}" == "." ]; then
green_on
red_on
sleep $BLINK_SPEED
green_off
red_off
sleep $BLINK_SPEED
else
if [ "${VALUE:i:1}" == "0" ]; then
TWICE=$(echo "scale=2; $BLINK_SPEED*2" | bc)
sleep "$TWICE"
else
# Convert hex to decimal number
DEC_VAL=$(echo "obase=10; ibase=16; ${VALUE:i:1}" | bc)

if [ "${VALUE:$i:1}" == "." ]; then
green_on
red_on
sleep $BLINK_SPEED
green_off
red_off
sleep $BLINK_SPEED
else
if [ "${VALUE:$i:1}" == "0" ]; then
TWICE=$(echo "scale=2; $BLINK_SPEED*2" | bc)
sleep "$TWICE"
else
# Convert hex to decimal number
DEC_VAL=$(echo "obase=10; ibase=16; ${VALUE:$i:1}" | bc)
# Blink decimal number
for ((j = 0; j < DEC_VAL; j++)); do
red_on
sleep $BLINK_SPEED
red_off
sleep $BLINK_SPEED
done
fi
fi
done
done

# Blink decimal number
for (( j=0; j<${DEC_VAL}; j++ )); do
red_on
sleep $BLINK_SPEED
red_off
sleep $BLINK_SPEED
done
fi
fi
done
done

# Reset to defaults
green_on
red_off
# Reset to defaults
green_on
red_off
fi
2 changes: 1 addition & 1 deletion download_repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ sudo apt-get update
sudo apt-get install -y python3-vcstool

# Download all Mirte repositories
vcs import < repos.yaml --workers 1 #TODO: get yaml file as parameter
vcs import --workers 1 <repos.yaml #TODO: get yaml file as parameter

# TODO: set remote to gitlab when checkout from local
8 changes: 4 additions & 4 deletions install_ROS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sudo sh -c 'echo "deb http://ftp.tudelft.nl/ros/ubuntu $(lsb_release -sc) main"
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
sudo apt install -y ros-noetic-ros-base python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential python3-catkin-tools python3-osrf-pycommon
grep -qxF "source /opt/ros/noetic/setup.bash" /home/mirte/.bashrc || echo "source /opt/ros/noetic/setup.bash" >> /home/mirte/.bashrc
grep -qxF "source /opt/ros/noetic/setup.bash" /home/mirte/.bashrc || echo "source /opt/ros/noetic/setup.bash" >>/home/mirte/.bashrc
source /opt/ros/noetic/setup.bash
sudo rosdep init
rosdep update
Expand All @@ -37,12 +37,12 @@ sudo pip3 install pyzbar

# Install Mirte ROS package
mkdir -p /home/mirte/mirte_ws/src
cd /home/mirte/mirte_ws/src
cd /home/mirte/mirte_ws/src || exit
ln -s $MIRTE_SRC_DIR/mirte-ros-packages .
cd ..
rosdep install -y --from-paths src/ --ignore-src --rosdistro noetic
catkin build
grep -qxF "source /home/mirte/mirte_ws/devel/setup.bash" /home/mirte/.bashrc || echo "source /home/mirte/mirte_ws/devel/setup.bash" >> /home/mirte/.bashrc
grep -qxF "source /home/mirte/mirte_ws/devel/setup.bash" /home/mirte/.bashrc || echo "source /home/mirte/mirte_ws/devel/setup.bash" >>/home/mirte/.bashrc
source /home/mirte/mirte_ws/devel/setup.bash

# install missing python dependencies rosbridge
Expand All @@ -68,7 +68,7 @@ sudo pip3 install pillow adafruit-circuitpython-ssd1306==2.12.1
# Install aio dependencies
sudo pip3 install janus async-generator nest-asyncio
git clone https://github.com/locusrobotics/aiorospy.git
cd aiorospy/aiorospy
cd aiorospy/aiorospy || exit
sudo pip3 install .
cd ../..
rm -rf aiorospy
2 changes: 1 addition & 1 deletion install_arduino.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ sudo adduser mirte dialout

# By default, armbian has ssh login for root enabled with password 1234.
# The password need to be set to mirte_mirte so users can use the
# Arduino IDE remotely.
# Arduino IDE remotely.
# TODO: when the Arduino IDE also supports ssh for non-root-users
# this has to be changed
echo -e "mirte_mirte\nmirte_mirte" | sudo passwd root
Expand Down
2 changes: 1 addition & 1 deletion install_fake_bt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ sudo dpkg -i linux-headers*.deb
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.21.tar.xz
xz -d -v linux-5.10.21.tar.xz
tar xvf linux-5.10.21.tar linux-5.10.21/net/bluetooth
cd linux-5.10.21/net/bluetooth
cd linux-5.10.21/net/bluetooth || exit

# Apply 'fix'
sed -i 's/flt_type = HCI_FLT_CLEAR_ALL;/\/\/flt_type = HCI_FLT_CLEAR_ALL;/g' hci_core.c
Expand Down
2 changes: 1 addition & 1 deletion install_jupyter_ros.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sudo apt install -y python3 python3-venv python3-dev git libffi-dev
# create and activate virtualenv
# Due to a build error on numpy we need to install numpy and
# padnas globally and us it in the virtual environment
cd /home/mirte
cd /home/mirte || exit
sudo apt install -y python3-numpy python3-pandas
python3 -m venv jupyter --system-site-packages
source /home/mirte/jupyter/bin/activate
Expand Down
6 changes: 3 additions & 3 deletions install_mirte.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ pip3 install numpy

sudo apt install -y bluez joystick
if [ "$(uname -a | grep sunxi)" != "" ]; then
# currently only supporting cheap USB dongles on OrangePi
./install_fake_bt.sh
# currently only supporting cheap USB dongles on OrangePi
./install_fake_bt.sh
fi

# Install Mirte documentation
cd $MIRTE_SRC_DIR/mirte-documentation
sudo apt install -y python3.8-venv libenchant-dev
python3 -m venv docs-env
source docs-env/bin/activate
pip install docutils==0.16.0 sphinx-tabs==3.2.0 #TODO: use files to freeze versions
pip install docutils==0.16.0 sphinx-tabs==3.2.0 #TODO: use files to freeze versions
pip install wheel sphinx sphinx-prompt sphinx-rtd-theme sphinxcontrib-spelling sphinxcontrib-napoleon
mkdir -p _modules/catkin_ws/src
cd _modules
Expand Down
4 changes: 2 additions & 2 deletions install_web.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ nodeenv --node=16.2.0 $MIRTE_SRC_DIR/mirte-web-interface/node_env
. $MIRTE_SRC_DIR/mirte-web-interface/node_env/bin/activate

# Install frontend
cd $MIRTE_SRC_DIR/mirte-web-interface/vue-frontend
cd $MIRTE_SRC_DIR/mirte-web-interface/vue-frontend || exit
npm install .
npm run build

# Install backend
cd $MIRTE_SRC_DIR/mirte-web-interface/nodejs-backend
cd $MIRTE_SRC_DIR/mirte-web-interface/nodejs-backend || exit
npm install .

# Install wetty
Expand Down
8 changes: 4 additions & 4 deletions network_install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash

MIRTE_SRC_DIR=/usr/local/src/mirte

Expand All @@ -22,8 +22,8 @@ sudo bash -c 'echo "nameserver 8.8.8.8" > /etc/resolv.conf'

# Install wifi-connect
MY_ARCH=$(arch)
if [[ "$MY_ARCH" == "armv7l" ]]; then MY_ARCH="rpi"; fi
wget https://github.com/balena-os/wifi-connect/releases/download/v4.4.6/wifi-connect-v4.4.6-linux-$(echo "$MY_ARCH").tar.gz
if [[ $MY_ARCH == "armv7l" ]]; then MY_ARCH="rpi"; fi
wget https://github.com/balena-os/wifi-connect/releases/download/v4.4.6/wifi-connect-v4.4.6-linux-"$(echo "$MY_ARCH")".tar.gz
tar -xf wifi-connect*
sudo mv wifi-connect /usr/local/sbin
rm wifi-connect*
Expand Down Expand Up @@ -68,7 +68,7 @@ sudo bash -c 'echo "libcomposite" >> /etc/modules'

# Generate wifi password (TODO: generate random password and put on NTFS)
if [ ! -f /home/mirte/.wifi_pwd ]; then
bash -c 'echo mirte_mirte > /home/mirte/.wifi_pwd'
bash -c 'echo mirte_mirte > /home/mirte/.wifi_pwd'
fi

# Allow wifi_pwd to be modified using the web interface
Expand Down
Loading