#!/bin/sh
# Change screen color temperature using the redshift tool.
# Give a temperature delta in $1, e.g. -500.
# If $1 or $2 = r, reset adjustments.
# If $1 or $2 = b, also change brightness. This is done using the backlight script (if backlight is module present), otherwise using redshift.
# If no parameters are given, uses a simple custom algorithm to automatically guess good values.
# Use this in a user's crontab (crontab -e -u user) for example like this:
# 5 * * * * DISPLAY=:0.0 /home/user/.scripts/redshift.sh

cachedir=~/.cache
scriptsdir=$(dirname "$(readlink -f "$0")")
tempfile=$cachedir/redshift_temp
max=6500
min=4000
set_brightness=""
[ "$1" = "b" ] && set_brightness=1
[ "$2" = "b" ] && set_brightness=1

[ ! -d $cachedir ] || [ ! "$(xhost 2>/dev/null)" ] && exit 1

[ ! -e $tempfile ] && echo $max > $tempfile 2>/dev/null
current=$(cat $tempfile)
[ ! "$current" ] && current=$max

if [ "$1" = "r" ] || [ "$2" = "r" ]
then
    [ "$(which notify-send 2>/dev/null)" ] && notify-send -h int:transient:1 "Reset redshift" -t 1000
    redshift -x
    ([ "$1" = "b" ] || [ "$2" = "b" ]) && $scriptsdir/backlight.sh 0.50
    [ -e $tempfile ] && echo $max > $tempfile
    exit 0
fi

if [ "$#" -gt 0 ] && [ "$(echo "$1" | grep "^[-+0-9]*$")" ]
then
    delta=$(echo "$1" | tr -d '+')
    new=$(echo $current + $delta | bc)
    if [ $new -gt $max ]
    then
        new=$max
    elif [ $new -lt $min ]
    then
        new=$min
    fi
    notify_time=300
else
    # Make it so that the brightness drops from 8pm to 2am.
    # Compensate for winter months making the shift earlier.
    month=$(date +%m)
    compensation=0
    [ $month -gt 10 ] && compensation=3
    [ $month -gt 11 ] && compensation=4
    [ $month -lt 3 ] && compensation=3
    [ $month -lt 2 ] && compensation=4
    hourval=$(expr $(date +%H) + $compensation)
    [ $hourval -lt 8 ] && hourval=26
    [ $hourval -gt 26 ] && hourval=26
    hourval=$(expr $hourval - 20)
    [ $hourval -lt 0 ] && hourval=0
    hourval=$(expr 6 - $hourval)
    set_brightness=1
    delta=$(expr $max - $min)
    new=$(echo "scale=2; $min + $hourval / 6 * $delta" | bc | cut -f 1 -d '.')
    notify_time=3000
fi

[ -e $tempfile ] && echo $new > $tempfile
# Don't do anything if new value would be the same as old one.
[ $new -eq $current ] && exit 0

# The -P reset parameter was introduced in redshift 1.12.
version=$(redshift -V | cut -f 2 -d ' ' | tr -d '.')
[ $version -gt 111 ] && resetparam="-P"

b=""
if [ "$set_brightness" ]
then
    brightness=$(echo "scale=2; $new / $max" | bc)
    # Script will succeed if hardware backlight can be used, will fail otherwise.
    # Use a much dimmer value for hardware backlights.
    $scriptsdir/backlight.sh $(echo "scale=2; $brightness * $brightness * $brightness * 0.75" | bc) || b="-b $brightness"
fi

redshift $resetparam -O $new $b 2>&1 > /dev/null
[ "$(which notify-send 2>/dev/null)" ] && notify-send -h int:transient:1 "New redshift value: $new" -t $notify_time


<reponame>AlanConfluent/examples
#!/bin/bash

echo "Sleeping 200 seconds until ksqlDB server starts and topics have data"
sleep 200

# Create KSQL queries
ksql http://ksqldb-server:8088 <<EOF
run script '/tmp/statements.sql';
exit ;
EOF


#!/bin/bash -e

# shellcheck disable=SC1090
source "$(dirname "$0")"/../scripts/resources.sh

if find . -name '*.js' -print0 | xargs -0 jslint --color --node --version=latest; then
    test_passed "$0"
else
    test_failed "$0"
fi


<filename>uai4u.sh<gh_stars>1-10
#! /bin/bash
#  *Ubuntu, the distro for human begins
#  Author: uai4u https://github.com/smashse/uai4u
#  License: GPL v3

#adiciona ao sources o release do *ubuntu utilizado
clear
echo "Qual o release do ubuntu utilizado?"
echo -n "Qual a opcao desejada? "
read release
clear

