on xenial help sign in
Make sure we have ssh started when we need it
92b7886Albert Astals
run_on_device+11−1
@@ -17,6 +17,7 @@ SUDO="echo $PASSWORD | sudo -S"
17NUM_JOBS='$(( `grep -c ^processor /proc/cpuinfo` + 1 ))'
17NUM_JOBS='$(( `grep -c ^processor /proc/cpuinfo` + 1 ))'
18FLIPPED=false
18FLIPPED=false
19CHROOT_PREFIX="/data/ubuntu"
19CHROOT_PREFIX="/data/ubuntu"
20+SSH_STARTED=0
20
21
21usage() {
22usage() {
22 echo "usage: run_on_device [OPTIONS]\n"
23 echo "usage: run_on_device [OPTIONS]\n"
@@ -32,7 +33,16 @@ usage() {
32 exit 1
33 exit 1
33}
34}
34
35
36+start_ssh() {
37+ if [ $SSH_STARTED -eq 0 ]; then
38+ exec_with_adb service ssh start
39+ SSH_STARTED=1
40+ fi
41+}
42+
35exec_with_ssh() {
43exec_with_ssh() {
44+ start_ssh
45+
36 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -t $USER@$TARGET_IP -p $TARGET_SSH_PORT sudo -u $USER -i bash -ic \"$@\"
46 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -t $USER@$TARGET_IP -p $TARGET_SSH_PORT sudo -u $USER -i bash -ic \"$@\"
37}
47}
38
48
@@ -66,7 +76,6 @@ setup_adb_forwarding() {
66
76
67install_dependencies() {
77install_dependencies() {
68 exec_with_adb rm /etc/init/ssh.override
78 exec_with_adb rm /etc/init/ssh.override
69− exec_with_adb service ssh start
70 exec_with_adb apt-get update
79 exec_with_adb apt-get update
71 exec_with_ssh $SUDO apt-get -y install build-essential rsync bzr ccache gdb ninja-build devscripts equivs
80 exec_with_ssh $SUDO apt-get -y install build-essential rsync bzr ccache gdb ninja-build devscripts equivs
72}
81}
@@ -74,6 +83,7 @@ install_dependencies() {
74sync_code() {
83sync_code() {
75 [ -e .bzr ] && bzr export --uncommitted --format=dir /tmp/$CODE_DIR
84 [ -e .bzr ] && bzr export --uncommitted --format=dir /tmp/$CODE_DIR
76 [ -e .git ] && git checkout-index -a -f --prefix=/tmp/$CODE_DIR/
85 [ -e .git ] && git checkout-index -a -f --prefix=/tmp/$CODE_DIR/
86+ start_ssh
77 rsync -crlOzv --delete --exclude builddir -e "ssh -p $TARGET_SSH_PORT -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" /tmp/$CODE_DIR/ $USER@$TARGET_IP:$CODE_DIR/
87 rsync -crlOzv --delete --exclude builddir -e "ssh -p $TARGET_SSH_PORT -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" /tmp/$CODE_DIR/ $USER@$TARGET_IP:$CODE_DIR/
78 rm -rf /tmp/$CODE_DIR
88 rm -rf /tmp/$CODE_DIR
79}
89}