Index: archive/autostart =================================================================== diff -u --- archive/autostart (revision 0) +++ archive/autostart (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,30 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2019-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file autostart +# +# @author (last) Behrouz NematiPour +# @date (last) 15-Dec-2022 +# @author (original) Behrouz NematiPour +# @date (original) 28-Oct-2019 +# +############################################################################ +case "$1" in + start) + logger "Starting autostart scripts" + HOME="/home/root" + cd "$HOME" + ./run.sh "$HOME" + logger $? + exit 0 + ;; + *) + echo "It's just a startup script and has no arguments or commands" + exit 1 + ;; +esac Index: archive/bluetooth_paired_clear.sh =================================================================== diff -u --- archive/bluetooth_paired_clear.sh (revision 0) +++ archive/bluetooth_paired_clear.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,39 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file bluetooth_paired_clear.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-Nov-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-Nov-2021 +# +############################################################################ + +# @details +# This file is called by UI Software to removed all the currnelty paired or cached devices. +# This is done before each scan to clean up and start a fresh scan. + +DEVICES=$(echo "devices" | sudo bluetoothctl | grep ^Device | cut -b 8-25) +if [ ! -z "$DEVICES" ]; then + for device in $DEVICES; do + if [ ! -z "$device" ]; then + echo "remove $device" | sudo bluetoothctl + fi + done +fi + +PAIRED_DEVICES=$(echo "paired-devices" | sudo bluetoothctl | grep ^Device | cut -b 8-25) +if [ ! -z "$PAIRED_DEVICES" ]; then + for paired_device in $PAIRED_DEVICES; do + if [ ! -z "$paired_device" ]; then + echo "remove $paired_device" | sudo bluetoothctl + fi + done +fi + Index: archive/bluetooth_paired_query.sh =================================================================== diff -u --- archive/bluetooth_paired_query.sh (revision 0) +++ archive/bluetooth_paired_query.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,30 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file bluetooth_paired_query.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 12-Dec-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-Nov-2021 +# +############################################################################ + +# @details +# This file is called by UI Software to query the Blood Pressure paired Bluetooth device. +# There should be only one device paired at a time regarding our design. +# The returned value is the devive mac address and the name assigned to it in the system. + +#test code +#PAIRED_DEVICE_INFO="28:FF:B2:78:5B:BF BP7000" +#PAIRED_DEVICE_INFO="" + +PAIRED_DEVICE_INFO=$(echo "paired-devices" | sudo bluetoothctl | grep ^Device | cut -b 8-125) + +echo $PAIRED_DEVICE_INFO + Index: archive/crypt_setup.sh =================================================================== diff -u --- archive/crypt_setup.sh (revision 0) +++ archive/crypt_setup.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,161 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2022-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file crypt_setup.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 15-May-2023 +# @author (original) Behrouz NematiPour +# @date (original) 15-May-2023 +# +############################################################################ + +IS_MOUNTED=0 + +ERR_CRYPTSETUP_UNKNOWN=100 + +ERR_CRYPTSETUP_USAGE=101 +ERR_CRYPTSETUP_PASSWORD=102 + +ERR_CRYPTSETUP_UMOUNT=111 +ERR_CRYPTSETUP_CLOSE=112 + +ERR_CRYPTSETUP_CREATE_MKDIR=121 +ERR_CRYPTSETUP_CREATE_FORMAT=122 +ERR_CRYPTSETUP_CREATE_OPEN=123 +ERR_CRYPTSETUP_CREATE_MKFS=124 +ERR_CRYPTSETUP_CREATE_MOUNT=125 + +ERR_CRYPTSETUP_MOUNT_TYPE=131 +ERR_CRYPTSETUP_MOUNT_OPEN=132 +ERR_CRYPTSETUP_MOUNT_MOUNT=133 +ERR_CRYPTSETUP_MOUNT_ISMOUNT=134 # is used in Application do not modify [DeviceController] +ERR_CRYPTSETUP_MOUNT_CRC=135 + +LOC_DEV="/dev/mmcblk0p7" +LOC_DIR="configurations" +LOC_MAP="/dev/mapper/"$LOC_DIR +LOC_VAR="/var/"$LOC_DIR +LOC_CRC="settings.crc" +LOC_CFG="/home/root/.config" + +DEV_TYP="crypto_LUKS" +DEV_MNT="/dev/mapper/configurations on /var/configurations type ext4 (rw,relatime)" + +function isEncrypted () { + if [ "$( blkid | grep "$LOC_DEV" | grep "TYPE=$DEV_TYP" )" != "" ]; then + echo "not an encrypted partition" + exit $ERR_CRYPTSETUP_MOUNT_TYPE + fi +} + +function isMounted() { + if [ "$( sudo mount | grep "$DEV_MNT" )" != "" ]; then + echo "partition already mounted" + return $IS_MOUNTED + fi + return 1 +} + +function checkPassword() { + if [ "$PASSWORD" == "" ]; then + echo "setup command missing password argument" + exit $ERR_CRYPTSETUP_PASSWORD + fi +} + +function checkShaSum() { + if [ "$(whoami)" == "root" ]; then + cd "$LOC_CFG" + else + cd "$LOC_VAR" + fi + + if [ ! -f "$LOC_CRC" ]; then + echo "Settings CRC failed [crc file does not exists]" + exit $ERR_CRYPTSETUP_MOUNT_CRC + fi + + out=$( sha256sum -c "$LOC_CRC" | grep "FAILED" ) + echo "$(pwd)" > /tmp/checksum.log + echo "$out" >> /tmp/checksum.log + + cd - + if [ ! "$out" == "" ]; then + echo "Settings CRC FAILED" + exit $ERR_CRYPTSETUP_MOUNT_CRC + fi +} + +function checkOutput() { + if [ "$3" == "" ]; then + out=` eval "$1" 2>&1` + else + out=`echo $3 | eval "$1" 2>&1` + fi + if [ "$?" -ne 0 ]; then + echo $out + exit $2 + fi +} + +function unmount_luks_partition() +{ + checkOutput "sudo umount $LOC_VAR " $ERR_CRYPTSETUP_UMOUNT + checkOutput "sudo cryptsetup luksClose $LOC_DIR " $ERR_CRYPTSETUP_CLOSE +} + +function create_luks_partition() +{ + isMounted && unmount_luks_partition + checkOutput "sudo mkdir -p $LOC_VAR " $ERR_CRYPTSETUP_CREATE_MKDIR + checkOutput "sudo cryptsetup luksFormat $LOC_DEV " $ERR_CRYPTSETUP_CREATE_FORMAT $PASSWORD + checkOutput "sudo cryptsetup luksOpen $LOC_DEV $LOC_DIR" $ERR_CRYPTSETUP_CREATE_OPEN $PASSWORD + checkOutput "sudo mkfs.ext4 $LOC_MAP " $ERR_CRYPTSETUP_CREATE_MKFS + checkOutput "sudo mount -t ext4 $LOC_MAP $LOC_VAR" $ERR_CRYPTSETUP_CREATE_MOUNT +} + +function mount_luks_partition() +{ + isEncrypted # if encrypted will continue else will exit with error + isMounted # if mounted will echo and return 0=IS_MOUNTED + if [ ! $? -eq $IS_MOUNTED ]; then # if not mounted, mount it + checkOutput "sudo cryptsetup luksOpen $LOC_DEV $LOC_DIR" $ERR_CRYPTSETUP_MOUNT_OPEN $PASSWORD + checkOutput "sudo mount -t ext4 $LOC_MAP $LOC_VAR" $ERR_CRYPTSETUP_MOUNT_MOUNT + fi + checkShaSum # if checksum fails echos and exits +} + +function handleCommand() { + # Handle the first argument to script, one of start, stop, erase, restart, force-reload or status + case $1 in + setup) + checkPassword + create_luks_partition + ;; + + mount) + checkPassword + mount_luks_partition + ;; + + umount) + unmount_luks_partition + ;; + + *) + echo "unknown command" + exit $ERR_CRYPTSETUP_UNKNOWN + ;; + + esac +} + +handleCommand $1 $2 + +exit 0 Index: archive/date_time_set.sh =================================================================== diff -u --- archive/date_time_set.sh (revision 0) +++ archive/date_time_set.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,28 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file date_time_set.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 20-Apr-2021 +# @author (original) Behrouz NematiPour +# @date (original) 20-Apr-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile 'yyyy-mm-dd HH:MM:SS'" + exit 0 +fi + +sudo date -s "$1" + +# set the hwclock from the system time +sudo hwclock -w + Index: archive/decommission.sh =================================================================== diff -u --- archive/decommission.sh (revision 0) +++ archive/decommission.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,236 @@ +#!/bin/sh + +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file decommission.sh +# +# @author (last) Vy Duong +# @date (last) 26-May-2023 +# @author (original) Vy Duong +# @date (original) 26-May-2023 +# +############################################################################ + +# @details +# This file is called by UI Software to decommission the device + +#TODO This script needs to be integrated with the globals.sh + +ERR_REMOVE_PRM_DIR=150 +ERR_REMOVE_PRM_FIL=151 +ERR_REMOVE_CMD_DIR=152 +ERR_REMOVE_CMD_FIL=153 +ERR_REMOVE_DEL_DIR=154 +ERR_REMOVE_DEL_FIL=155 + +ERR_CLEAN_SETTINGS_CONF_PASSNOTFOUNT=159 +ERR_CLEAN_SETTINGS_CONF_OVERWRITE=160 +ERR_CLEAN_SETTINGS_DFLT_RESTORE=161 + +ERR_CLEAN_LOGS=162 + +ERR_COUDSYNC_TOKENS=163 + +LOC_WIFI_CONFIGURATION="/etc/wpa_supplicant/wpa_supplicant-wlan0.conf" +LOC_BLUETOOTH_DEVCACHE="/var/lib/bluetooth/" +LOC_SETTINGS_CONF="/var/configurations/Settings/System.conf" +LOC_SETTINGS_DFLT="/var/configurations/Settings/System.dflt" +LOC_LOG_BASE_FOLDER="/media/sd-card/" +LOC_TX_LOG_BASE_FOLDER="/var/configurations/treatment/" +LOC_COUDSYNC_TOKENS="/var/configurations/CloudSync/" + +TRUE=1 +FALSE=0 +function false() { echo $FALSE; } +function true () { echo $TRUE ; } + +# check if the passed argument is a non-zero number +function isNonZero () + # $1 - mutant: the argument to be detected +{ + local _ok_=$FALSE + if [[ $1 =~ ^[0-9]+$ ]]; then + if (( $1 )); then + _ok_=$TRUE + fi + fi + echo $_ok_ +} + +# checks if the passed argument is a number +function isNumber () + # $1 - mutant: the argument to be detected +{ + local _ok_=$FALSE + if [[ $1 =~ ^[0-9]+$ ]]; then + _ok_=$TRUE + fi + echo $_ok_ +} + +# checks if the passed argument is a directory +function isDirectory() + # $1 - string: the argument to be detected +{ + local _ok_=$FALSE + if [[ -d $1 ]]; then + _ok_=$TRUE + fi + echo $_ok_ +} + +# checks if the passed argument is a file +function isFile() + # $1 - string: the argument to be detected +{ + local _ok_=$FALSE + if [[ -f $1 ]]; then + _ok_=$TRUE + fi + echo $_ok_ +} + +# checks if the passed argument exists +function exits() + # $1 - string: the argument to be detected +{ + local _ok_=$FALSE + if [[ -e $1 ]]; then + _ok_=$TRUE + fi + echo $_ok_ +} + +# exits with the exit code if the condistion ($1) is non-zero +function exitError () + # $1 - number: boolean result to exit if non-zero, with exit code + # $1 - number: exit code + # $2 - string: echo message [optional] +{ + if (( $2 )); then + echo $3 + fi + + if (( $(isNonZero $1) )); then + exit $2 + fi +} + +# removes all the files in the directory and subdirectory in a recursive manner +function clearFolderContent() + # $1 - Directory path + # $2 - Directory alias name +{ + local _has_error_=$[ ! $(isDirectory $1)] + exitError $_has_error_ $ERR_REMOVE_PRM_DIR "'$1' is not a directory" + + rm -rf "$1/*/*" + _has_error_=$? + exitError $_has_error_ $ERR_REMOVE_CMD_DIR "Failed $2 folder deletion" + + list=("$1"/*) + fileCount=${#list[@]} + _has_error_=$fileCount + exitError $_has_error_ $ERR_REMOVE_DEL_DIR "Remained '$fileCount' file(s) undeleted" +} + +# exits rm command fails or if file was not removed +function removeSingleFile() + # $1 - path to file + # $2 - file alias name +{ + local _has_error_=$[ ! $(isFile $1)] + exitError $_has_error_ $ERR_REMOVE_PRM_FIL "'$1' is not a file" + + rm "$1" + _has_error_=$? + exitError $_has_error_ $ERR_REMOVE_CMD_FIL "Failed $2 file deletion" + + _has_error_=$(exists $1) + exitError $_has_error_ $ERR_REMOVE_DEL_FIL "Remained $2 file undeleted" +} + +function deleteWiFi() { + SCRIPTS=/home/$(whoami)/scripts + $SCRIPTS/wifi_disconnect_network.sh wlan0 +} + +function deleteBluetooth() { + SCRIPTS=/home/$(whoami)/scripts + $SCRIPTS/bluetooth_paired_clear.sh +} + +function defaultSettings() { + local _has_error_=$FALSE + + cp $LOC_SETTINGS_DFLT $LOC_SETTINGS_CONF # reset the settings to default settings + _has_error_=$? + exitError $_has_error_ $ERR_CLEAN_SETTINGS_CONF_OVERWRITE "Service settings overwrite failed" +} + +function deleteLogFiles() { + # handling log deletion in a special manner: + # - Log files generated today + # - are not deleted + # - not part of the checking whether deletion was successful + # - setting maxDepth to 2 due to path used is root level with sd-card/ folders of logs + find "$LOC_LOG_BASE_FOLDER" -maxdepth 2 -type f -daystart -mtime +0 | xargs rm + _has_error_=!$? + exitError $_has_error_ $ERR_REMOVE_CMD_FIL "Log file deletion" + + fileCount=$(find "$LOC_LOG_BASE_FOLDER" -maxdepth 2 -type f -daystart -mtime +0 | wc -l) + _has_error_=$fileCount + exitError $_has_error_ $ERR_REMOVE_DEL_FIL "Remained '$fileCount' file undeleted" + + # Deleting treatment logs in encrypted partition: + find "$LOC_TX_LOG_BASE_FOLDER" -maxdepth 2 -type f | xargs rm + + _has_error_=!$? + exitError $_has_error_ $ERR_REMOVE_CMD_FIL "Tx Log file deletion" + + fileCount=$(find "$LOC_TX_LOG_BASE_FOLDER" -maxdepth 2 -type f | wc -l) + _has_error_=$fileCount + exitError $_has_error_ $ERR_REMOVE_DEL_FIL "Remained '$fileCount' file undeleted" +} + +function deletePartitionPassword() { + # TODO it is not clear how + # and by the way it is not user dependent password toget reset + # it is managed by UI App and it will be working regardless of the user. + # ./crupt_setup + echo "" # cannot be empty, syntax error +} + +function deleteCloudSyncTokens() { + # TODO this will always fail due to the fact that + # the security design, makes any Linux user responsible for each application/service + # therfore denali user does not have access to the cloud user files + # and cannot delete the CloudSync tokens and credentials. + clearFolderContent $LOC_COUDSYNC_TOKENS "CloudSync Tokens" $ERR_COUDSYNC_TOKENS +} + +# delete WiFi settings +# delete Bluetooth settings +# settings.conf to default (including service password) +# delete logs +# delete service password + +# delete partition password +# delete cloudsync tokens +function main() { + deleteWiFi + deleteBluetooth + defaultSettings + deleteLogFiles + deletePartitionPassword + deleteCloudSyncTokens +} + +main +echo "" +exit 0 Index: archive/export_logs.sh =================================================================== diff -u --- archive/export_logs.sh (revision 0) +++ archive/export_logs.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,54 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2022-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file export_logs.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 14-Jan-2022 +# @author (original) Behrouz NematiPour +# @date (original) 14-Jan-2022 +# +############################################################################ + +CURRNET_DATE=$(date +%Y_%m_%d) +PATH_SRC="$1" +PATH_DST="$2" +PASS_HAS="$3" + +function echo_usage() { + if [[ -z "$PATH_SRC" || -z "$PATH_DST" ]]; then + echo "Usage:" + echo "./export_logs.sh " + echo "" + fi +} + +function export_logs() { + OPTP="" + PASS="Empty Password" + if [[ -n "$PASS_HAS" ]]; then + PASS=$(pwgen -ABcsnv1 16) + OPTP=--password="$PASS" + fi + + EXPORT_FILE=$CURRNET_DATE"_logs" + + echo "$PATH_DST"/"$EXPORT_FILE".zip # echo the out zip + rm -frd "$PATH_DST"/"$EXPORT_FILE".zip && # remove the old zip from dest + rm -frd $HOME/"$EXPORT_FILE".zip && # remove the old zip from home + zip -jr9 $HOME/"$EXPORT_FILE".zip "$PATH_SRC" "$OPTP" && # compress the new zip to home neesd to change to 7zzs + cp $HOME/"$EXPORT_FILE".zip "$PATH_DST" && # copy the new zip to dest + echo $PASS > "$PATH_DST"/"$EXPORT_FILE".pas && # copy the new pas to dest + rm -frd $HOME/"$EXPORT_FILE".zip # remove the tmp zip from home +} + +if [[ "$1" == "" ]]; then + echo_usage +fi + +export_logs Index: archive/factory_reset.sh =================================================================== diff -u --- archive/factory_reset.sh (revision 0) +++ archive/factory_reset.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,242 @@ +#!/bin/sh + +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file factory_reset.sh +# +# @author (last) Vy Duong +# @date (last) 26-May-2023 +# @author (original) Vy Duong +# @date (original) 26-May-2023 +# +############################################################################ + +# @details +# This file is called by UI Software to remove and reset the device + +#TODO This script needs to be integrated with the globals.sh + +ERR_REMOVE_PRM_DIR=150 +ERR_REMOVE_PRM_FIL=151 +ERR_REMOVE_CMD_DIR=152 +ERR_REMOVE_CMD_FIL=153 +ERR_REMOVE_DEL_DIR=154 +ERR_REMOVE_DEL_FIL=155 + +ERR_CLEAN_SETTINGS_CONF_PASSNOTFOUND=159 +ERR_CLEAN_SETTINGS_CONF_OVERWRITE=160 +ERR_CLEAN_SETTINGS_DFLT_RESTORE=161 + +ERR_CLEAN_LOGS=162 + +LOC_WIFI_CONFIGURATION="/etc/wpa_supplicant/wpa_supplicant-wlan0.conf" +LOC_BLUETOOTH_DEVCACHE="/var/lib/bluetooth/" +LOC_SETTINGS_CONF="/var/configurations/Settings/System.conf" +LOC_SETTINGS_DFLT="/var/configurations/Settings/System.dflt" +LOC_LOG_BASE_FOLDER="/media/sd-card/" +LOC_TX_LOG_BASE_FOLDER="/var/configurations/treatment/" +LOC_SCRIPTS=$HOME/scripts +LOC_SCRIPTS_BRIGHTNESS=$LOC_SCRIPTS/brightness_set.sh + +DEFAULT_BRIGHTNESS_LEVEL=10 + + +TRUE=1 +FALSE=0 +function false() { echo $FALSE; } +function true () { echo $TRUE ; } + +# check if the passed argument is a non-zero number +function isNonZero () + # $1 - mutant: the argument to be detected +{ + local _ok_=$FALSE + if [[ $1 =~ ^[0-9]+$ ]]; then + if (( $1 )); then + _ok_=$TRUE + fi + fi + echo $_ok_ +} + +# checks if the passed argument is a number +function isNumber () + # $1 - mutant: the argument to be detected +{ + local _ok_=$FALSE + if [[ $1 =~ ^[0-9]+$ ]]; then + _ok_=$TRUE + fi + echo $_ok_ +} + +# checks if the passed argument is a directory +function isDirectory() + # $1 - string: the argument to be detected +{ + local _ok_=$FALSE + if [[ -d $1 ]]; then + _ok_=$TRUE + fi + echo $_ok_ +} + +# checks if the passed argument is a file +function isFile() + # $1 - string: the argument to be detected +{ + local _ok_=$FALSE + if [[ -f $1 ]]; then + _ok_=$TRUE + fi + echo $_ok_ +} + +# checks if the passed argument exists +function exists() + # $1 - string: the argument to be detected +{ + local _ok_=$FALSE + if [[ -e $1 ]]; then + _ok_=$TRUE + fi + echo $_ok_ +} + +# exits with the exit code if the condition ($1) is non-zero +function exitError () + # $1 - number: boolean result to exit if non-zero, with exit code + # $1 - number: exit code + # $2 - string: echo message [optional] +{ + if (( $2 )); then + echo "$3" + fi + + if (( $(isNonZero $1) )); then + exit $2 + fi +} + +# removes all the files in the directory and sub-directory in a recursive manner +function clearFolderContent() + # $1 - Directory path + # $2 - Directory alias name +{ + local _has_error_=$[ ! $(isDirectory $1)] + exitError $_has_error_ $ERR_REMOVE_PRM_DIR "'$1' is not a directory" + + rm -rf "$1/*/*" + _has_error_=$? + exitError $_has_error_ $ERR_REMOVE_CMD_DIR "Failed $2 folder deletion" + + list=("$1"/*) + fileCount=${#list[@]} + _has_error_=$fileCount + exitError $_has_error_ $ERR_REMOVE_DEL_DIR "Remained '$fileCount' file(s) undeleted" +} + +# exits rm command fails or if file was not removed +function removeSingleFile() + # $1 - path to file + # $2 - file alias name +{ + local _has_error_=$[ ! $(isFile $1)] + exitError $_has_error_ $ERR_REMOVE_PRM_FIL "'$1' is not a file" + + rm -f "$1" + _has_error_=$? + exitError $_has_error_ $ERR_REMOVE_CMD_FIL "Failed $2 file deletion" + + _has_error_=$(exists $1) + exitError $_has_error_ $ERR_REMOVE_DEL_FIL "Remained $2 file undeleted" +} + +function deleteWiFi() { + SCRIPTS=/home/$(whoami)/scripts + $SCRIPTS/wifi_disconnect_network.sh wlan0 +} + +function deleteBluetooth() { + SCRIPTS=/home/$(whoami)/scripts + $SCRIPTS/bluetooth_paired_clear.sh +} + +function defaultSettings() { + local _has_error_=$FALSE + + servicePasswordLine=$(grep -A1 "\[Service\]" "$LOC_SETTINGS_CONF" | grep Password) # store the service password line + _has_error_= [[ -z "$servicePasswordLine" ]] + exitError $_has_error_ $ERR_CLEAN_SETTINGS_CONF_PASSNOTFOUND "Password not found in '$LOC_SETTINGS_CONF'" + + cp $LOC_SETTINGS_DFLT $LOC_SETTINGS_CONF # reset the settings to default settings + _has_error_=$? + exitError $_has_error_ $ERR_CLEAN_SETTINGS_CONF_OVERWRITE "Service settings overwrite failed" + + sed -i "s/^.*Password.*$/$servicePasswordLine/" $LOC_SETTINGS_CONF # keep the service password + _has_error_=$? + exitError $_has_error_ $ERR_CLEAN_SETTINGS_DFLT_RESTORE "Service password restore failed" +} + +function defaultBrightness() { + $LOC_SCRIPTS_BRIGHTNESS $DEFAULT_BRIGHTNESS_LEVEL +} + +function deleteLogFiles() { + # handling log deletion in a special manner: + # - Log files generated today + # - are not deleted + # - not part of the checking whether deletion was successful + # - setting maxDepth to 2 due to path used is root level with sd-card/ folders of logs + # NOTE: find command always return true / non-zero! when using with exec + # TODO: Checking the file count should be fixed later + + # Remove the contents of the log folder + rm "$LOC_LOG_BASE_FOLDER"/log/* + _has_error_=!$? + exitError $_has_error_ $ERR_REMOVE_CMD_FIL "Log file deletion" + + # Remove the contents of the service folder + rm "$LOC_LOG_BASE_FOLDER"/service/* + _has_error_=!$? + exitError $_has_error_ $ERR_REMOVE_CMD_FIL "Service file deletion" + + fileCount=$(find "$LOC_LOG_BASE_FOLDER" -maxdepth 2 -type f -daystart -mtime +0 | wc -l) + _has_error_=$fileCount + exitError $_has_error_ $ERR_REMOVE_DEL_FIL "Remained '$fileCount' file undeleted" + + # Deleting treatment logs in encrypted partition: + find "$LOC_TX_LOG_BASE_FOLDER" -maxdepth 2 -type f | xargs rm + + _has_error_=!$? + exitError $_has_error_ $ERR_REMOVE_CMD_FIL "Tx Log file deletion" + + fileCount=$(find "$LOC_TX_LOG_BASE_FOLDER" -maxdepth 2 -type f | wc -l) + _has_error_=$fileCount + exitError $_has_error_ $ERR_REMOVE_DEL_FIL "Remained '$fileCount' file undeleted" +} + +# delete WiFi settings +# delete Bluetooth settings +# settings.conf to default +# brightness to default (10) +# delete logs +# keep partition password +# keep service password +# keep cloudsync tokens +function main() { + deleteWiFi + deleteBluetooth + defaultSettings + defaultBrightness + deleteLogFiles +} + +main +echo "" +exit 0 Index: archive/globals.sh =================================================================== diff -u --- archive/globals.sh (revision 0) +++ archive/globals.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,702 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2022-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file globals.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 15-Dec-2022 +# @author (original) Behrouz NematiPour +# @date (original) 15-Dec-2022 +# +############################################################################ + +# @details +# This script includes the global variables and functions to be used in the setup and start scripts. + +TRUE=1 +FALSE=0 + +COMMENT_STAR="********************************************************************************" +COMMENT_DASH="--------------------------------------------------------------------------------" + +DATETIME="$1 $2" + +#DO NOT MODIFY VARIABLES, unless the denali application is updated as well to match. +SDCARD_DEV=/dev/mmcblk1 +SDCARD_PRT=/dev/mmcblk1p1 +SDCARD_MNT=/media/sd-card +SDCARD_TYP_NAME=ext4 +SDCARD_TYP_NUMB=83 + +USB_DEV=/dev/sda1 +USB_MNT=/media/usb + +CLOUDSYNC_FOLDER=cloudsync # both for log and application + +LOG_LOCATION=$HOME/Desktop +LOG_OUT_FILE="" +LOG_ERR_FILE="" + +LOG_BASE=$SDCARD_MNT +LOG_LOC_LOG=log +LOG_LOC_ERR=service +EXT_GZIP=gz +EXT_PEND=u + +ERR_MISSING_FOLDER=101 +ERR_MISSING_FILE=102 +ERR_CONNECTION=103 +ERR_DENALI_BIN=104 +ERR_FONTS_EMTY=105 +ERR_FONTS_PATH=106 +ERR_KILLPROMPT=107 +ERR_MISSING_KEY=109 +ERR_SCP_FAIL=110 +ERR_INVALID_IP=111 +ERR_SD_CARD=112 +ERR_LOGBACKUP_PATH=113 + +SRC_FILE_SSHKEY="$HOME/.ssh/id_rsa" +SRC_FILE_SSHKEY_PUB=$SRC_FILE_SSHKEY.pub +SRC_PATH_SCRIPTS="scripts" +SRC_PATH_CONFIG="settings" +SRC_PATH_CLOUDSYNC="cloudsync" +SRC_PATH_DRYDEMO="dry-demo" +SRC_PATH_FONTS="fonts" + +DST_IP="" +DST_USER=root +DST_PATH_CONFIG="/home/$DST_USER/.config" +DST_PATH_HOME="/home/$DST_USER" +DST_PATH_SCRIPTS="/home/$DST_USER/scripts" +DST_PATH_CLOUDSYNC="/home/$DST_USER/cloudsync" +DST_PATH_DRYDEMO="/home/$DST_USER/dry-demo" +DST_PATH_FONTS="/usr/share/fonts/truetype" + +POSTLOG=/tmp/post.log +POSTERR=/tmp/post.err +POSTOUT=/tmp/post.out +POSTMSG_POSTFIX_PASSED=" passed" +POSTMSG_POSTFIX_FAILED=" failed" +POSTMSG_CANBUS="CANBus" +POSTMSG_SDCARD="SD-CARD" +POSTMSG_TOUCH="Touch" +POSTMSG_RTC="RTC" +POSTMSG_WIFI="WiFi" +POSTMSG_BLUETOOTH="Bluetooth" +POSTMSG_SHASUM="App shasum" +POSTMSG_CLOUDSYNC="CloudSync" +POSTMSG_SETTINGSCRC="SettingsCRC" + +TDCTL_NTP_USED=$FALSE +TDCTL_RTC_LOCL=$TRUE +TDCTL_TIMEZONE=America/Los_Angeles + +IP_SEG_MAX_LEN=3 +IP_EMT="192.168.10." +SSH_PARAM="-oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no -oLogLevel=ERROR -oConnectTimeout=2" + +CMD_RTC_EPOCH="cat /sys/class/rtc/rtc0/since_epoch" +CMD_SDCARD_DEV="ls $SDCARD_DEV" +CMD_SDCARD_PRT="ls $SDCARD_PRT" +CMD_LINUX_TYPE="sfdisk --part-type $SDCARD_DEV 1" + +INITD_LOCATION=/etc/init.d/ +INITD_AUTOSTART=autostart +DENALI_BIN=denali +LAUNCH_SCR=run.sh + +SETUP_CONF_FILE="setup.conf" +SETUP_ENABLE_MANUFACTURING_MODE="ManufacturingMode" +SETUP_ENABLE_UpdatingING_MODE="UpdatingMode" + +# Log cli options +# x: enable long name (IMPORTANT: removed for the impact on Test Protocols, and timeline) +# y: enable upload +# z: enable compression +APPLICATION_PARAMS_DEFAULT="-yz" +APPLICATION_PARAMS="" + +CloudSync_DRT_SERVER_IP="" +CloudSync_DRT_SERVER_PORT=80 + +CLOUD_USER=cloud +CLOUD_HOME=/home/$CLOUD_USER +DENALI_USER=denali +DENALI_HOME=/home/$DENALI_USER +DEMO_USER=root +DEMO_HOME=/home/$DEMO_USER + +SETTING_CONF_FOLDER_PATH=/var/configurations +SETTINGS_CRC_FILE_PATH=$DENALI_HOME/settings.crc + +DEMO_MODE=0 +P_CANBUS=can0 +V_CANBUS=can1 +D_CANBUS=$P_CANBUS + +function checkDemoMode() { + if [ -d "$DEMO_HOME/$SRC_PATH_DRYDEMO" ]; then + DEMO_MODE=1 + fi +} + +# *** this function should be used without brackets in the if to be effective. +function isDemoMode() { + if [ $DEMO_MODE -eq 1 ]; then + echo $TRUE + else + echo $FALSE + fi +} + +function user_input() { + read -p "$1? $2" -n 1 -r + if [ "$CONTINUE" == "y" ]; then + echo "" + return $TRUE + else + echo "" + return $FALSE + fi +} + +function confirm() { + read -p "$1? [y,n]" -n 1 -r CONTINUE + if [ "$CONTINUE" == "y" ]; then + echo "" + return $TRUE + else + echo "" + return $FALSE + fi +} + +function string_trim() { + local var="$*" + # remove leading whitespace characters + var="${var#"${var%%[![:space:]]*}"}" + # remove trailing whitespace characters + var="${var%"${var##*[![:space:]]}"}" + printf '%s' "$var" +} + +function echo_star_comment() { + echo "$COMMENT_STAR"" $1 " +} + +function echo_star_message() { + echo " * $1" +} + +function echo_dash_comment() { + echo "$COMMENT_DASH"" $1 " +} + +function echo_dash_message() { + echo " $1" +} + +function timestamp() { + echo $(date +"%Y%m%d-%H%M%S") +} + +function validIP() +{ + local ip=$1 + if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + OIFS=$IFS + IFS='.' + ip=($ip) + IFS=$OIFS + if [[ ${ip[0]} -gt 255 && \ + ${ip[1]} -gt 255 && \ + ${ip[2]} -gt 255 && \ + ${ip[3]} -gt 255 ]]; then + return $ERR_INVALID_IP + fi + else + return $ERR_INVALID_IP + fi + return 0 +} + +# Does the file contain a string? if +# not, add a line at end. +# If $1 not in $2 then append line $3 to end. +# $1 What to look for. +# $2 File name. +# $3 What to add. +function appendIfMissing() { + # q for quiet, F for regular string match, not -x because not full line. + # Done as one command because this is done remotely. + grep -qF $1 $2 || echo $3 >> $2 +} + + +# Remove all lines that contain $1 in file $2 then append $3. +# $1 What to look for. +# $2 File name. +function removeIfFound() { + sed -i /${1}/d $2 +} + +function existsFolder() { + if [ ! -d "$1" ]; then + return "$ERR_MISSING_FOLDER" + fi +} + +function existsFile() { + if [ ! -f "$1" ]; then + return "$ERR_MISSING_FILE" + fi +} + +COUT="/dev/null" +function setupConsoleout() { + # /dev/ttymxc1 + COUT="/dev/$(echo $(dmesg | grep "printk: console") | sed 's/.*printk: console.*\(tty.*\)].*/\1/')" +} + +function post_log_clear () { echo "" > $POSTLOG; } +function post_err_clear () { echo "" > $POSTERR; } +function post_out_clear () { echo "" > $POSTOUT; } + +function post_log_pass () { echo "$1" >> $POSTLOG; echo "[ OK ] $1" > "$COUT"; } +function post_log_fail () { echo "$1" >> $POSTLOG; echo "[FAILED] $1" > "$COUT"; } +function post_log_dash () { echo "$COMMENT_DASH$1" >> $POSTLOG; echo "$COMMENT_DASH$1" > "$COUT"; } +function post_log_star () { echo "$COMMENT_DASH$1" >> $POSTLOG; echo "$COMMENT_STAR$1" > "$COUT"; } +function post_log () { echo "$1" >> $POSTLOG; echo " $1" > "$COUT"; } + +function post_err () { echo "$1" >> $POSTERR; } +function post_err_dash () { echo "$COMMENT_DASH$1" >> $POSTERR; } + +function post_out () { echo "$1" >> $POSTOUT; } +function post_out_dash () { echo "$COMMENT_DASH$1" >> $POSTOUT; } + +function debug () { + echo_dash_comment + echo_dash_message "$1" + echo_dash_comment +} + + +function disableRootSSH() { + local SSHD_CONFIG="/etc/ssh/sshd_config" + sudo sed -i '/PermitRootLogin/c\PermitRootLogin no' $SSHD_CONFIG +} + + +function setupResolved() { + echo nameserver 8.8.8.8 > /etc/resolv.conf + systemctl start systemd-resolved.service +} + +function cleanupPOSTLogs() { + # cleanup the POST log file + post_log_clear + post_err_clear + post_out_clear + + post_log_star " ***** " + post_log "Start: $(timestamp)" # log the current date, time +} + +function killApplication() { + # ---------------------------------------- STOP denali in case running (sys not rebooted) + killall $DENALI_BIN +} + +function queryOSVersion() { + #get the OS version ----------------------- OS Version + post_log_dash " OS Version " + post_log "$(cat /etc/os-release)" +} + +function setupEthernet() { + #setting up ethernet----------------------- Ethernet + post_log_dash " Ethernet " + ieth=eth0 + udhcpc --timeout=5 --retries=2 -n -i $ieth + post_log "$(ip addr show $ieth)" # -details -statistics +} + +function setupPCAN() { + #setting up can interface ----------------- CANBus + post_log_dash " CANBus " + #current settings can be retrieved by the command below + #$ ip -details -statistics link show $P_CANBUS + ip link set $P_CANBUS up type can bitrate 250000 restart-ms 100 + ifconfig $P_CANBUS txqueuelen 4000 +} + +function setupVCAN() { + modprobe vcan + ip link add dev $V_CANBUS type vcan + ip link set $V_CANBUS up +} + +function checkCANBus() { + candump $D_CANBUS -T1 # check if candump can successfully use the port. will terminate in 1ms + if [ $? -eq 0 ]; then + post_log_pass "$POSTMSG_CANBUS$POSTMSG_POSTFIX_PASSED" + post_log "$(ip link show $D_CANBUS)" # -details -statistics + else + post_log_fail "$POSTMSG_CANBUS$POSTMSG_POSTFIX_FAILED" + fi +} + +function setupCANBus() { + if [ "$1" == "setup" ];then + D_CANBUS=$P_CANBUS # it is the default but kept to be consistent. + setupPCAN + else + if [ $(isDemoMode) -eq $TRUE ]; then + D_CANBUS=$V_CANBUS + setupVCAN + else + D_CANBUS=$P_CANBUS # it is the default but kept to be consistent. + setupPCAN + fi + fi + checkCANBus +} + +function setupSDCard() { + #mounting sdcard -------------------------- SD-CARD + post_log_dash " SD-CARD " + mkdir -p $SDCARD_MNT + mount -o noexec,nodev,nosuid $SDCARD_PRT $SDCARD_MNT + SDCTEST="$(mount | grep "$SDCARD_PRT on $SDCARD_MNT type $SDCARD_TYP_NAME (rw,")" + if ! [ -z "$SDCTEST" ]; then + SDINFO="$(df -h | grep -i $SDCARD_MNT)" + post_log_pass "$POSTMSG_SDCARD$POSTMSG_POSTFIX_PASSED" + post_log "$SDCTEST" + post_log "$SDINFO" + else + post_log_fail "$POSTMSG_SDCARD$POSTMSG_POSTFIX_FAILED" + fi +} + +function testRTC() { + #test the RTC ----------------------------- RTC + post_log_dash " RTC" + #may not be an accurate test but sufficient for now + #and could not find a way to get the rtc clock with the higher resolusion + #it should not be confused with date command which is system date/time and not hwclock + hwclock -r # if there is any issue with rtc hwclock will show errors + if [ $? -eq 0 ]; then + RTC1=$($CMD_RTC_EPOCH) + sleep 1 + RTC2=$($CMD_RTC_EPOCH) + if [ $(($RTC2 - $RTC1)) -eq 1 ]; then + post_log_pass "$POSTMSG_RTC$POSTMSG_POSTFIX_PASSED" + else + post_log_fail "$POSTMSG_RTC$POSTMSG_POSTFIX_FAILED" + fi + fi +} + +function setupWiFi() { + # ----------------------------------------- WiFi + post_log_dash " WiFi " + + # create the wpa supplicant folder for conf storing + iwlan=wlan0 + WPA_SUPPLICANT_DIR="/etc/wpa_supplicant/" + WPA_SUPPLICANT_CNF="wpa_supplicant-$iwlan.conf" + mkdir -p $WPA_SUPPLICANT_DIR + + # remove any software blocks + rfkill unblock wlan + + if [[ ! -z $(dmesg | grep "wlan: driver loaded") ]]; then + post_log_pass "$POSTMSG_WIFI$POSTMSG_POSTFIX_PASSED [driver]" + post_log "$(dmesg | grep -i wlan:)" + + # start the wpa_supplicant service + post_log "start wpa_supplicant service" + systemctl start wpa_supplicant@$iwlan.service + if [ $? -eq 0 ]; then + post_log_pass "$POSTMSG_WIFI$POSTMSG_POSTFIX_PASSED [service]" + # try to connect to WiFi + if [ -f $WPA_SUPPLICANT_DIR$WPA_SUPPLICANT_CNF ]; then + post_log_dash " WiFi Connection " + killall udhcpc + post_log "connecting to WiFi" + # run this manually in terminal if didn't work on bootup + udhcpc --timeout=5 --retries=2 -n -i $iwlan + fi + post_log "$(ip link show $iwlan)" # -details -statistics + else + post_log_fail "$POSTMSG_WIFI$POSTMSG_POSTFIX_FAILED" + post_log "$(systemctl --failed | grep wpa)" + fi + else + post_log_fail "$POSTMSG_WIFI$POSTMSG_POSTFIX_FAILED" + fi +} + +function setupBluetooth() { + # ----------------------------------------- Bluetooth + post_log_dash " Bluetooth " + /usr/share/silex-uart/silex-uart.sh stop 1>> $POSTOUT 2>> $POSTERR + sleep 1 + /usr/share/silex-uart/silex-uart.sh start 1>> $POSTOUT 2>> $POSTERR + sleep 5 + hciconfig hci0 up + if [ $? -eq 0 ]; then + post_log_pass "$POSTMSG_BLUETOOTH$POSTMSG_POSTFIX_PASSED" + post_log "$(hciconfig hci0)" + else + post_log_fail "$POSTMSG_BLUETOOTH$POSTMSG_POSTFIX_FAILED" + fi +} + +function testTouchscreen() { + #test the touch screen -------------------- Touch + post_log_dash " Touch " + # when successfully connected and can be loaded + # Sitronix touch driver 2.10.2 Release date: 20180809 + # atmel_mxt_ts 3-004a: Direct firmware load for maxtouch.cfg failed with error -2 + # atmel_mxt_ts 3-004a: Touchscreen size X1279Y799 + # input: Atmel maXTouch Touchscreen as /devices/platform/soc@0/soc@0:bus@30800000/30a50000.i2c/i2c-3/3-004a/input/input2 + # When NOT connected + # Sitronix touch driver 2.10.2 Release date: 20180809 + TSTEST="$(dmesg | grep "input: Atmel maXTouch Touchscreen as ")" + if [ "$?" -eq 0 ]; then + post_log_pass "$POSTMSG_TOUCH$POSTMSG_POSTFIX_PASSED" + post_log "$TSTEST" + else + post_log_fail "$POSTMSG_TOUCH$POSTMSG_POSTFIX_FAILED" + fi +} + +function testApplicationShasum_setup() { + # ----------------------------------------- Sha256Sum + post_log_dash " Sha256Sum " + #check the denali applicatoin checksum + SHA_ACT=$(tail -c 83 $HOME/$DENALI_BIN | cut -c19-82) + SHA_EXP=$(head -c -83 $HOME/$DENALI_BIN | sha256sum -b --tag | cut -c14-77) + if [ "$SHA_ACT" == "$SHA_EXP" ]; then + post_log_pass "$POSTMSG_SHASUM$POSTMSG_POSTFIX_PASSED" + else + post_log_fail "$POSTMSG_SHASUM$POSTMSG_POSTFIX_FAILED" + fi +} + +function testApplicationShasum_local() { + # ----------------------------------------- Sha256Sum + post_log_dash " Sha256Sum " + #check the denali applicatoin checksum + SHA_ACT=$(tail -c 83 $DENALI_HOME/$DENALI_BIN | cut -c19-82) + SHA_EXP=$(head -c -83 $DENALI_HOME/$DENALI_BIN | sha256sum -b --tag | cut -c14-77) + if [ "$SHA_ACT" == "$SHA_EXP" ]; then + post_log_pass "$POSTMSG_SHASUM$POSTMSG_POSTFIX_PASSED" + else + post_log_fail "$POSTMSG_SHASUM$POSTMSG_POSTFIX_FAILED" + fi +} + +function testCloudSystem() { + # ----------------------------------------- CloudSystem + post_log_dash " CloudSystem " + post_log "$(ip addr show $iwlan)" # -details -statistics + post_log "$(ping www.diality.staging.kebormed.com -I $iwlan -c 3 -4)" +} + +function startCloudSync_setup() { + # ----------------------------------------- CloudSync + post_log_dash " CloudSync " + local CLOUDSYNC_PATH=$HOME/$CLOUDSYNC_FOLDER + if [ -d $CLOUDSYNC_PATH ]; then + + # removing the previous treatment logs so the new buff starts with fresh sequence + echo "Removing CloudSync I/O buff" + local CLOUDSYNC_LOGS="$SDCARD_MNT/$CLOUDSYNC_FOLDER/" + local CLOUDSYNC_CONF="$CLOUDSYNC_PATH/cloudsync/config/" + local CLOUDSYNC_MODE="" + if [[ "$APPLICATION_PARAMS" == *"-E"* ]]; then + CLOUDSYNC_MODE="upgrade" + else + CLOUDSYNC_MODE="update" + fi + rm $(find $CLOUDSYNC_LOGS -name "*[_inp,_out].buf" ) 1>> $POSTOUT 2>> $POSTERR + rm $(find $CLOUDSYNC_CONF -name "config_*.json" ) 1>> $POSTOUT 2>> $POSTERR + echo "Executing the CloudSync" + cd $CLOUDSYNC_PATH + ./cs.py start debug $CLOUDSYNC_MODE & + CLOUDSYNC_STATUS="$(ps ax | grep -e cs.py -e cloud_sync.py | grep -v grep)" + if [ -n "$CLOUDSYNC_STATUS" ]; then + post_log_pass "$POSTMSG_CLOUDSYNC$POSTMSG_POSTFIX_PASSED" + else + post_log_fail "$POSTMSG_CLOUDSYNC$POSTMSG_POSTFIX_FAILED" + fi + post_log "$CLOUDSYNC_STATUS" + cd + else + post_log_fail "$POSTMSG_CLOUDSYNC$POSTMSG_POSTFIX_FAILED" + fi +} + +function startApplication_setup() { + # ----------------------------------------- Denali + post_log_dash " Denali " + #launching denali application + DENALI_VERSION="$($HOME/$DENALI_BIN -v)" + if [[ -n "$DENALI_VERSION" ]]; then + post_log_pass "$($HOME/$DENALI_BIN -v)" # log UI Software version + if [[ "$APPLICATION_PARAMS" == *"-E"* ]]; then + $HOME/$DENALI_BIN $APPLICATION_PARAMS & # do not enclose the APPLICATION_PARAMS in "", then it becomes an empty parameter to the denali which is not accepted. + else + $HOME/$DENALI_BIN $APPLICATION_PARAMS & + fi + else + post_log_fail "Unknown Applicaion Version" + fi +} + +function confirm_reboot() { + read -p "ready to reboot? [y,n]" -n 1 -r CONFIRM + if [ "$CONFIRM" == "y" ]; then + reboot + fi + echo "" +} + +function startCloudSync_local() { + # ----------------------------------------- CloudSync + post_log_dash " CloudSync " + local CLOUDSYNC_PATH=$CLOUD_HOME/$CLOUDSYNC_FOLDER + local DATE_UTC=$(date -u +%Y_%m_%d) + if [ -d $CLOUDSYNC_PATH ]; then + + # removing the previous treatment logs so the new buff starts with fresh sequence + echo "Removing CloudSync I/O buff" + local CLOUDSYNC_LOGS="$SDCARD_MNT/$CLOUDSYNC_FOLDER/" + sudo -u $CLOUD_USER rm $(find $CLOUDSYNC_LOGS -name "*[_inp,_out].buf" ) 1>> $POSTOUT 2>> $POSTERR + + echo "Creating new bufs for the denali and cloud user" + sudo -u $CLOUD_USER touch "$CLOUDSYNC_LOGS/$DATE_UTC"_out.buf + sudo -u $DENALI_USER touch "$CLOUDSYNC_LOGS/$DATE_UTC"_inp.buf + + echo "Executing the CloudSync" + cd $CLOUDSYNC_PATH + sudo -u $CLOUD_USER ./cs.py start + CLOUDSYNC_STATUS="$(ps ax | grep -e cs.py -e cloud_sync.py | grep -v grep)" + if [ -n "$CLOUDSYNC_STATUS" ]; then + post_log_pass "$POSTMSG_CLOUDSYNC$POSTMSG_POSTFIX_PASSED" + else + post_log_fail "$POSTMSG_CLOUDSYNC$POSTMSG_POSTFIX_FAILED" + fi + post_log "$CLOUDSYNC_STATUS" + cd + else + post_log_fail "$POSTMSG_CLOUDSYNC$POSTMSG_POSTFIX_FAILED" + fi +} + +function startApplication_local() { + # ----------------------------------------- Denali + post_log_dash " Denali " + #launching denali application + DENALI_VERSION="$($DENALI_HOME/$DENALI_BIN -v)" + if [ -n "$DENALI_VERSION" ]; then + post_log_pass "$DENALI_VERSION" # log UI Software version + if [ $(isDemoMode) -eq $TRUE ]; then + APPLICATION_PARAMS="$APPLICATION_PARAMS"" -q -D -A $D_CANBUS" + fi + sudo -u $DENALI_USER $DENALI_HOME/$DENALI_BIN $APPLICATION_PARAMS_DEFAULT $APPLICATION_PARAMS 1>> /tmp/denali.out 2>> /tmp/denali.out & + else + post_log_fail "Unknown Applicaion Version for $DENALI_HOME/$DENALI_BIN" + fi +} + +function startDemoMode_local() { + # *** eliminated brackets are intentional. *** + if [ $(isDemoMode) -eq $TRUE ]; then + # ----------------------------------------- Demo Mode + post_log_dash " Demo Mode " + local DRYDEMO_PATH=$DEMO_HOME/$SRC_PATH_DRYDEMO + cd $DRYDEMO_PATH + ./run.py > $DRYDEMO_PATH.log & # create the log file at same level and name of the folder. + post_log "Dry-Demo Started" + fi +} + +function log_backup() { + if [[ "$1" == "" ]]; then + post_log "Log Backup failed: Missing log location" + return $ERR_LOGBACKUP_PATH; + fi + local LOG_PATH="$LOG_BASE"/"$1" + cd "$LOG_PATH" + for logname in $(find -type f ! -name "*.$EXT_PEND.*"); do + name=$(basename $logname) + base="${name%%.*}" + ext="${name##*.}" + exts="${name#*.}" + #DEBUG echo name: $base + #DEBUG echo ext : $ext + #DEBUG echo exts: $exts + if [[ "$ext" == "$EXT_GZIP" ]]; then + mv "$name" "$base.u.$exts" + else + echo gzip "$name" + echo mv "$name.$EXT_GZIP" "$base.$EXT_PEND.$exts.$EXT_GZIP" + fi + echo + done +} + +function log_backup_logApp() { + log_backup $LOG_LOC_LOG +} + +function log_backup_logErr() { + log_backup $LOG_LOC_ERR +} + +function backupApplicationLogs() { + log_backup_logApp + log_backup_logErr +} + +function timerStart() { + time_start=$(date +%s) +} + +function timerEndLog() { + # ----------------------------------------- END + # tag the end time in the POST log file + post_log "End: $(timestamp)" + time_end=$(date +%s) + post_log "time spent: "$(( $time_end - $time_start ))" seconds" + post_log_star " ***** " +} + +function applicationPOST() { + setupConsoleout + disableRootSSH + cleanupPOSTLogs + backupApplicationLogs + checkDemoMode + queryOSVersion + setupCANBus $1 + setupResolved + killApplication + setupEthernet + setupSDCard + testRTC + setupWiFi + setupBluetooth + testTouchscreen + testCloudSystem +} + Index: archive/lockdown.sh =================================================================== diff -u --- archive/lockdown.sh (revision 0) +++ archive/lockdown.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,296 @@ +#!/bin/sh + +# @details +# This file sets up and verifies some of the SOM security. + +source ./globals.sh + +CONTENT_SUDOERS=" +Defaults env_reset +Defaults mail_badpass +Defaults secure_path=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\" +Defaults use_pty + +# User privilege specification +root ALL=(ALL:ALL) ALL + +# Allow members of group sudo to execute any command +# this line should have been commented out to revoke any access from sudoers, +# other than what has been specifically mentioned below. +# but since it make the serviceability so hard it has not been. +%sudo ALL=(ALL:ALL) ALL + +# Allow the denali user to execute specific commands as root. +denali ALL=(root) NOPASSWD: /usr/bin/bluetoothctl +denali ALL=(root) NOPASSWD: /usr/bin/tee * +denali ALL=(root) NOPASSWD: /bin/date -s * +denali ALL=(root) NOPASSWD: /sbin/hwclock -w +denali ALL=(root) NOPASSWD: /bin/sed -i * +denali ALL=(root) NOPASSWD: /bin/systemctl stop wpa_supplicant@* +denali ALL=(root) NOPASSWD: /bin/systemctl restart wpa_supplicant@* +denali ALL=(root) NOPASSWD: /bin/rm -f /etc/wpa_supplicant/wpa_supplicant-* +denali ALL=(root) NOPASSWD: /bin/chmod 640 /etc/wpa_supplicant/wpa_supplicant-* +denali ALL=(root) NOPASSWD: /sbin/ip link set * +denali ALL=(root) NOPASSWD: /sbin/ip route show +denali ALL=(root) NOPASSWD: /sbin/ip route del default +denali ALL=(root) NOPASSWD: /sbin/ip route add default via * +denali ALL=(root) NOPASSWD: /sbin/ip link set * +denali ALL=(root) NOPASSWD: /usr/bin/wpa_passphrase * +denali ALL=(root) NOPASSWD: /sbin/ifconfig * +denali ALL=(root) NOPASSWD: /sbin/iwconfig wlan0 +denali ALL=(root) NOPASSWD: /usr/bin/killall udhcpc +denali ALL=(root) NOPASSWD: /sbin/udhcpc --timeout=5 --retries=1 -n -i * +denali ALL=(root) NOPASSWD: /usr/sbin/rfkill unblock wifi +denali ALL=(root) NOPASSWD: /usr/sbin/rfkill block wifi +denali ALL=(root) NOPASSWD: /sbin/iwlist * +denali ALL=(root) NOPASSWD: /bin/ping -I * +denali ALL=(root) NOPASSWD: /usr/bin/mount * +denali ALL=(root) NOPASSWD: /usr/bin/umount * +denali ALL=(root) NOPASSWD: /bin/mkdir * +denali ALL=(root) NOPASSWD: /usr/sbin/cryptsetup * +denali ALL=(root) NOPASSWD: /sbin/mkfs.ext4 * +denali ALL=(root) NOPASSWD: /bin/systemctl start sshd.socket +denali ALL=(root) NOPASSWD: /bin/systemctl stop sshd.socket +denali ALL=(root) NOPASSWD: /bin/systemctl disable sshd.socket +denali ALL=(root) NOPASSWD: /bin/systemctl status sshd.socket +" + +CONTENT_IPTABLES=" +*filter + +# Set default chain policies +:INPUT DROP [0:0] +:FORWARD DROP [0:0] +:OUTPUT ACCEPT [0:0] + +# Accept all connections via lo interface +-A INPUT -i lo -j ACCEPT +-A OUTPUT -o lo -j ACCEPT + +# Accept SSH connections +-A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT +-A OUTPUT -p tcp --sport 22 -m conntrack --ctstate ESTABLISHED -j ACCEPT + +# Accept incoming VNC connections +# -A INPUT -p tcp --dport 5900 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT +# -A OUTPUT -p tcp --sport 5900 -m conntrack --ctstate ESTABLISHED -j ACCEPT + +# Allow established inbound connections +-A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT + +COMMIT +" + +CONTENT_SSHD_CONFIG=" +# $OpenBSD: sshd_config,v 1.102 2018/02/16 02:32:40 djm Exp $ + +# This is the sshd server system-wide configuration file. See +# sshd_config(5) for more information. + +# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin +LoginGraceTime 2m +PermitRootLogin no + +AuthorizedKeysFile .ssh/authorized_keys + +PasswordAuthentication no +PermitEmptyPasswords yes + +ChallengeResponseAuthentication yes + +UsePAM yes + +Compression no +ClientAliveInterval 15 +ClientAliveCountMax 4 + +Subsystem sftp /usr/libexec/sftp-server +" + + +# Allow the denali app to run specific commands as root. +function updateSudoers() { + # ----------------------------------------- Update Sudoers + post_log_dash " Update Sudoers " + local fileTarget="/etc/sudoers" + # Allow the denali user to execute specific commands as root. + echo "$CONTENT_SUDOERS" > $fileTarget + + #removing the cloud user who runs the CloudSync entirely from sudoers + gpasswd -d cloud sudo +} + + +# Turn on IPTables Firewall security. +function secureIPTables() { + # ----------------------------------------- Secure Iptables + post_log_dash " Secure Iptables " + local fileTarget="/etc/iptables/iptables.rules" + iptables -F + echo "$CONTENT_IPTABLES" > $fileTarget +} + + +# Turn on some ssh security. +function secureSsh() { + # ----------------------------------------- Secure SSH + post_log_dash " Secure SSH " + local fileTarget="/etc/ssh/sshd_config" + + echo "$CONTENT_SSHD_CONFIG" > $fileTarget + + chown -R root.denali ${fileTarget} + chmod -R g+rw ${fileTarget} + + # Disable the ssh service by defalut and will be enalbed when needed. + systemctl disable sshd.socket +} + + +function secureDenali() { + # ----------------------------------------- Secure the denali + post_log_dash " Secure the denali " + # Unset the immutable attribute for all of the files in case we are rerunning this script. + chattr -R -i /home/denali/* + + + if [ -f ~/denali ]; then + rm -f /home/denali/denali + mv ~/denali /home/denali/ + fi + + if [ -d ~/scripts ]; then + rm -rf /home/denali/scripts + mv ~/scripts /home/denali/ + fi + + chown -R denali.denali /home/denali + chmod -R o-rwx /home/denali +} + + +function secureCloudSync() { + # ----------------------------------------- Secure the CloudSync + post_log_dash " Secure the CloudSync " + # Unset the immutable attribute for all of the files in case we are rerunning this script. + chattr -R -i /home/cloud/* + + if [ -d ~/cloudsync ]; then + rm -rf /home/cloud/cloudsync + mv ~/cloudsync /home/cloud/ + fi + + #TODO Improve later : Add a quick fix for the CloudSync registration in UpdateOnly mode + cp /var/configurations/CloudSync/config/config.json /home/cloud/cloudsync/cloudsync/config/config.json + + chown -R cloud.cloud /home/cloud + chmod -R o-rwx /home/cloud +} + + +# Set all permissions for our users that +# are not root. +function setPermissionsCustomerAppFiles() { + # ----------------------------------------- Secure the filesystem + post_log_dash " Secure the filesystem " + + # TODO there seem to be some duplicate commands here to review later. + + # Make sure the other users have no access to these directories. + chmod -R o-rwx /home/cloud + chmod -R o-rwx /home/denali + chmod u+rx /home/denali/denali + + # ***** denali + # Give read-write access to denali by making it the owner. + mkdir -p /media/sd-card/log + chown -R denali.denali /media/sd-card/log + + mkdir -p /media/sd-card/service + chown -R denali.denali /media/sd-card/service + + # Give read-only access to cloud by making the group owner. + mkdir -p /var/configurations/treatment + chown -R denali.cloud /var/configurations/treatment + chmod -R g-w,g+r,o-rwx /var/configurations/treatment + + # Give read-only access to cloud by making the group owner. + mkdir -p /var/configurations/treatment/pending + chown -R denali.cloud /var/configurations/treatment/pending/ + chmod -R g-w,g+r,o-rwx /var/configurations/treatment/pending/ + + # Give read-only access to Settings/Systems + chown -R denali.denali /var/configurations/Settings + + # ***** cloud + # Give read-only access to denali by making the group owner. + chown -R cloud.denali /var/configurations/CloudSync + # Give only listing permission to the denali user (e.g Denali can only ls, not cat or open files) + # Set the cloud sync directories to have read-only permissions + find /var/configurations/CloudSync -type d -exec chmod g-w,g+r,o-rwx {} \; + # Set the files to not have read/write permissions + find /var/configurations/CloudSync -type f -exec chmod g-rwx,o-rwx {} \; + + # Give read-only access to denali by making the group owner. + mkdir -p /media/sd-card/cloudsync + chown -R cloud.denali /media/sd-card/cloudsync + chmod -R u+rw,g+rw,o-rwx /media/sd-card/cloudsync + + # Set the immutable attribute for all of the files. + chattr -R +i /home/cloud/* + chattr -R +i /home/denali/* + + # Add Denali and Cloud to other user groups as needed. + usermod -a -G video denali + usermod -a -G input denali + usermod -a -G tty denali + + # copy the settings crc + local FIL_RMD=readme.md + local FIL_CRC=settings.crc + local SRC_CRC=/home/root/.config/ + local DST_CRC=/var/configurations/ + cp "$SRC_CRC$FIL_RMD" "$DST_CRC$FIL_RMD" #TODO remove from the shasum + cp "$SRC_CRC$FIL_CRC" "$DST_CRC$FIL_CRC" + chown denali.denali "$DST_CRC$FIL_CRC" + chmod u=r "$DST_CRC$FIL_CRC" + chmod g-rwx "$DST_CRC$FIL_CRC" + chmod o-rwx "$DST_CRC$FIL_CRC" +} + +function cleanup() { + # ----------------------------------------- Remove the setup files + post_log_dash " Remove the setup files " + + rm $SETUP_CONF_FILE + rm /home/root/setup.sh + rm -frd $HOME/.ssh + rm -frd /media/sd-card/cloudsync/* + +} + +function main() { + cleanup + + secureDenali + secureCloudSync + + setPermissionsCustomerAppFiles + updateSudoers + + secureIPTables + + secureSsh + +} + +# Running the main function +main + +rm $(basename $0) + +sync +sync +sync + +reboot Index: archive/rootsshaccess.sh =================================================================== diff -u --- archive/rootsshaccess.sh (revision 0) +++ archive/rootsshaccess.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,123 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file ssh_access.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 23-aug-2023 +# @author (original) Behrouz NematiPour +# @date (original) 23-aug-2023 +# +############################################################################ + +TERM=dumb + +ECHO_STRING="ssh connection" +SSHD_CONFIG="/etc/ssh/sshd_config" +ERR_EXECUTION=201 + +_enable=1 +_disable=0 + +#TODO Move to globals.sh +function check_num() { + if [ $1 != 0 ]; then + echo "execution failed" + exit $ERR_EXECUTION + fi +} + + +function sshd_set() { + if [ $_enable == $1 ]; then + sudo systemctl start sshd.socket + check_num $? ", started" + else + # is is always disabled but to make sure and be backward compatible will do it again. + sudo systemctl disable sshd.socket + check_num $? ", disabled" + # stop the ssh service + sudo systemctl stop sshd.socket + check_num $? ", stopped" + fi +} + +function sshd_get() { + out=$(sudo systemctl status sshd.socket | grep "Active: active (listening)") + if [ -n "$out" ]; then + echo $_enable + else + echo $_disable + fi +} + +function root_set() { + if [ $_enable == $1 ]; then + sudo sed -i '/PermitRootLogin/c\PermitRootLogin yes' $SSHD_CONFIG + check_num $? " enalbed" + else + sudo sed -i '/PermitRootLogin/c\PermitRootLogin no' $SSHD_CONFIG + check_num $? " disalbed" + fi +} + +function root_get() { + if [ "$(grep -ir "^PermitRootLogin" $SSHD_CONFIG | tr -s ' ' | cut -f2 -d' ')" == "yes" ]; then + echo $_enable + else + echo $_disable + fi +} + +function handleCommand() { + local state=$1 + # sshd and root + local sshd_disable=0 # 0 0 + local sshd_enable=1 # 1 0 + local root_enable=2 # 1 1 + + case $1 in + $sshd_disable) + sshd_set $_disable + root_set $_disable + ;; + $sshd_enable) + sshd_set $_enable + root_set $_disable + ;; + $root_enable) + sshd_set $_enable + root_set $_enable + ;; + esac +} + +function toCheckState() { + local sshd=$(sshd_get) + local root=$(root_get) + case $sshd in + $_disable) + echo 0 + ;; + $_enable) + echo $(( $sshd + $root )) + ;; + esac +} + +case "$#" in + 0) + echo $(toCheckState) + ;; + 1) + handleCommand $1 + ;; +esac + +echo "" +exit 0 Index: archive/run.sh =================================================================== diff -u --- archive/run.sh (revision 0) +++ archive/run.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,29 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2019-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file run.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 05-Apr-2023 +# @author (original) Behrouz NematiPour +# @date (original) 28-Oct-2019 +# +############################################################################ + +# globals.sh needs to be initialized by the user home path +# otherwise creates the post.log in the / folder instead of home. +HOME=/home/$(whoami) +source ./globals.sh + +timerStart +applicationPOST +testApplicationShasum_local +startCloudSync_local +startDemoMode_local +startApplication_local +timerEndLog Index: archive/setup.sh =================================================================== diff -u --- archive/setup.sh (revision 0) +++ archive/setup.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,194 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2020-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file setup.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 16-Dec-2022 +# @author (original) Behrouz NematiPour +# @date (original) 13-Mar-2020 +# +############################################################################ + +# @details +# This script is part of setting up the newly flashed SoM which will run on the device +# after the start.sh script is done copying files on the device. + +source ./globals.sh "$1" "$2" + +function check_sdcard() { + while true; do + if [ ! "$($CMD_SDCARD_DEV)" == "$SDCARD_DEV" ];then # if no SD-Card found ask operator to install on and retry after power-cycle. + echo_dash_comment + echo_dash_message "No SD-Card detected" + echo_dash_message "UI Software logging will not work without a SD-Card" + echo_dash_message "Insert a SD-Card and continue when ready" + echo_dash_comment + confirm "Continue" + if [ $? -eq $FALSE ]; then + exit $ERR_SD_CARD + fi + else + break + fi + done + + if [ ! "$($CMD_SDCARD_PRT)" == "$SDCARD_PRT" ]; then return $FALSE; fi # if partition 1 doesn't exist , do the format + if [ ! "$($CMD_LINUX_TYPE)" == "$SDCARD_TYP_NUMB" ]; then return $FALSE; fi # if partition 1 type is not Linux(83) , do the format + return $TRUE # otherwise , do not format +} + +function format_sdcard() { + check_sdcard + if [ $? -eq $TRUE ]; then # if sd-card is OK + echo "Found the SD-Card $SDCARD_DEV" + confirm "Do you want to format the SD-Card" + if [ $? -eq $FALSE ]; then # give user an option to skip the format + return $? + fi + fi + + while true; do + echo "Unmount the SD-Card if is in use" + umount "$SDCARD_PRT" + if [ ! "$( mount | grep $SDCARD_PRT)" == "" ]; then # is still mounted + if [ $? -eq $FALSE ]; then # if SD-Card cannot the unmounted then stop the format. + echo "The SD-Card $SDCARD_DEV cannot be unmounted, therefore cannot be formatted" + confirm "Do you want to retry?" + if [ $? -eq $FALSE ]; then + return $FALSE # do not continue with format + fi + else + break + fi + else + break + fi + done + + echo "Removing current partitions" + sfdisk --delete $SDCARD_DEV 1>/dev/null 2>/dev/null + echo "Create new partition" + echo "label:MBR" | sfdisk $SDCARD_DEV 1>/dev/null 2>/dev/null + echo "type=83" | sfdisk $SDCARD_DEV 1>/dev/null 2>/dev/null + echo "Create a ext4 file system" + mkfs.ext4 $SDCARD_PRT -L "Denali_Log" -F # 1>/dev/null 2>/dev/null + + check_sdcard + if [ $? -eq $TRUE ]; then + echo "SD-Card format PASSED" + else + echo "SD-Card format FAILED !!!" + fi +} + +function set_timezone() { + echo "setup the time/date controller" + # to use the system time/date and not use the network time protocol + timedatectl set-ntp $TDCTL_NTP_USED + + echo "Setup the timezone (PDT Pacific)" + timedatectl set-timezone $TDCTL_TIMEZONE + timedatectl set-local-rtc $TDCTL_RTC_LOCL +} + +function set_datetime() { + echo "Setup the time/date" + while true; do + timedatectl set-time "$DATETIME" 1>/dev/null 2>/dev/null + if [ $? -eq 0 ]; then + break + else + read -p "please enter the date (yyyy-MM-dd HH:mm): " -e -i "$DATETIME" -r DATETIME + fi + done +} + +function disable_service() { + echo "Disabling '$1' service" + systemctl stop "$1" + systemctl disable "$1" + if [ -z $(systemctl status | cat | grep "$1" | grep -v grep) ]; then + echo "'$1' service disabled" + else + echo "'$1' service not disabled!" + fi +} + +function disable_unwanted_services() { + disable_service b2qt.service + disable_service connman.service + disable_service qtlauncher.service + disable_service ebikedata.service + disable_service rpcbind.service + disable_service rpcbind.socket + disable_service rpcbind.target +} + +function setup_denali() { + echo "Setting denali as default auto start application" + + chmod a+x $HOME/$INITD_AUTOSTART + chmod a+x $HOME/$LAUNCH_SCR + chmod a+x $HOME/$DENALI_BIN + + rm -f "$POSTLOG" "$POSTERR" "$POSTOUT" + + echo "Syncing file system updates" + sync;sync;sync +} + +function disable_autostart() { + # in case the device is alread setup, disable the autostart of the application until the setup script enables it. + rm -f $INITD_LOCATION$INITD_AUTOSTART +} + +function enable_autostart() { + mkdir -p $INITD_LOCATION + mv $INITD_AUTOSTART $INITD_LOCATION + update-rc.d $INITD_AUTOSTART defaults +} + +function enableDRT() { + # trying to temporarily add the DRT server input open for the device registration + iptables -A INPUT -p tcp -s $CloudSync_DRT_SERVER_IP --dport $CloudSync_DRT_SERVER_PORT -j ACCEPT + # enables the ping from the DRT server to the device [ useful for testing ] + iptables -A INPUT -p icmp --icmp-type echo-request -s $CloudSync_DRT_SERVER_IP -j ACCEPT +} + +function executionMode() { + if [ "$(grep $SETUP_ENABLE_MANUFACTURING_MODE $SETUP_CONF_FILE)" = "" ]; then + # -U for Updating mode + # -a for disabling the non-minimizable Alarms + APPLICATION_PARAMS="-U -a" + else + # -E for Maunufacturing mode + # -a for disabling the non-minimizable Alarms + APPLICATION_PARAMS="-E -a" + fi + enableDRT + applicationPOST "setup" + testApplicationShasum_setup + startCloudSync_setup + startApplication_setup +} + +function main() { + disable_autostart + format_sdcard + set_timezone + # set_datetime "$1" "$2" + disable_unwanted_services + setup_denali + enable_autostart + executionMode +} + +main "$1" "$2" + +exit 0 Index: archive/start.sh =================================================================== diff -u --- archive/start.sh (revision 0) +++ archive/start.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,434 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file start.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 15-Dec-2022 +# @author (original) Behrouz NematiPour +# @date (original) 11-Aug-2021 +# +############################################################################ + +# @details +# This file is used to setup newly flashed SoM to copy everythin on the device. + +source ./globals.sh + +DEMO_SETUP=0 +DEMO_SWITCH="-D" + +MANUFACTURING_SETUP=0 +MANUFACTURING_SWITCH="-E" #Update only setup + +SERVER_IP="" # $CloudSync_DRT_SERVER_IP +SERVER_WS="" +SERVER_PORT="3000" +SERVER_SWITCH_DRT_WS="-W" #DRT server workspace/environment +SERVER_SWITCH_DRT_IP="-S" #DRT server IP address +SERVER_CONFIG_LINE=".*\"url_mft\".*" +SERVER_CONFIG_BGN=" \"url_mft\": \"http:\/\/" +SERVER_CONFIG_END=":$SERVER_PORT\"," +SERVER_CONFIG_FILE="./cloudsync/cloudsync/config/config" +SERVER_CONFIG_EXT="json" +SERVER_CONFIG_JSON="$SERVER_CONFIG_FILE.$SERVER_CONFIG_EXT" +SERVER_CONFIG_JSON_WS="$SERVER_CONFIG_FILE" +SERVER_DRT_WS_PRODUCT="production" +SERVER_DRT_WS_STAGING="staging" +SERVER_DRT_WS_QUALITY="quality" +SERVER_DRT_WS_QUALITY2="quality2" + +GLOBALS_CONFIG_MDFY="CloudSync_DRT_SERVER_IP=" +GLOBALS_CONFIG_LINE="CloudSync_DRT_SERVER_IP=.*" +GLOBALS_FILE="./globals.sh" + +# command line parameters detection +function setupParameters() { + DST_IP="$1" + for arg in "$@"; do + case $arg in + "$DEMO_SWITCH") + DEMO_SETUP=1 + ;; + "$MANUFACTURING_SWITCH") + MANUFACTURING_SETUP=1 + ;; + "$SERVER_SWITCH_DRT_IP"*) + SERVER_IP="${arg:2}" + ;; + "$SERVER_SWITCH_DRT_WS"*) + SERVER_WS="${arg:2}" + ;; + esac + done +} + +function setupPreparation() { + getDeviceIP + echo "Device IP Address : $DST_IP" + + if (( $DEMO_SETUP )); then + echo "Device operation Mode : Demo Mode" + else + echo "Device operation Mode : Normal Operation" + fi + + # if it is the update only we don't need the configuration + if (( $MANUFACTURING_SETUP )); then + echo "Device setup Mode : Manufacturing Setup" + + getServerIP + echo "DRT Server IP Address : $SERVER_IP" + + getServerWS + echo "DRT Server Environment: $SERVER_WS" + else + echo "Device setup Mode : Update Only" + SERVER_WS=$SERVER_DRT_WS_PRODUCT + fi + + # create the config.json file + local config_env_json="$SERVER_CONFIG_JSON_WS""_""$SERVER_WS"".""$SERVER_CONFIG_EXT" + local config_json="$SERVER_CONFIG_JSON" + echo "CloudSync config base : "$config_env_json + cp $config_env_json $config_json # copy the config for the selected environment to config.json + if [[ ! -e $config_json ]]; then + echo "The file $config_json cannot be created" + exit 0 + fi + + if (( $MANUFACTURING_SETUP )); then + # setting up the DRT Server IP address + #If the server IP is not given or is invalid will be asked to enter and the defualt Diality prefered will be suggested. + #If the server IP is valid and accepted then change the CloudSync conf file + sed -i "s/$SERVER_CONFIG_LINE/$SERVER_CONFIG_BGN$SERVER_IP$SERVER_CONFIG_END/" $config_json + #and modify the globals.sh + sed -i "s/$GLOBALS_CONFIG_LINE/$GLOBALS_CONFIG_MDFY$SERVER_IP/" $GLOBALS_FILE + fi +} + +function displayHelp() { + if [ "$1" = "-h" -o "$1" = "--help" ]; then + echo -e "-h \t This help" + echo "usage start.sh [ [xxx.xxx.xxx.xxx] ] -D [-S[xxx.xxx.xxx.xxx] -W]" + echo "device IP : The Device IP Address Under Setup" + echo " Must always be the first parameter" + echo "-D : Demo mode" + echo " Demo mode mode can be used to use the device as a demo unit." + echo " In this mode Application will not work with the actual hardware and will work in simulation mode." + echo " The Demo application folder need to be copied to the update folder manually." + echo "-E : Manufacturing setup mode" + echo " The Manufacturing setup will wipe device configuration, setup, registration," + echo " and nees a fresh configuration, and device registration on the cloud," + echo " therefore the -S and -W is mandatory." + echo "-S : The DRT Server IP address" + echo " Need to be entered fully in a valid IP format [xxx.xxx.xxx.xxx]" + echo " There should be no space between -S and the server IP address" + echo " For example : -S192.168.1.5" + echo "-W : The DRT Server Workspace/Environment:" + echo " Shall only include the server environment from the following list:" + echo " - production" + echo " - staging" + echo " - quality" + echo " - quality2" + echo " For example : -Wproduction" + exit 0 + fi +} + +function exitConfirm() { + read -p "Continue? [y,n]" -n 1 -r CONTINUE + if [ "$CONTINUE" != "y" ]; then + echo "" + exit "$1" + else + echo "" + fi +} + +function setupLogs() { + local log_location=$LOG_LOCATION/$DST_IP + mkdir -p $log_location + LOG_OUT_FILE="$log_location/update-$(timestamp).log" + LOG_ERR_FILE="$log_location/update-$(timestamp).err" + touch $LOG_OUT_FILE + touch $LOG_ERR_FILE +} + +function sshKeyExists() { + existsFile $SRC_FILE_SSHKEY_PUB + return $? +} + +function sshKeyGen() { + sshKeyExists + if [ ! $? -eq 0 ]; then + echo "No ssh key found,Generating ssh key" + ssh-keygen -N "" -f $SRC_FILE_SSHKEY 1>>$LOG_OUT_FILE 2>>$LOG_ERR_FILE + return $? + else + echo "Found ssh key :" $SRC_FILE_SSHKEY_PUB + fi + return 0 +} + +function sshKeyCopy() { + echo "Please wait ..." + echo "Registering the ssh key on the device $DST_IP" + ssh-copy-id $SSH_PARAM -f -i $SRC_FILE_SSHKEY_PUB $DST_USER@$DST_IP 1>>$LOG_OUT_FILE 2>>$LOG_ERR_FILE + if [ ! $? -eq 0 ]; then + echo "Connection to host $DST_IP failed." | tee -a $LOG_OUT_FILE + exitConfirm $? + return $? + fi +} + +function sshRun() { + ssh $SSH_PARAM $DST_USER@$DST_IP $1 + return $? +} + +function copyFolderTo() { + existsFolder "$1" + if [ $? -eq 0 ]; then + echo -n "Copy folder" >> $LOG_OUT_FILE + scp -r $SSH_PARAM $1/* $DST_USER@$DST_IP:$2 + if [ $? -eq 0 ]; then + echo " Successfull - $1" >> $LOG_OUT_FILE + else + echo " Failed" >> $LOG_OUT_FILE + exitConfirm $? + return $? + fi + else + echo "File '$1' doesn't exist" | tee -a $LOG_OUT_FILE + exitConfirm $? + fi + return 0 +} + +function copyFileTo() { + existsFile "$1" + if [ $? -eq 0 ]; then + echo -n "Copy file" >> $LOG_OUT_FILE + scp $SSH_PARAM $1 $DST_USER@$DST_IP:$2 + if [ $? -eq 0 ]; then + echo " Successfull - $1" >> $LOG_OUT_FILE + else + echo " Failed" >> $LOG_OUT_FILE + exitConfirm $? + return $? + fi + else + echo "File '$1' doesn't exist" | tee -a $LOG_OUT_FILE + exitConfirm $? + fi + return 0 +} + +function killPrompt() { + echo_star_comment + echo_star_message "Current running UI Software on the device will be stopped." + echo_star_message "All the settings, configurations and binaries will be overwritten" + echo_star_comment + exitConfirm $ERR_KILLPROMPT +} + +function manufacturingModePrompt() { + if (( $MANUFACTURING_SETUP )); then :; else return; fi + + echo_star_comment + echo_star_message "Do you want to run in the Manufacturing Mode?" + echo_star_comment + read -p "Continue? [y,n]" -n 1 -r CONTINUE + echo "" # to echo prompts on new line + if [ "$CONTINUE" == "y" ]; then + sshRun "echo $SETUP_ENABLE_MANUFACTURING_MODE > $SETUP_CONF_FILE" + echo_star_message "Set the setup in manufacturing mode" + else + echo_star_message "Abort the Manufacturing setup by user" + exit 0 + fi +} + +function getDeviceIP() { + while true; do + validIP "$DST_IP" + if [ $? -eq 0 ]; then + break + else + read -p "Please enter the device Ip address: " -e -i "" -r DST_IP + validIP "$DST_IP" + if [ $? -eq 0 ]; then + break + else + echo "The entered IP address is not valid [$DST_IP]" + exitConfirm $? + fi + fi + done +} + +function getServerIP() { + while true; do + validIP "$SERVER_IP" + if [ $? -eq 0 ]; then + break + else + read -p "Please enter the server Ip address : " -e -i "" -r SERVER_IP + validIP "$SERVER_IP" + if [ $? -eq 0 ]; then + break + else + echo "The entered IP address is not valid [$SERVER_IP]" + exitConfirm $? + fi + fi + done +} + +function validWS() { + if [[ -z $SERVER_WS ]]; then return 1; fi + case $SERVER_WS in + "$SERVER_DRT_WS_PRODUCT");; + "$SERVER_DRT_WS_STAGING");; + "$SERVER_DRT_WS_QUALITY");; + "$SERVER_DRT_WS_QUALITY2");; + *) + echo "The entered server environment is not valid [$SERVER_WS]" + return 1 + esac + return 0 +} + +function getServerWS() { + while true; do + validWS "$SERVER_WS" + if [ $? -eq 0 ]; then + break + else + read -p "Please enter the server environment: " -e -i "" -r SERVER_WS + validWS "$SERVER_WS" + if [ $? -eq 0 ]; then + break + else + echo "The entered server environment is not valid [$SERVER_WS]" + exitConfirm $? + fi + fi + done +} + +function setupBootupScripts() { + echo_dash_comment + echo_dash_message "Installing bootup scripts" | tee -a $LOG_OUT_FILE + echo_dash_comment + copyFileTo "globals.sh" $DST_PATH_HOME + copyFileTo "autostart" $DST_PATH_HOME + copyFileTo "run.sh" $DST_PATH_HOME + copyFileTo "setup.sh" $DST_PATH_HOME +} + +function setupSettingsScripts() { + echo_dash_comment + echo_dash_message "Installing settings scripts" | tee -a $LOG_OUT_FILE + echo_dash_comment + sshRun "rm -frd $DST_PATH_SCRIPTS;" + sshRun "mkdir -p $DST_PATH_SCRIPTS;" + copyFolderTo $SRC_PATH_SCRIPTS $DST_PATH_SCRIPTS + sshRun "cd $1; chmod a+x *.sh;" +} + +function setupConfigurations() { + echo_dash_comment + echo_dash_message "Installing configurations" | tee -a $LOG_OUT_FILE + echo_dash_comment + sshRun "rm -frd $DST_PATH_CONFIG;" + sshRun "mkdir -p $DST_PATH_CONFIG;" + copyFolderTo $SRC_PATH_CONFIG $DST_PATH_CONFIG +} + +function setupCloudSync() { + echo_dash_comment + echo_dash_message "Installing CloudSync" | tee -a $LOG_OUT_FILE + echo_dash_comment + sshRun "killall python3" + sshRun "rm -frd $DST_PATH_CLOUDSYNC;" + sshRun "mkdir -p $DST_PATH_CLOUDSYNC;" + copyFolderTo $SRC_PATH_CLOUDSYNC $DST_PATH_CLOUDSYNC +} + +function setupFonts() { + echo_dash_comment + echo_dash_message "Installing fonts" | tee -a $LOG_OUT_FILE + echo_dash_comment + copyFolderTo $SRC_PATH_FONTS $DST_PATH_FONTS +} + +function setupApplication() { + echo_dash_comment + echo_dash_message "Installing UI Software" | tee -a $LOG_OUT_FILE + echo_dash_comment + sshRun "killall $DENALI_BIN" + copyFileTo $DENALI_BIN $DST_PATH_HOME +} + +function setupDemoMode() { + if [ "$DEMO_SETUP" != "1" ]; then return; fi + echo_dash_comment + echo_dash_message "Installing Dry-Demo" | tee -a $LOG_OUT_FILE + echo_dash_comment + sshRun "killall python3" + sshRun "rm -frd $DST_PATH_DRYDEMO;" + sshRun "mkdir -p $DST_PATH_DRYDEMO;" + copyFolderTo $SRC_PATH_DRYDEMO $DST_PATH_DRYDEMO +} + +function connect() { + echo_dash_comment + echo_dash_message "please ssh into device $DST_IP and run ./setup.sh" + echo_dash_comment + read -p "Hit enter to continue" + sshRun # the setup.sh has to run on the device while user has logged into the device. + #TODO needs to handle the SD-Card format question + # sshRun "./setup.sh" # the setup.sh has to run on the device while user has logged into the device. +} + +function wipe_device() { + WIPEOUT="wiped.out" + sshRun "find -maxdepth 1 ! \( -name '.ssh' -o -name $SETUP_CONF_FILE -o -name . -o -name .. \) > $WIPEOUT" + sshRun "xargs -a $WIPEOUT rm -frd" +} + +function main() { + setupLogs + + sshKeyGen + sshKeyCopy + + killPrompt + manufacturingModePrompt + wipe_device + + setupDemoMode + setupBootupScripts + setupSettingsScripts + setupConfigurations + setupCloudSync + setupFonts + setupApplication +} + +# running the main function +displayHelp "$1" +setupParameters "$@" +setupPreparation +main "$1" +connect +exit 0 + Index: archive/wifi_disconnect_network.sh =================================================================== diff -u --- archive/wifi_disconnect_network.sh (revision 0) +++ archive/wifi_disconnect_network.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,35 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_disconnect_network.sh +# +# @author (last) Vy +# @date (last) 26-Jan-2023 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +iface=$1 + +# stop the wpa service +sudo systemctl stop wpa_supplicant@"$iface".service + +#remove the wpa configuration file +sudo rm -f /etc/wpa_supplicant/wpa_supplicant-"$iface".conf + +#Shutoff wifi interface +sudo ip link set $iface down + + Index: archive/wifi_generate_wpa_supplicant.sh =================================================================== diff -u --- archive/wifi_generate_wpa_supplicant.sh (revision 0) +++ archive/wifi_generate_wpa_supplicant.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,83 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_generate_wpa_supplicant.sh +# +# @author (last) Vy +# @date (last) 30-Jan-2023 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +ssid=$1 +password=$2 +dest=/etc/wpa_supplicant/wpa_supplicant-"$3".conf +securityType=$4 +psk=$(sudo wpa_passphrase "$ssid" "$password" | grep "psk=" | grep -v "#psk" | sed -nr 's/.*psk=(.*)/\1/p') +case $securityType in + +#-- WPA3 SAE does not support hashed password +#-- wpa3 ------------------------------------ + wpa3) + echo "Security: $securityType"; + echo "\ +ctrl_interface=/var/run/wpa_supplicant +ctrl_interface_group=0 +update_config=1 + +network={ + ssid=\"$ssid\" + sae_password=\"$password\" + proto=RSN + key_mgmt=SAE + pairwise=CCMP + group=CCMP + ieee80211w=2 +}" | sudo tee $dest > /dev/null;; + +#-- wpa2 ------------------------------------ + wpa2) + echo "Security: wpa2"; + echo "\ +ctrl_interface=/var/run/wpa_supplicant +ctrl_interface_group=0 +update_config=1 + +network={ + ssid=\"$ssid\" + key_mgmt=WPA-PSK + pairwise=CCMP TKIP + group=CCMP TKIP + scan_ssid=1 + psk="$psk" +}" | sudo tee $dest > /dev/null;; + +#-- wpa ------------------------------------ + wpa) + echo "Security: wpa"; + echo "\ +ctrl_interface=/var/run/wpa_supplicant +ctrl_interface_group=0 +update_config=1 + +network={ + ssid=\"$ssid\" + psk="$psk" +}" | sudo tee $dest > /dev/null;; + +esac + +sudo chmod 640 $dest + Index: archive/wifi_read_dns.sh =================================================================== diff -u --- archive/wifi_read_dns.sh (revision 0) +++ archive/wifi_read_dns.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,22 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_read_dns.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ +if [ "$1" == "-h" ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile" + exit 0 +fi +cat /etc/resolv.conf | grep "nameserver" Index: archive/wifi_read_gateway.sh =================================================================== diff -u --- archive/wifi_read_gateway.sh (revision 0) +++ archive/wifi_read_gateway.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,24 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_read_gateway.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ "$1" == "-h" ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile" + exit 0 +fi + +sudo ip route show | grep "default via" Index: archive/wifi_read_ip_settings.sh =================================================================== diff -u --- archive/wifi_read_ip_settings.sh (revision 0) +++ archive/wifi_read_ip_settings.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,25 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_read_ip_settings.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +iface=$1 +sudo ifconfig $iface | grep "inet " Index: archive/wifi_read_network_info.sh =================================================================== diff -u --- archive/wifi_read_network_info.sh (revision 0) +++ archive/wifi_read_network_info.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,26 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2023-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_read_network_info.sh +# +# @author (last) Vy +# @date (last) 16-May-2023 +# @author (original) Vy +# @date (original) 16-May-2023 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +iface=$1 +sudo iwconfig wlan0 + Index: archive/wifi_request_auto_assigned_ip.sh =================================================================== diff -u --- archive/wifi_request_auto_assigned_ip.sh (revision 0) +++ archive/wifi_request_auto_assigned_ip.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,26 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_request_auto_assigned_ip.sh +# +# @author (last) Vy +# @date (last) 24-Jan-2023 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +iface=$1 +sudo killall udhcpc +sudo udhcpc --timeout=5 --retries=1 -n -i $iface Index: archive/wifi_reset_adapter.sh =================================================================== diff -u --- archive/wifi_reset_adapter.sh (revision 0) +++ archive/wifi_reset_adapter.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,25 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_reset_adapter.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ "$1" == "-h" ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile" + exit 0 +fi + +sudo rfkill block wifi +sudo rfkill unblock wifi Index: archive/wifi_reset_interface.sh =================================================================== diff -u --- archive/wifi_reset_interface.sh (revision 0) +++ archive/wifi_reset_interface.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,25 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_reset_interface.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +sudo ip link set $1 down +sudo ip link set $1 up Index: archive/wifi_save_dhcp_interface.sh =================================================================== diff -u --- archive/wifi_save_dhcp_interface.sh (revision 0) +++ archive/wifi_save_dhcp_interface.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,28 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_save_dhcp_interface.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 25-Feb-2022 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +iface=$1 +echo "auto $iface +sudo iface $iface inet dhcp + wpa-driver wext + wpa-conf /etc/wpa_supplicant.conf" | sudo tee /etc/network/interfaces > /dev/null Index: archive/wifi_save_static_interface_assignments.sh =================================================================== diff -u --- archive/wifi_save_static_interface_assignments.sh (revision 0) +++ archive/wifi_save_static_interface_assignments.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,35 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_save_static_interface_assignments.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +iface=$1 +ip=$2 +gateway=$3 +subnet_mask=$4 + +echo "auto $iface +iface $iface inet static + address $ip + netmask $subnet_mask + gateway $3" | sudo tee /etc/network/interfaces > /dev/null + +./wifi_set_gateway.sh $gateway Index: archive/wifi_set_auto_assigned_ip.sh =================================================================== diff -u --- archive/wifi_set_auto_assigned_ip.sh (revision 0) +++ archive/wifi_set_auto_assigned_ip.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,27 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_set_auto_assigned_ip.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +iface=$1 + +echo "auto $iface +iface $iface inet dhcp" | sudo tee -a /etc/network/interfaces > /dev/null Index: archive/wifi_set_dns.sh =================================================================== diff -u --- archive/wifi_set_dns.sh (revision 0) +++ archive/wifi_set_dns.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,24 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_set_dns.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +echo "nameserver $1" | sudo tee -a /etc/resolv.conf > /dev/null Index: archive/wifi_set_gateway.sh =================================================================== diff -u --- archive/wifi_set_gateway.sh (revision 0) +++ archive/wifi_set_gateway.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,25 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_set_gateway.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +sudo ip route del default +sudo ip route add default via $1 Index: archive/wifi_set_static_ip.sh =================================================================== diff -u --- archive/wifi_set_static_ip.sh (revision 0) +++ archive/wifi_set_static_ip.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,24 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_set_static_ip.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +sudo ifconfig $1 $2 Index: archive/wifi_set_subnetmask.sh =================================================================== diff -u --- archive/wifi_set_subnetmask.sh (revision 0) +++ archive/wifi_set_subnetmask.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,24 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_set_subnetmask.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +sudo ifconfig $1 netmask $2 Index: archive/wifi_start_wpa_supplicant.sh =================================================================== diff -u --- archive/wifi_start_wpa_supplicant.sh (revision 0) +++ archive/wifi_start_wpa_supplicant.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,31 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_start_wpa_supplicant.sh +# +# @author (last) Vy +# @date (last) 07-Feb-2023 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +iface=$1 +wpa_supplicant_path=$2 + +# make sure hardware is up +sudo ip link set $iface up + +# restart the wpa_supplicant service for wifi +sudo systemctl restart wpa_supplicant@"$iface".service Index: archive/wifi_test_internet.sh =================================================================== diff -u --- archive/wifi_test_internet.sh (revision 0) +++ archive/wifi_test_internet.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,25 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_test_internet.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ "$1" == "-h" ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +iface=$1 +sudo ping -I $iface -c 4 www.linuxfoundation.org Index: scripts/_errors_ =================================================================== diff -u --- scripts/_errors_ (revision 0) +++ scripts/_errors_ (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,68 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file _errors_ +# +# @author (last) Behrouz NematiPour +# @date (last) 15-Jan-2025 +# @author (original) Behrouz NematiPour +# @date (original) 15-Jan-2025 +# +############################################################################ + +# Description +# Definition of all the error ID and Descriptions +# Parameters +# No specific parameter +# Retruns +# No specific response +# Considerations +# The error IDs shall not be negative +# The error Messages are assumed as system errors and will not be translated. +# The error Messages returned by the caller script will only be shown on the Application +# if only the exit code of the caller script is non-zero. + +# TODO +# - rearrange the Error IDs by group + +# sources + +# variables +# 0x: General Errors +ERR_GENERAL_SCRIPT_FAIL=1 +ERR_GENERAL_SCRIPT_PARAM_COUNT=2 +ERR_GENERAL_SCRIPT_EMPTY_STRING=3 +ERR_GENERAL_SCRIPT_FILE_EXIST=4 + +# 1x: Empty parameters +ERR_MTPARAM_WIFI_SSID=10 +ERR_MTPARAM_WIFI_PASS=11 +ERR_MTPARAM_BRIGHTNESS_VALUE=12 +ERR_MTPARAM_USB_DEVICE=13 +ERR_MTPARAM_USB_FOLDER=14 + +# 2x: WiFi Errors 2x +ERR_CMDFAIL_WIFI_SCAN=20 +ERR_CMDFAIL_WIFI_CONNECT=21 +ERR_CMDFAIL_WIFI_DISCONNECT=22 +ERR_CMDFAIL_WIFI_INFO_SSID=23 +ERR_CMDFAIL_WIFI_INFO_IPMASK=24 +ERR_CMDFAIL_WIFI_INFO_ADDR=25 +ERR_CMDFAIL_WIFI_INFO_MASK=26 +ERR_CMDFAIL_WIFI_INFO_GATEWAY=27 +ERR_CMDFAIL_WIFI_INFO_DNS=28 + +# 3x: Brightness Errors 3x +ERR_CMDFAIL_BRIGHTNESS_GET=30 +ERR_CMDFAIL_BRIGHTNESS_SET=31 + +# 4x: USB Device Errors +ERR_CMDFAIL_USB_FOLDER_MAKE=40 +ERR_CMDFAIL_USB_DEVICE_MOUNT=41 +ERR_CMDFAIL_USB_FOLDER_REMOVE=42 +ERR_CMDFAIL_USB_DEVICE_UMOUNT=43 Index: scripts/_functions_ =================================================================== diff -u --- scripts/_functions_ (revision 0) +++ scripts/_functions_ (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,176 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file _functions_ +# +# @author (last) Behrouz NematiPour +# @date (last) 15-Jan-2025 +# @author (original) Behrouz NematiPour +# @date (original) 15-Jan-2025 +# +############################################################################ + +# Description +# Definition of all the globally used functions in scripts. +# Parameters +# No specific parameter +# Retruns +# No specific response +# Considerations +# Any function need to follow the same documentation format, +# to make sure the correct documentation is displayed by vscode editor, +# when used in the caller script. + +# sources +. ./_errors_ + +# functions + +# Description +# Trimms the given string by removing leading spaces +# Parameters +# $1: the given string +# Retruns +# The left trimmed string. +# Considerations +# No specific considerations. +ltrim() { + string="$1" + trimmed="${string#"${string%%[![:space:]]*}"}" + echo """$trimmed""" +} + +# Description +# Trimms the given string by removing trailing spaces +# Parameters +# $1: the given string +# Retruns +# The right trimmed string. +# Considerations +# No specific considerations. +rtrim() { + string="$1" + trimmed="${string%"${string##*[![:space:]]}"}" + echo """$trimmed""" +} + +# Description +# Trimms the given string by removing leading and trailing spaces +# Parameters +# $1: the given string +# Retruns +# The trimmed string. +# Considerations +# No specific consideration. +trim() { + trimmed="$1" + trimmed="${trimmed#"${trimmed%%[![:space:]]*}"}" + trimmed="${trimmed%"${trimmed##*[![:space:]]}"}" + echo """$trimmed""" +} + +# Description +# Checks if the given string is empty +# Parameters +# $1: the given string +# Retruns +# Exits by the $2 if set, on fail, +# or by ERR_GENERAL_SCRIPT_FILE_EXIST by default. +# Considerations +# this function won't trim the given string. +check_empty_string() { + if [ "$1" = "" ]; then + echo "" + if [ "$2" = "" ]; then + exit "$ERR_GENERAL_SCRIPT_EMPTY_STRING" + else + exit "$2" + fi + fi +} + +# Description +# Checks if the given string is empty +# Parameters +# $1: the given string +# Retruns +# returns true if the given string is empty +# Considerations +# this function won't trim the given string. +# this function won't exit if the given string is empty. +is_empty_string() { + if [ "$1" = "" ]; then + echo true + else + echo false + fi +} + +# Checks if the given parameter is more or equal to required number of parameters. +# It also first checks the given parameters to this funcion is correct. +# $1: always the $# of the caller script +# $2: the number of required parameters. +# Exits by ERR_GENERAL_SCRIPT_FILE_EXIST on fail. +check_param_count() { + # first do the self check + PARAM_COUNT=2 + if [ "$#" -lt "$PARAM_COUNT" ]; then + echo "" + exit $ERR_GENERAL_SCRIPT_PARAM_COUNT + fi + + count_act="$1" + count_exp="$2" + if [ "$count_act" -lt "$count_exp" ]; then + echo "" + exit $ERR_GENERAL_SCRIPT_PARAM_COUNT + fi +} + +# Checks if command execution failed +# $1: always the $? of the just executed command +# $2: the exit error number +# Exits by the $2 if set, on fail, +# or by ERR_GENERAL_SCRIPT_FILE_EXIST by default. +check_result() { + PARAM_COUNT=2 + check_param_count "$#" "$PARAM_COUNT" + if [ ! "$1" -eq 0 ]; then + ERR_ID="$2" + if [ "$ERR_ID" = "" ]; then + ERR_ID "$ERR_GENERAL_SCRIPT_FAIL" + fi + # echo $(errorMessage "$ERR_ID") + exit "$ERR_ID" + fi + # echo "" +} + +# Checks if the given file exists +# $1: the file full path +# Exits with ERR_GENERAL_SCRIPT_FILE_EXIST on fail +check_file_exists() { + if [ -f "$FILE" ]; then + echo "" + exit "$ERR_GENERAL_SCRIPT_FILE_EXIST" + fi +} + +errorMessage() { + # this is the minimum required number of parameters + # any error ID can have optional multiple extra parameters to get embedded in the message. + PARAM_COUNT=1 + check_param_count "$#" "$PARAM_COUNT" + + case "$1" in + "$ERR_CMDFAIL_USB_FOLDER_MAKE" ) echo "usb mount point folder '$2' cannot be made." ;; + # "$ERR_CMDFAIL_USB_DEVICE_MOUNT" ) echo "usb device '$2' cannot be mounted." ;; + "$ERR_CMDFAIL_USB_DEVICE_UMOUNT" ) echo "usb drive '$2' cannot be unmounted." ;; + "$ERR_CMDFAIL_USB_FOLDER_REMOVE" ) echo "usb mount point '$2' cannot be removed." ;; + esac +} Index: scripts/_variables_ =================================================================== diff -u --- scripts/_variables_ (revision 0) +++ scripts/_variables_ (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,31 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file _variables_ +# +# @author (last) Behrouz NematiPour +# @date (last) 15-Jan-2025 +# @author (original) Behrouz NematiPour +# @date (original) 15-Jan-2025 +# +############################################################################ + +# Description +# Definition of all the global variables +# Parameters +# No specific parameter +# Retruns +# No specific response +# Considerations +# This gloval variables are different than the error varables and shall not be combinled. +# For error definitions use the _errors_ file. + +# sources + +# variables +BRIGHTNESS_SYSFS="/sys/class/backlight/lvds_backlight/brightness" Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/autostart'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/bluetooth_paired_clear.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/bluetooth_paired_query.sh'. Fisheye: No comparison available. Pass `N' to diff? Index: scripts/brightness.sh =================================================================== diff -u --- scripts/brightness.sh (revision 0) +++ scripts/brightness.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,47 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file brightness_get.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 15-Jan-2025 +# @author (original) Behrouz NematiPour +# @date (original) 15-Jan-2025 +# +############################################################################ + +# sources +. ./_errors_ +. ./_functions_ +. ./_variables_ + +# local variables +# either set or get a parameter always has to be given. +PARAM_COUNT=1 +BRIGHTNESS_VALUE="$(trim "$1")" + +# local functions + +# checks +check_param_count "$#" "$PARAM_COUNT" +check_file_exists "$BRIGHTNESS_SYSFS" "$BRIGHTNESS_SYSFS" + +# main +# if a value is give update the brightness +if [ "$BRIGHTNESS_VALUE" != "" ]; then + echo "$BRIGHTNESS_VALUE" > "$BRIGHTNESS_SYSFS" + check_result "$?" "$ERR_CMDFAIL_BRIGHTNESS_SET" +fi + +# return the current/updated brightness +BRIGHTNESS_VALUE="$(cat $BRIGHTNESS_SYSFS)" +check_result "$?" "$ERR_CMDFAIL_BRIGHTNESS_GET" + +sleep 0.1 +echo $BRIGHTNESS_VALUE +exit 0 Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/brightness_get.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/brightness_set.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/crypt_setup.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/date_time_set.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/decommission.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/export_logs.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/factory_reset.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/globals.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/lockdown.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/rootsshaccess.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/run.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/setup.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/start.sh'. Fisheye: No comparison available. Pass `N' to diff? Index: scripts/test.sh =================================================================== diff -u --- scripts/test.sh (revision 0) +++ scripts/test.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,58 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file test.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 15-Jan-2025 +# @author (original) Behrouz NematiPour +# @date (original) 15-Jan-2025 +# +############################################################################ + +# Description +# TEST ONLY +# Parameters +# No Parameters +# Retruns +# TEST ONLY +# Considerations +# + +# sources +. ./_errors_ +. ./_functions_ + +# variables + +# functions + +# checks + +# main +echo "-" +sleep 0.1 +echo "\\" +sleep 0.1 +echo "|" +sleep 0.1 +echo "/" +sleep 0.1 +echo "-" +sleep 0.1 +echo "\\" +sleep 0.1 +echo "|" +sleep 0.1 +echo "/" +sleep 0.1 + +# exit gracefully +sleep 0.1 +echo "100" +exit 0 \ No newline at end of file Index: scripts/usb_mount.sh =================================================================== diff -u -r468de49b0616e53a79b1100d9dbc87a7ca82e2b0 -re3f3836273d068ae1bd0b0c5d6a9d25765d34aba --- scripts/usb_mount.sh (.../usb_mount.sh) (revision 468de49b0616e53a79b1100d9dbc87a7ca82e2b0) +++ scripts/usb_mount.sh (.../usb_mount.sh) (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -6,31 +6,49 @@ # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN # WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # -# @file unmountUSB.sh +# @file usb_mount.sh # # @author (last) Behrouz NematiPour -# @date (last) 11-May-2021 +# @date (last) 15-Jan-2025 # @author (original) Behrouz NematiPour -# @date (original) 11-May-2021 +# @date (original) 15-Jan-2025 # ############################################################################ -# $1 - usb device -# $2 - usb drive -# eg. sudo mount -o "noexec,sync,nodev,nosuid" /dev/sda1 /media/usb/ +# Description +# Trys to mount the given usb device in the usb drive/location. +# Parameters +# $1: usb device full path +# $2: usb drive full path (mount point) +# Retruns +# No specific response +# Considerations +# No specific considerations. -USER=root # change to leahi after Cybersecurity implementation -mkdir -p "$2" -if [ $? 1= 0 ]; then - echo "usb mount point folder '$2' cannot be made." - exit 1001 -fi +# sources +. ./_errors_ +. ./_functions_ +# variables +PARAM_COUNT=2 +USB_DEVICE="$(trim "$1")" +USB_FOLDER="$(trim "$2")" + +USER=root # leahi - change to leahi user after Cybersecurity implementation + +# functions + +# checks +check_param_count "$#" "$PARAM_COUNT" +check_empty_string "$USB_DEVICE" "$ERR_MTPARAM_USB_DEVICE" +check_empty_string "$USB_FOLDER" "$ERR_MTPARAM_USB_FOLDER" + +mkdir -p "$USB_FOLDER" +check_result "$?" "$ERR_CMDFAIL_USB_FOLDER_MAKE" + sudo mount -o uid=${USER},gid=${USER},umask=077,noexec,sync,nodev,nosuid "$1" "$2" -if [ $? != 0 ]; then - echo "usb device '$1' cannot be mounted." - exit 1002 -fi +check_result "$?" "$ERR_CMDFAIL_USB_DEVICE_MOUNT" +sleep 0.1 echo "" exit 0 \ No newline at end of file Index: scripts/usb_unmount.sh =================================================================== diff -u -r468de49b0616e53a79b1100d9dbc87a7ca82e2b0 -re3f3836273d068ae1bd0b0c5d6a9d25765d34aba --- scripts/usb_unmount.sh (.../usb_unmount.sh) (revision 468de49b0616e53a79b1100d9dbc87a7ca82e2b0) +++ scripts/usb_unmount.sh (.../usb_unmount.sh) (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -6,29 +6,47 @@ # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN # WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # -# @file unmountUSB.sh +# @file usb_mount.sh # # @author (last) Behrouz NematiPour -# @date (last) 11-May-2021 +# @date (last) 15-Jan-2025 # @author (original) Behrouz NematiPour -# @date (original) 11-May-2021 +# @date (original) 15-Jan-2025 # ############################################################################ -# $1 - usb device -# $2 - usb drive +# Description +# Trys to unmount the given usb device from the usb drive/location. +# Parameters +# $1: usb device full path +# $2: usb drive full path (mount point) +# Retruns +# No specific response +# Considerations +# No specific considerations. -sudo umount $2 -if [ $? != 0 ]; then - echo "usb drive '$2' cannot be unmounted." - exit 1001 -fi +# sources +. ./_errors_ +. ./_functions_ -mkdir -p "$2" -if [ $? != 0 ]; then - echo "usb mount point '$2' cannot be removed." - exit 1002 -fi +# variables +PARAM_COUNT=2 +USB_DEVICE="$(trim "$1")" +USB_FOLDER="$(trim "$2")" +# functions + +# checks +check_param_count "$#" "$PARAM_COUNT" +check_empty_string "$USB_DEVICE" "$ERR_MTPARAM_USB_DEVICE" +check_empty_string "$USB_FOLDER" "$ERR_MTPARAM_USB_FOLDER" + +sudo umount "$USB_FOLDER" +check_result "$?" "$ERR_CMDFAIL_USB_DEVICE_UMOUNT" + +rmdir "$USB_FOLDER" +check_result "$?" "$ERR_CMDFAIL_USB_FOLDER_REMOVE" + +sleep 0.1 echo "" exit 0 \ No newline at end of file Index: scripts/wifi_connect.sh =================================================================== diff -u --- scripts/wifi_connect.sh (revision 0) +++ scripts/wifi_connect.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,52 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_connect.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 15-Jan-2025 +# @author (original) Behrouz NematiPour +# @date (original) 15-Jan-2025 +# +############################################################################ + +# Description +# Connects to the given SSID with the given password. +# Parameters +# $1: the SSID name +# $2: the SSID password +# Retruns +# No specific response. +# Considerations +# For security reasons the system is not allowed to connect to a passwordless AP. +# Therefore an empty password is an error. + +# TODO +# Add static connection +# The static IP enable shall only be a boolean argument for this script. +# When set to 1(true), the corretly defined connection will be made static. + +# sources +. ./_errors_ +. ./_functions_ + +# variables +PARAM_COUNT=2 +SSID_NAME="$(trim "$1")" +SSID_PASS="$(trim "$2")" + +# functions + +# checks +check_param_count "$#" "$PARAM_COUNT" +check_empty_string "$SSID_NAME" "$ERR_MTPARAM_WIFI_SSID" +check_empty_string "$SSID_PASS" "$ERR_MTPARAM_WIFI_PASS" + +# main +sudo nmcli dev wifi connect "$SSID_NAME" password "$SSID_PASS" +check_result "$?" "$ERR_CMDFAIL_WIFI_CONNECT" Index: scripts/wifi_disconnect.sh =================================================================== diff -u --- scripts/wifi_disconnect.sh (revision 0) +++ scripts/wifi_disconnect.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,43 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_disconnect.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 15-Jan-2025 +# @author (original) Behrouz NematiPour +# @date (original) 15-Jan-2025 +# +############################################################################ + +# Description +# Disconnects from the given SSID($1) +# Parameters +# $1: the SSID name +# Returns +# No specific response +# Considerations +# - The system has to be already connected to the given SSID + +# sources +. ./_errors_ +. ./_functions_ + +# variables +PARAM_COUNT=1 +SSID_NAME="$(trim "$1")" + +# functions + +# checks +check_param_count "$#" "$PARAM_COUNT" +check_empty_string "$SSID_NAME" "$ERR_MTPARAM_WIFI_SSID" + +# main +sudo nmcli connection delete "$SSID_NAME" +check_result "$?" "$ERR_CMDFAIL_WIFI_DISCONNECT" Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/wifi_disconnect_network.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/wifi_generate_wpa_supplicant.sh'. Fisheye: No comparison available. Pass `N' to diff? Index: scripts/wifi_info.sh =================================================================== diff -u --- scripts/wifi_info.sh (revision 0) +++ scripts/wifi_info.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,65 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_info.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 15-Jan-2025 +# @author (original) Behrouz NematiPour +# @date (original) 15-Jan-2025 +# +############################################################################ + +# Description +# Gets the active connection information +# Parameters +# No Parameters +# Retruns +# A csv string of the active connection info +# with the columns defined $COLUMNS in order. +# Considerations +# For the Application to work with the List of APs +# - it has to be sorted by SSID +# - it has to use defined columns exactly as has been defined in $COLUMN. + +# sources +. ./_errors_ +. ./_functions_ + +# variables +PARAM_COUNT=0 +COLUMNS="IP4.ADDRESS,IP4.GATEWAY,IP4.DNS" + +# functions + +# checks +check_param_count "$#" "$PARAM_COUNT" + +# main +SSID="$(sudo nmcli -t -f NAME connection show --active)" +check_result "$?" "$ERR_CMDFAIL_WIFI_INFO_SSID" + +IPMASK="$(sudo nmcli -t -g IP4.ADDRESS device show wlan0)" +check_result "$?" "$ERR_CMDFAIL_WIFI_INFO_IPMASK" + +ADDR="$(echo $IPMASK | sed 's/\/.*//g')" +check_result "$?" "$ERR_CMDFAIL_WIFI_INFO_ADDR" + +MASK="$(sudo ipcalc -m "$(echo $IPMASK)" | sed "s/NETMASK=//g")" +check_result "$?" "$ERR_CMDFAIL_WIFI_INFO_MASK" + +GATEWAY="$(sudo nmcli -t -g IP4.GATEWAY device show wlan0)" +check_result "$?" "$ERR_CMDFAIL_WIFI_INFO_GATEWAY" + +DNS="$(sudo nmcli -t -g IP4.DNS device show wlan0 | sed "s/ //g"| sed 's/|/,/g')" +check_result "$?" "$ERR_CMDFAIL_WIFI_INFO_DNS" + +echo "$SSID,$ADDR,$MASK,$GATEWAY,$DNS" +exit 0 + + Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/wifi_read_dns.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/wifi_read_gateway.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/wifi_read_ip_settings.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/wifi_read_network_info.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/wifi_request_auto_assigned_ip.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/wifi_reset_adapter.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/wifi_reset_interface.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/wifi_save_dhcp_interface.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/wifi_save_static_interface_assignments.sh'. Fisheye: No comparison available. Pass `N' to diff? Index: scripts/wifi_scan.sh =================================================================== diff -u --- scripts/wifi_scan.sh (revision 0) +++ scripts/wifi_scan.sh (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,49 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_scan.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 15-Jan-2025 +# @author (original) Behrouz NematiPour +# @date (original) 15-Jan-2025 +# +############################################################################ + +# Description +# Lists all the available Access Points using nmcli command of NetworkManager module. +# Parameters +# No Parameters +# Retruns +# Sorted list of the APs in defined column as specified in the $COLUMNS. +# Considerations +# For the Application to work with the List of APs +# - it has to be sorted by SSID +# - it has to use defined columns exactly as has been defined in $COLUMN. + +# sources +. ./_errors_ +. ./_functions_ + +# variables +PARAM_COUNT=0 +COLUMNS="SSID,BSSID,FREQ,RATE,SIGNAL,SECURITY,WPA-FLAGS,RSN-FLAGS,IN-USE" + +# functions + +# checks +check_param_count "$#" "$PARAM_COUNT" + +# main +OUTPUT="$(sudo nmcli -t -f $COLUMNS dev wifi list --rescan yes | sed 's/:/,/g;s/\\,/:/g' | sort)" +check_result "$?" "$ERR_CMDFAIL_WIFI_SCAN" + +# exit gracefully +sleep 0.1 +echo -e "$OUTPUT" +exit 0 \ No newline at end of file Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/wifi_scan_for_networks.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/wifi_set_auto_assigned_ip.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/wifi_set_dns.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/wifi_set_gateway.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/wifi_set_static_ip.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/wifi_set_subnetmask.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/wifi_start_wpa_supplicant.sh'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e3f3836273d068ae1bd0b0c5d6a9d25765d34aba refers to a dead (removed) revision in file `scripts/wifi_test_internet.sh'. Fisheye: No comparison available. Pass `N' to diff? Index: wlan0-nmcli-2.out~ =================================================================== diff -u --- wlan0-nmcli-2.out~ (revision 0) +++ wlan0-nmcli-2.out~ (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -0,0 +1,55 @@ + + +DIRECT-2b-HP M402 LaserJet,AA:A7:95:D0:4C:2B,2412 MHz,65 Mbit/s,57,WPA2,(none),pair_ccmp group_ccmp psk, +DIRECT-DE-HP OfficeJet 3830,E4:E7:49:CE:9F:DF,2437 MHz,65 Mbit/s,22,WPA2,(none),pair_ccmp group_ccmp psk, +DIRECT-Fl-USIVN-PRT-1857,5A:EF:68:27:FB:A3,2412 MHz,54 Mbit/s,30,WPA2,(none),pair_ccmp group_ccmp psk, +Diality Guest,04:BD:88:75:36:00,2462 MHz,195 Mbit/s,60,WPA2,(none),pair_ccmp group_ccmp psk, +Diality Guest,04:BD:88:75:36:10,5660 MHz,405 Mbit/s,40,WPA2,(none),pair_ccmp group_ccmp psk, +Diality Guest,7C:57:3C:FC:E9:10,5260 MHz,540 Mbit/s,37,WPA2,(none),pair_ccmp group_ccmp psk, +Diality Guest,7C:57:3C:FD:69:70,5745 MHz,540 Mbit/s,40,WPA2,(none),pair_ccmp group_ccmp psk, +Diality Guest,7C:57:3C:FE:4C:C0,2412 MHz,130 Mbit/s,59,WPA2,(none),pair_ccmp group_ccmp psk, +Diality Guest,7C:57:3C:FE:4C:D0,5580 MHz,540 Mbit/s,67,WPA2,(none),pair_ccmp group_ccmp psk, +DialityHQ,04:BD:88:75:36:01,2462 MHz,195 Mbit/s,62,WPA2,(none),pair_ccmp group_ccmp psk, +DialityHQ,04:BD:88:75:36:11,5660 MHz,405 Mbit/s,40,WPA2,(none),pair_ccmp group_ccmp psk, +DialityHQ,7C:57:3C:FC:E9:11,5260 MHz,540 Mbit/s,35,WPA2,(none),pair_ccmp group_ccmp psk, +DialityHQ,7C:57:3C:FD:69:61,2462 MHz,130 Mbit/s,52,WPA2,(none),pair_ccmp group_ccmp psk, +DialityHQ,7C:57:3C:FD:69:71,5745 MHz,540 Mbit/s,40,WPA2,(none),pair_ccmp group_ccmp psk, +DialityHQ,7C:57:3C:FE:4C:C1,2412 MHz,130 Mbit/s,59,WPA2,(none),pair_ccmp group_ccmp psk, +DialityHQ,7C:57:3C:FE:4C:D1,5580 MHz,540 Mbit/s,67,WPA2,(none),pair_ccmp group_ccmp psk, +DialityHQ_5GEXT,CC:2D:21:8B:D9:1D,5745 MHz,270 Mbit/s,32,WPA1 WPA2,pair_ccmp group_ccmp psk,pair_ccmp group_ccmp psk, +DialityHQ_5GEXT,CC:2D:21:8B:DB:ED,5745 MHz,270 Mbit/s,39,WPA1 WPA2,pair_ccmp group_ccmp psk,pair_ccmp group_ccmp psk, +DialityHQ_EXT,CC:2D:21:8B:D9:19,2412 MHz,270 Mbit/s,40,WPA1 WPA2,pair_ccmp group_ccmp psk,pair_ccmp group_ccmp psk, +DialityWAPA,04:BD:88:75:36:04,2462 MHz,195 Mbit/s,60,WPA1,pair_tkip pair_ccmp group_tkip psk,(none), +DialityWAPA,04:BD:88:75:36:14,5660 MHz,405 Mbit/s,40,WPA1,pair_tkip pair_ccmp group_tkip psk,(none), +DialityWAPA,7C:57:3C:FC:E9:14,5260 MHz,540 Mbit/s,37,WPA1,pair_tkip pair_ccmp group_tkip psk,(none), +DialityWAPA,7C:57:3C:FD:69:74,5745 MHz,540 Mbit/s,40,WPA1,pair_tkip pair_ccmp group_tkip psk,(none), +DialityWAPA,7C:57:3C:FE:4C:C4,2412 MHz,130 Mbit/s,60,WPA1,pair_tkip pair_ccmp group_tkip psk,(none), +DialityWAPA,7C:57:3C:FE:4C:D4,5580 MHz,540 Mbit/s,65,WPA1,pair_tkip pair_ccmp group_tkip psk,(none), +DialityWAPB,04:BD:88:75:36:05,2462 MHz,195 Mbit/s,60,WPA1 WPA2,pair_tkip group_tkip psk,pair_ccmp group_tkip psk, +DialityWAPB,04:BD:88:75:36:15,5660 MHz,405 Mbit/s,39,WPA1 WPA2,pair_tkip group_tkip psk,pair_ccmp group_tkip psk, +DialityWAPB,7C:57:3C:FC:E9:15,5260 MHz,540 Mbit/s,35,WPA1 WPA2,pair_tkip group_tkip psk,pair_ccmp group_tkip psk, +DialityWAPB,7C:57:3C:FD:69:75,5745 MHz,540 Mbit/s,40,WPA1 WPA2,pair_tkip group_tkip psk,pair_ccmp group_tkip psk, +DialityWAPB,7C:57:3C:FE:4C:C5,2412 MHz,130 Mbit/s,59,WPA1 WPA2,pair_tkip group_tkip psk,pair_ccmp group_tkip psk, +DialityWAPB,7C:57:3C:FE:4C:D5,5580 MHz,540 Mbit/s,67,WPA1 WPA2,pair_tkip group_tkip psk,pair_ccmp group_tkip psk, +DialityWAPC,7C:57:3C:FC:E9:16,5260 MHz,540 Mbit/s,39,WPA3,(none),pair_ccmp group_ccmp sae, +DialityWAPC,7C:57:3C:FD:69:66,2462 MHz,130 Mbit/s,54,WPA3,(none),pair_ccmp group_ccmp sae, +DialityWAPC,7C:57:3C:FD:69:76,5745 MHz,540 Mbit/s,40,WPA3,(none),pair_ccmp group_ccmp sae, +DialityWAPC,7C:57:3C:FE:4C:C6,2412 MHz,130 Mbit/s,59,WPA3,(none),pair_ccmp group_ccmp sae, +DialityWAPC,7C:57:3C:FE:4C:D6,5580 MHz,540 Mbit/s,67,WPA3,(none),pair_ccmp group_ccmp sae, +DialityWEP,04:BD:88:75:36:03,2462 MHz,54 Mbit/s,59,WEP,(none),(none), +DialityWEP,04:BD:88:75:36:13,5660 MHz,54 Mbit/s,40,WEP,(none),(none), +DialityWEP,7C:57:3C:FC:E9:13,5260 MHz,54 Mbit/s,37,WEP,(none),(none), +DialityWEP,7C:57:3C:FD:69:73,5745 MHz,54 Mbit/s,40,WEP,(none),(none), +DialityWEP,7C:57:3C:FE:4C:C3,2412 MHz,54 Mbit/s,57,WEP,(none),(none), +DialityWEP,7C:57:3C:FE:4C:D3,5580 MHz,54 Mbit/s,65,WEP,(none),(none), +DilaityIoT,04:BD:88:75:36:02,2462 MHz,195 Mbit/s,65,WPA2,(none),pair_ccmp group_ccmp psk, +DilaityIoT,04:BD:88:75:36:12,5660 MHz,405 Mbit/s,40,WPA2,(none),pair_ccmp group_ccmp psk, +DilaityIoT,7C:57:3C:FC:E9:12,5260 MHz,540 Mbit/s,39,WPA2,(none),pair_ccmp group_ccmp psk, +DilaityIoT,7C:57:3C:FD:69:72,5745 MHz,540 Mbit/s,39,WPA2,(none),pair_ccmp group_ccmp psk, +DilaityIoT,7C:57:3C:FE:4C:C2,2412 MHz,130 Mbit/s,59,WPA2,(none),pair_ccmp group_ccmp psk, +DilaityIoT,7C:57:3C:FE:4C:D2,5580 MHz,540 Mbit/s,69,WPA2,(none),pair_ccmp group_ccmp psk, +ZB-Validated,70:7D:B9:C6:6D:81,2437 MHz,195 Mbit/s,25,WPA2 802.1X,(none),pair_ccmp group_ccmp 802.1X, +ZB-Validated,70:7D:B9:C6:6D:8E,5260 MHz,405 Mbit/s,34,WPA2 802.1X,(none),pair_ccmp group_ccmp 802.1X, +Zimmerbiometguest,70:7D:B9:C6:6D:82,2437 MHz,195 Mbit/s,24,WPA2,(none),pair_ccmp group_ccmp psk, +wpa3r3,96:17:CA:C4:23:FD,2412 MHz,270 Mbit/s,79,WPA2 WPA3,(none),pair_ccmp group_ccmp psk sae,* +