#cria backup do sources.list
echo "#Criando backup do sources.list"
sudo mv /etc/apt/sources.list /etc/apt/sources.list.backup
sudo rm -rf /etc/apt/sources.list.d/*

#adiciona repositorios ao novo sources.list
echo "#Adicionando repositorios ao novo sources.list"
touch "/etc/apt/sources.list"

echo "#ubuntu" >> "/etc/apt/sources.list"
echo "deb http://br.archive.ubuntu.com/ubuntu $release main restricted universe multiverse" >> "/etc/apt/sources.list"
echo "deb http://br.archive.ubuntu.com/ubuntu $release-updates main restricted universe multiverse" >> "/etc/apt/sources.list"
echo "deb http://br.archive.ubuntu.com/ubuntu $release-backports main restricted universe multiverse" >> "/etc/apt/sources.list"
echo "deb http://br.archive.ubuntu.com/ubuntu $release-proposed main restricted universe multiverse" >> "/etc/apt/sources.list"
echo "#security" >> "/etc/apt/sources.list"
echo "deb http://security.ubuntu.com/ubuntu $release-security main restricted universe multiverse" >> "/etc/apt/sources.list"
echo "#partner" >> "/etc/apt/sources.list"
echo "deb http://archive.canonical.com/ubuntu $release partner" >> "/etc/apt/sources.list"

#executando o upgrade
echo "#Executando o upgrade"
sudo apt-get update --fix-missing
sudo apt-get dist-upgrade -y --force-yes
clear

#instala pacotes para audio e video para ubuntu ou kubuntu
gui() {
echo "Utilizando Ubuntu, Kubuntu ou Xubuntu?"
echo "Digite ubuntu, kubuntu ou xubuntu!"
echo -n "Qual a opcao desejada? "
read gui

case $gui in
   ubuntu) ubuntu ;;
   kubuntu) kubuntu ;;
   xubuntu) xubuntu ;;
   *) clear ; echo "Digite [ubuntu] se usa gnome/unitym [kubuntu] se usa kde ou [xubuntu] se usa xfce!" ; sleep 3 ; clear ; gui ;;
esac

}

ubuntu() {
   echo "#Instalando plugins e codecs de audio e video para sua escolha!"
   sudo apt-get install ubuntu-restricted-extras -y --force-yes
}

kubuntu() {
   echo "#Instalando plugins e codecs de audio e video para sua escolha!"
   echo "#ppa-kubuntu" >> "/etc/apt/sources.list"
   echo "deb http://ppa.launchpad.net/kubuntu-ppa/ppa/ubuntu $release main" >> "/etc/apt/sources.list"
   echo "deb http://ppa.launchpad.net/kubuntu-ppa/backports/ubuntu $release main" >> "/etc/apt/sources.list"
   sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys <KEY>
   sudo apt-get update --fix-missing
   sudo apt-get dist-upgrade -y --force-yes
   sudo apt-get install kubuntu-restricted-extras -y --force-yes
}

xubuntu() {
   echo "#Instalando plugins e codecs de audio e video para sua escolha!"
   sudo apt-get install xubuntu-restricted-extras -y --force-yes
}

gui

clear

#instala suporte a temas
temas() {
echo "Deseja instalar temas?"
echo "Digite sim ou nao!"
echo -n "Qual a opcao desejada? "
read temas

case $temas in
   sim) Sim ;;
   nao) Nao ;;
   *) clear ; echo "Digite [sim] se deseja instalar os temas ou [nao] para finalizar o processo!" ; sleep 3 ; clear ; temas ;;
esac

}

Sim() {
   sudo add-apt-repository ppa:numix/ppa
   sudo add-apt-repository ppa:fossfreedom/budgie-desktop
   sudo add-apt-repository ppa:budgie-remix/ppa
   sudo apt-get update --fix-missing
   sudo apt-get install numix-icon-theme-circle arc-theme -y --force-yes
}

Nao() {
   echo "Temas nao instalados!"
}

temas

clear

#instala suporte ao google-chrome
chrome() {
echo "Deseja suporte ao Google-Chrome?"
echo "Digite sim ou nao!"
echo -n "Qual a opcao desejada? "
read chrome

case $chrome in
   sim) Sim ;;
   nao) Nao ;;
   *) clear ; echo "Digite [sim] se deseja instalar o google-chrome ou [nao] para finalizar o processo!" ; sleep 3 ; clear ; chrome ;;
esac

}

Sim() {
   echo "#google-chrome" >> "/etc/apt/sources.list"
   echo "deb http://dl.google.com/linux/chrome/deb stable main" >> "/etc/apt/sources.list"
   sudo wget -q https://dl-ssl.google.com/linux/linux_signing_key.pub -O- | sudo apt-key add -
   sudo apt-get update --fix-missing
   sudo apt-get install google-chrome-stable -y --force-yes
}

Nao() {
   echo "Google-Chrome nao instalado!"
}

chrome

clear

echo "Obrigado por utilizar o uai4u!"
sleep 3
clear

exit


<gh_stars>0
#!/bin/bash
export MIX_ENV=test
mix deps.get
mix travis_test || { echo 'Tests failed!' ; exit 1; }
if [[ "$TRAVIS_BRANCH" == "staging" ]]; then
  SILENT=true make release
fi


<reponame>UB-Dortmund/metafacture-core
#!/usr/bin/env bash
#
# Copyright 2017, 2018 <NAME>
#
# Licensed under the Apache License, Version 2.0 the "License";
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#
# When building branches Travis does not check out the branch but a specific
# commit. This results in the working copy being in "detached HEAD" state.
# This breaks the logic for deriving version numbers from branch names in the
# build script.
#
# This script checks if the current build corresponds to the tip of a branch.
# If it does then the branch is checked out.
#

function main {
    require_not_building_pull_request
    require_not_triggered_by_tag
    require_on_tip_of_branch
    checkout_branch
}

function require_not_building_pull_request {
    if [ -v TRAVIS_PULL_REQUEST -a "$TRAVIS_PULL_REQUEST" != "false" ]; then
        echo "Building pull request. Will not replace detached head with branch"
        exit 0
    fi
}

#
# In builds triggered by a tag Travis sets the variable TRAVIS_BRANCH to the
# tag name instead of the branch name. It is not possible (and not necessary)
# to check out the branch in this case.
#
function require_not_triggered_by_tag {
    if [ -v TRAVIS_TAG -a "$TRAVIS_TAG" != "" ] ; then
        echo "Build was triggered by a tag. Will not replace detached head with branch"
        exit 0
    fi
}

function require_on_tip_of_branch {
    if [ $TRAVIS_COMMIT != $( git rev-parse --verify $TRAVIS_BRANCH ) ] ; then
        echo "Detached head does not match tip of current branch. Staying on detached head."
        exit 0
    fi
}

function checkout_branch {
    echo "Detached head matches tip of current branch. Replacing detached head with branch"
    git checkout $TRAVIS_BRANCH
}

main


<filename>scripts/entrypoint.sh
#!/bin/sh
set -e

root="/vault/config"
mkdir -p $root

f="$root/go_signal"

echo "Waiting for signal file at $f"

while [ ! -e $f ]
do
    sleep 2
done

echo "Go signal detected. Running vault"
vault server -config /vault/config/vault.conf


<reponame>kazuhira-r/infinispan-getting-started
#!/bin/bash

cd `dirname $0`

CONTAINERS=`cat servers`

for C in $CONTAINERS
do
    docker exec $C bash -c 'bin/add-user.sh -u test -p testpassword'
done


#!/bin/bash

./pants binary src/main/python/api/src:api


<filename>cs/sample/init.sh
#!/bin/bash
[[ -z "$1" ]] && { echo "Project name is empty" ; exit 1; }
name=$1
echo mkdir -p Sample/"${name^}"/
mkdir -p Sample/"${name^}"/
echo touch Sample/"${name^}"/"${name^}".cs
touch Sample/"${name^}"/"${name^}".cs

echo mkdir -p Sample.Tests/"${name^}"/
mkdir -p Sample.Tests/"${name^}"/
echo touch Sample.Tests/"${name^}"/test"${name^}".cs
touch Sample.Tests/"${name^}"/test"${name^}".cs

./write.sh $name


<gh_stars>0
#!/usr/bin/env bats

load "$BATS_TEST_DIRNAME/global.bash"

# Export note function in test to make it available to external scripts.
# export -f note

sourcedir="$(dirname $BATS_TEST_DIRNAME)"
testfile="$sourcedir/tools"

##############################################################################
# Tests for debug

#-----------------------------------------------------------------------------
@test 'no debug prints nothing' {
  source "$testfile"
  run debug 'nada-debug'
  assert_success
  assert_output ''
}

#-----------------------------------------------------------------------------
@test 'debug prints something' {
  source "$testfile"
  export DEBUG=1
  msg=$(random_string)
  expected_output="[il][test_functions.bash:run:038] $msg"
  run debug "$msg"
  assert_success
  assert_output "$expected_output"
}

#-----------------------------------------------------------------------------
@test 'debug nothing returns something' {
  export DEBUG=1
  printf -v expected_output '%s ' '[il][test-tools-debug:018]'
  run "$BATS_TEST_DIRNAME/bin/test-tools-debug" "$sourcedir"
  assert_success
  assert_output "$expected_output"
}

#-----------------------------------------------------------------------------
@test 'debug something returns same thing' {
  export DEBUG=1
  msg=$(random_string)
  printf -v expected_output '%s %s' '[il][test-tools-debug:018]' "$msg"
  run "$BATS_TEST_DIRNAME/bin/test-tools-debug" "$sourcedir" "$msg"
  assert_success
  assert_output "$expected_output"
}

#-----------------------------------------------------------------------------
@test 'multiline debug prints' {
  export DEBUG=1
  printf -v msg '%s\n%s' "$(random_string)" "$(random_string)"
  printf -v expected_output '%s %s' '[il][test-tools-debug:018]' "$msg"
  run "$BATS_TEST_DIRNAME/bin/test-tools-debug" "$sourcedir" "$msg"
  assert_success
  assert_output "$expected_output"
}

#-----------------------------------------------------------------------------
@test 'multi parameters debug prints' {
  export DEBUG=1

  msg1="$(random_string)"
  msg2="$(random_string)"
  msg3="$(random_string)"

  printf -v msg '%s\n' "$msg1" "$msg2"
  msg+="$msg3"

  run "$BATS_TEST_DIRNAME/bin/test-tools-debug" "$sourcedir" "$msg"
  assert_output "$msg>>>"
}


#!/usr/bin/env bash
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
echo $DIR

curl -F "file=@$DIR/avatar.jpg" http://localhost:8081/api/upload/file


<filename>test/kitchen/site-cookbooks/dd-agent-install-script/files/dogstatsd_install_script.sh
#!/bin/bash
# (C) Datadog, Inc. 2010-2016
# All rights reserved
# Licensed under Simplified BSD License (see LICENSE)
# Datadog Dogstatsd installation script: install and set up Dogstatsd on supported Linux distributions
# using the package manager and Datadog repositories.

set -e
install_script_version=1.0.0
logfile="ddagent-install.log"

ETCDIR="/etc/datadog-dogstatsd"
CONF="$ETCDIR/dogstatsd.yaml"

# Set up a named pipe for logging
npipe=/tmp/$$.tmp
mknod $npipe p

# Log all output to a log for error checking
tee <$npipe $logfile &
exec 1>&-
exec 1>$npipe 2>&1
trap 'rm -f $npipe' EXIT

function on_error() {
    printf "\033[31m$ERROR_MESSAGE
It looks like you hit an issue when trying to install Dogstatsd.

If you're still having problems, please send an email to <EMAIL>
with the contents of ddagent-install.log and we'll do our very best to help you
solve your problem.\n\033[0m\n"
}
trap on_error ERR

hostname=
if [ -n "$DD_HOSTNAME" ]; then
    hostname=$DD_HOSTNAME
fi

site=
if [ -n "$DD_SITE" ]; then
    site="$DD_SITE"
fi

apikey=
if [ -n "$DD_API_KEY" ]; then
    apikey=$DD_API_KEY
fi

no_start=
if [ -n "$DD_INSTALL_ONLY" ]; then
    no_start=true
fi

host_tags=
# comma-separated list of tags
if [ -n "$DD_HOST_TAGS" ]; then
    host_tags=$DD_HOST_TAGS
fi

if [ -n "$REPO_URL" ]; then
    repository_url=$REPO_URL
else
    repository_url="datadoghq.com"
fi

if [ -n "$TESTING_YUM_URL" ]; then
  yum_url=$TESTING_YUM_URL
else
  yum_url="yum.${repository_url}"
fi

if [ -n "$TESTING_APT_URL" ]; then
  apt_url=$TESTING_APT_URL
else
  apt_url="apt.${repository_url}"
fi

upgrade=
if [ -n "$DD_UPGRADE" ]; then
  upgrade=$DD_UPGRADE
fi

agent_major_version=7
# if [ -n "$DD_AGENT_MAJOR_VERSION" ]; then
#   if [ "$DD_AGENT_MAJOR_VERSION" != "6" ] && [ "$DD_AGENT_MAJOR_VERSION" != "7" ]; then
#     echo "DD_AGENT_MAJOR_VERSION must be either 6 or 7. Current value: $DD_AGENT_MAJOR_VERSION"
#     exit 1;
#   fi
#   agent_major_version=$DD_AGENT_MAJOR_VERSION
# else
#   echo -e "\033[33mWarning: DD_AGENT_MAJOR_VERSION not set. Installing Agent version 6 by default.\033[0m"
# fi

agent_flavor="datadog-dogstatsd"
# if [ -n "$DD_AGENT_FLAVOR" ]; then
#     agent_flavor=$DD_AGENT_FLAVOR
# fi

agent_dist_channel=stable
if [ -n "$DD_AGENT_DIST_CHANNEL" ]; then
  if [ "$DD_AGENT_DIST_CHANNEL" != "stable" ] && [ "$DD_AGENT_DIST_CHANNEL" != "beta" ]; then
    echo "DD_AGENT_DIST_CHANNEL must be either 'stable' or 'beta'. Current value: $DD_AGENT_DIST_CHANNEL"
    exit 1;
  fi
  agent_dist_channel=$DD_AGENT_DIST_CHANNEL
fi

if [ -n "$TESTING_YUM_VERSION_PATH" ]; then
  yum_version_path=$TESTING_YUM_VERSION_PATH
else
  yum_version_path="${agent_dist_channel}/${agent_major_version}"
fi

if [ -n "$TESTING_APT_REPO_VERSION" ]; then
  apt_repo_version=$TESTING_APT_REPO_VERSION
else
  apt_repo_version="${agent_dist_channel} ${agent_major_version}"
fi

keyserver="hkp://keyserver.ubuntu.com:80"
# use this env var to specify another key server, such as
# hkp://p80.pool.sks-keyservers.net:80 for example.
if [ -n "$DD_KEYSERVER" ]; then
  keyserver="$DD_KEYSERVER"
fi

if [ ! "$apikey" ]; then
  # if it's an upgrade, then we will use the transition script
  if [ ! "$upgrade" ]; then
    printf "\033[31mAPI key not available in DD_API_KEY environment variable.\033[0m\n"
    exit 1;
  fi
fi

# OS/Distro Detection
# Try lsb_release, fallback with /etc/issue then uname command
KNOWN_DISTRIBUTION="(Debian|Ubuntu|RedHat|CentOS|openSUSE|Amazon|Arista|SUSE)"
DISTRIBUTION=$(lsb_release -d 2>/dev/null | grep -Eo $KNOWN_DISTRIBUTION  || grep -Eo $KNOWN_DISTRIBUTION /etc/issue 2>/dev/null || grep -Eo $KNOWN_DISTRIBUTION /etc/Eos-release 2>/dev/null || grep -m1 -Eo $KNOWN_DISTRIBUTION /etc/os-release 2>/dev/null || uname -s)

if [ "$DISTRIBUTION" = "Darwin" ]; then
    printf "\033[31mThis script does not support installing on the Mac.

Please use the 1-step script available at https://app.datadoghq.com/account/settings#agent/mac.\033[0m\n"
    exit 1;

elif [ -f /etc/debian_version ] || [ "$DISTRIBUTION" == "Debian" ] || [ "$DISTRIBUTION" == "Ubuntu" ]; then
    OS="Debian"
elif [ -f /etc/redhat-release ] || [ "$DISTRIBUTION" == "RedHat" ] || [ "$DISTRIBUTION" == "CentOS" ] || [ "$DISTRIBUTION" == "Amazon" ]; then
    OS="RedHat"
# Some newer distros like Amazon may not have a redhat-release file
elif [ -f /etc/system-release ] || [ "$DISTRIBUTION" == "Amazon" ]; then
    OS="RedHat"
# Arista is based off of Fedora14/18 but do not have /etc/redhat-release
elif [ -f /etc/Eos-release ] || [ "$DISTRIBUTION" == "Arista" ]; then
    OS="RedHat"
# openSUSE and SUSE use /etc/SuSE-release or /etc/os-release
elif [ -f /etc/SuSE-release ] || [ "$DISTRIBUTION" == "SUSE" ] || [ "$DISTRIBUTION" == "openSUSE" ]; then
    OS="SUSE"
fi

# Root user detection
if [ "$(echo "$UID")" = "0" ]; then
    sudo_cmd=''
else
    sudo_cmd='sudo'
fi

# Install the necessary package sources
if [ "$OS" = "RedHat" ]; then
    echo -e "\033[34m\n* Installing YUM sources for Datadog\n\033[0m"

    UNAME_M=$(uname -m)
    if [ "$UNAME_M" == "i686" ] || [ "$UNAME_M" == "i386" ] || [ "$UNAME_M" == "x86" ]; then
      printf "\033[31mThe Datadog Dogstatsd installer is only available for x86_64 CentOS-based machines.\033[0m\n"
    elif [ "$UNAME_M" == "aarch64" ]; then
      printf "\033[31mThe Datadog Dogstatsd installer is only available for x86_64 CentOS-based machines.\033[0m\n"
    else
        ARCHI="x86_64"
    fi

    gpgkeys="https://${yum_url}/DATADOG_RPM_KEY.public"

    $sudo_cmd sh -c "echo -e '[datadog]\nname = Datadog, Inc.\nbaseurl = https://${yum_url}/${yum_version_path}/${ARCHI}/\nenabled=1\ngpgcheck=1\nrepo_gpgcheck=0\npriority=1\ngpgkey=${gpgkeys}' > /etc/yum.repos.d/datadog.repo"

    printf "\033[34m* Installing the Datadog Dogstatsd package\n\033[0m\n"
    $sudo_cmd yum -y clean metadata

    dnf_flag=""
    if [ -f "/etc/fedora-release" ] && [ -f "/usr/bin/dnf" ]; then
      # On Fedora, yum is an alias of dnf, dnf install doesn't
      # upgrade a package if a newer version is available, unless
      # the --best flag is set
      dnf_flag="--best"
    fi

    $sudo_cmd yum -y --disablerepo='*' --enablerepo='datadog' install $dnf_flag "$agent_flavor" || $sudo_cmd yum -y install $dnf_flag "$agent_flavor"

elif [ "$OS" = "Debian" ]; then

    printf "\033[34m\n* Installing apt-transport-https\n\033[0m\n"
    $sudo_cmd apt-get update || printf "\033[31m'apt-get update' failed, the script will not install the latest version of apt-transport-https.\033[0m\n"
    $sudo_cmd apt-get install -y apt-transport-https
    # Only install dirmngr if it's available in the cache
    # it may not be available on Ubuntu <= 14.04 but it's not required there
    cache_output=`apt-cache search dirmngr`
    if [ ! -z "$cache_output" ]; then
      $sudo_cmd apt-get install -y dirmngr
    fi
    printf "\033[34m\n* Installing APT package sources for Datadog\n\033[0m\n"
    $sudo_cmd sh -c "echo 'deb https://${apt_url}/ ${apt_repo_version}' > /etc/apt/sources.list.d/datadog.list"
    $sudo_cmd apt-key adv --recv-keys --keyserver "${keyserver}" A2923DFF56EDA6E76E55E492D3A80E30382E94DE

    printf "\033[34m\n* Installing the Datadog Agent package\n\033[0m\n"
    ERROR_MESSAGE="ERROR
Failed to update the sources after adding the Datadog repository.
This may be due to any of the configured APT sources failing -
see the logs above to determine the cause.
If the failing repository is Datadog, please contact Datadog support.
*****
"
    $sudo_cmd apt-get update -o Dir::Etc::sourcelist="sources.list.d/datadog.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
    ERROR_MESSAGE="ERROR
Failed to install the Datadog package, sometimes it may be
due to another APT source failing. See the logs above to
determine the cause.
If the cause is unclear, please contact Datadog support.
*****
"
    $sudo_cmd apt-get install -y --force-yes "$agent_flavor"
    ERROR_MESSAGE=""
elif [ "$OS" = "SUSE" ]; then
  UNAME_M=$(uname -m)
  if [ "$UNAME_M"  == "i686" ] || [ "$UNAME_M"  == "i386" ] || [ "$UNAME_M"  == "x86" ]; then
      printf "\033[31mThe Datadog Agent installer is only available for x86_64 SUSE Enterprise machines.\033[0m\n"
      exit;
  elif [ "$UNAME_M"  == "aarch64" ]; then
      printf "\033[31mThe Datadog Agent installer is only available for x86_64 SUSE Enterprise machines.\033[0m\n"
  else
      ARCHI="x86_64"
  fi

  # Try to guess if we're installing on SUSE 11, as it needs a different flow to work
  if cat /etc/SuSE-release 2>/dev/null | grep VERSION | grep 11; then
    SUSE11="yes"
  fi

  echo -e "\033[34m\n* Importing the Datadog GPG Keys\n\033[0m"
  if [ "$SUSE11" == "yes" ]; then
    # SUSE 11 special case
    $sudo_cmd curl -o /tmp/DATADOG_RPM_KEY.public "https://${yum_url}/DATADOG_RPM_KEY.public"
    $sudo_cmd rpm --import /tmp/DATADOG_RPM_KEY.public
  else
    $sudo_cmd rpm --import "https://${yum_url}/DATADOG_RPM_KEY.public"
  fi

  gpgkeys="https://${yum_url}/DATADOG_RPM_KEY.public"

  echo -e "\033[34m\n* Installing YUM Repository for Datadog\n\033[0m"
  $sudo_cmd sh -c "echo -e '[datadog]\nname=datadog\nenabled=1\nbaseurl=https://${yum_url}/suse/${yum_version_path}/${ARCHI}\ntype=rpm-md\ngpgcheck=1\nrepo_gpgcheck=0\ngpgkey=${gpgkeys}' > /etc/zypp/repos.d/datadog.repo"

  echo -e "\033[34m\n* Refreshing repositories\n\033[0m"
  $sudo_cmd zypper --non-interactive --no-gpg-checks refresh datadog

  echo -e "\033[34m\n* Installing Datadog Agent\n\033[0m"
  $sudo_cmd zypper --non-interactive install "$agent_flavor"

else
    printf "\033[31mYour OS or distribution are not supported by this install script.
Please follow the instructions on the Agent setup page:

    https://app.datadoghq.com/account/settings#agent\033[0m\n"
    exit;
fi

# Set the configuration
if [ -e $CONF ] && [ -z "$upgrade" ]; then
  printf "\033[34m\n* Keeping old datadog.yaml configuration file\n\033[0m\n"
else
  if [ ! -e $CONF ]; then
    $sudo_cmd cp $CONF.example $CONF
  fi
  if [ "$apikey" ]; then
    printf "\033[34m\n* Adding your API key to the Agent configuration: $CONF\n\033[0m\n"
    $sudo_cmd sh -c "sed -i 's/api_key:.*/api_key: $apikey/' $CONF"
  fi
  if [ "$site" ]; then
    printf "\033[34m\n* Setting SITE in the Agent configuration: $CONF\n\033[0m\n"
    $sudo_cmd sh -c "sed -i 's/# site:.*/site: $site/' $CONF"
  fi
  if [ -n "$DD_URL" ]; then
    printf "\033[34m\n* Setting DD_URL in the Agent configuration: $CONF\n\033[0m\n"
    $sudo_cmd sh -c "sed -i 's|# dd_url:.*|dd_url: $DD_URL|' $CONF"
  fi
  if [ "$hostname" ]; then
    printf "\033[34m\n* Adding your HOSTNAME to the Agent configuration: $CONF\n\033[0m\n"
    $sudo_cmd sh -c "sed -i 's/# hostname:.*/hostname: $hostname/' $CONF"
  fi
  if [ "$host_tags" ]; then
      printf "\033[34m\n* Adding your HOST TAGS to the Agent configuration: $CONF\n\033[0m\n"
      formatted_host_tags="['""$( echo "$host_tags" | sed "s/,/','/g" )""']"  # format `env:prod,foo:bar` to yaml-compliant `['env:prod','foo:bar']`
      $sudo_cmd sh -c "sed -i \"s/# tags:.*/tags: ""$formatted_host_tags""/\" $CONF"
  fi
  $sudo_cmd chown dd-agent:dd-agent $CONF
  $sudo_cmd chmod 640 $CONF
