diff --git a/util/connect_BBB.sh b/util/connect_BBB.sh new file mode 100755 index 0000000000000000000000000000000000000000..3b412bba63923c38b7f13210cbfd078fd24e87cf --- /dev/null +++ b/util/connect_BBB.sh @@ -0,0 +1,8 @@ +#!/bin/bash +############################################################################### +# This line of code connects to the BBB via ssh, runs the startup file and +# remains in the shell of the BBB after executing startup.sh on the BBB +# +# The code may be executed from anywhere on the HOST computer. +############################################################################### +ssh -t debian@192.168.7.2 "./LabConnection.jl/util/startup.sh; bash -l" diff --git a/util/connect_BBB.sh~ b/util/connect_BBB.sh~ new file mode 100755 index 0000000000000000000000000000000000000000..3b412bba63923c38b7f13210cbfd078fd24e87cf --- /dev/null +++ b/util/connect_BBB.sh~ @@ -0,0 +1,8 @@ +#!/bin/bash +############################################################################### +# This line of code connects to the BBB via ssh, runs the startup file and +# remains in the shell of the BBB after executing startup.sh on the BBB +# +# The code may be executed from anywhere on the HOST computer. +############################################################################### +ssh -t debian@192.168.7.2 "./LabConnection.jl/util/startup.sh; bash -l" diff --git a/util/flash_BBB.sh b/util/flash_BBB.sh new file mode 100755 index 0000000000000000000000000000000000000000..60eb8bbe1b004d7bdf431c9dc2dbfe7be4bbb3e4 --- /dev/null +++ b/util/flash_BBB.sh @@ -0,0 +1,60 @@ +#!/bin/bash +############################################################################### +# This code clones or upps the most recent code from github and transfers it to +# the BBB before connecting to it and running the startup file on the BBB. +# +# The code may be executed from anywhere on the HOST computer. +############################################################################### + +BLUE='\033[0;34m' +GREEN='\033[0;32m' +RED='\033[0;31m' +NC='\033[0m' + +printf "${BLUE}Updating project${NC}\n..." + +codeHost=gitlab.control.lth.se +codeUser=labdev +projects=(LabConnection.jl) +flag=false + +for project in "${projects[@]}"; do + { + if [ -d "${project}" ]; then + # Try to clone repository + printf "${GREEN}Pulling /${project}...${NC}\n" + cd "${project}" + echo $(ls) + git pull "https://${codeHost}/${codeUser}/${project}.git" + cd ".." + else + printf "${GREEN}Cloning /${project}...${NC}\n" + git clone "https://${codeHost}/${codeUser}/${project}.git" + fi + } || { # catch + # save log for exception + flag=false + printf "${RED}Could not udate repository /${project}${NC}, aborting.\n" + } +done + +printf "${BLUE}Initializing Transferring files to BBB${NC}\n" +if [ "{flag}"=true ]; then + for project in "${projects[@]}"; do + { + printf "${GREEN}Transferring /${project}...${NC}\n" + scp -r ${project} debian@192.168.7.2:/home/debian + } || { # catch + # save log for exception + flag=false + printf "${RED}Could not send folder /${project} to the BBB, aborting!${NC}\n" + } + done +fi + +printf "${BLUE}Connecting to the BBB${NC}\n" +{ + ssh -t debian@192.168.7.2 "./LabConnection.jl/util/startup.sh; bash -l" +} || { + printf "${RED}Could Connect to the BBB!${NC}\n" +} diff --git a/util/flash_BBB.sh~ b/util/flash_BBB.sh~ new file mode 100755 index 0000000000000000000000000000000000000000..60eb8bbe1b004d7bdf431c9dc2dbfe7be4bbb3e4 --- /dev/null +++ b/util/flash_BBB.sh~ @@ -0,0 +1,60 @@ +#!/bin/bash +############################################################################### +# This code clones or upps the most recent code from github and transfers it to +# the BBB before connecting to it and running the startup file on the BBB. +# +# The code may be executed from anywhere on the HOST computer. +############################################################################### + +BLUE='\033[0;34m' +GREEN='\033[0;32m' +RED='\033[0;31m' +NC='\033[0m' + +printf "${BLUE}Updating project${NC}\n..." + +codeHost=gitlab.control.lth.se +codeUser=labdev +projects=(LabConnection.jl) +flag=false + +for project in "${projects[@]}"; do + { + if [ -d "${project}" ]; then + # Try to clone repository + printf "${GREEN}Pulling /${project}...${NC}\n" + cd "${project}" + echo $(ls) + git pull "https://${codeHost}/${codeUser}/${project}.git" + cd ".." + else + printf "${GREEN}Cloning /${project}...${NC}\n" + git clone "https://${codeHost}/${codeUser}/${project}.git" + fi + } || { # catch + # save log for exception + flag=false + printf "${RED}Could not udate repository /${project}${NC}, aborting.\n" + } +done + +printf "${BLUE}Initializing Transferring files to BBB${NC}\n" +if [ "{flag}"=true ]; then + for project in "${projects[@]}"; do + { + printf "${GREEN}Transferring /${project}...${NC}\n" + scp -r ${project} debian@192.168.7.2:/home/debian + } || { # catch + # save log for exception + flag=false + printf "${RED}Could not send folder /${project} to the BBB, aborting!${NC}\n" + } + done +fi + +printf "${BLUE}Connecting to the BBB${NC}\n" +{ + ssh -t debian@192.168.7.2 "./LabConnection.jl/util/startup.sh; bash -l" +} || { + printf "${RED}Could Connect to the BBB!${NC}\n" +} diff --git a/util/getfrom_BBB.sh b/util/getfrom_BBB.sh new file mode 100755 index 0000000000000000000000000000000000000000..ed3b59b92d5f2f336899c8062eaa4f8cecdbc70a --- /dev/null +++ b/util/getfrom_BBB.sh @@ -0,0 +1,14 @@ +#!/bin/bash +############################################################################### +# This pice of code attemps to scp files from the BBB to a directory $PWD/temp +# +# The code may be executed from anywhere on the HOST computer. +############################################################################### +{ + if [ ! -d "temp" ]; then + mkdir temp + fi + sudo scp -r debian@192.168.7.2:/home/debian/$1 $PWD/temp +} || { + echo "Could not find or transfer $1, check that the file exists on the BBB" +} diff --git a/util/getfrom_BBB.sh~ b/util/getfrom_BBB.sh~ new file mode 100755 index 0000000000000000000000000000000000000000..00246845492ec516ca249cf0cb3866c0a1da6b0e --- /dev/null +++ b/util/getfrom_BBB.sh~ @@ -0,0 +1,14 @@ +#!/bin/bash +############################################################################### +# This pice of tries to scp files from the BBB to a directory $PWD/temp +# +# The code may be executed from anywhere on the HOST computer. +############################################################################### +{ + if [ ! -d "temp" ]; then + mkdir temp + fi + sudo scp -r debian@192.168.7.2:/home/debian/$1 $PWD/temp +} || { + echo "Could not find or transfer $1, check that the file exists on the BBB" +} diff --git a/util/startup.sh b/util/startup.sh new file mode 100755 index 0000000000000000000000000000000000000000..78a8c75b74c62a7e02de9283fb4bd10d5ba94a0a --- /dev/null +++ b/util/startup.sh @@ -0,0 +1,5 @@ +#!/bin/sh +ls +cd "LabConnection.jl/test/BeagleBone" +sudo /home/debian/julia-903644385b/bin/julia + diff --git a/util/startup.sh~ b/util/startup.sh~ new file mode 100755 index 0000000000000000000000000000000000000000..78a8c75b74c62a7e02de9283fb4bd10d5ba94a0a --- /dev/null +++ b/util/startup.sh~ @@ -0,0 +1,5 @@ +#!/bin/sh +ls +cd "LabConnection.jl/test/BeagleBone" +sudo /home/debian/julia-903644385b/bin/julia +