diff --git a/.travis.yml b/.travis.yml index 50f419c1a..fcd4bb764 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ branches: before_install: - sudo apt-get update - - sudo apt-get install -y liblxc1 lxc-dev lxc + - sudo apt-get install -y liblxc1 lxc-dev lxc shellcheck - sudo apt-get install -y qemu - sudo bash ./scripts/travis-rkt.sh - sudo bash ./scripts/travis-consul.sh diff --git a/GNUmakefile b/GNUmakefile index c309d651b..fe567d6db 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -164,6 +164,11 @@ check: ## Lint the source code $(CHECKS) \ ./... +.PHONY: checkscripts +checkscripts: ## Lint shell scripts + @echo "==> Linting scripts..." + @shellcheck ./scripts/* + generate: LOCAL_PACKAGES = $(shell go list ./... | grep -v '/vendor/') generate: ## Update generated code @go generate $(LOCAL_PACKAGES) diff --git a/scripts/deps.sh b/scripts/deps.sh index eff0c42e0..4ab9ad45e 100755 --- a/scripts/deps.sh +++ b/scripts/deps.sh @@ -1,14 +1,14 @@ #!/usr/bin/env bash # First get the OS-specific packages -GOOS=windows go get $DEP_ARGS github.com/StackExchange/wmi -GOOS=windows go get $DEP_ARGS github.com/shirou/w32 -GOOS=linux go get $DEP_ARGS github.com/docker/docker/pkg/mount -GOOS=linux go get $DEP_ARGS github.com/opencontainers/runc/libcontainer/cgroups/fs -GOOS=linux go get $DEP_ARGS github.com/opencontainers/runc/libcontainer/configs -GOOS=linux go get $DEP_ARGS github.com/coreos/go-systemd/util -GOOS=linux go get $DEP_ARGS github.com/coreos/go-systemd/dbus +GOOS=windows go get "${DEP_ARGS}" github.com/StackExchange/wmi +GOOS=windows go get "${DEP_ARGS}" github.com/shirou/w32 +GOOS=linux go get "${DEP_ARGS}" github.com/docker/docker/pkg/mount +GOOS=linux go get "${DEP_ARGS}" github.com/opencontainers/runc/libcontainer/cgroups/fs +GOOS=linux go get "${DEP_ARGS}" github.com/opencontainers/runc/libcontainer/configs +GOOS=linux go get "${DEP_ARGS}" github.com/coreos/go-systemd/util +GOOS=linux go get "${DEP_ARGS}" github.com/coreos/go-systemd/dbus # Get the rest of the deps DEPS=$(go list -f '{{range .TestImports}}{{.}} {{end}}' ./...) -go get $DEP_ARGS ./... $DEPS +go get "${DEP_ARGS}" ./... "${DEPS}" diff --git a/scripts/dist.sh b/scripts/dist.sh index 67e59477d..71340d51e 100755 --- a/scripts/dist.sh +++ b/scripts/dist.sh @@ -3,7 +3,7 @@ set -e # Get the version from the command line VERSION=$1 -if [ -z $VERSION ]; then +if [ -z "${VERSION}" ]; then echo "Please specify a version. (format: 0.4.0-rc1)" exit 1 fi @@ -14,10 +14,10 @@ while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )" # Change into that dir because we expect that -cd $DIR +cd "${DIR}" # Generate the tag. -if [ -z $NOTAG ]; then +if [ -z "${NOTAG}" ]; then echo "==> Tagging..." git commit --allow-empty -a --gpg-sign=348FFC4C -m "Release v$VERSION" git tag -a -m "Version $VERSION" -s -u 348FFC4C "v${VERSION}" master @@ -26,21 +26,19 @@ fi # Zip all the files rm -rf ./pkg/dist mkdir -p ./pkg/dist -for FILENAME in $(find ./pkg -mindepth 1 -maxdepth 1 -type f); do - FILENAME=$(basename $FILENAME) - cp ./pkg/${FILENAME} ./pkg/dist/nomad_${VERSION}_${FILENAME} -done + +find ./pkg -mindepth 1 -maxdepth 1 -type f -exec cp ./pkg/{} ./pkg/dist/nomad_"${VERSION}"_{} \; # Make the checksums pushd ./pkg/dist -shasum -a256 * > ./nomad_${VERSION}_SHA256SUMS -if [ -z $NOSIGN ]; then +shasum -a256 ./* > "./nomad_${VERSION}_SHA256SUMS" +if [ -z "${NOSIGN}" ]; then echo "==> Signing..." - gpg --default-key 348FFC4C --detach-sig ./nomad_${VERSION}_SHA256SUMS + gpg --default-key 348FFC4C --detach-sig "./nomad_${VERSION}_SHA256SUMS" fi popd # Upload -if [ -z $HC_RELEASE ]; then - hc-releases upload $DIR/pkg/dist && hc-releases publish +if [ -z "${HC_RELEASE}" ]; then + hc-releases upload "${DIR}/pkg/dist" && hc-releases publish fi diff --git a/scripts/example_weave.bash b/scripts/example_weave.bash index ba190f73f..de916a6bb 100755 --- a/scripts/example_weave.bash +++ b/scripts/example_weave.bash @@ -1,7 +1,7 @@ #!/bin/bash if [[ "$USER" != "vagrant" ]]; then echo "WARNING: This script is intended to be run from Nomad's Vagrant" - read -rsp $'Press any key to continue anyway...\n' -n1 key + read -rsp $'Press any key to continue anyway...\n' -n1 fi set -e @@ -12,7 +12,7 @@ if [[ ! -a /usr/local/bin/weave ]]; then sudo chmod a+x /usr/local/bin/weave fi weave launch || echo "weave running" -eval $(weave env) +eval "$(weave env)" if curl -s localhost:8500 > /dev/null; then echo "Consul running" diff --git a/scripts/travis.sh b/scripts/travis.sh index bc181faae..1a6a8a5f0 100755 --- a/scripts/travis.sh +++ b/scripts/travis.sh @@ -5,8 +5,10 @@ export PING_SLEEP=60 bash -c "while true; do echo \$(date) - building ...; sleep $PING_SLEEP; done" & PING_LOOP_PID=$! -trap "kill $PING_LOOP_PID" EXIT HUP INT QUIT TERM +trap 'kill ${PING_LOOP_PID}' EXIT HUP INT QUIT TERM +make check +make checkscripts make test TEST_OUTPUT=$? diff --git a/scripts/update_docker.sh b/scripts/update_docker.sh index 6e7a7074d..1f5f7a801 100755 --- a/scripts/update_docker.sh +++ b/scripts/update_docker.sh @@ -6,10 +6,10 @@ DOCKER_VERSION="1.10.3" sudo stop docker sudo rm -rf /var/lib/docker -sudo rm -f `which docker` +sudo rm -f "$(which docker)" sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list sudo apt-get update -sudo apt-get install -y --force-yes -o Dpkg::Options::="--force-confnew" docker-engine=$DOCKER_VERSION-0~`lsb_release -cs` +sudo apt-get install -y --force-yes -o Dpkg::Options::="--force-confnew" docker-engine="$DOCKER_VERSION-0~$(lsb_release -cs)" docker version diff --git a/scripts/vagrant-linux-priv-go.sh b/scripts/vagrant-linux-priv-go.sh index 4a320b40b..e5cb90989 100755 --- a/scripts/vagrant-linux-priv-go.sh +++ b/scripts/vagrant-linux-priv-go.sh @@ -12,7 +12,7 @@ function install_go() { wget -q -O /tmp/go.tar.gz ${download} - tar -C /tmp -xvf /tmp/go.tar.gz + tar -C /tmp -xf /tmp/go.tar.gz sudo mv /tmp/go /usr/local sudo chown -R root:root /usr/local/go }