fi

# Creating or overriding the install information
install_info_content="---
install_method:
  tool: install_script
  tool_version: install_script
  installer_version: install_script-$install_script_version
"
$sudo_cmd sh -c "echo '$install_info_content' > $ETCDIR/install_info"

# On SUSE 11, sudo service datadog-agent start fails (because /sbin is not in a base user's path)
# However, sudo /sbin/service datadog-agent does work.
# Use which (from root user) to find the absolute path to service

service_cmd="service"
if [ "$SUSE11" == "yes" ]; then
  service_cmd=`$sudo_cmd which service`
fi

# Use /usr/sbin/service by default.
# Some distros usually include compatibility scripts with Upstart or Systemd. Check with: `command -v service | xargs grep -E "(upstart|systemd)"`
restart_cmd="$sudo_cmd $service_cmd datadog-dogstatsd restart"
stop_instructions="$sudo_cmd $service_cmd datadog-dogstatsd stop"
start_instructions="$sudo_cmd $service_cmd datadog-dogstatsd start"

if command -v systemctl 2>&1; then
  # Use systemd if systemctl binary exists
  restart_cmd="$sudo_cmd systemctl restart datadog-dogstatsd.service"
  stop_instructions="$sudo_cmd systemctl stop datadog-dogstatsd"
  start_instructions="$sudo_cmd systemctl start datadog-dogstatsd"
elif /sbin/init --version 2>&1 | grep -q upstart; then
  # Try to detect Upstart, this works most of the times but still a best effort
  restart_cmd="$sudo_cmd stop datadog-dogstatsd || true ; sleep 2s ; $sudo_cmd start datadog-dogstatsd"
  stop_instructions="$sudo_cmd stop datadog-dogstatsd"
  start_instructions="$sudo_cmd start datadog-dogstatsd"
fi

if [ $no_start ]; then
    printf "\033[34m
* DD_INSTALL_ONLY environment variable set: the newly installed version of the agent
will not be started. You will have to do it manually using the following
command:

    $start_instructions

\033[0m\n"
    exit
fi

printf "\033[34m* Starting the Agent...\n\033[0m\n"
eval "$restart_cmd"

# Metrics are submitted, echo some instructions and exit
printf "\033[32m

Your Agent is running and functioning properly. It will continue to run in the
background and submit metrics to Datadog.

If you ever want to stop the Agent, run:

    $stop_instructions

And to run it again run:

    $start_instructions

\033[0m"


<gh_stars>100-1000
#!/usr/bin/env bash
set -o errexit

# cd into current directory
cd $( dirname "$0" )

# App root directory is one level upper
APP=$(dirname "$( pwd -P )")

# sourcing variable from config file
source $APP/init_config.file

RED='\033[0;31m'
NC='\033[0m' # No Color
GREEN='\033[0;32m'

PWD=$(pwd -P)
YARN_GLOBAL_DIR=$(yarn global dir)

# If current folder is localed inside yarn global folder, means it is installed globally
if [[ $PWD == $YARN_GLOBAL_DIR* ]]; then

    # yarn added globally, dependencies are installed as siblings directory
    DEPENDENCIES_ROOT="$(dirname "$(dirname "$( pwd -P )")")/$DEPENDENCIES_SCOPE_NAME"
else

    # yarn installed locally, dependencies are installed under current's project directory
    DEPENDENCIES_ROOT="$(dirname "$( pwd -P )")/node_modules/$DEPENDENCIES_SCOPE_NAME"
fi

EOSDOCKER="$DEPENDENCIES_ROOT/docker-eosio-nodeos"
SHIPDOCKER="$DEPENDENCIES_ROOT/docker-ship"
LOCALSERVICE="$DEPENDENCIES_ROOT/api-eosio-compiler"
COMPILER="$LOCALSERVICE/docker-eosio-cdt"
ISDEV=false
MAKESAMPLEDATA=false
SET_MODE=false
NODEOS=false
nodeos_value_passed=$NODE_DEFAULT_ENDPOINT
nodeos_endpoint=$NODE_DEFAULT_ENDPOINT
domain_name="localhost"

USAGE="Usage: eosio-explorer init [-s | --sample-data] [--server-mode]
                           [-dev | --develop] [-b | --build] (program to initialize eosio-explorer)
                           [--set-mode=<1/2/3>] [--nodeos_endpoint=<endpoint>]

where:
    -s, --sample-data   Starts the tool with pre-existing sample accounts and smart contracts
    --server-mode       Starts the tool in server-mode, it will start the docker containers but not the gui
    --set-mode          Set mode can take the value 1, 2 or 3(e.g.: --set-mode=1),
                        1- Connect to default Nodeos instance provided by the tool
                        2- Connect to the endpoint passed using 'nodeos_endpoint=<endpoint>' argument
                        3- Connect to the endpoint mentioned in config file (location: $HOME/eosio_explorer_config.json)
    --nodeos-endpoint   Starts the tool by connecting to the Nodeos instance endpoint(RPC endpoint) passed, this argument is valid only when --set-mode=2

    Only available in development:
    -dev, --develop     Starts the tool in development mode
    -b, --build         Build gui"

write_to_log()
{
  echo $1 >> $APP/logger.txt
}

echo "" > $APP/logger.txt
write_to_log "Arguments passed to init:"
# check for arguments
for arg in $@
do
  write_to_log "$arg"
  case $arg in
    -dev|--develop)
      ISDEV=true
      ;;
    -s|--sample-data)
      MAKESAMPLEDATA=true
      ;;
    --server-mode)
      echo "Running the tool in server mode"
      ;;
    -b|--build)
      echo "Running the tool with building gui"
      ;;
    --set-mode=*)
      SET_MODE=true
      option="${arg#*=}"
      ;;
    --nodeos-endpoint=*|nodeos-endpoint=*)
      NODEOS=true
      nodeos_value_passed="${arg#*=}"
      ;;
    -h|--help)
      echo " "
      echo "$USAGE"
      echo " "
      exit
      ;;
    *)
      printf "Unknown option: %s\n" "$arg" >&2
      echo " "
      echo "$USAGE" >&2
      exit 1
      ;;
  esac
done

printf ${GREEN}"\n"
printf "=========================\n"
printf "Welcome to EOSIO Explorer\n"
printf "=========================\n"
printf "\n"${NC}

# If set-mode is false then provide the options to select the endpoints
if ( ! $SET_MODE ); then
  echo "Please type 1, 2 or 3, to start the tool and connect to your required endpoint, which are as follows: "
  echo ""
  echo "1. Default Nodeos instance provided by the tool"
  echo "2. A pre-existing Nodeos instance"
  echo "3. The Nodeos instance endpoint detailed in the config file (location: $HOME/eosio_explorer_config.json)"

  read option

  write_to_log "Manual selected mode: $option"

  echo " "
  if [ $option == 1 ]
  then
    echo "Starting tool with default instance..."
  elif [ $option == 2 ]
  then
    echo "Please enter Nodeos instance endpoint:"
    read nodeos_endpoint
  elif [ $option == 3 ]
  then
    echo "Reading the endpoint from $HOME/eosio_explorer_config.json"
    nodeos_endpoint=$(cat $HOME/eosio_explorer_config.json | sed -n 's|.*"NodeEndpoint":"\([^"]*\)".*|\1|p')
    write_to_log "nodeos_endpoint entered: $nodeos_endpoint"
  else
    echo "Invalid option, starting tool with default instance... "
  fi
else
  # If set-mode is true then read the endpoint from arguments

  if [ $option == 1 ]
  then
    echo "Starting tool with default instance..."
  elif [ $option == 2 ]; then
    if ( ! $NODEOS ); then
      echo "You have passed the mode as 2 but not provided the Nodeos instance endpoint."
      echo "please run the command again with endpoint or pass the mode as 1 to run with the default instance"
      echo "To know more about options, run 'eosio-explorer init -h'"
      echo " "
      exit 1
    else
      nodeos_endpoint=$nodeos_value_passed
    fi
  elif [ $option == 3 ]; then
    echo "Reading the endpoint from $HOME/eosio_explorer_config.json"
    nodeos_endpoint=$(cat $HOME/eosio_explorer_config.json | sed -n 's|.*"NodeEndpoint":"\([^"]*\)".*|\1|p')
  else
    echo "Invalid mode, accepted values for --set-mode argument is 1, 2 or 3."
    echo "Please run the command again with the valid mode or run 'eosio-explorer init' without --set-mode to select the mode manually"
    echo "To know more about options, run 'eosio-explorer init -h'"
    echo " "
    exit 1
  fi
fi

#remove '/' at the end if any
nodeos_endpoint=${nodeos_endpoint%/};

echo " "
echo "Connecting to $nodeos_endpoint"

write_to_log "Connecting to $nodeos_endpoint"

if [ $option == 2 ] || [ $option == 3 ] || [ $option == 4 ];
then
  echo " "
  echo "========================"
  echo "VALIDATING NODE ENDPOINT"
  echo "========================"
  blockchain_info=`curl --max-time 15 $nodeos_endpoint/v1/chain/get_info -k -s -f -o /dev/null && echo "SUCCESS" || echo "ERROR"`
  echo $blockchain_info

  if [ $blockchain_info != "ERROR" ];
  then
    echo " "
    echo "========================"
    echo "CHECKING THE EOS VERSION"
    echo "========================"
    # extract version from the get_info output
    version=$(curl -s $nodeos_endpoint/v1/chain/get_info | sed -n 's|.*"server_version_string":"\([^"]*\)".*|\1|p')
    echo "version $version"
    write_to_log "eos version: $version"
    version=${version:1:5}

    # Check the extracted version if it's a number
    re='^[0-9.]+$'
    if ! [[ $version =~ $re ]] ; then
      echo " "
      printf "${RED}The EOS version of the node you are trying to connect to is not compatible with the tool, \nplease run the command again with the node endpoint running on EOS version 1.8.1 above \n ${NC}"
      echo " "
      exit 1
    else
      if [[ "$version" > 1.8.0 ]];
      then
        echo "Compatible with tool"
        write_to_log "valid endpoint"
      else
        echo " "
        printf "${RED}The EOS version of the node you are trying to connect to is not compatible with the tool, \nplease run the command again with the node endpoint running on EOS version 1.8.1 above \n ${NC}"
        echo " "
        exit 1
      fi
    fi
    #  remove this
    # exit 1
  else
    if [ $nodeos_endpoint == $NODE_DEFAULT_ENDPOINT ];
    then
      echo " "
      echo "The docker will start the Nodeos instance"
    else
      echo " "
      printf "${RED}Invalid node endpoint, please run the command again with a valid endpoint \n ${NC}"
      echo " "
      write_to_log "Invalid endpoint"
      exit 1
    fi
  fi
fi

echo " "
echo "==============================="
echo "INITIALISING CONFIG IN PACKAGES"
echo "==============================="

# copy init config into different packages
cp -f $APP/init_config.file $EOSDOCKER/config.file.local
cp -f $APP/init_config.file $EOSDOCKER/scripts/config.file.local
cp -f $APP/init_config.file $COMPILER/config.file.local
cp -f $APP/init_config.file $SHIPDOCKER/config.file.local
cp -f $APP/init_config.file $APP/config.file.local

# extract domain name from the URL for fill-pg
domain_name=$(echo $nodeos_endpoint | cut -d'/' -f3 | cut -d':' -f1)

echo "NODE_ENDPOINT_DOMAIN_NAME=$domain_name" >> $SHIPDOCKER/config.file.local

# print init config and save it as .env.local into different packages

rm -f $APP/.env.local
echo "REACT_APP_LOCAL_SERVICE_PORT=$LOCAL_SERVICE_PORT" >> $APP/.env.local
echo "REACT_APP_APP_SERVE_PORT=$APP_SERVE_PORT" >> $APP/.env.local
echo "REACT_APP_POSTGRES_DB_PORT=$POSTGRES_PORT" >> $APP/.env.local

echo "LOCAL_SERVICE_PORT=$LOCAL_SERVICE_PORT" > $LOCALSERVICE/.env.local

echo "Copying initial config done."
echo " "
write_to_log "Copied configuration to all dependencies"

# DO NOT yarn install if the app is installed globally to avoid node modules collision
if [[ !($PWD == $YARN_GLOBAL_DIR*) ]]; then
  echo "======================="
  echo "INSTALLING DEPENDENCIES"
  echo "======================="
  write_to_log "Running yarn install"
  yarn install
fi

echo " "
echo "====================="
echo "BUILDING EOSIO DOCKER"
echo "====================="
write_to_log "Build eosio docker"
(cd $EOSDOCKER && ./build_eosio_docker.sh && printf "${GREEN}done${NC}")

echo " "
echo "=================================================="
echo "BUILDING EOSIO_CDT DOCKER USED BY COMPILER SERVICE"
echo "=================================================="
write_to_log "Build eosio-cdt docker"
(cd $COMPILER && ./build_eosio_cdt_docker.sh && printf "${GREEN}done${NC}")

echo " "
echo "============================"
echo "PULLING FILL-PG DOCKER IMAGE"
echo "============================"
write_to_log "Pulling fill-pg docker image"
(cd $SHIPDOCKER && ./build_ship_docker.sh && printf "${GREEN}done${NC}")

# remove existing dockers
write_to_log "Clean up existing docker containers"
./remove_dockers.sh

if [ $option != 3 ];
then
  #Create a config file in home directory
  echo " "
  echo "========================================"
  echo "Creating config files to store endpoints"
  echo "========================================"

  (cd $HOME && echo '{"NodeEndpoint":"'$nodeos_endpoint'"}'>eosio_explorer_config.json && printf "${GREEN}done${NC}")

  write_to_log "Created config file in $HOME directory"
  echo " "
  echo "Path:" $HOME/eosio_explorer_config.json
  echo '{"NodeEndpoint":"'$nodeos_endpoint'"}'
  echo " "
