feat: Add JOZ scripts
This commit is contained in:
11
bin/.expect-btg-login
Executable file
11
bin/.expect-btg-login
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/expect -f
|
||||
eval spawn $argv
|
||||
set timeout -1
|
||||
match_max 100000
|
||||
expect "*?assword:*"
|
||||
puts "\nAutofill password..."
|
||||
send -- "$env(BTG_PASSWORD)\r"
|
||||
sleep 0.3
|
||||
send -- "su\r"
|
||||
send -- "cd /media/ram\r"
|
||||
interact
|
||||
12
bin/.expect-btg-pass
Executable file
12
bin/.expect-btg-pass
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/expect -f
|
||||
eval spawn $argv
|
||||
set timeout -1
|
||||
match_max 100000
|
||||
expect "*?assword:*"
|
||||
puts "\nAutofill password..."
|
||||
send -- "$env(BTG_PASSWORD)\r"
|
||||
expect eof
|
||||
|
||||
set return_code [wait]
|
||||
exit [lindex $return_code 3]
|
||||
|
||||
14
bin/.expect-btg-test-jozagv
Executable file
14
bin/.expect-btg-test-jozagv
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/expect -f
|
||||
eval spawn $argv
|
||||
set timeout -1
|
||||
match_max 100000
|
||||
expect "*?assword:*"
|
||||
puts "\nAutofill password..."
|
||||
send -- "$env(BTG_PASSWORD)\r"
|
||||
sleep 0.3
|
||||
send -- "su\r"
|
||||
send -- "/etc/init.d/crond stop\r"
|
||||
send -- "/etc/init.d/jozagv stop\r"
|
||||
send -- "killall -9 jozagv\r"
|
||||
send -- "/media/ram/jozagv\r"
|
||||
interact
|
||||
1
bin/btg
Executable file
1
bin/btg
Executable file
@@ -0,0 +1 @@
|
||||
~/.local/bin/.expect-btg-login ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no btg@$BTG_IP
|
||||
1
bin/btg-download
Executable file
1
bin/btg-download
Executable file
@@ -0,0 +1 @@
|
||||
btg-scp btg@$BTG_IP:$@ .
|
||||
1
bin/btg-download-database
Executable file
1
bin/btg-download-database
Executable file
@@ -0,0 +1 @@
|
||||
btg-scp btg@$BTG_IP:/usr/share/joz/jozdb.sqlite3 .
|
||||
11
bin/btg-download-full
Executable file
11
bin/btg-download-full
Executable file
@@ -0,0 +1,11 @@
|
||||
out_dir=$(date +'full_%Y_%m_%d__%H_%M_%S')
|
||||
|
||||
mkdir $out_dir
|
||||
cd $out_dir
|
||||
|
||||
# Download logs
|
||||
btg-scp -r btg@$BTG_IP:/joz/agv/logs .
|
||||
|
||||
btg-download-jozagv
|
||||
btg-download-map
|
||||
btg-download-database
|
||||
1
bin/btg-download-jozagv
Executable file
1
bin/btg-download-jozagv
Executable file
@@ -0,0 +1 @@
|
||||
btg-scp btg@$BTG_IP:/joz/agv/jozagv .
|
||||
2
bin/btg-download-logs
Executable file
2
bin/btg-download-logs
Executable file
@@ -0,0 +1,2 @@
|
||||
logs_dir=$(date +'logs_%Y_%m_%d__%H_%M_%S')
|
||||
btg-scp -r btg@$BTG_IP:/joz/agv/logs $logs_dir
|
||||
1
bin/btg-download-map
Executable file
1
bin/btg-download-map
Executable file
@@ -0,0 +1 @@
|
||||
btg-scp btg@$BTG_IP:/etc/joz/*.xml .
|
||||
1
bin/btg-download-ram
Executable file
1
bin/btg-download-ram
Executable file
@@ -0,0 +1 @@
|
||||
btg-download /media/ram/$@ .
|
||||
26
bin/btg-mount-fs
Executable file
26
bin/btg-mount-fs
Executable file
@@ -0,0 +1,26 @@
|
||||
mount_folder=/mnt/btg
|
||||
.enable_sshfs_user_allow_other.sh
|
||||
|
||||
if [[ ! $(sudo echo 0) ]]; then exit; fi
|
||||
|
||||
if mountpoint -q $mount_folder
|
||||
then
|
||||
echo "Mount point $mount_folder is already mounted, to unmount call 'umount $mount_folder'"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
sudo mkdir -p $mount_folder
|
||||
sudo chmod 777 $mount_folder
|
||||
|
||||
#Execute the sshfs command using the expect script
|
||||
sshfs -o allow_other -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o password_stdin btg@$BTG_IP:/ $mount_folder <<< $BTG_PASSWORD
|
||||
|
||||
retval=$?
|
||||
|
||||
# Check if retval is zero
|
||||
if [ $retval -eq 0 ]; then
|
||||
echo "Successfully mounted to $mount_folder"
|
||||
else
|
||||
echo "Error: command failed with return code $retval"
|
||||
exit $retval
|
||||
fi
|
||||
1
bin/btg-ping
Executable file
1
bin/btg-ping
Executable file
@@ -0,0 +1 @@
|
||||
ping $BTG_IP
|
||||
33
bin/btg-scp
Executable file
33
bin/btg-scp
Executable file
@@ -0,0 +1,33 @@
|
||||
#Execute the scp command using the expect script
|
||||
~/.local/bin/.expect-btg-pass scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $@
|
||||
|
||||
#get result
|
||||
retval=$?
|
||||
|
||||
# Define error code messages
|
||||
case $retval in
|
||||
0)
|
||||
echo "Upload/Download Successfull!"
|
||||
;;
|
||||
1)
|
||||
echo "Invalid command line argument"
|
||||
;;
|
||||
2)
|
||||
echo "Conflicting arguments given"
|
||||
;;
|
||||
3)
|
||||
echo "General runtime error"
|
||||
;;
|
||||
4)
|
||||
echo "Unrecognized response from ssh (parse error)"
|
||||
;;
|
||||
5)
|
||||
echo "Invalid/incorrect password"
|
||||
;;
|
||||
6)
|
||||
echo "Host public key is unknown. sshpass exits without confirming the new key."
|
||||
;;
|
||||
*)
|
||||
echo "Unknown error code: $retval"
|
||||
;;
|
||||
esac
|
||||
2
bin/btg-test-jozagv
Executable file
2
bin/btg-test-jozagv
Executable file
@@ -0,0 +1,2 @@
|
||||
btg-upload-jozagv
|
||||
~/bin/.expect-btg-test-jozagv ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no btg@$BTG_IP
|
||||
1
bin/btg-upload-database
Executable file
1
bin/btg-upload-database
Executable file
@@ -0,0 +1 @@
|
||||
btg-scp $@ btg@$BTG_IP:/usr/share/joz/jozdb.sqlite3
|
||||
4
bin/btg-upload-jozagv
Executable file
4
bin/btg-upload-jozagv
Executable file
@@ -0,0 +1,4 @@
|
||||
JOZAGV_PATH=$JOZ_PATH/jozagv/build/JOZ_Robot_Controller_SDK/MinSizeRel/jozagv
|
||||
|
||||
btg-upload-jozagv-configs
|
||||
btg-upload-jozagv-release
|
||||
1
bin/btg-upload-jozagv-configs
Executable file
1
bin/btg-upload-jozagv-configs
Executable file
@@ -0,0 +1 @@
|
||||
btg-scp -r $JOZ_PATH/jozagv/config/* btg@$BTG_IP:/etc/joz
|
||||
5
bin/btg-upload-jozagv-debug
Executable file
5
bin/btg-upload-jozagv-debug
Executable file
@@ -0,0 +1,5 @@
|
||||
JOZAGV_PATH=$JOZ_PATH/jozagv/build/JOZ_Robot_Controller_SDK/Debug/jozagv
|
||||
|
||||
btg-upload-jozagv-configs
|
||||
echo "Upload jozagv with modification date: $(stat -c '%y' $JOZAGV_PATH)"
|
||||
btg-scp-ram $JOZAGV_PATH
|
||||
4
bin/btg-upload-jozagv-release
Executable file
4
bin/btg-upload-jozagv-release
Executable file
@@ -0,0 +1,4 @@
|
||||
JOZAGV_PATH=$JOZ_PATH/jozagv/build/JOZ_Robot_Controller_SDK/MinSizeRel/jozagv
|
||||
|
||||
echo "Upload jozagv with modification date: $(stat -c '%y' $JOZAGV_PATH)"
|
||||
btg-upload-ram $JOZAGV_PATH
|
||||
1
bin/btg-upload-map
Executable file
1
bin/btg-upload-map
Executable file
@@ -0,0 +1 @@
|
||||
btg-scp $@ btg@$BTG_IP:/etc/joz/map.xml
|
||||
1
bin/btg-upload-ram
Executable file
1
bin/btg-upload-ram
Executable file
@@ -0,0 +1 @@
|
||||
btg-scp $@ btg@$BTG_IP:/media/ram
|
||||
3
bin/btg-upload-remote
Executable file
3
bin/btg-upload-remote
Executable file
@@ -0,0 +1,3 @@
|
||||
newest_build_file=$(ls -td $JOZ_PATH/remote/build/joz/*/* | head -1)
|
||||
newest_build_dir=$(dirname ${newest_build_file})
|
||||
btg-scp $newest_build_dir/language.bin $newest_build_dir/version $newest_build_dir/firmware.bin btg@$BTG_IP:/etc/joz/remote/0
|
||||
Reference in New Issue
Block a user