|  | #!/bin/bash | 
|  |  | 
|  | # Builds and uploads a debian package containing the CLI executables | 
|  | # that are used on all the jumphosts | 
|  | # List contains | 
|  | #   - powercycle: remotely powercycles bots and/or devices. | 
|  | #   - censustaker: enumaterates powercycleable bots on network. | 
|  |  | 
|  | # Make sure we have a rack id. | 
|  | print_usage() { | 
|  | echo "Usage: $0 MESSAGE INSTANCE_IDS" | 
|  | echo "     MESSAGE     is the message to be included in the release package." | 
|  | echo "     INSTANCE_IDS are the ids of the instances targeted by this package." | 
|  | exit 1 | 
|  | } | 
|  | if [ "$#" -ne 2 ]; then | 
|  | print_usage | 
|  | fi | 
|  |  | 
|  | set -x -e | 
|  | TARGET_INSTANCE_IDS=$2 | 
|  |  | 
|  | # Strip the second argument to keep this compatible with the shared build script. | 
|  | set -- "$1" | 
|  |  | 
|  | for INSTANCE_ID in $TARGET_INSTANCE_IDS; do | 
|  | APPNAME="trooper-tools-${INSTANCE_ID}" | 
|  | SYSTEMD="powercycle-daemon.service" | 
|  | DESCRIPTION="Various executables that ease the troopers role for jumphost-${INSTANCE_ID} in the skolo." | 
|  |  | 
|  | # Copy files into the right locations in ${ROOT}. | 
|  | copy_release_files() | 
|  | { | 
|  | INSTALL="fakeroot install -D --verbose --backup=none --group=root --owner=root" | 
|  | INSTALL_DIR="fakeroot install -d --verbose --backup=none --group=root --owner=root" | 
|  |  | 
|  | # Install the powercycle binary and config files. | 
|  | ${INSTALL} --mode=755 -T ${GOPATH}/bin/powercycle-cli            ${ROOT}/usr/local/bin/powercycle | 
|  | ${INSTALL} --mode=644 -T ./sys/powercycle-${INSTANCE_ID}.json5   ${ROOT}/etc/powercycle.json5 | 
|  |  | 
|  | # Install the censustaker binary and ansible scripts | 
|  | ${INSTALL} --mode=755 -T ${GOPATH}/bin/censustaker     ${ROOT}/usr/local/bin/censustaker | 
|  | ${INSTALL} --mode=644 -T ./sys/ansible.cfg             ${ROOT}/usr/local/share/trooper_tools/censustaker/ansible.cfg | 
|  | ${INSTALL} --mode=644 -T ./sys/enumerate_hostnames.yml ${ROOT}/usr/local/share/trooper_tools/censustaker/enumerate_hostnames.yml | 
|  | ${INSTALL} --mode=644 -T ./sys/all-hosts               ${ROOT}/usr/local/share/trooper_tools/censustaker/all-hosts | 
|  |  | 
|  | # Install the powercycle daemon | 
|  | ${INSTALL} --mode=755 -T ${GOPATH}/bin/powercycle-daemon ${ROOT}/usr/local/bin/powercycle-daemon | 
|  | ${INSTALL} --mode=644 -T ./sys/powercycle-daemon.service  ${ROOT}/etc/systemd/system/powercycle-daemon.service | 
|  | } | 
|  |  | 
|  | source ../bash/release.sh | 
|  | done |