fi

#Inserting the entered endpoint from the user to a config file to connect to from front-end
if $ISDEV; then
  write_to_log "Development mode"
  (cd $APP/public && echo 'window._env_={"NODE_PATH": "'$nodeos_endpoint'"}'>env-config.js)
  write_to_log "Write nodeos endpoint to front-end config file in public folder"
else
  write_to_log "Production mode"
  if [ -e $APP"/build" ]
  then
    (cd $APP/build && echo 'window._env_={"NODE_PATH": "'$nodeos_endpoint'"}'>env-config.js)
    write_to_log "Write nodeos endpoint to front-end config file in build folder"
  else
    write_to_log "build folder doesn't exists"
  fi
fi

# start the dockers and gui

./start.sh $@ --clear-browser-storage

P1=$!

# wait $P1
wait $P1


#!/usr/bin/env bash

set -e

# Pull PostgreSQL manually (Git submodules doesn’t work for some reason)
if [[ ! -d postgresql ]]; then
    git clone git://git.postgresql.org/git/postgresql.git
fi

cd postgresql
git checkout tags/REL_11_2

# PostgreSQL build prerequisites
sudo yum install -y bison-devel readline-devel zlib-devel openssl-devel wget
sudo yum groupinstall -y 'Development Tools'

# Build PostgreSQL
./configure
make
make check

# Return to root directory
cd ..

# Build layer
mkdir -p moo-postgresql-layer/lib

# Copy lib files from postgres to lib directory
cp postgresql/tmp_install/usr/local/pgsql/lib/libpq.so* moo-postgresql-layer/lib
cp vendor/moo-postgresql moo-postgresql-layer

# Zip the layer
cd moo-postgresql-layer
zip -r aws-lambda-layer-moo-postgresql.zip *

# Move to project root
cd ..
mv moo-postgresql-layer/aws-lambda-layer-moo-postgresql.zip .
rm -r moo-postgresql-layer

echo 'Done.'
echo 'You may now download `aws-lambda-layer-moo-postgresql.zip`, e.g. using `scp`'


#!/bin/bash

sudo apt-get install -y python3-pip
sudo apt-get install -y python3-pyqt5
pip3 install --upgrade pip
pip3 install numpy
sudo apt-get install -y git


<gh_stars>0
browserify lib/jquery.min.js lib/underscore-min.js src/inject.js -o js/inject.js


#!/usr/bin/env bash

./node_modules/.bin/electron ./dist/lib/electronApp/appMain.js $1 $2 $3 $4 $5 $6 $7 $8 $9


<gh_stars>1-10
#!/bin/bash
# install_tool.sh script for VNNCOMP21 for oval

TOOL_NAME=oval
VERSION_STRING=v1

# check arguments
if [ "$1" != ${VERSION_STRING} ]; then
	echo "Expected first argument (version string) '$VERSION_STRING', got '$1'"
	exit 1
fi

echo "Installing $TOOL_NAME"
DIR=$(dirname $(dirname $(realpath $0)))

eval "$(conda shell.bash hook)" &&  # Allow for conda activate within bash script
conda create -y -n oval python=3.6 &&
conda activate oval &&
conda install -y pytorch torchvision cudatoolkit -c pytorch &&
pip install "$DIR" &&
conda deactivate


#!/bin/bash -e

[ -z "$DEBUG" ] || set -x

main() {
  minify_css
  minify_js
  prepare_output
}

minify_css() {
  echo "Minifying CSS files"
  [ -z "$DIRECTORY_CSS" ] || find "web-application/$DIRECTORY_CSS" -name "*.css" -exec yui-compressor {} -v --type css --output={} \;
}

minify_js() {
  echo "Minifying JS files"
  [ -z "$DIRECTORY_JS" ] || find "web-application/$DIRECTORY_JS" -name "*.js" -exec yui-compressor {} -v --type js --output={} \;
}

prepare_output() {
  cp -r web-application/. web-application-min
}

main


<gh_stars>10-100
#!/bin/bash

if [[ "$#" -lt 4 ]] || [[ "$#" -gt 5 ]]; then
    printf "Usage: bash start_node_incremental_gcp.sh [dev|staging|spring|summer] <Shard Index> <Node Index> [fast|full] [--keystore]\n"
    printf "Example: bash start_node_incremental_gcp.sh spring 0 0 fast --keystore\n"
    exit
fi

# 1. Configure env vars (GENESIS_CONFIGS_DIR, TRACKER_WS_ADDR, ...)
printf "\n#### [Step 1] Configure env vars ####\n\n"

export GENESIS_CONFIGS_DIR=genesis-configs/testnet
KEYSTORE_DIR=testnet_dev_staging_keys
if [[ "$1" = 'spring' ]]; then
    export TRACKER_WS_ADDR=ws://172.16.58.3:5000
    KEYSTORE_DIR=testnet_prod_keys
elif [[ "$1" = 'summer' ]]; then
    export TRACKER_WS_ADDR=ws://172.16.58.3:5000
    KEYSTORE_DIR=testnet_prod_keys
elif [[ "$1" = 'staging' ]]; then
    export TRACKER_WS_ADDR=ws://172.16.58.3:5000
elif [[ "$1" = 'dev' ]]; then
    if [[ "$2" = 0 ]]; then
        export TRACKER_WS_ADDR=ws://192.168.127.12:5000  # dev-tracker-ip
    elif [[ "$2" = 1 ]]; then
        export TRACKER_WS_ADDR=ws://172.16.31.10:5000  # dev-shard-1-tracker-ip
    elif [[ "$2" = 2 ]]; then
        export TRACKER_WS_ADDR=ws://172.16.58.3:5000  # dev-shard-2-tracker-ip
    elif [[ "$2" = 3 ]]; then
        export TRACKER_WS_ADDR=ws://3192.168.3.11:5000  # dev-shard-3-tracker-ip
    elif [[ "$2" = 4 ]]; then
        export TRACKER_WS_ADDR=ws://172.16.31.10:5000  # dev-shard-4-tracker-ip
    elif [[ "$2" = 5 ]]; then
        export TRACKER_WS_ADDR=ws://172.16.58.3:5000  # dev-shard-5-tracker-ip
    elif [[ "$2" = 6 ]]; then
        export TRACKER_WS_ADDR=ws://172.16.31.10:5000  # dev-shard-6-tracker-ip
    elif [[ "$2" = 7 ]]; then
        export TRACKER_WS_ADDR=ws://172.16.17.32:5000  # dev-shard-7-tracker-ip
    elif [[ "$2" = 8 ]]; then
        export TRACKER_WS_ADDR=ws://172.16.58.3:5000  # dev-shard-8-tracker-ip
    elif [[ "$2" = 9 ]]; then
        export TRACKER_WS_ADDR=ws://172.16.17.32:5000  # dev-shard-9-tracker-ip
    elif [[ "$2" = 10 ]]; then
        export TRACKER_WS_ADDR=ws://192.168.3.11:5000  # dev-shard-10-tracker-ip
    elif [[ "$2" = 11 ]]; then
        export TRACKER_WS_ADDR=ws://172.16.58.3:5000  # dev-shard-11-tracker-ip
    elif [[ "$2" = 12 ]]; then
        export TRACKER_WS_ADDR=ws://172.16.17.32:5000  # dev-shard-12-tracker-ip
    elif [[ "$2" = 13 ]]; then
        export TRACKER_WS_ADDR=ws://192.168.3.11:5000  # dev-shard-13-tracker-ip
    elif [[ "$2" = 14 ]]; then
        export TRACKER_WS_ADDR=ws://192.168.127.12:5000  # dev-shard-14-tracker-ip
    elif [[ "$2" = 15 ]]; then
        export TRACKER_WS_ADDR=ws://172.16.17.32:5000  # dev-shard-15-tracker-ip
    elif [[ "$2" = 16 ]]; then
        export TRACKER_WS_ADDR=ws://192.168.127.12:5000  # dev-shard-16-tracker-ip
    elif [[ "$2" = 17 ]]; then
        export TRACKER_WS_ADDR=ws://192.168.3.11:5000  # dev-shard-17-tracker-ip
    elif [[ "$2" = 18 ]]; then
        export TRACKER_WS_ADDR=ws://172.16.31.10:5000  # dev-shard-18-tracker-ip
    elif [[ "$2" = 19 ]]; then
        export TRACKER_WS_ADDR=ws://192.168.127.12:5000  # dev-shard-19-tracker-ip
    elif [[ "$2" = 20 ]]; then
        export TRACKER_WS_ADDR=ws://192.168.3.11:5000  # dev-shard-20-tracker-ip
    else
        printf "Invalid <Shard Index> argument: $2\n"
        exit
    fi
    if [[ "$2" -gt 0 ]]; then
        # Create a genesis_params.json
        export GENESIS_CONFIGS_DIR="genesis-configs/shard_$2"
        mkdir -p "./$GENESIS_CONFIGS_DIR"
        node > "./$GENESIS_CONFIGS_DIR/genesis_params.json" <<EOF
        const data = require('./genesis-configs/testnet/genesis_params.json');
        data.blockchain.TRACKER_WS_ADDR = '$TRACKER_WS_ADDR';
        data.consensus.MIN_NUM_VALIDATORS = 3;
        console.log(JSON.stringify(data, null, 2));
EOF
    fi
else
    printf "Invalid <Project/Season> argument: $1\n"
    exit
fi

printf "TRACKER_WS_ADDR=$TRACKER_WS_ADDR\n"
printf "GENESIS_CONFIGS_DIR=$GENESIS_CONFIGS_DIR\n"
printf "KEYSTORE_DIR=$KEYSTORE_DIR\n"

if [[ "$3" -lt 0 ]] || [[ "$3" -gt 4 ]]; then
    printf "Invalid <Node Index> argument: $3\n"
    exit
fi

if [[ "$4" != 'fast' ]] && [[ "$4" != 'full' ]]; then
    printf "Invalid <Sync Mode> argument: $2\n"
    exit
fi

export SYNC_MODE="$4"
printf "SYNC_MODE=$SYNC_MODE\n"
KEYSTORE_OPTION=$5
printf "KEYSTORE_OPTION=$KEYSTORE_OPTION\n"

export DEBUG=false
export CONSOLE_LOG=false
export ENABLE_DEV_SET_CLIENT_API=false
export ENABLE_TX_SIG_VERIF_WORKAROUND=false
export ENABLE_GAS_FEE_WORKAROUND=true
export LIGHTWEIGHT=false
export STAKE=100000
export BLOCKCHAIN_DATA_DIR="/home/ain_blockchain_data"

date=$(date '+%Y-%m-%dT%H-%M')
printf "date=$date\n"
NEW_DIR_PATH="../ain-blockchain-$date"
printf "NEW_DIR_PATH=$NEW_DIR_PATH\n"

# 2. Get currently used directory
printf "\n#### [Step 2] Get currently used directory ####\n\n"

OLD_DIR_PATH=$(find ../ain-blockchain* -maxdepth 0 -type d)
printf "OLD_DIR_PATH=$OLD_DIR_PATH\n"

# 3. Create a new directory
printf "\n#### [Step 3] Create a new directory ####\n\n"

MKDIR_CMD="sudo mkdir $NEW_DIR_PATH"
printf "MKDIR_CMD=$MKDIR_CMD\n"
eval $MKDIR_CMD

sudo chmod -R 777 $NEW_DIR_PATH
mv * $NEW_DIR_PATH
sudo mkdir -p $BLOCKCHAIN_DATA_DIR
sudo chmod -R 777 $BLOCKCHAIN_DATA_DIR

# 4. Install dependencies
printf "\n#### [Step 4] Install dependencies ####\n\n"

cd $NEW_DIR_PATH
npm install

# 5. Kill old node server
printf "\n#### [Step 5] Kill old node server ####\n\n"

KILL_CMD="sudo killall node"
printf "KILL_CMD='$KILL_CMD'\n\n"
eval $KILL_CMD
sleep 10

# 6. Remove old directory keeping the chain data
printf "\n#### [Step 6] Remove old directory keeping the chain data ####\n\n"

RM_CMD="sudo rm -rf $OLD_DIR_PATH"
printf "RM_CMD='$RM_CMD'\n"
eval $RM_CMD

# 7. Start a new node server
printf "\n#### [Step 7] Start new node server ####\n\n"

# NOTE(liayoo): Currently this script supports --keystore option only for the parent chain.
if [[ "$KEYSTORE_OPTION" != '--keystore' ]] || [[ "$2" -gt 0 ]]; then
    export ACCOUNT_INDEX="$3"
    printf "ACCOUNT_INDEX=$ACCOUNT_INDEX\n"
    COMMAND_PREFIX=""
else
    if [[ "$3" = 0 ]]; then
        KEYSTORE_FILENAME="keystore_node_0.json"
    elif [[ "$3" = 1 ]]; then
        KEYSTORE_FILENAME="keystore_node_1.json"
    elif [[ "$3" = 2 ]]; then
        KEYSTORE_FILENAME="keystore_node_2.json"
    elif [[ "$3" = 3 ]]; then
        KEYSTORE_FILENAME="keystore_node_3.json"
    else
        KEYSTORE_FILENAME="keystore_node_4.json"
    fi
    printf "KEYSTORE_FILENAME=$KEYSTORE_FILENAME\n"
    sudo mkdir -p $BLOCKCHAIN_DATA_DIR/keys/8080
    sudo mv $NEW_DIR_PATH/$KEYSTORE_DIR/$KEYSTORE_FILENAME $BLOCKCHAIN_DATA_DIR/keys/8080/
    export KEYSTORE_FILE_PATH=$BLOCKCHAIN_DATA_DIR/keys/8080/$KEYSTORE_FILENAME
    echo "KEYSTORE_FILE_PATH=$KEYSTORE_FILE_PATH"
fi

MAX_OLD_SPACE_SIZE_MB=5500

# NOTE(liayoo): This is a temporary setting. Remove once domain is set up for afan metaverse related services.
export CORS_WHITELIST=*
printf "CORS_WHITELIST=$CORS_WHITELIST\n"

START_CMD="nohup node --async-stack-traces --max-old-space-size=$MAX_OLD_SPACE_SIZE_MB client/index.js >/dev/null 2>error_logs.txt &"
printf "START_CMD='$START_CMD'\n"
eval $START_CMD

printf "\n* << Node server successfully deployed! ***************************************\n\n"


