Skip to content

Instantly share code, notes, and snippets.

@cr-chsn1
Last active April 21, 2021 19:56
Show Gist options
  • Save cr-chsn1/a525fd56548fe78379bde2b948eb06f8 to your computer and use it in GitHub Desktop.
Save cr-chsn1/a525fd56548fe78379bde2b948eb06f8 to your computer and use it in GitHub Desktop.
HWBOT Prime script for Orange Pi
#!/bin/bash
clear
# Bash coloring
color_reset='\033[0m'
color_cyan='\033[0;36m'
color_green='\033[0;32m'
color_red='\033[0;31m'
color_yellow='\033[0;33m'
# Function for converting frequencies kHz > MHz
function convert_to_MHz {
let value=$1/1000
echo "$value"
}
printf "${color_cyan}######################################${color_reset}\n"
printf "${color_cyan}# #${color_reset}\n"
printf "${color_cyan}# HWBOT Prime Script for Orange Pi #${color_reset}\n"
printf "${color_cyan}# #${color_reset}\n"
printf "${color_cyan}# by cr_chsn1 Version 1.0 #${color_reset}\n"
printf "${color_cyan}######################################${color_reset}\n"
echo
echo
if [ "${1}" = "--install" ]; then
printf "${color_green}### Installing dependencies ###${color_reset}\n"
echo
echo "Did you resized your file system on the SD-card?"
echo "[1] Yes"
echo "[2] No"
echo
echo "Please select your answer (1..2), followed by [ENTER]:"
read input
echo
if (("$input" == "1")); then
sudo apt update
sudo apt -y install cpufrequtils lsb-core openjdk-8-jre
wget http://downloads.hwbot.org/hwbotprime.jar
echo
printf "${color_green}Everything is installed. Please restart the script for benchmarking.${color_reset}\n"
echo
exit 0
fi
if (("$input" == "2")); then
printf "${color_red}Please resize your file system, because this installion will need more space you probably have.${color_reset}\n"
printf "${color_red}Use 'fdisk /dev/mmcblk0' to expand the Linux-partition. After a reboot type 'resize2fs /dev/mmcblk0p2'.${color_reset}\n"
echo
exit 0
fi
fi
printf "${color_green}### Software-Information ###${color_reset}\n"
echo
printf "${color_green}Versions:${color_reset}\n"
os_name=$(lsb_release -si)
os_codename=$(lsb_release -sc)
os_version=$(cat /etc/debian_version)
echo "Operating system:" $os_name $os_version "("$os_codename")"
echo
printf "${color_green}Linux-Kernel:${color_reset}\n"
uname -r -v
echo
printf "${color_green}Java Runtime:${color_reset}\n"
java -version
echo
echo
printf "${color_yellow}### SoC-Information ###${color_reset}\n"
echo
printf "${color_yellow}Orange Pi Model (/sys/firmware/devicetree/base/model):${color_reset}\n"
cat /sys/firmware/devicetree/base/model && echo
echo
printf "${color_yellow}Identification (/proc/device-tree/compatible):${color_reset}\n"
cat /proc/device-tree/compatible && echo
echo
printf "${color_yellow}Sensor Status :${color_reset}\n"
sudo cpufreq-set -g performance
freq_arm=$(sudo cpufreq-info -w)
freq_arm=$(convert_to_MHz $freq_arm)
echo "Frequency (ARM): $freq_arm MHz"
echo
echo
printf "${color_red}### Benchmark ###${color_reset}\n"
echo
date_time=`date '+%Y-%m-%d_%H.%M.%S'`
java -jar ./hwbotprime.jar "$date_time"_"$freq_arm"arm_.hwbot
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment