forked from CircuitHappy/wifi-onboarding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·33 lines (27 loc) · 1017 Bytes
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
GADGET_ADDR="[email protected]"
DEFAULT_KEY="$HOME/.ssh/gadget_default_rsa"
INDIVIDUAL_KEY="$HOME/.ssh/gadget_rsa"
function fatal()
{
msg="${@:-ERROR}"
echo $msg
exit 1
}
function remote()
{
ssh -i "${KEY}" "${GADGET_ADDR}" $@
}
! [[ -e "${DEFAULT_KEY}" ]] && fatal "${DEFAULT_KEY} does not exist."
#find out key
KEY=""
ssh -q -o PasswordAuthentication=no -i "${DEFAULT_KEY}" "${GADGET_ADDR}" ls && KEY="${DEFAULT_KEY}"
ssh -q -o PasswordAuthentication=no -i "${INDIVIDUAL_KEY}" "${GADGET_ADDR}" ls && KEY="${INDIVIDUAL_KEY}"
[[ -z "${KEY}" ]] && fatal "neither ${DEFAULT_KEY} nor ${INDIVIDUAL_KEY} work"
echo "using KEY=${KEY}"
remote "mount -o remount,rw ubi0:rootfs_a" || \
remote "mount -o remount,rw ubi0:rootfs_b"
scp -i "${KEY}" build/linux_arm/wifi-onboarding ${GADGET_ADDR}:/usr/bin/wifi-onboarding
remote "mkdir -p /usr/lib/wifi-onboarding"
scp -i "${KEY}" -r static ${GADGET_ADDR}:/usr/lib/wifi-onboarding/
scp -i "${KEY}" -r view ${GADGET_ADDR}:/usr/lib/wifi-onboarding/