updated script and README

This commit is contained in:
Robin Müller 2021-08-14 19:10:57 +02:00
parent 62d358adda
commit 487d631358
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
3 changed files with 99 additions and 12 deletions

View File

@ -40,9 +40,3 @@ binary conveniently.
```sh ```sh
sudo apt-get install sshpass sudo apt-get install sshpass
``` ```
5. Specify the ssh password as the `SSHPASS` variable
```sh
export SSHPASS="<sshPassword>"
```

99
bld-deploy-q7s.sh Executable file
View File

@ -0,0 +1,99 @@
#!/bin/bash
scriptname="deploy-q7s.sh"
app_name="q7s-rs-crosscompile"
read -r -d '' cli_help <<EOD
Q7S Rust Deployment Helper
Builds the image and can optionally transfer and run it on the target system
as well.
Usage:
${scriptname} [flags] [options]
Flags:
-p, --release Build production image
-t, --transfer Transfer image to Q7S
-r, --run Run the image
Options:
-f, --sshfile FILE SSH key file. Otherwise, use password from
environmental variable SSHPASS
-e, --sshenv Take password from environmental variable
EOD
arg_transfer=n
arg_help=n
arg_run=n
arg_ssh_env=n
arg_ssh_file=n
arg_release=n
sshkey_file=""
while (( "${#}" )); do
case "${1}" in
-t|--transfer)
arg_transfer=y
shift
;;
-h|--help)
arg_help=y
shift
;;
-r|--run)
arg_run=y
shift
;;
-e|--sshenv)
arg_ssh_env=y
shift
;;
-p|--release)
arg_release=y
shift
;;
-f|--sshfile)
arg_ssh_file=y
if [ "${#}" -ge 2 ]; then
sshkey_file="${2}"
else
echo "Error: Missing argument for ${1}"
exit 1
fi
shift
;;
esac
done
# handle help
if [ ${arg_help} = y ]; then
echo "${cli_help}"
exit 0
fi
cargo_opts=""
build_folder="debug"
if [ ${arg_release} = y ]; then
cargo_opts+="--release"
build_folder="release"
fi
target="armv7-unknown-linux-gnueabihf"
cargo build ${cargo_opts}
if [ ${arg_ssh_file} = y ]; then
sshpass_args="-f ${sshkey_file}"
elif [ ${arg_ssh_env} = y ]; then
sshpass_args="-e"
fi
if [ ${arg_transfer} = y ]; then
app_loc="./target/${target}/${build_folder}/${app_name}"
transfer_cmd="sshpass ${sshpass_args} q7s-cp.py ${app_loc}"
echo "Running transfer command: ${transfer_cmd}"
eval ${transfer_cmd}
if [ ${arg_run} = y ]; then
echo "Running transferred executable.."
sshpass ${sshpass_args} ssh -p 1535 root@localhost "./${app_name}"
fi
fi

View File

@ -1,6 +0,0 @@
#!/bin/bash
target="armv7-unknown-linux-gnueabihf"
cargo build --target ${target}
sshpass -e q7s-cp.py ./target/${target}/debug/q7s-rs-crosscompile