updated script and README
This commit is contained in:
parent
62d358adda
commit
487d631358
@ -40,9 +40,3 @@ binary conveniently.
|
||||
```sh
|
||||
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
99
bld-deploy-q7s.sh
Executable 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
|
@ -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
|
Loading…
Reference in New Issue
Block a user