<gh_stars>1-10
DB_PORT=3310
DB_NAME=db1
DB_USER=root
DB_HOST=localhost
CLIENT_NUM=5
QUERY_NUM=`echo $CLIENT_NUM*1000|bc`
ITERATIONS=2
time mysqlslap -u$DB_USER -h$DB_HOST -P $DB_PORT --protocol=tcp --create-schema=$DB_NAME -p --concurrency=$CLIENT_NUM --number-of-queries=$QUERY_NUM -i $ITERATIONS  --engine=innodb  -q input.sql


<reponame>HXZhong1997/detectron2<gh_stars>0
python tools/lazyconfig_train_net.py --config-file configs/COCO-Detection/fcos_R_50_FPN_1x.py --num-gpus 2


<filename>Aquire/install_phytoMorph_toolKits.sh
#!/bin/bash

if [ $# -eq 0 ]
	then
		echo "Install Menu."
		echo "Please select one."
		echo "[1] phytoPhoto tool kit."
		echo "[2] phytoStreams tool kit."
		echo "[3] iCommands."
		echo "[4] Matlab MCR 2017b."
		echo "[5] sqlite database."
		echo "[6] gphoto2."
		echo "[7] Condor File Transfer."
		echo "[8] Install Condor Key."
		echo "[9] plantProfiler"
		echo "[10] JARs for Java"
		echo "[11] phytoMeta"
		echo "[12] dcraw"
		echo "[13] phytoDAQ"

		read selection

		case $selection in
			1)
				installProgram="phytoPhoto"
			;;
			2)
				installProgram="phytoStreams"
			;;
			3)
				installProgram="icommands"
			;;
			4)
				installProgram="matlabMCR2017b"
			;;
			5)
				installProgram="sqlite3"
			;;
			6)
				installProgram="gphoto2"
			;;
			7)
				installProgram="condorFileTransfer"
			;;
			8)
				installProgram="copyToken"
			;;
			9)
				installProgram="plantProfiler"
			;;
			10)
				installProgram='JARs'
			;;
			11)
				installProgram='phytoMeta'
			;;
			12)
				installProgram='dcraw'
			;;
			13)
				installProgram='phytoDAQ'
			;;

		esac
else
	installProgram=$1
fi

# make install location
mkdir -p $HOME/phytoMorphTK/

# is registered and first time run?
echo '0'> $HOME/phytoMorphTK/reg.txt
echo '0'> $HOME/phytoMorphTK/freg.txt

# make location for objects
PHYTO_OBJECTS=$HOME'/phytoMorphTK/objects/'
mkdir -p $PHYTO_OBJECTS
mkdir $PHYTO_OBJECTS'/.recycle/'
export "PHYTO_OBJECTS="$PHYTO_OBJECTS
echo "export PHYTO_OBJECTS="$PHYTO_OBJECTS"     #phytomorph - phytomorph objects" >> ~/.bashrc

# make base install directory
mkdir -p ~/phytoMorphTK/baseInstall

# make variable for phytomorph software reg key
PHYTO_REG=$HOME'/phytoMorphTK/baseInstall/reg.msg'

# make variable for phytomorph dictionary
PHYTO_DICT=$HOME'/phytoMorphTK/baseInstall/pmd.json'
mkdir -p $PHYTO_DICT
export "PHYTO_DICT="$PHYTO_DICT
echo "export PHYTO_DICT="$PHYTO_DICT"     #phytomorph - phytmorph dictionary" >> ~/.bashrc

# make temp location
PHYTO_TMP=$HOME"/phytoMorphTK/tmpFiles"
mkdir -p $PHYTO_TMP
export "PHYTO_TMP="$PHYTO_TMP
echo "export PHYTO_TMP="$PHYTO_TMP"     #phytomorph - tmpLocation" >> ~/.bashrc

# make files folder
PHYTO_FILES=$HOME"/phytoMorphTK/files"
mkdir -p $PHYTO_FILES
export "PHYTO_FILES="$PHYTO_FILES
echo "export PHYTO_FILES="$PHYTO_FILES"     #phytomorph - tmpLocation" >> ~/.bashrc

# set the image store base
PHYTO_IMAGE_BASE=$HOME"/imageStore/"
mkdir -p $PHYTO_IMAGE_BASE
echo "export PHYTO_IMAGE_BASE="$PHYTO_IMAGE_BASE"     #phytomorph - image_base" >> ~/.bashrc
export "PHYTO_IMAGE_BASE="$PHYTO_IMAGE_BASE

# set the signature base
PHYTO_SIGNATURE_BASE=$HOME"/imageStore/.signatures/"
mkdir -p $PHYTO_SIGNATURE_BASE
echo "export PHYTO_SIGNATURE_BASE="$PHYTO_SIGNATURE_BASE"     #phytomorph - signature_base" >> ~/.bashrc
export "PHYTO_SIGNATURE_BASE="$PHYTO_SIGNATURE_BASE

# export the current path for this install
PATH='~/phytoMorphTK/:'$PATH
export "PATH="$PATH

# copy the install script into the install base
cp install_phytoMorph_toolKits.sh ~/phytoMorphTK/

# install main script
wget -O ~/phytoMorphTK/phytomorph https://de.cyverse.org/dl/d/20E09C21-361E-4F95-8457-50C864A5CFC7/phytomorph

# run update and autoremove
sudo apt-get -q autoremove
sudo apt-get -q update

case $installProgram in
	phytoPhoto)
		echo "***************************************************************************"
		echo "*			Start Installing phytoPhoto				*"
		echo "***************************************************************************"
		./install_phytoMorph_toolKits.sh gphoto2
		# make the directory for phytoStreams
		mkdir -p ~/phytoMorphTK/phytoPhoto/
		# make the directory for the install file
		mkdir -p ~/phytoMorphTK/installFiles/
		# make the directory for the databases(s)
		mkdir -p ~/phytoMorphTK/dataBaseFiles/
		# get the current zip containing the phytoStreams toolkit
		wget -c -O ~/phytoMorphTK/installFiles/phytoPhoto.zip https://de.cyverse.org/dl/d/5CB594AD-DC65-4E73-A36F-B7FBB76AFBED/phytoPhoto.zip
		# unzip the phytoStreams toolkit
		unzip -o ~/phytoMorphTK/installFiles/phytoPhoto.zip -d ~/phytoMorphTK/phytoPhoto/
		# export the current path for this install
		export PATH=~/phytoMorphTK/phytoPhoto/:$PATH
		# export future shells to include the phytoStreams toolkit
		echo 'export PATH=~/phytoMorphTK/phytoPhoto/:$PATH        #phytomorph' >> ~/.bashrc
		configurePhoto
		#########################
		# call to import ENV vars
		OLDIFS=$IFS
		IFS=$'\n'
		for line in $(cat ~/phytoMorphTK/tmpFiles/envVar)
		do
			eval $line
			export $line
			var=$(echo -n $line | cut -d= -f1)
			value=$(echo -n $line | cut -d= -f2)
			echo '---------------------'
			echo 'export var:'$var
			echo 'export value:'$value
			echo 'line:'$line
			echo '---------------------'
		done
		IFS=$OLDIFS
		#########################
		# call create streams
		echo "PRE-source:"$PHYTOPORTS_DB_FILE
		. ~/.bashrc
		echo "POST-source:"$PHYTOPORTS_DB_FILE
		createPortsDB
		echo "***************************************************************************"
		echo "*			End Installing phytoPhoto				*"
		echo "***************************************************************************"
		;;
	phytoStreams)
		echo "***************************************************************************"
		echo "*			Start Installing phytoStreams				*"
		echo "***************************************************************************"
		./install_phytoMorph_toolKits.sh sqlite3
		# make the directory for phytoStreams
		mkdir -p ~/phytoMorphTK/phytoStreams/
		# make the directory for the install file
		mkdir -p ~/phytoMorphTK/installFiles/
		# make the directory for the databases(s)
		mkdir -p ~/phytoMorphTK/dataBaseFiles/
		# get the current zip containing the phytoStreams toolkit
		wget -c -O ~/phytoMorphTK/installFiles/phytoStreams.zip https://de.cyverse.org/dl/d/129CBA87-46C6-4D67-90C7-CC7331CEF0BF/phytoStreams.zip
		# unzip the phytoStreams toolkit
		unzip -o ~/phytoMorphTK/installFiles/phytoStreams.zip -d ~/phytoMorphTK/phytoStreams/
		# export the current path for this install
		export "PATH=~/phytoMorphTK/phytoStreams/:"$PATH
		# export future shells to include the phytoStreams toolkit
		echo 'export PATH=~/phytoMorphTK/phytoStreams/:$PATH    #phytomorph' >> ~/.bashrc
		configureStreams
		#########################
		# call to import ENV vars
		OLDIFS=$IFS
		IFS=$'\n'
		for line in $(cat ~/phytoMorphTK/tmpFiles/envVar)
		do
			eval $line
			export $line
			var=$(echo -n $line | cut -d= -f1)
			value=$(echo -n $line | cut -d= -f2)
			echo '---------------------'
			echo 'export var:'$var
			echo 'export value:'$value
			echo '---------------------'
			export $var
		done
		IFS=$OLDIFS
		#########################
		# call create streams
		createStreamsDB
		echo "***************************************************************************"
		echo "*			End Installing phytoStreams				*"
		echo "***************************************************************************"
		;;
	icommands)
		echo "***************************************************************************"
		echo "*			Start Installing icommands				*"
		echo "***************************************************************************"
		# download the icommands DEB package
		wget -O ~/irods_install.deb https://files.renci.org/pub/irods/releases/4.1.10/ubuntu14/irods-icommands-4.1.10-ubuntu14-x86_64.deb
		# run the install
		sudo apt-get -y  -q install ~/irods_install.deb
		echo "***************************************************************************"
		echo "*			End Installing icommands				*"
		echo "***************************************************************************"
		;;
	matlabMCR2017b)
		echo "***************************************************************************"
		echo "*			Start Installing Matlab MCR 2017b			*"
		echo "***************************************************************************"
		# make the folder for the MCR 2017b
		mkdir -p ~/phytoMorphTK/installFiles/matlabMCR2017b/
		# download MCR from matlab
		wget ~/phytoMorphTK/installFiles/matlabMCR2017b.zip https://www.mathworks.com/supportfiles/downloads/R2017b/deployment_files/R2017b/installers/glnxa64/MCR_R2017b_glnxa64_installer.zip
		# unzip the zip file
		unzip -q MCR_R2017b_glnxa64_installer.zip -d ~/phytoMorphTK/installFiles/matlabMCR2017b/
		# run the installer
 		sudo ~/phytoMorphTK/installFiles/matlabMCR2017b/install -agreeToLicense yes -mode silent
		# remove the unzipped
		rm -r -f ~/phytoMorphTK/installFiles/matlabMCR2017b/
		# move files
		sudo mv /usr/local/MATLAB/MATLAB_Runtime/v93/bin/glnxa64/libcrypto.so.1.0.0 /usr/local/MATLAB/MATLAB_Runtime/v93/bin/glnxa64/libcrypto.so.1.0.0_BK
		sudo mv /usr/local/MATLAB/MATLAB_Runtime/v93//bin/glnxa64/libssl.so.1.0.0 /usr/local/MATLAB/MATLAB_Runtime/v93//bin/glnxa64/libssl.so.1.0.0_BK
		echo "***************************************************************************"
		echo "*			End Installing Matlab MCR 2017b			*"
		echo "***************************************************************************"
		;;
	sqlite3)
		echo "***************************************************************************"
		echo "*			Start Installing sqlite					*"
		echo "***************************************************************************"
		sudo apt-get -f -y -q install sqlite3
		echo "***************************************************************************"
		echo "*			End Installing sqlite					*"
		echo "***************************************************************************"
		;;
	gphoto2)
		echo "***************************************************************************"
		echo "*			Start Installing gphoto					*"
		echo "***************************************************************************"
		sudo apt-get -f -y -q install gphoto2
		echo "***************************************************************************"
		echo "*			End Installing gphoto					*"
		echo "***************************************************************************"
		;;
	condorFileTransfer)
		echo "***************************************************************************"
		echo "*			Start Installing Condor File Transfer			*"
		echo "***************************************************************************"
		export UBUNTU_CODENAME=$(grep UBUNTU_CODENAME /etc/os-release | cut -d'=' -f2)
		# grab a key file - signed by condor team
		wget https://research.cs.wisc.edu/htcondor/ubuntu/HTCondor-Release.gpg.key
		# add get to apt
		sudo apt-key add HTCondor-Release.gpg.key
		#  place condor repo into the computer repo
		sudo sh -c "echo deb http://research.cs.wisc.edu/htcondor/ubuntu/8.9/$UBUNTU_CODENAME $UBUNTU_CODENAME contrib >> /etc/apt/sources.list"
		sudo sh -c "echo deb-src http://research.cs.wisc.edu/htcondor/ubuntu/8.9/$UBUNTU_CODENAME $UBUNTU_CODENAME contrib >> /etc/apt/sources.list"
		# install condor and depend
		sudo apt-get -y -q install libglobus-gss-assist3 htcondor
		# get config files
		wget https://de.cyverse.org/dl/d/FA7254D5-2EAA-4A11-914A-5538C5CD5977/htcondor_file_transfer_config.zip
		sudo unzip htcondor_file_transfer_config.zip -d /etc/condor/config.d/
		sudo mkdir /etc/condor/{tokens.d,passwords.d}

		###########################################################################
		###########################################################################
		#sep="_"
		#echo "Please enter your institution."
		#read institution
		#institution="${institution// /}"
		#echo "Please enter the lab's principal investigator."
		#read pi
		#pi="${pi// /}"
		#echo "Please enter the building name."
		#read buildingName
		#buildingName="${buildingName// /}"
		#echo "Please enter the room number."
		#read roomNumber
		#roomNumber="${roomNumber// /}"
		#RANDOM_ID=$(printf "%05d" $RANDOM)
		#uniqueID=$institution$sep$pi$sep$buildingName$sep$roomNumber$sep$RANDOM_ID
		#sed -i "s/uwtest0001/$uniqueID/" /etc/condor/config.d/20-Name
		#sed -i "s/TEST/$RANDOM_ID/" /etc/condor/config.d/40-CCB
		#echo "Please email <NAME> at <EMAIL> for an authentication token."
		#echo "Please include the unique computer name in the email."
		#echo "Unique computer name:" $uniqueID
		###########################################################################
		###########################################################################

		# enable the condor service
		sudo systemctl enable condor.service
		echo "***************************************************************************"
		echo "*			End Installing Condor File Transfer                     *"
		echo "***************************************************************************"
		;;
	copyToken)
		echo "***************************************************************************"
		echo "*			Start Copy-Token Condor File Transfer                   *"
		echo "***************************************************************************"
		sudo cp ~/Downloads/STARTD_*.key /etc/condor/tokens.d/
		sudo systemctl restart condor.service
		echo "***************************************************************************"
		echo "*			End Copy-Token Condor File Transfer                     *"
		echo "***************************************************************************"
		;;
	plantProfiler)
		echo "***************************************************************************"
		echo "*			Start Install Plant Profiler                            *"
		echo "***************************************************************************"
		# install JARs
		./install_phytoMorph_toolKits.sh JARs3
		# install dcraw
		./install_phytoMorph_toolKits.sh dcraw3
		# install sqlite
		./install_phytoMorph_toolKits.sh sqlite3
		# install the photo tool kit
		./install_phytoMorph_toolKits.sh phytoPhoto
		# install the data stream tool kit
		./install_phytoMorph_toolKits.sh phytoStreams
		# install the icommands
		./install_phytoMorph_toolKits.sh icommands
		# install MCR
		./install_phytoMorph_toolKits.sh matlabMCR2017b
		mkdir -p ~/phytoMorphTK/plantProfiler/
		wget -O ~/phytoMorphTK/plantProfiler/plantProfiler https://de.cyverse.org/dl/d/28B9AEBE-2730-40DA-97D7-7820E707CCCB/plantProfiler
		wget -O ~/phytoMorphTK/plantProfiler/run_plantProfiler https://de.cyverse.org/dl/d/25C38603-11C2-4CA6-9926-64F878E53220/run_plantProfiler.sh
		chmod +x ~/phytoMorphTK/plantProfiler/run_plantProfiler
		chmod +x ~/phytoMorphTK/plantProfiler/plantProfiler

		#####################################
		# add pathing
		PATH='~/phytoMorphTK/:'~/phytoMorphTK/$packageName/
		export "PATH="$PATH
		echo 'export PATH=~/phytoMorphTK/'$packageName'/:$PATH' >> ~/.bashrc
		#####################################

		;;
	JARs)
		mkdir -p ~/phytoMorphTK/JARs/
		wget -O ~/phytoMorphTK/JARs/core-3.2.1.jar https://de.cyverse.org/dl/d/187AA822-2A3D-468C-BA30-69389C641247/core-3.2.1.jar
		wget -O ~/phytoMorphTK/JARs/javase-3.2.1.jar https://de.cyverse.org/dl/d/D8436F43-220C-40F2-B9DE-F0CADE39C796/javase-3.2.1.jar
		echo "***************************************************************************"
		echo "*			End Install Plant Profiler                              *"
		echo "***************************************************************************"
		;;
	phytoMeta)
		echo "***************************************************************************"
		echo "*			Start Install phytoMeta                                 *"
		echo "***************************************************************************"
		sudo apt-get update
		sudo apt-get -y  -q install imagemagick
		sudo apt-get -y  -q install qrencode
		sudo apt-get -y  -q install libqrencode3
		packageName=phytoMeta
		# make the directory for phytoStreams
		mkdir -p ~/phytoMorphTK/$packageName/
		# make the directory for the install file
		mkdir -p ~/phytoMorphTK/installFiles/
		# get the current zip containing the phytoStreams toolkit
		wget -c -O ~/phytoMorphTK/installFiles/$packageName.zip https://de.cyverse.org/dl/d/1411C0CD-A6B3-41DC-B691-23413415B360/phytoMeta.zip
		# unzip the phytoStreams toolkit
		unzip -o ~/phytoMorphTK/installFiles/$packageName.zip -d ~/phytoMorphTK/$packageName/
		# export the current path for this install
		PATH=~/phytoMorphTK/$packageName/:$PATH
		export "PATH=$PATH"
		# export future shells to include the phytoQR toolkit
		echo 'export PATH=~/phytoMorphTK/'$packageName'/:$PATH' >> ~/.bashrc
		#configureQR
		echo "***************************************************************************"
		echo "*			End Install phytoMeta                                   *"
		echo "***************************************************************************"
		;;
	dcraw)
		echo "***************************************************************************"
		echo "*			Start Install dcraw                                     *"
		echo "***************************************************************************"
		sudo  -q -y apt-get install dcraw
		echo "***************************************************************************"
		echo "*			End Install dcraw					*"
		echo "***************************************************************************"
	;;
	phytoDAQ)
		echo "***************************************************************************"
		echo "*			Start Install phytoDAQ                                  *"
		echo "***************************************************************************"
		# install the icommands
		./install_phytoMorph_toolKits.sh phytoMeta
		# install JARs
		./install_phytoMorph_toolKits.sh JARs3
		# install dcraw
		./install_phytoMorph_toolKits.sh dcraw3
		# install sqlite
		./install_phytoMorph_toolKits.sh sqlite3
		# install the photo tool kit
		./install_phytoMorph_toolKits.sh phytoPhoto
		# install the data stream tool kit
		./install_phytoMorph_toolKits.sh phytoStreams
		# install the icommands
		./install_phytoMorph_toolKits.sh icommands
		# install MCR
		./install_phytoMorph_toolKits.sh matlabMCR2017b
		# install phytoPhoto
		./install_phytoMorph_toolKits.sh phytoPhoto
		#####################################
		# init the package name
		packageName='deviceBank'
		mkdir -p ~/phytoMorphTK/$packageName/
		wget -O ~/phytoMorphTK/$packageName/$packageName https://de.cyverse.org/dl/d/F1295C02-3887-4FE1-881C-219396D50786/deviceBank
		wget -O ~/phytoMorphTK/$packageName/run_$packageName https://de.cyverse.org/dl/d/6B2FA4A1-4D3F-4E60-BA47-3B71B85CA9A6/run_deviceBank.sh
		chmod +x ~/phytoMorphTK/$packageName/run_$packageName
		chmod +x ~/phytoMorphTK/$packageName/$packageName
		#####################################
		# add pathing
		PATH='~/phytoMorphTK/:'~/phytoMorphTK/$packageName/
		export "PATH="$PATH
		echo 'export PATH=~/phytoMorphTK/'$packageName'/:$PATH' >> ~/.bashrc
		#####################################
		echo "***************************************************************************"
		echo "*			End Install phytoDAQ                                    *"
		echo "***************************************************************************"
		;;
	all)
		echo "***************************************************************************"
		echo "*			Start Install All                                       *"
		echo "***************************************************************************"
		./install_phytoMorph_toolKits.sh phytoPhoto
		./install_phytoMorph_toolKits.sh phytoStreams
		./install_phytoMorph_toolKits.sh icommands
		./install_phytoMorph_toolKits.sh matlabMCR2017b
		./install_phytoMorph_toolKits.sh sqlite3
		./install_phytoMorph_toolKits.sh gphoto2
		./install_phytoMorph_toolKits.sh condorFileTransfer
		./install_phytoMorph_toolKits.sh copyToken
		./install_phytoMorph_toolKits.sh plantProfiler
		./install_phytoMorph_toolKits.sh JARs
		./install_phytoMorph_toolKits.sh phytoMeta
		./install_phytoMorph_toolKits.sh dcraw
		./install_phytoMorph_toolKits.sh phytoDAQ
		echo "***************************************************************************"
		echo "*			End Install All					*"
		echo "***************************************************************************"
	;;
	*)
		echo "You did not make a proper selection."
		;;
