Index: scripts/create_update_folder.sh =================================================================== diff -u --- scripts/create_update_folder.sh (revision 0) +++ scripts/create_update_folder.sh (revision 3e49c0cb545fafdaaff760dd51dce8bc3263ab46) @@ -0,0 +1,65 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2019-2020 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 create_update_usb.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 01-Nov-2021 +# @author (original) Behrouz NematiPour +# @date (original) 01-Nov-2021 +# +############################################################################ + +# This script is collecting all the scripts and files and copy in a folder +# to be later used to update a newly flashed SoM +# Run example +# └$ /home/denali/Projects/application/scripts/create_update_usb.sh Projects/application/ /media/denali/usb-disk1/ + + +FOLDER_BIN=/home/denali/Projects/tmp/build/denali-Qt_5_12_5_iMX8-Release +FOLDER_SRC=/home/denali/Projects/application +FOLDER_DST=/home/denali/Desktop/update-folder + +DENALI_BIN=denali +FOLDER_SCR=scripts +FOLDER_FNT=resources/fonts +FOLDER_SET=resources/settings + +SCRIPT_SLF=create_update_folder.sh +SCRIPT_AUT=autostart +SCRIPT_RUN=run.sh +SCRIPT_SU1=start.sh +SCRIPT_SU2=setup.sh + +if [ ! -z "$1" ]; then + FOLDER_SRC="$1" +fi + +if [ ! -z "$2" ]; then + FOLDER_DST="$2" +fi + +#create the destination folder +mkdir -p "$FOLDER_DST" + +#copy the required folders +cp -r "$FOLDER_SRC"/"$FOLDER_SCR" "$FOLDER_DST" +cp -r "$FOLDER_SRC"/"$FOLDER_FNT" "$FOLDER_DST" +cp -r "$FOLDER_SRC"/"$FOLDER_SET" "$FOLDER_DST" + +#move the setup scrips to the root folder of the usb +mv "$FOLDER_DST"/"$FOLDER_SCR"/"$SCRIPT_SU1" "$FOLDER_DST" +mv "$FOLDER_DST"/"$FOLDER_SCR"/"$SCRIPT_SU2" "$FOLDER_DST" +mv "$FOLDER_DST"/"$FOLDER_SCR"/"$SCRIPT_RUN" "$FOLDER_DST" +mv "$FOLDER_DST"/"$FOLDER_SCR"/"$SCRIPT_AUT" "$FOLDER_DST" + +#copy the UI Software device binary to the root folder of the usb +cp "$FOLDER_BIN"/"$DENALI_BIN" "$FOLDER_DST" + +#removing this script to clean up the script folder +rm "$FOLDER_DST"/"$FOLDER_SCR"/"$SCRIPT_SLF" Index: scripts/setup.sh =================================================================== diff -u -raa873f8620e3f402bf60827e9c54623b5e09280e -r3e49c0cb545fafdaaff760dd51dce8bc3263ab46 --- scripts/setup.sh (.../setup.sh) (revision aa873f8620e3f402bf60827e9c54623b5e09280e) +++ scripts/setup.sh (.../setup.sh) (revision 3e49c0cb545fafdaaff760dd51dce8bc3263ab46) @@ -9,11 +9,16 @@ # @file setup.sh # # @author (last) Behrouz NematiPour -# @date (last) 11-Aug-2021 +# @date (last) 01-Nov-2021 # @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. + echo "setup the time/date controller" # to use the system time/date and not use the network time protocol timedatectl set-ntp 0 Index: scripts/start.sh =================================================================== diff -u -r936ed882bee8169edec9fe24cbd4e49ccca667d9 -r3e49c0cb545fafdaaff760dd51dce8bc3263ab46 --- scripts/start.sh (.../start.sh) (revision 936ed882bee8169edec9fe24cbd4e49ccca667d9) +++ scripts/start.sh (.../start.sh) (revision 3e49c0cb545fafdaaff760dd51dce8bc3263ab46) @@ -9,31 +9,35 @@ # @file copy.sh # # @author (last) Behrouz NematiPour -# @date (last) 11-Aug-2021 +# @date (last) 01-Nov-2021 # @author (original) Behrouz NematiPour # @date (original) 13-Mar-2020 # ############################################################################ -# device default Ip Address and denali application path -if [ "$1" == "" ]; then - IPADDR="192.168.10.135" -else - IPADDR="$1" -fi -SSHUSER=root +# @details +# This file is used to setup newly flashed SoM to copy everythin on the device. -CONFIGPATH="/home/$SSHUSER/.config/" -HOMEPATH="/home/$SSHUSER/" -SCRIPTSPATH="/home/$SSHUSER/scripts/" -FONTPATH="/usr/share/fonts/truetype/" -CONFIGSPATH="/home/denali/Projects/application/resources/settings/" -FONTSPATH="/home/denali/Projects/application/resources/fonts/" -DENALIPATH="/home/denali/Projects/tmp/build/denali-Qt_5_12_5_iMX8-Release/" +SRC_PATH_SCRIPTS="scripts" +SRC_PATH_CONFIG="settings" +SRC_PATH_FONTS="fonts" -DENALINAME=denali +DST_IP="192.168.10.135" +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_FONTS="/usr/share/fonts/truetype" +SRC_PATH_DENALI="." +DENALI_BIN=denali + +# device default Ip Address and denali application path +if [ -n "$1" ]; then +DST_IP="$1" +fi + function folderExists() { if [ ! -d "$1" ]; then echo 1 @@ -52,23 +56,23 @@ function copyFolderTo() { echo $1 - scp -r $1/* $SSHUSER@$IPADDR:$2 + scp -r $1/* $DST_USER@$DST_IP:$2 if [ ! $? -eq 0 ];then - echo "copy of file $1 unsuccessful" + echo "copy of folder $1 unsuccessful" return 1 fi return 0 } function copyFileTo() { if [ $(fileExists "$1") -eq 0 ]; then - scp $1 $SSHUSER@$IPADDR:$2 + scp $1 $DST_USER@$DST_IP:$2 if [ ! $? -eq 0 ];then echo "copy of file $1 unsuccessful" return 1 fi else - echo "File $1 doesn't exist" + echo " ~~~ File $1 doesn't exist" fi return 0 } @@ -84,135 +88,116 @@ } function removeIPFromHost() { - ssh-keygen -f "/home/denali/.ssh/known_hosts" -R "$IPADDR" + ssh-keygen -f "/home/denali/.ssh/known_hosts" -R "$DST_IP" sleep 5 } # getting the ip address of the device function getIpAddress() { while true; do - read -p "Please enter the device Ip address: " -e -i $IPADDR -r IPADDR + read -p "Please enter the device Ip address: " -e -i $DST_IP -r DST_IP echo "removing device Ip Address from known hosts" removeIPFromHost - echo "Testing connection on IP $IPADDR" - if [ ! -z $IPADDR ]; then - ping $IPADDR -c1 -W1 + echo "Testing connection on IP $DST_IP" + if [ ! -z "$DST_IP" ]; then + ping "$DST_IP" -c1 -W1 if [ $? -eq 0 ]; then break else - echo "Cannot connect to the device." - echo "Either device not connected or the IP address is not correct." + echo " ~~~ Cannot connect to the device." + echo " ~~~ Either device not connected or the IP address is not correct." exitconfirm 1 fi fi done - echo "Connection successful on device with IP $IPADDR" + echo "Connection successful on device with IP $DST_IP" echo "" } # getting the denali application path function getDenaliPath() { while true; do - read -p "Please enter the Denali application path: " -e -i $DENALIPATH -r DENALIPATH + read -p "Please enter the Denali application path: " -e -i $SRC_PATH_DENALI -r SRC_PATH_DENALI echo "Testing the Denali application path" - if [ $(fileExists "$DENALIPATH/$DENALINAME") -eq 0 ]; then + if [ $(fileExists "$SRC_PATH_DENALI/$DENALI_BIN") -eq 0 ]; then break else - echo "Cannot find the Denali application." - echo "Either the path is not correct or the Denali application doesn't exist." + echo " ~~~ Cannot find the Denali application." + echo " ~~~ Either the path is not correct or the Denali application doesn't exist." exitconfirm 2 fi done - echo "The Denali application found successfully in path '$DENALIPATH'" + echo "The Denali application found successfully in path '$SRC_PATH_DENALI'" echo "" } # getting the fonts path function getFontsPath() { while true; do - read -p "Please enter the fonts path: " -e -i $FONTSPATH -r FONTSPATH + read -p "Please enter the fonts path: " -e -i $SRC_PATH_FONTS -r SRC_PATH_FONTS echo "Testing fonts path" - if [ "$(folderExists "$FONTSPATH")" -eq 0 ]; then + if [ "$(folderExists "$SRC_PATH_FONTS")" -eq 0 ]; then if [ "$(ls)" != "" ]; then break else - echo "The folder $FONTSPATH is empty" + echo " ~~~ The folder $SRC_PATH_FONTS is empty" exitconfirm 3 fi else - echo "Cannot find Fonts path." + echo " ~~~ Cannot find Fonts path." exitconfirm 4 fi done - echo "Fonts found successfully in path '$FONTSPATH'" + echo "Fonts found successfully in path '$SRC_PATH_FONTS'" echo "" } # SSH Connection function connect() { - echo "please ssh into device $IPADDR and run ./setup.sh" + echo "please ssh into device $DST_IP and run ./setup.sh" read -p "Do you want to ssh into device? [y,n]" -n 1 -r CONFIRM if [ "$CONFIRM" == "y" ]; then echo "" - ssh $SSHUSER@$IPADDR + ssh $DST_USER@$DST_IP else echo "" fi } -# copy the date/time settings scripts -function copyDateTimeScripts() { - copyFileTo "date_time_set.sh" $SCRIPTSPATH -} - -# copy the wifi settings scripts -function copyWifiScripts() { - scripts=$(ls wifi_*.sh) - for script in $scripts - do - copyFileTo $script $SCRIPTSPATH - done -} - -# copy the brightness settings scripts -function copyBrightnessScripts() { - scripts=$(ls brightness_*.sh) - for script in $scripts - do - copyFileTo $script $SCRIPTSPATH - done -} - # copy the settings scripts function setupSettingsScripts() { - ssh $SSHUSER@$IPADDR "mkdir $SCRIPTSPATH;" - copyDateTimeScripts - copyWifiScripts - copyBrightnessScripts - ssh $SSHUSER@$IPADDR "cd $1; chmod a+x *.sh;" + ssh $DST_USER@$DST_IP "mkdir -p $DST_PATH_SCRIPTS;" + copyFolderTo $SRC_PATH_SCRIPTS $DST_PATH_SCRIPTS + ssh $DST_USER@$DST_IP "cd $1; chmod a+x *.sh;" } # copy the instructions function setupInstructions() { - ssh $SSHUSER@$IPADDR "rm -frd $CONFIGPATH/*;" - copyFolderTo $CONFIGSPATH $CONFIGPATH + ssh $DST_USER@$DST_IP "mkdir -p $DST_PATH_CONFIG;" + ssh $DST_USER@$DST_IP "rm -frd $DST_PATH_CONFIG/*;" + copyFolderTo $SRC_PATH_CONFIG $DST_PATH_CONFIG } +# copy the fonts +function setupFonts() { + getFontsPath + copyFolderTo $SRC_PATH_FONTS $DST_PATH_FONTS +} + function main() { getIpAddress - copyFileTo "autostart" $HOMEPATH - copyFileTo "run.sh" $HOMEPATH - copyFileTo "setup.sh" $HOMEPATH + copyFileTo "autostart" $DST_PATH_HOME + copyFileTo "run.sh" $DST_PATH_HOME + copyFileTo "setup.sh" $DST_PATH_HOME setupSettingsScripts setupInstructions + setupFonts getDenaliPath - copyFileTo $DENALIPATH/$DENALINAME $HOMEPATH + copyFileTo "$SRC_PATH_DENALI/$DENALI_BIN" $DST_PATH_HOME - getFontsPath - copyFolderTo $FONTSPATH $FONTPATH } # running the main function