Index: denali.pro.user =================================================================== diff -u -r29424716b9b1aafc77443cc2607572ddbd9da372 -r936ed882bee8169edec9fe24cbd4e49ccca667d9 --- denali.pro.user (.../denali.pro.user) (revision 29424716b9b1aafc77443cc2607572ddbd9da372) +++ denali.pro.user (.../denali.pro.user) (revision 936ed882bee8169edec9fe24cbd4e49ccca667d9) @@ -1,6 +1,6 @@ - + EnvironmentId Fisheye: Tag 936ed882bee8169edec9fe24cbd4e49ccca667d9 refers to a dead (removed) revision in file `scripts/copy.sh'. Fisheye: No comparison available. Pass `N' to diff? Index: scripts/run.sh =================================================================== diff -u -r3ad21b53b6b15cc0c88661cf17ba454fe0a302b1 -r936ed882bee8169edec9fe24cbd4e49ccca667d9 --- scripts/run.sh (.../run.sh) (revision 3ad21b53b6b15cc0c88661cf17ba454fe0a302b1) +++ scripts/run.sh (.../run.sh) (revision 936ed882bee8169edec9fe24cbd4e49ccca667d9) @@ -9,7 +9,7 @@ # @file run.sh # # @author (last) Behrouz NematiPour -# @date (last) 2-Aug-2021 +# @date (last) 11-Aug-2021 # @author (original) Behrouz NematiPour # @date (original) 28-Oct-2019 # @@ -105,9 +105,9 @@ #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=$(cat /sys/class/rtc/rtc/since_epoch) + RTC1=$(cat /sys/class/rtc/rtc0/since_epoch) sleep 1 - RTC2=$(cat /sys/class/rtc/rtc/since_epoch) + RTC2=$(cat /sys/class/rtc/rtc0/since_epoch) if [ $(($RTC2 - $RTC1)) -eq 1 ]; then echo $POSTMSG_RTC >> $POSTLOG fi @@ -131,10 +131,13 @@ $HOME/denali -u & -# setup wifi -udhcpc -i eth0 -n & - - # tag the end time in the POST log file echo "End: $(date +"%d%m%Y%H%M%S")" >> $POSTLOG + +# setup ethernet +# note: At this time the application is running and also the ehternet connection is not necessary +# so the sleep here is not hurtung any part of the applicaion progress. +sleep 10 +udhcpc eth0 & + Index: scripts/setup.sh =================================================================== diff -u -r506a9e3db1a20bda1685e38c5e9041005c9a4a4f -r936ed882bee8169edec9fe24cbd4e49ccca667d9 --- scripts/setup.sh (.../setup.sh) (revision 506a9e3db1a20bda1685e38c5e9041005c9a4a4f) +++ scripts/setup.sh (.../setup.sh) (revision 936ed882bee8169edec9fe24cbd4e49ccca667d9) @@ -8,10 +8,10 @@ # # @file setup.sh # -# @author (last) Behrouz NematiPour -# @date (last) 13-Mar-2020 -# @author (original) Behrouz NematiPour -# @date (original) 13-Mar-2020 +# @author (last) Behrouz NematiPour +# @date (last) 11-Aug-2021 +# @author (original) Behrouz NematiPour +# @date (original) 13-Mar-2020 # ############################################################################ echo "setup the time/date controller" Index: scripts/start.sh =================================================================== diff -u --- scripts/start.sh (revision 0) +++ scripts/start.sh (revision 936ed882bee8169edec9fe24cbd4e49ccca667d9) @@ -0,0 +1,221 @@ +#!/bin/bash +########################################################################### +# +# 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 copy.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-Aug-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 + +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/" + +DENALINAME=denali + +function folderExists() { + if [ ! -d "$1" ]; then + echo 1 + return + fi + echo 0 +} + +function fileExists() { + if [ ! -f "$1" ]; then + echo 1 + return + fi + echo 0 +} + +function copyFolderTo() { + echo $1 + scp -r $1/* $SSHUSER@$IPADDR:$2 + if [ ! $? -eq 0 ];then + echo "copy of file $1 unsuccessful" + return 1 + fi + return 0 +} + +function copyFileTo() { + if [ $(fileExists "$1") -eq 0 ]; then + scp $1 $SSHUSER@$IPADDR:$2 + if [ ! $? -eq 0 ];then + echo "copy of file $1 unsuccessful" + return 1 + fi + else + echo "File $1 doesn't exist" + fi + return 0 +} + +function exitconfirm() { + read -p "Continue? [y,n]" -n 1 -r CONTINUE + if [ "$CONTINUE" != "y" ]; then + echo "" + exit "$1" + else + echo "" + fi +} + +function removeIPFromHost() { + ssh-keygen -f "/home/denali/.ssh/known_hosts" -R "$IPADDR" + 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 + echo "removing device Ip Address from known hosts" + removeIPFromHost + echo "Testing connection on IP $IPADDR" + if [ ! -z $IPADDR ]; then + ping $IPADDR -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." + exitconfirm 1 + fi + fi + done + echo "Connection successful on device with IP $IPADDR" + echo "" +} + +# getting the denali application path +function getDenaliPath() { + while true; do + read -p "Please enter the Denali application path: " -e -i $DENALIPATH -r DENALIPATH + echo "Testing the Denali application path" + if [ $(fileExists "$DENALIPATH/$DENALINAME") -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." + exitconfirm 2 + fi + done + echo "The Denali application found successfully in path '$DENALIPATH'" + echo "" +} + +# getting the fonts path +function getFontsPath() { + while true; do + read -p "Please enter the fonts path: " -e -i $FONTSPATH -r FONTSPATH + echo "Testing fonts path" + if [ "$(folderExists "$FONTSPATH")" -eq 0 ]; then + if [ "$(ls)" != "" ]; then + break + else + echo "The folder $FONTSPATH is empty" + exitconfirm 3 + fi + else + echo "Cannot find Fonts path." + exitconfirm 4 + fi + done + echo "Fonts found successfully in path '$FONTSPATH'" + echo "" +} + +# SSH Connection +function connect() { + echo "please ssh into device $IPADDR 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 + 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;" +} + +# copy the instructions +function setupInstructions() { + ssh $SSHUSER@$IPADDR "rm -frd $CONFIGPATH/*;" + copyFolderTo $CONFIGSPATH $CONFIGPATH +} + +function main() { + getIpAddress + + copyFileTo "autostart" $HOMEPATH + copyFileTo "run.sh" $HOMEPATH + copyFileTo "setup.sh" $HOMEPATH + + setupSettingsScripts + setupInstructions + + getDenaliPath + copyFileTo $DENALIPATH/$DENALINAME $HOMEPATH + + getFontsPath + copyFolderTo $FONTSPATH $FONTPATH +} + +# running the main function +main +connect +