esac

#resource
. ~/.bashrc


GIT=https://gitlab.redox-os.org/redox-os/Smith.git
GIT_UPSTREAM=https://github.com/IGI-111/Smith.git


#!/bin/sh
PROTOC_GEN_TS_PATH="node_modules/.bin/protoc-gen-ts"
OUT_DIR="src/protobufs"
protoc \
    -I${PROTO} \
    -I${GOCELER}/webproxy/proto \
    --plugin="protoc-gen-ts=${PROTOC_GEN_TS_PATH}" \
    --js_out="import_style=commonjs,binary:${OUT_DIR}" \
    --ts_out="service=grpc-web:${OUT_DIR}" \
    ${PROTO}/message.proto \
    ${PROTO}/entity.proto \
    ${PROTO}/chain.proto \
    ${GOCELER}/webproxy/proto/web_proxy.proto


<gh_stars>0
#!/bin/bash

# Various ways to list hardware
#
# Favorites..
#
# [GUI]
#    kinfocenter
#
# [cmdline]
#
#    inxi -Fx              #(Notice: I had problems running inxi from a bash script)
#
#    hwinfo                #(>15k lines)
#    hwinfo --all          #(~1000 lines)
#    hwinfo --short        #(<100 lines)
#
#    hwinfo --short --<ITEM>
#
#         ITEM is one of ..
#
#         all, arch, bios, block, bluetooth, braille, bridge, camera, cdrom, chipcard,  cpu,  disk,  dsl,  dvb,  fingerprint,  floppy,
#         framebuffer, gfxcard,  hub,  ide,  isapnp, isdn, joystick, keyboard, memory, mmc-ctrl, modem, monitor, mouse, netcard,
#         network, partition, pci, pcmcia, pcmcia-ctrl, pppoe, printer, redasd, reallyall, scanner, scsi, smp, sound, storage-ctrl,
#         sys, tape, tv, uml,  usb,  usb-ctrl,  vbe,  wlan, xen, zip
#
# [Others]
#
#     dmidecode
#     free -m
#     hwloc-ls
#     lsblk
#     lsb_release -a
#     lscpu
#     lshw
#     lspci
#     uname -a
#
#     cat /proc/cpuinfo
#     cat /proc/meminfo
#     cat /proc/interrupts
#
# Also 'dmesg' to display all messages from the kernel ring buffer
#
#     dmesg
#     dmesg --facility=kern,user,etc. (see below)
#     dmesg --level=emerg,alert,crit,err
#     dmesg --level=warn,notice
#
#         Supported log facilities:
#             kern - kernel messages
#             user - random user-level messages
#             mail - mail system
#           daemon - system daemons
#             auth - security/authorization messages
#           syslog - messages generated internally by syslogd
#              lpr - line printer subsystem
#             news - network news subsystem
#
#         Supported log levels (priorities):
#            emerg - system is unusable
#            alert - action must be taken immediately
#             crit - critical conditions
#              err - error conditions
#             warn - warning conditions
#           notice - normal but significant condition
#             info - informational
#            debug - debug-level messages

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
doit()
{
    export TIMEFORMAT=%3lR
    TMPF=`mktemp`
    echo
    echo x=:================================================================================================================================
    date +"[%Y-%m%m-%H%M%S.%3N] CMD x=: $*"
    ( time $* ) 2>&1 > $TMPF 2>&1
    echo Output lines x=: `cat $TMPF | wc -l`
    echo Elapsed time x=: `grep -E "^[0-9][0-9]*m[0-9][0-9]*\.[0-9][0-9]*s$" $TMPF`
    echo
    cat $TMPF
    rm $TMPF
    echo EOT
}

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ***  M A I N  ***

doit dmidecode
doit free -m
doit lsblk
doit lscpu
doit lshw
doit lspci
doit dmesg

# for bluetooth troubleshooting

bluetoothctl show
bluetoothctl devices

# some of these take ~6 sconds ('--dsl' and '--pppoe') (which means also '', '--all', and '--reallyall')

doit hwinfo
doit hwinfo --all
doit hwinfo --arch
doit hwinfo --bios
doit hwinfo --block
doit hwinfo --bluetooth
doit hwinfo --braille
doit hwinfo --bridge
doit hwinfo --camera
doit hwinfo --cdrom
doit hwinfo --chipcard
doit hwinfo --cpu
doit hwinfo --disk
doit hwinfo --dsl
doit hwinfo --dvb
doit hwinfo --fingerprint
doit hwinfo --floppy
doit hwinfo --framebuffer
doit hwinfo --gfxcard
doit hwinfo --hub
doit hwinfo --ide
doit hwinfo --isapnp
doit hwinfo --isdn
doit hwinfo --joystick
doit hwinfo --keyboard
doit hwinfo --memory
doit hwinfo --mmc-ctrl
doit hwinfo --modem
doit hwinfo --monitor
doit hwinfo --mouse
doit hwinfo --netcard
doit hwinfo --network
doit hwinfo --partition
doit hwinfo --pci
doit hwinfo --pcmcia
doit hwinfo --pcmcia-ctrl
doit hwinfo --pppoe
doit hwinfo --printer
doit hwinfo --redasd
doit hwinfo --reallyall
doit hwinfo --scanner
doit hwinfo --scsi
doit hwinfo --smp
doit hwinfo --sound
doit hwinfo --storage-ctrl
doit hwinfo --sys
doit hwinfo --tape
doit hwinfo --tv
doit hwinfo --uml
doit hwinfo --usb
doit hwinfo --usb-ctrl
doit hwinfo --vbe
doit hwinfo --wlan
doit hwinfo --xen
doit hwinfo --zip

# 3.0 version of inxi sometimes would peg CPU (load avg 18!!!) without end,
# so only run the one I've installed (which is newer)

[ -x /home/rmbjr60/.local/src/inxi/inxi ] && INXI=/home/rmbjr60/.local/src/inxi/inxi || INXI=inxi
[ ! _$INXI = _inxi ] && doit $INXI -Fx || echo OLD INXI VERSION `inxi --version | grep ... | head -1`


#!/usr/bin/env bash

set -e

GCP_SERVICE_ACCOUNT_FILE=~/docker-267311-serviceaccount.json
export GCP_SERVICE_ACCOUNT_FILE
ansible-playbook ./playbooks/docker_runner/playbook.yml --key-file ~/.ssh/appuser


<filename>scripts/pushone.sh<gh_stars>1-10
#!/bin/bash

set -x
hostname=$1
shift

if test -z "$hostname"; then
  echo 'usage, pushone <hostname> [OPTIONS]'
  exit 1
fi

