Skip to content

Commit

Permalink
Merge cc0d23e into 4f33171
Browse files Browse the repository at this point in the history
  • Loading branch information
dotdoom committed Oct 5, 2016
2 parents 4f33171 + cc0d23e commit 5fc52ca
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 14 deletions.
17 changes: 14 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
sudo: required
dist: trusty

language: go

go:
- 1.6
- 1.7
- tip

cache:
Expand All @@ -12,13 +15,15 @@ addons:
apt:
packages:
- libi2c-dev
- gcc-arm-linux-gnueabi
- libc6-dev-armel-cross
# shellcheck is not in Travis' Ubuntu
#- shellcheck

install:
- pip install --user --upgrade platformio
- platformio lib install 19 580 # Adafruit-DHT, EasyVR
- platformio lib update
- platformio lib --global install 19 580 # Adafruit-DHT, EasyVR
- platformio lib --global update

script:
# Raspberry Pi part
Expand All @@ -33,6 +38,12 @@ script:
- platformio ci --board=diecimilaatmega328 mc
# Shell part
- curl https://raw.githubusercontent.com/dasfoo/travis/master/shell.sh | sh -s bin/*
- |
echo "${REMOTE_HOST_KEY?}" >>$HOME/.ssh/known_hosts
eval "$(ssh-agent)"
ssh-add <(tr '|' '\n' <<<"${REMOTE_HOST_LOGIN_KEY?}")
bin/deploy push
before_deploy:
# Generate deploy script
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

# golang cross-compiling with CGo

* https://medium.com/@rakyll/go-1-5-cross-compilation-488092ba44ec
* https://wiki.debian.org/RaspberryPi (from here we learn that Pi is "armel")
* https://wiki.debian.org/CrossToolchains
* https://developer.ubuntu.com/en/snappy/guides/cross-build/
* -https://medium.com/@rakyll/go-1-5-cross-compilation-488092ba44ec
* -https://wiki.debian.org/RaspberryPi (from here we learn that Pi is "armel")
* -https://wiki.debian.org/CrossToolchains

# Raspberry PI (A+ V1.1) preparations

Expand Down Expand Up @@ -48,10 +49,11 @@ https://wiki.ubuntu.com/ReducingDiskFootprint#Documentation)

## packages

`# apt install git pptp-linux socat`
`# apt install git pptp-linux`

## $HOME (/home/pi)

`https://github.com/golang/protobuf`
`$ git clone https://github.com/dasfoo/rover.git`

## systemd
Expand Down
24 changes: 17 additions & 7 deletions bin/deploy
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,30 @@ GOARM=5
ENV
}

ssh_port=$((31416+22))
ssh_user=pi
ssh_host="$ssh_user"@rover.dasfoo.org
ssh_fallback_host="$ssh_user"@fb.rover.dasfoo.org

deploy_ssh() {
[ "$(id -un)" = pi ] || ssh_prefix='sudo -u pi --'
$ssh_prefix ssh pi "$@"
if ! ssh -p "$ssh_port" "$ssh_host" "$@"; then
if [ $? -eq 255 ]; then
ssh -p "$ssh_port" "$ssh_fallback_host" "$@"
else
return $?
fi
fi
}

deploy_copy() {
: "${1?source required}"
[ -n "$2" ] && transform="--transform 's|.*|$2|'"
tar -czpf - -C "$(dirname "$1")" "$(basename "$1")" |
deploy_ssh "tar xzf - -P $transform"
if ! scp -r -P "$ssh_port" "${1?source required}" "$ssh_host":/tmp; then
scp -r -P "$ssh_port" "$1" "$ssh_fallback_host":/tmp
fi
}

deploy_push() {
(
package_path="$(realpath -m "$0/../..")"
package_path="$(readlink -fm "$0/../..")"
cd "$package_path"
# propagade the following environment variables to "go build"
set -a
Expand All @@ -38,6 +47,7 @@ deploy_push() {
cd ..
package="$(basename "$package_path")"
deploy_copy "$package"
exit 1
deploy_ssh "
sudo sh -ec '
ln -sf \$PWD/$package/systemd/rover.service \
Expand Down

0 comments on commit 5fc52ca

Please sign in to comment.