ngage push $hostname gen/$hostname/* $@


#!/bin/bash
if [ -z "${PG_PASS}" ]
then
  echo "You need to set PG_PASS environment variable to run this script"
  exit 1
fi
# devstats here is a log database name
./devel/db.sh psql -h 172.17.0.1 -p 65432 devstats-lfda


<filename>run.sh
python ./src/jnc_filter.py --input_path ./data/JNC-corpus.json --output_path ./output/


#!/bin/sh -ex

cd build && npm run build && cd .. && node server/server.js


#!/bin/bash

set -e

export ENV=$1
source scripts/setup-env.sh

GCP_CI_BUILDER_CREDENTIALS=$2

IMAGE_TAG=$3
# Overwrite version
VERSION=$(echo $IMAGE_TAG | sed 's/\./\-/g')

./scripts/compile.sh

cd compile/

gcloud --project=${GCP_PROJECT_NAME} auth activate-service-account <EMAIL> --key-file=../${GCP_CI_BUILDER_CREDENTIALS}
gcloud --project=${GCP_PROJECT_NAME} app deploy --version=${VERSION} app.yaml

cd ..


<reponame>elocnatsirt/off-killter
#!/usr/bin/env bash

# Local Server
run_server() {
  if [[ "$OSTYPE" == "linux-gnu" ]]; then
    open https://localhost
  elif [[ "$OSTYPE" == "darwin"* ]]; then
    open https://localhost
    echo "navigate to https://$(ifconfig en0 | grep 'inet ' | sed 's/.*inet //;s/ netmask.*//') on another locally networked PC"
  else
    echo "Navigate to https://localhost in your browser"
  fi
  echo ""

  which serve &> /dev/null
  if [ $? -eq 0 ]; then
    serve .
  else
    echo "Install https-localhost -- (npm i -g --only=prod https-localhost) -- https://github.com/daquinoaldo/https-localhost"
  fi
}

# Preview README
preview() {
  which grip &> /dev/null

  if [ $? -eq 0 ]; then
    open http://localhost:6419
    grip
  else
    echo "Install grip: https://github.com/joeyespo/grip"
  fi
}

# Package
package() {
  cd ./build
  build_name=build_$(date +%s).zip
  zip -r $build_name ./*
  mv $build_name ../builds/
  cd ../
  echo "Build located at $(pwd)/builds/$build_name"
}

# Build
build() {
  rsync -avr --exclude='node_modules/' --exclude='*.zip' --exclude='dist/' --exclude='.cache/' --exclude='node_modules/' --exclude='.git*' --exclude='build/' --exclude='builds/' --exclude='.eslintrc.js' --exclude='tools.sh' --exclude='hidden/' ./ ./build/

  package
}

while getopts “sbr” opt; do
  case $opt in
    s ) run_server
    ;;
    b ) build
    ;;
    r ) preview
    ;;
  esac
done


#!/usr/bin/env bash
# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
  source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
  source "$0.runfiles/$f" 2>/dev/null || \
  source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
  source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
  { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
# --- end runfiles.bash initialization v2 ---

set -euo pipefail

DAMLC="$(rlocation "$TEST_WORKSPACE/$1")"

SDK_VERSION=$2

DIFF=$3

DIR=$(mktemp -d)
trap "rm -rf $DIR" EXIT

cat > $DIR/daml.yaml <<EOF
sdk-version: $SDK_VERSION
name: foobar
version: 0.1.0
source: src
dependencies: [daml-prim, daml-stdlib]
EOF
mkdir -p $DIR/src

$DAMLC build --target=1.dev --project-root $DIR -o $DIR/out.dar
# The last line is the main dalf which we don’t need. We don’t need to worry about excluding daml-prim
# and daml-stdlib since they are only pulled in when necessary and they are clearly not required for
# an empty package
$DIFF -u -b <($DAMLC inspect-dar $DIR/out.dar | sed '1,/following packages/d' | head -n -1) <(cat <<EOF

daml-prim-DA-Exception-ArithmeticError-f1cf1ff41057ce327248684089b106d0a1f27c2f092d30f663c919addf173981 "f1cf1ff41057ce327248684089b106d0a1f27c2f092d30f663c919addf173981"
daml-prim-DA-Exception-AssertionFailed-0b6d5242cee0f53a6aa39ab7caa8122e3864b200b86338007b334b0ad3c65830 "0b6d5242cee0f53a6aa39ab7caa8122e3864b200b86338007b334b0ad3c65830"
daml-prim-DA-Exception-GeneralError-a4c4df2bd621b1bc1ba9fb5d3e633a5ddffb5b59e379bb091a18ce3f7801a7e4 "a4c4df2bd621b1bc1ba9fb5d3e633a5ddffb5b59e379bb091a18ce3f7801a7e4"
daml-prim-DA-Exception-PreconditionFailed-dc9576d7b3a816944d0d07c7e2d57f8ebe247187f9e08629d6fa9b1020a77b5d "dc9576d7b3a816944d0d07c7e2d57f8ebe247187f9e08629d6fa9b1020a77b5d"
daml-prim-DA-Internal-Erased-76bf0fd12bd945762a01f8fc5bbcdfa4d0ff20f8762af490f8f41d6237c6524f "76bf0fd12bd945762a01f8fc5bbcdfa4d0ff20f8762af490f8f41d6237c6524f"
daml-prim-DA-Internal-PromotedText-d58cf9939847921b2aab78eaa7b427dc4c649d25e6bee3c749ace4c3f52f5c97 "d58cf9939847921b2aab78eaa7b427dc4c649d25e6bee3c749ace4c3f52f5c97"
daml-prim-DA-Types-40f452260bef3f29dede136108fc08a88d5a5250310281067087da6f0baddff7 "40f452260bef3f29dede136108fc08a88d5a5250310281067087da6f0baddff7"
daml-prim-GHC-Prim-e491352788e56ca4603acc411ffe1a49fefd76ed8b163af86cf5ee5f4c38645b "e491352788e56ca4603acc411ffe1a49fefd76ed8b163af86cf5ee5f4c38645b"
daml-prim-GHC-Tuple-6839a6d3d430c569b2425e9391717b44ca324b88ba621d597778811b2d05031d "6839a6d3d430c569b2425e9391717b44ca324b88ba621d597778811b2d05031d"
daml-prim-GHC-Types-518032f41fd0175461b35ae0c9691e08b4aea55e62915f8360af2cc7a1f2ba6c "518032f41fd0175461b35ae0c9691e08b4aea55e62915f8360af2cc7a1f2ba6c"
daml-stdlib-DA-Date-Types-bfcd37bd6b84768e86e432f5f6c33e25d9e7724a9d42e33875ff74f6348e733f "bfcd37bd6b84768e86e432f5f6c33e25d9e7724a9d42e33875ff74f6348e733f"
daml-stdlib-DA-Internal-Any-cc348d369011362a5190fe96dd1f0dfbc697fdfd10e382b9e9666f0da05961b7 "cc348d369011362a5190fe96dd1f0dfbc697fdfd10e382b9e9666f0da05961b7"
daml-stdlib-DA-Internal-Down-057eed1fd48c238491b8ea06b9b5bf85a5d4c9275dd3f6183e0e6b01730cc2ba "057eed1fd48c238491b8ea06b9b5bf85a5d4c9275dd3f6183e0e6b01730cc2ba"
daml-stdlib-DA-Internal-Template-d14e08374fc7197d6a0de468c968ae8ba3aadbf9315476fd39071831f5923662 "d14e08374fc7197d6a0de468c968ae8ba3aadbf9315476fd39071831f5923662"
daml-stdlib-DA-Logic-Types-c1f1f00558799eec139fb4f4c76f95fb52fa1837a5dd29600baa1c8ed1bdccfd "c1f1f00558799eec139fb4f4c76f95fb52fa1837a5dd29600baa1c8ed1bdccfd"
daml-stdlib-DA-Monoid-Types-6c2c0667393c5f92f1885163068cd31800d2264eb088eb6fc740e11241b2bf06 "6c2c0667393c5f92f1885163068cd31800d2264eb088eb6fc740e11241b2bf06"
daml-stdlib-DA-NonEmpty-Types-e22bce619ae24ca3b8e6519281cb5a33b64b3190cc763248b4c3f9ad5087a92c "e22bce619ae24ca3b8e6519281cb5a33b64b3190cc763248b4c3f9ad5087a92c"
daml-stdlib-DA-Semigroup-Types-8a7806365bbd98d88b4c13832ebfa305f6abaeaf32cfa2b7dd25c4fa489b79fb "8a7806365bbd98d88b4c13832ebfa305f6abaeaf32cfa2b7dd25c4fa489b79fb"
daml-stdlib-DA-Set-Types-97b883cd8a2b7f49f90d5d39c981cf6e110cf1f1c64427a28a6d58ec88c43657 "97b883cd8a2b7f49f90d5d39c981cf6e110cf1f1c64427a28a6d58ec88c43657"
daml-stdlib-DA-Time-Types-733e38d36a2759688a4b2c4cec69d48e7b55ecc8dedc8067b815926c917a182a "733e38d36a2759688a4b2c4cec69d48e7b55ecc8dedc8067b815926c917a182a"
daml-stdlib-DA-Validation-Types-<KEY>5 "<KEY>"
EOF
)


#!/usr/bin/env bash
set -euo pipefail # exit on errors

# Exit immediately if a pipeline returns a non-zero status.
#set -o errexit

# If set, any trap on ERR is inherited by shell functions, command substitutions, and commands executed in a subshell environment. The ERR trap is normally not inherited in such cases.
#set -o errtrace

# See https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
# -u The shell shall write a message to standard error when it tries to expand a variable that  is  not set and immediately exit.
# pipefail
#    If set, the return value of a pipeline is the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands in the pipeline exit successfully. This option is disabled by default.

set -x # debug traces
declare -i errcount=0
declare -i errcode=0

readonly API_HOST="${API_HOST:?must be set}"
readonly API_PORT="${API_PORT:?must be set}"
readonly USERNAME="${USERNAME:?must be set}"
readonly PASSWORD="${PASSWORD:?<PASSWORD>}"
readonly CLIENT_ID="${CLIENT_ID:?must be set}"
readonly CLIENT_SECRET="${CLIENT_SECRET:?must be set}"
readonly DEFAULT_ORG="${DEFAULT_ORG:?must be set}"
readonly DEFAULT_SPACE="${DEFAULT_SPACE:?must be set}"
readonly SKIP_SSL_VALIDATION="${SKIP_SSL_VALIDATION:?must be set}"
readonly GRADLE_ARGS="${GRADLE_ARGS//\$PWD/${PWD}}" # Replace $PWD litteral with content of the PWD env var, ie current build
readonly ARTIFACTORY_URL="${ARTIFACTORY_URL:?must be set}"

# Temporary variables to construct gradle command line
readonly gradle_http_proxy_host=$(echo $http_proxy | sed -E "s#http://(.*):(.+)#\1#")
readonly gradle_http_proxy_port=$(echo $http_proxy | sed -E "s#http://(.*):(.+)#\2#")
readonly gradle_noproxy=$(echo $no_proxy | sed -E "s#,#|#g")
readonly gradle_proxy_config="-Dhttp.proxyHost=${gradle_http_proxy_host} -Dhttps.proxyHost=${gradle_http_proxy_host} -Dhttps.nonProxyHosts=${gradle_noproxy} -Dhttps.proxyPort=${gradle_http_proxy_port} -Dhttp.proxyPort=${gradle_http_proxy_port} -Dhttp.nonProxyHosts=${gradle_noproxy} "

# Inspired from https://raw.githubusercontent.com/spring-io/concourse-java-scripts/v0.0.2/concourse-java.sh
# Setup Maven and Gradle symlinks for caching
setup_symlinks() {
  if [[ -d $PWD/maven && ! -d $HOME/.m2 ]]; then
  ln -s "$PWD/maven" "$HOME/.m2"
  fi
  if [[ -d $PWD/gradle && ! -d $HOME/.gradle ]]; then
  ln -s "$PWD/gradle" "$HOME/.gradle"
  fi
}

build() {
  if [[ $BUILD == "true" ]]; then
    ./gradlew ${gradle_proxy_config} assemble -x test -x javadoc -x sourcesJar -x javadocJar
  else
    echo "Skipping initial build"
  fi
}

# jar file name is versioned yet referenced in env var to be loaded by acceptance tests
# e.g.
# $PWD/osb-cmdb/build/libs/osb-cmdb-1.0.0.jar
# To avoid changing the deployment automation, we simply rename the jar to remove the version
# so that the pipeline var does not need to change upon each release.
# This is easier to be done in this script than in the concourse pipeline yml
rename_jar_file_to_be_predicable() {

  #See inspiration from http://tldp.org/LDP/abs/html/globbingref.html
  #IFS="$(printf '\n\t')"   # Remove space.

  for file in ${PWD}/osb-cmdb/build/libs/osb-cmdb-*.jar ; do         # Use ./* ... NEVER bare *
    echo "renaming $file into $PWD/osb-cmdb/build/libs/osb-cmdb.jar"

    # $ mv --help
    #   -u, --update                 move only when the SOURCE file is newer
    #                                 than the destination file or when the
    #                                 destination file is missing
    mv -u "${file}" "$PWD/osb-cmdb/build/libs/osb-cmdb.jar"
  done

  if [ ! -f  "$PWD/osb-cmdb/build/libs/osb-cmdb.jar" ]; then
    echo "did not find expected jar file at $PWD/osb-cmdb/build/libs/osb-cmdb.jar Exiting"
    exit 1
  fi
}

run_tests() {
  # The AT build.gradle explicitly propagates system properties starting with spring to the test environment

  OSB_CMDB_PROPS=""

  # when set to "true", then the AT properies are exposed. Required for testing osbcmdb dynamic catalog
  if [[ $EXPOSE_AT_PROPS == "true" ]]; then
    # During debug, we once attempted to bypass env variables with JVM properties
    # This was not the root cause, and rather creates divergence with production mechanis using env var
    # with cloudfoundry cf-set-env allow vars separated with dots while bash does not allow it
    OSB_CMDB_PROPS="${OSB_CMDB_PROPS} -Dspring.cloud.appbroker.acceptance-test.cloudfoundry.api-host=${API_HOST}"
    OSB_CMDB_PROPS="${OSB_CMDB_PROPS} -Dspring.cloud.appbroker.acceptance-test.cloudfoundry.api-port=${API_PORT}"
    OSB_CMDB_PROPS="${OSB_CMDB_PROPS} -Dspring.cloud.appbroker.acceptance-test.cloudfoundry.username=${USERNAME}"
    OSB_CMDB_PROPS="${OSB_CMDB_PROPS} -Dspring.cloud.appbroker.acceptance-test.cloudfoundry.password=${PASSWORD}"
    OSB_CMDB_PROPS="${OSB_CMDB_PROPS} -Dspring.cloud.appbroker.acceptance-test.cloudfoundry.client_id=${CLIENT_ID}"
    OSB_CMDB_PROPS="${OSB_CMDB_PROPS} -Dspring.cloud.appbroker.acceptance-test.cloudfoundry.client_secret=${CLIENT_SECRET}"
    OSB_CMDB_PROPS="${OSB_CMDB_PROPS} -Dspring.cloud.appbroker.acceptance-test.cloudfoundry.default-org=${DEFAULT_ORG}"
    OSB_CMDB_PROPS="${OSB_CMDB_PROPS} -Dspring.cloud.appbroker.acceptance-test.cloudfoundry.default-space=${DEFAULT_SPACE}"
    OSB_CMDB_PROPS="${OSB_CMDB_PROPS} -Dspring.cloud.appbroker.acceptance-test.cloudfoundry.skip-ssl-validation=${SKIP_SSL_VALIDATION}"
  fi

  # when set to "true", then the prod env vars are exposed. Required for testing prod environment startup
  if [[ $EXPOSE_PROD_ENV_VARS == "true" ]]; then
    # During debug, we once attempted to bypass env variables with JVM properties
    # This was not the root cause, and rather creates divergence with production mechanis using env var
    # with cloudfoundry cf-set-env allow vars separated with dots while bash does not allow it
#    OSB_CMDB_PROPS="${OSB_CMDB_PROPS} -Dspring.cloud.appbroker.deployer.cloudfoundry.api-host=${API_HOST}"
#    OSB_CMDB_PROPS="${OSB_CMDB_PROPS} -Dspring.cloud.appbroker.deployer.cloudfoundry.api-port=${API_PORT}"
#    OSB_CMDB_PROPS="${OSB_CMDB_PROPS} -Dspring.cloud.appbroker.deployer.cloudfoundry.username=${USERNAME}"
#    OSB_CMDB_PROPS="${OSB_CMDB_PROPS} -Dspring.cloud.appbroker.deployer.cloudfoundry.password=${PASSWORD}"
#    OSB_CMDB_PROPS="${OSB_CMDB_PROPS} -Dspring.cloud.appbroker.deployer.cloudfoundry.client_id=${CLIENT_ID}"
#    OSB_CMDB_PROPS="${OSB_CMDB_PROPS} -Dspring.cloud.appbroker.deployer.cloudfoundry.client_secret=${CLIENT_SECRET}"
#    OSB_CMDB_PROPS="${OSB_CMDB_PROPS} -Dspring.cloud.appbroker.deployer.cloudfoundry.default-org=${DEFAULT_ORG}"
#    OSB_CMDB_PROPS="${OSB_CMDB_PROPS} -Dspring.cloud.appbroker.deployer.cloudfoundry.default-space=${DEFAULT_SPACE}"
#    OSB_CMDB_PROPS="${OSB_CMDB_PROPS} -Dspring.cloud.appbroker.deployer.cloudfoundry.skip-ssl-validation=${SKIP_SSL_VALIDATION}"

    # To check received env in gradle test, use a gradle --debug output which produces the following trace
    # > 10:56:56.188 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Environment for process 'Gradle Test Executor 1': { [...] }
    export SPRING_CLOUD_APPBROKER_DEPLOYER_CLOUDFOUNDRY_API_HOST="${API_HOST}"
    export SPRING_CLOUD_APPBROKER_DEPLOYER_CLOUDFOUNDRY_API_PORT="${API_PORT}"
    export SPRING_CLOUD_APPBROKER_DEPLOYER_CLOUDFOUNDRY_USERNAME="${USERNAME}"
    export SPRING_CLOUD_APPBROKER_DEPLOYER_CLOUDFOUNDRY_PASSWORD="${PASSWORD}"
    export SPRING_CLOUD_APPBROKER_DEPLOYER_CLOUDFOUNDRY_DEFAULT_ORG="${DEFAULT_ORG}"
    export SPRING_CLOUD_APPBROKER_DEPLOYER_CLOUDFOUNDRY_DEFAULT_SPACE="${DEFAULT_SPACE}"
    export SPRING_CLOUD_APPBROKER_DEPLOYER_CLOUDFOUNDRY_SKIP_SSL_VALIDATION="${SKIP_SSL_VALIDATION}"

  fi
  # when set to "true", then the acceptance test env vars are exposed. Required for launching SCAB AT.
  if [[ $EXPOSE_AT_ENV_VARS == "true" ]]; then
    export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_API_HOST="${API_HOST}"
    export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_API_PORT="${API_PORT}"
    export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_USERNAME="${USERNAME}"
    export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_PASSWORD="${PASSWORD}"
    export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_CLIENT_ID="${CLIENT_ID}"
    export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_CLIENT_SECRET="${CLIENT_SECRET}"
    export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_DEFAULT_ORG="${DEFAULT_ORG}"
    export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_DEFAULT_SPACE="${DEFAULT_SPACE}"
    export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_SKIP_SSL_VALIDATION="${SKIP_SSL_VALIDATION}"
  fi
  export TESTS_BROKERAPPPATH=build/libs/spring-cloud-app-broker-acceptance-tests.jar

  # Don't wait on test error in order to still package test report
  set +e

  ./gradlew ${gradle_proxy_config} ${OSB_CMDB_PROPS} ${GRADLE_ARGS}

  if [[ $? -ne 0 ]]; then
    errcount=$(( errcount + 1 ))
  fi
  set -e
}
load_metadata() {
    # Grab the metadata published by metadata resource
  url=$(cat metadata/atc_external_url)
  team=$(cat metadata/build_team_name)
  pipeline=$(cat metadata/build_pipeline_name)
  job=$(cat metadata/build_job_name)
  build=$(cat metadata/build_name)
}
zip_reports_for_publication() {
  report_file_name="reports_${job}_${build}.tgz"
  echo "packaging found reports into ${report_file_name}"
  # Avoid leading . in the tgz archive which breaks jcr
  # See https://stackoverflow.com/questions/60988334/artifactory-archive-entry-download-404-for-tgz-with-leading-dot-in-path-to-arch
  find . -type d -name "reports" | xargs -n 20 tar cvfz "${report_file_name}" --transform='s|^\./||S'
  report_dirs=$(find . -type d -name "reports")
  index_files=$(for d in $report_dirs; do find $d -name index.html | sed "s|^\./||"; done)

  notif_file_name="notification.md"
  touch ${notif_file_name}
  # Reset content from previous execution to avoid reporting duplicates
  echo > ${notif_file_name}
  # shellcheck disable=SC2129

  # Pull request variant https://github.com/telia-oss/github-pr-resource#get
  if [ -f .git/resource/title ]; then
    printf "\nFrom pr#" >> ${notif_file_name}
    cat .git/resource/pr >> ${notif_file_name}
    printf " with title:\`" >> ${notif_file_name}
    cat .git/resource/title >> ${notif_file_name}
    printf "\`\n" >> ${notif_file_name}
  fi

  printf "\nLast commit has message: \n\`\`\`\n" >> ${notif_file_name}
  # Git resource variant
  if [ -f .git/commit_message ]; then
    cat .git/commit_message >> ${notif_file_name}
  fi
  # Pull request variant https://github.com/telia-oss/github-pr-resource#get
  if [ -f .git/resource/message ]; then
    cat .git/resource/message >> ${notif_file_name}
  fi

  printf "\n\`\`\`\nand hash: \`" >> ${notif_file_name}
  # Git resource variant
  if [ -f .git/ref ]; then
    cat .git/ref >> ${notif_file_name}
  fi
  # Pull request variant https://github.com/telia-oss/github-pr-resource#get
  if [ -f .git/resource/head_sha ]; then
    cat .git/resource/head_sha >> ${notif_file_name}
  fi
  printf "\`" >> ${notif_file_name}

  # shellcheck disable=SC2129
  echo >> ${notif_file_name}

  echo "Gradle [report archive](${ARTIFACTORY_URL}/${report_file_name}) with: " >> ${notif_file_name}
  for f in ${index_files}; do
    #See Artifactory archive entry download specs at https://www.jfrog.com/confluence/display/JFROG/Artifactory+REST+API#ArtifactoryRESTAPI-ArchiveEntryDownload
    echo "* [$f](${ARTIFACTORY_URL}/${report_file_name}!/$f) " >> ${notif_file_name}
  done
  echo "notification content written to ${notif_file_name}"
}
main() {
  setup_symlinks
  load_metadata
  pushd "git-repo" > /dev/null
    build
    rename_jar_file_to_be_predicable
    run_tests
    zip_reports_for_publication
  popd > /dev/null

  if  (( errcount > 0 ))
  then
      echo "Test failed with $errcount errors"
  fi
  exit $errcount

}
main

}


<reponame>schellingb/SWFAutomation
echo Building \'swfautomation-linux-`uname -m`\' ...
g++ -x c++ -Wall main.cpp -o swfautomation-linux-`uname -m`
echo Done!


<filename>kind/scripts/common.sh
#!/usr/bin/env bash

readonly KUBERNETES_VERSION=$( cat "${SCRIPT_DIR}/../KIND_KUBERNETES_VERSION" )
if [[ "${BUILD_TYPE}" == "pr" ]]; then
    readonly IMAGE_NAME="${DOCKER_PUSH_REPOSITORY:-"eu.gcr.io/kyma-project/test-infra"}${DOCKER_PUSH_DIRECTORY:-"/pr"}/kubernetes-kind:PR-${PULL_NUMBER}"
else
    readonly IMAGE_NAME="${DOCKER_PUSH_REPOSITORY:-"eu.gcr.io/kyma-project/test-infra"}${DOCKER_PUSH_DIRECTORY}/kubernetes-kind:${KUBERNETES_VERSION}"
fi
ARTIFACTS_DIR="${ARTIFACTS:-"$( cd "${SCRIPT_DIR}/.." && pwd )/tmp"}" # ARTIFACTS environment variable is provided by Prow
if [[ ! -d ${ARTIFACTS_DIR} ]]; then
    mkdir -p "${ARTIFACTS_DIR}"
fi
readonly ARTIFACTS_DIR="$( cd "${ARTIFACTS_DIR}" && pwd )"
readonly STORE_TEST_OUTPUT="tee ${ARTIFACTS_DIR}/lastTestOutput.log"
readonly STORE_TEST_OUTPUT_APPEND="tee -a ${ARTIFACTS_DIR}/lastTestOutput.log"

function log() {
    echo "$(date +"%Y/%m/%d %T %Z"): ${1}"
}

function startDocker() {
    log "Docker in Docker enabled, initializing..."
    printf '=%.0s' {1..80}; echo
    # If we have opted in to docker in docker, start the docker daemon,
    service docker start
    # the service can be started but the docker socket not ready, wait for ready
    local WAIT_N=0
    local MAX_WAIT=20
    while true; do
        # docker ps -q should only work if the daemon is ready
        docker ps -q > /dev/null 2>&1 && break
        if [[ ${WAIT_N} -lt ${MAX_WAIT} ]]; then
            WAIT_N=$((WAIT_N+1))
            log "Waiting for docker to be ready, sleeping for ${WAIT_N} seconds."
            sleep ${WAIT_N}
        else
            log "Reached maximum attempts, not waiting any longer..."
            exit 1
        fi
    done
    printf '=%.0s' {1..80}; echo

    docker-credential-gcr configure-docker
    log "Done setting up docker in docker."
}

function authenticate() {
    log "Authenticating"
    gcloud auth activate-service-account --key-file "${GOOGLE_APPLICATION_CREDENTIALS}"
}

TESTS_COUNT=0
FAILED_TESTS_COUNT=0
SKIPPED_TESTS_COUNT=0
CURRENT_TEST_CASE=
CURRENT_TEST_START_TIME=
TEST_SUITE_START_TIME=
TEST_SUITE_NAME=

function initTestSuite() {
    TEST_SUITE_START_TIME=$(date +%s)
    TEST_SUITE_NAME="${1}"
    readonly TEST_SUITE_NAME TEST_SUITE_START_TIME
    rm -rf "${ARTIFACTS_DIR}/junit_${TEST_SUITE_NAME}_suite.xml"
    rm -rf "${ARTIFACTS_DIR}/lastTestOutput.log"
}

function testStart() {
    TESTS_COUNT=$((++TESTS_COUNT))
    CURRENT_TEST_CASE="${TEST_SUITE_NAME}/${1}"
    CURRENT_TEST_START_TIME=$(date +%s)
    echo "=== RUN: ${CURRENT_TEST_CASE} 🤔"
}

function testPassed() {
    local -r duration=$(($(date +%s)-CURRENT_TEST_START_TIME))
    echo "--- PASS: ${CURRENT_TEST_CASE} (${duration}s) 😍"
    echo "        <testcase name=\"${CURRENT_TEST_CASE}\" time=\"${duration}\"></testcase>" >> "${ARTIFACTS_DIR}/junit_${TEST_SUITE_NAME}_suite.xml"
}

function testFailed() {
    local -r duration=$(($(date +%s)-CURRENT_TEST_START_TIME))
    FAILED_TESTS_COUNT=$((++FAILED_TESTS_COUNT))
    echo "--- FAIL: ${CURRENT_TEST_CASE} (${duration}s) 💩"
    echo "        <testcase name=\"${CURRENT_TEST_CASE}\" time=\"${duration}\"><failure>$(< "${ARTIFACTS_DIR}/lastTestOutput.log" tr -cd '\11\12\15\40-\176' | sed 's/&/\&/g; s/</\</g; s/>/\>/g; s/"/\"/g; s/'"'"'/\'/g')</failure></testcase>" >> "${ARTIFACTS_DIR}/junit_${TEST_SUITE_NAME}_suite.xml"
    return 1
}

function testSkipped() {
    local -r duration=$(($(date +%s)-CURRENT_TEST_START_TIME))
    SKIPPED_TESTS_COUNT=$((++SKIPPED_TESTS_COUNT))
    echo "--- SKIP: ${CURRENT_TEST_CASE} (${duration}s) 🙈"
    echo "        <testcase name=\"${CURRENT_TEST_CASE}\" time=\"${duration}\"><skipped>${1}</skipped></testcase>" >> "${ARTIFACTS_DIR}/junit_${TEST_SUITE_NAME}_suite.xml"
}

function saveTestSuite() {
    local -r suiteDuration=$(($(date +%s)-TEST_SUITE_START_TIME))
    echo "<testsuite failures=\"${FAILED_TESTS_COUNT}\" name=\"${TEST_SUITE_NAME}\" skipped=\"${SKIPPED_TESTS_COUNT}\" tests=\"${TESTS_COUNT}\" time=\"${suiteDuration}\">
$(cat "${ARTIFACTS_DIR}/junit_${TEST_SUITE_NAME}_suite.xml")
</testsuite>" > "${ARTIFACTS_DIR}/junit_${TEST_SUITE_NAME}_suite.xml"
}