#!/bin/bash

set -o errexit
set -o pipefail
set -o nounset
set -x

# On macOS, restart docker to avoid bugs where containers can't be deleted
if [ "${OSTYPE%%[0-9]*}" = "darwin" ]; then
  killall Docker || true
  nohup /Applications/Docker.app/Contents/MacOS/Docker --unattended &
  sleep 10
fi

# Make sure docker is working
echo "Waiting for docker to come up: $(date)"
date && timeout -v 10m bash -c 'while ! docker ps >/dev/null 2>&1 ; do
  sleep 10
  echo "Waiting for docker to come up: $(date)"
done'
echo "Testing again to make sure docker came up: $(date)"
if ! docker ps >/dev/null 2>&1 ; then
  echo "Docker is not running, exiting"
  exit 1
fi

if [ ! -z "${DOCKERHUB_PULL_USERNAME:-}" ]; then
  set +x
  echo "${DOCKERHUB_PULL_PASSWORD:-}" | docker login --username "${DOCKERHUB_PULL_USERNAME}" --password-stdin
  set -x
fi

rm -rf ~/.ddev/Test* ~/.ddev/global_config.yaml ~/.ddev/homeadditions ~/.ddev/commands

# Run any testbot maintenance that may need to be done
echo "running selfhosted-upgrades.sh"
bash $(dirname $0)/selfhosted-upgrades.sh

echo "cleaning up docker and Test directories"
echo "Warning: deleting all docker containers and deleting ~/.ddev/Test*"
ddev poweroff || true
if [ "$(docker ps -aq | wc -l )" -gt 0 ] ; then
	docker rm -f $(docker ps -aq) >/dev/null 2>&1 || true
fi
docker system prune --volumes --force >/dev/null || true

# Our testbot should be sane, run the testbot checker to make sure.
./.github/workflows/sanetestbot.sh

# Update any images that could have changed
( docker images | awk '/drud/ {print $1":"$2 }' | xargs -L1 docker pull ) || true

# homebrew sometimes removes /usr/local/etc/my.cnf.d
mkdir -p /usr/local/etc/my.cnf.d


<reponame>Neurone/core-commander
#!/usr/bin/env bash

process_monitor ()
{
    clear
    echo -e "\n$(text_yellow " Use Ctrl+C to return to menu")\n"
    trap : INT

    pm2 monit
}


# Start a local cluster of doozers for testings
#
# Usage: doozer_cluster.sh <start|stop|restart> [<instances> <dzns_instances>]

BIND_IP="127.0.0.1"

START_PORT=8046
START_WEB_PORT=8080

START_DZNS_PORT=10000
START_DZNS_WEB_PORT=11000

DZNS_INSTANCES=5
CLUSTER_INSTANCES=5

function usage {
  echo "Usage: doozer_cluster.sh <start|stop|restart> [<instances> <dzns_instances>]"
  exit 1
}

if [ $# -lt 1 ]
then
  usage
fi

if [ $1 != "start" ] && [ $1 != "stop" ] && [ $1 != "restart" ]
then
  usage
fi

if [ $# -gt 1 ]; then
  CLUSTER_INSTANCES=$2
  if [ $CLUSTER_INSTANCES -lt 1 ]
  then
    echo "Need at least one instance (have $CLUSTER_INSTANCES)"
    exit 1
  fi
fi

if [ $# -eq 3 ]; then
  DZNS_INSTANCES=$3
  if [ $DZNS_INSTANCES -lt 1 ]
  then
    echo "Need at least one DZNS instance (have $DZNS_INSTANCES)"
    exit 1
  fi
fi

function start {
  # First startup our DzNS cluster
  for dzns_count in $(seq 0 $(($DZNS_INSTANCES-1)))
  do
    dzns_port=$((START_DZNS_PORT+$dzns_count))
    dzns_web_port=$((START_DZNS_WEB_PORT+$dzns_count))
    if [ $dzns_count -eq 0 ]
    then
      echo doozerd -timeout 5 -l "$BIND_IP:$dzns_port" -w ":$dzns_web_port" -c "dzns"
      doozerd -timeout 5 -l "$BIND_IP:$dzns_port" -w ":$dzns_web_port" -c "dzns" 2>/dev/null &
      sleep 1
    else
      # add to DzNS cluster
	  echo doozerd -timeout 5 -l "$BIND_IP:$dzns_port" -w ":$dzns_web_port" -c "dzns" -a "$BIND_IP:$START_DZNS_PORT"
      doozerd -timeout 5 -l "$BIND_IP:$dzns_port" -w ":$dzns_web_port" -c "dzns" -a "$BIND_IP:$START_DZNS_PORT" 2>/dev/null &
      printf '' | doozer -a "doozer:?ca=$BIND_IP:$START_DZNS_PORT" add "/ctl/cal/$dzns_count" >/dev/null &
    fi
  done

  # Now startup doozer instances
  for dz_count in $(seq 0 $(($CLUSTER_INSTANCES-1)))
  do
    dz_port=$(( $START_PORT + $dz_count ))
    dz_web_port=$(( $START_WEB_PORT + $dz_count ))
    echo doozerd -timeout 5 -l "$BIND_IP:$dz_port" -w ":$dz_web_port" -c "skynet" -b "doozer:?ca=$BIND_IP:$START_DZNS_PORT"
    doozerd -timeout 5 -l "$BIND_IP:$dz_port" -w ":$dz_web_port" -c "skynet" -b "doozer:?ca=$BIND_IP:$START_DZNS_PORT" 2>/dev/null &

    if [ $dz_count -eq 0 ]
    then
      sleep 1
    else
      # add to cluster
      # this has to connect to master, it blows up with a REV_MISMATCH if we connect to anyone else
      printf '' | doozer -a "doozer:?ca=$BIND_IP:$START_PORT" -b "doozer:?ca=$BIND_IP:$START_DZNS_PORT" add "/ctl/cal/$dz_count" >/dev/null &
    fi
  done
}

function stop {
  killall doozerd
}

if [ $1 = "start" ]; then
  start
elif [ $1 = "stop" ]; then
  stop
elif [ $1 = "restart" ]; then
  stop
  start
fi


<gh_stars>0
#!  /bin/bash

#Setup a dev laptop for Docker and Terraform development

apt update
apt install software-properties-common -y
apt-add-repository --yes --update ppa:ansible/ansible
DEBIAN_FRONTEND=noninteractive apt install ansible ansible-lint -y


<filename>ranger/install.sh
#!/bin/bash

CURRENT_DIR=$(pwd)
CONFIG_DIR=$HOME/.config/ranger

ln -s $CURRENT_DIR/plugins/__init__.py $CONFIG_DIR/plugins/__init__.py
ln -s $CURRENT_DIR/plugins/devicons_linemode.py $CONFIG_DIR/plugins/devicons_linemode.py
ln -s $CURRENT_DIR/commands.py $CONFIG_DIR/commands.py
ln -s $CURRENT_DIR/devicons.py $CONFIG_DIR/devicons.py
ln -s $CURRENT_DIR/rc.conf $CONFIG_DIR/rc.conf
ln -s $CURRENT_DIR/scope.sh $CONFIG_DIR/scope.sh


#!/bin/sh

input_path = $1
output_path = $1

python test.py --input input_path --output output_path


<filename>examples/digitalocean/scripts/setup_db.sh
#! /bin/bash

apt update
apt install unzip -y
docker run -d -p 5432:5432 -e POSTGRES_USER=boundary -e POSTGRES_PASSWORD=<PASSWORD> -e POSTGRES_DB=boundary postgres:12


#!/bin/bash

cmp ()
{
	compare -metric PSNR "$1" "$2" /dev/null
}

gradset ()
{
	pamgradient \#a0b0c0 \#203040 \#8070d0 \#10d070 $1 $2 | pamtopnm > $GRADIENT_PPM_BIN
	ppmtopgm < $GRADIENT_PPM_BIN > $GRADIENT_PGM_BIN
	pgmtopbm < $GRADIENT_PGM_BIN > $GRADIENT_PBM_BIN
	pnmtoplainpnm < $GRADIENT_PPM_BIN > $GRADIENT_PPM_ASC
	pnmtoplainpnm < $GRADIENT_PGM_BIN > $GRADIENT_PGM_ASC
	pnmtoplainpnm < $GRADIENT_PBM_BIN > $GRADIENT_PBM_ASC
}

# Some of the pnmtools do not generate repeatable output (!),
# so use actual files for testing:
GRADIENT_PBM_ASC=/dev/shm/gradient.asc.pbm
GRADIENT_PGM_ASC=/dev/shm/gradient.asc.pgm
GRADIENT_PPM_ASC=/dev/shm/gradient.asc.ppm
GRADIENT_PBM_BIN=/dev/shm/gradient.bin.pbm
GRADIENT_PGM_BIN=/dev/shm/gradient.bin.pgm
GRADIENT_PPM_BIN=/dev/shm/gradient.bin.ppm

# Generate full set of gradients:
gradset 80 50

cmp \
  <( pgmmake 0.5 7 9 ) \
  <( pgmmake 0.5 7 9 | ./pnmcopy )

cmp \
  <( pgmmake 0.5 7 9 ) \
  <( pgmmake 0.5 7 9 | pnmtoplainpnm | ./pnmcopy )

cmp $GRADIENT_PPM_BIN <( ./pnmcopy < $GRADIENT_PPM_BIN )
cmp $GRADIENT_PGM_BIN <( ./pnmcopy < $GRADIENT_PGM_BIN )
cmp $GRADIENT_PBM_BIN <( ./pnmcopy < $GRADIENT_PBM_BIN )
cmp $GRADIENT_PPM_ASC <( ./pnmcopy < $GRADIENT_PPM_ASC )
cmp $GRADIENT_PGM_ASC <( ./pnmcopy < $GRADIENT_PGM_ASC )
cmp $GRADIENT_PBM_ASC <( ./pnmcopy < $GRADIENT_PBM_ASC )

for wd in `seq 1 10`
do
	for ht in `seq 1 10`
	do
		gradset $wd $ht

		cmp $GRADIENT_PPM_BIN <( ./pnmcopy < $GRADIENT_PPM_BIN )
		cmp $GRADIENT_PGM_BIN <( ./pnmcopy < $GRADIENT_PGM_BIN )
		cmp $GRADIENT_PBM_BIN <( ./pnmcopy < $GRADIENT_PBM_BIN )
		cmp $GRADIENT_PPM_ASC <( ./pnmcopy < $GRADIENT_PPM_ASC )
		cmp $GRADIENT_PGM_ASC <( ./pnmcopy < $GRADIENT_PGM_ASC )
		cmp $GRADIENT_PBM_ASC <( ./pnmcopy < $GRADIENT_PBM_ASC )
	done
done

rm \
  $GRADIENT_PBM_ASC \
  $GRADIENT_PGM_ASC \
  $GRADIENT_PPM_ASC \
  $GRADIENT_PBM_BIN \
  $GRADIENT_PGM_BIN \
  $GRADIENT_PPM_BIN \


<filename>app_frontend/run_dev.sh
#!/bin/bash

script_location=$(dirname $0)
echo $script_location
cd $script_location
pwd
# browsrer url = 'http://127.0.0.1:8600/'

npm run dev


#!/bin/bash
# executed from the vms
set -euo pipefail

cp -r /mnt/input corpus

# Unmount the network share so that it doesn't interfere with coverage
umount /mnt/input

rm corpus/run_cov.sh
mv corpus/syz-executor .
mv corpus/syz-execprog .

# Replay all the test cases
mkdir cover
pushd corpus
	for f in *; do
		../syz-execprog -executor ../syz-executor -coverfile "../cover/$f" $f
	done
popd

# Copy the coverage data to the host
mkdir -p /mnt/output
mount -t 9p -o trans=virtio,version=9p2000.L output /mnt/output
cp cover/* /mnt/output
umount /mnt/output

poweroff


#!/bin/sh

# Download icons from various sources
# Filter those used by the presets
# Convert them from SVG to PDF
# Build an asset catalog containing the images

NAME=(temaki 									maki)
GIT=(https://github.com/ideditor/temaki.git		https://github.com/mapbox/maki.git)
FILES=('icons/*.svg'							'icons/*.svg')

# fetch icons from repositories
for index in "${!NAME[@]}"; do
	name=${NAME[index]}
	git=${GIT[index]}
	files=${FILES[index]}

	rm -rf /tmp/$name
	(cd /tmp/ && git clone --depth 1 $git)
	for f in /tmp/$name/$files; do
		f2=${f##*/}
		mv -f $f ./$name"-"$(echo $f2 | sed 's/-15//')
	done
done

# fetch FontAwesome icons (might require website login)
echo "fetching fontawesome icons"
curl -fLsS --output /tmp/fas.zip https://use.fontawesome.com/releases/v5.15.4/fontawesome-free-5.15.4-web.zip

(cd /tmp/ && unzip -q -o ./fas.zip)
for style in "brands" "regular" "solid"; do
	for f in /tmp/fontawesome-*/svgs/$style/*; do
		f2=${f##*/}
		prefix="fa"${style:0:1}
		mv -f $f ./$prefix"-"$f2
	done
done

# filter out any files not required by presets
presetIcons=($(cd ../presets && ./presetIcons.py | sort | uniq | sed 's/$/.svg/'))
presetStrings=" ${presetIcons[@]} "
for f in *.svg; do
	if [[ ! $presetStrings =~ $f ]]; then
		rm $f
	fi
done

# Special case fetching icons created in iD
echo "fetching iD icons"
for f in "${presetIcons[@]}"; do
	if [[ $f = "iD-"* ]]; then
		f2=${f:3}
		echo $f2
		curl -fLsS --output ./$f "https://raw.githubusercontent.com/openstreetmap/iD/develop/svg/iD-sprite/presets/$f2"
	fi
done

for f in "${presetIcons[@]}"; do
	if [ ! -f "$f" ]; then
		echo "Missing preset icon" $f
	fi
done

# convert from svg to pdf
rm -f *.pdf
export SOURCE_DATE_EPOCH=1521324801 # set CreationDate within PDF so files don't change unnecessarily
/Applications/Inkscape.app/Contents/MacOS/inkscape --export-type=pdf *.svg
rm *.svg

# build asset catalog
echo "Building asset catalog"
rm -rf ./POI-Icons.xcassets
mkdir POI-Icons.xcassets
for f in *.pdf; do
	f2=${f%.*}
	mkdir ./POI-Icons.xcassets/$f2.imageset
	mv $f ./POI-Icons.xcassets/$f2.imageset/$f
	cat > ./POI-Icons.xcassets/$f2.imageset/Contents.json <<EOF
{
  "images" : [
    {
      "filename" : "$f",
      "idiom" : "universal",
      "scale" : "1x"
    },
    {
      "idiom" : "universal",
      "scale" : "2x"
    },
    {
      "idiom" : "universal",
      "scale" : "3x"
    }
  ],
  "properties" : {
    "preserves-vector-representation" : true
  }
}
EOF
done

git add ./POI-Icons.xcassets

echo "done"


<reponame>ymotongpoo/services
#!/bin/bash
#
# Copyright 2021 <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.

set -ex

/usr/bin/env python3 $(dirname $(realpath $0))/delete-files.py

TRASH_EMPTY=$(which trash-empty)
if [ -z "$TRASH_EMPTY" ]; then
    $TRASH_EMPTY
fi


cp ../../p4src int.p4app/ -r
sudo cp p4app /usr/local/bin
sudo p4app run int.p4app --manifest int_v1.0.json
rm int.p4app/p4src -rf


<filename>tm/test-data/shell/subjectRoom.sh<gh_stars>0
echo "USE timeTable;"
IFS=,
while read -e sname room
do
echo "INSERT INTO subjectRoom(subjectId, roomId, snapshotId) VALUES ((SELECT subjectId FROM subject WHERE subjectShortName=\"$sname\"),(SELECT roomId from room WHERE roomShortName=\"$room\"), 1);";
done


<filename>target/MeetHere/resources/bootstrap-datetimepicker-master/minify.sh
#!/bin/sh
java -jar ~/yuicompressor-2.4.7/building/yuicompressor-2.4.7.jar css/bootstrap-datetimepicker.css >css/bootstrap-datetimepicker.min.css
java -jar ~/yuicompressor-2.4.7/building/yuicompressor-2.4.7.jar js/bootstrap-datetimepicker.js >js/bootstrap-datetimepicker.min.js


#!/usr/bin/env bash
set -v
arch=`uname -m`
VERSION=0.3.17
#COMMIT=974acb39ff86121a5a94be4853f58bd728b56b81
BRANCH=develop
if [ -f  OpenBLAS-${VERSION}.tar.gz ]; then
    echo "using existing"  OpenBLAS-${VERSION}.tar.gz
#if [ -f  OpenBLAS-$COMMIT.zip ]; then
#    echo "using existing"  OpenBLAS-${COMMIT}.zip
else
    rm -rf OpenBLAS*
#    curl -L https://github.com/xianyi/OpenBLAS/archive/$COMMIT.zip -o OpenBLAS-$COMMIT.zip
    curl -L https://github.com/xianyi/OpenBLAS/archive/v${VERSION}.tar.gz -o OpenBLAS-${VERSION}.tar.gz
fi
#unzip -n -q OpenBLAS-$COMMIT.zip
#ln -sf OpenBLAS-$COMMIT OpenBLAS
tar xzf OpenBLAS-${VERSION}.tar.gz
ln -sf OpenBLAS-${VERSION} OpenBLAS
cd OpenBLAS
# patch for apple clang -fopenmp
patch -p0 < ../clang_omp.patch
# patch for pgi/nvfortran missing -march=armv8
patch -p0 < ../arm64_fopt.patch
if [[  -z "${FORCETARGET}" ]]; then
FORCETARGET=" "
UNAME_S=$(uname -s)
if [[ ${UNAME_S} == Linux ]]; then
    CPU_FLAGS=$(cat /proc/cpuinfo | grep flags |tail -n 1)
    CPU_FLAGS_2=$(cat /proc/cpuinfo | grep flags |tail -n 1)
elif [[ ${UNAME_S} == Darwin ]]; then
    CPU_FLAGS=$(/usr/sbin/sysctl -n machdep.cpu.features)
    CPU_FLAGS_2=$(/usr/sbin/sysctl -n machdep.cpu.leaf7_features)
fi
  GOTSSE2=$(echo ${CPU_FLAGS}   | tr  'A-Z' 'a-z'| awk ' /sse2/   {print "Y"}')
   GOTAVX=$(echo ${CPU_FLAGS}   | tr  'A-Z' 'a-z'| awk ' /avx/    {print "Y"}')
  GOTAVX2=$(echo ${CPU_FLAGS_2} | tr  'A-Z' 'a-z'| awk ' /avx2/   {print "Y"}')
GOTAVX512=$(echo ${CPU_FLAGS}   | tr  'A-Z' 'a-z'| awk ' /avx512f/{print "Y"}')
if [[ "${GOTAVX2}" == "Y" ]]; then
    echo "forcing Haswell target when AVX2 is available"
    FORCETARGET=" TARGET=HASWELL "
fi
if [[ "${GOTAVX512}" == "Y" ]]; then
    echo "forcing Haswell target on SkyLake"
    FORCETARGET=" TARGET=HASWELL "
fi
fi #FORCETARGET
if [[  -z "${BLAS_SIZE}" ]]; then
   BLAS_SIZE=8
fi
if [[ ${BLAS_SIZE} == 8 ]]; then
  sixty4_int=1
else
  sixty4_int=0
fi
if [[ "${NWCHEM_TARGET}" == "LINUX" ]]; then
  binary=32
  sixty4_int=0
else
  binary=64
fi
if [ -n "${USE_DYNAMIC_ARCH}" ]; then
    FORCETARGET+="DYNAMIC_ARCH=1 DYNAMIC_OLDER=1"
fi
#cray ftn wrapper
if [[ ${FC} == ftn ]]; then
    FCORG=ftn
    if [[ ${PE_ENV} == PGI ]]; then
          FC=pgf90
#          _CC=pgcc
    fi
    if [[ ${PE_ENV} == INTEL ]]; then
	FC=ifort
    fi
    if [[ ${PE_ENV} == GNU ]]; then
	FC=gfortran
    fi
    if [[ ${PE_ENV} == AMD ]]; then
	FC=flang
    fi
fi
if [[ -n ${FC} ]] &&  [[ ${FC} == xlf ]] || [[ ${FC} == xlf_r ]] || [[ ${FC} == xlf90 ]]|| [[ ${FC} == xlf90_r ]]; then
    FORCETARGET+=" CC=gcc "
    _FC=xlf
    LAPACK_FPFLAGS_VAL=" -qstrict=ieeefp -O2 -g"
elif  [[ -n ${FC} ]] && [[ "${FC}" == "flang" ]]; then
    FORCETARGET+=' F_COMPILER=FLANG '
    LAPACK_FPFLAGS_VAL=" -O1 -g -Kieee"
elif  [[ -n ${FC} ]] && [[ "${FC}" == "pgf90" ]] || [[ "${FC}" == "nvfortran" ]]; then
    FORCETARGET+=' F_COMPILER=PGI '
#    if [[ "$arch" == "aarch64" ]]; then
	LAPACK_FLAGS="-O2  -Mrecursive -Kieee -fPIC"
        if [[ ${BLAS_SIZE} == 8 ]]; then
	    LAPACK_FLAGS+=" -i8"
	fi
#    fi
    LAPACK_FPFLAGS_VAL=" -O1 -g -Kieee"
elif  [[ -n ${FC} ]] && [[ "${FC}" == "ifort" ]] || [[ "${FC}" == "ifx" ]]; then
    FORCETARGET+=' F_COMPILER=INTEL '
    LAPACK_FPFLAGS_VAL=" -fp-model source -O2 -g "
else
    LAPACK_FPFLAGS_VAL=" "
fi
if [[   -z "${CC}" ]]; then
    CC=cc
fi
let GCCVERSIONGT5=$(expr `${CC} -dumpversion | cut -f1 -d.` \> 5)
# check gcc version for skylake
if [[ "$FORCETARGET" == *"SKYLAKEX"* ]]; then
    if [[ ${GCCVERSIONGT5} != 1 ]]; then
	echo
	echo you have gcc version $(${CC} -dumpversion | cut -f1 -d.)
	echo gcc version 6 and later needed for skylake
	echo
	exit 1
    fi
fi
#this fixes avx512 detection for icc
if [[ "${CC}" == "icc" ]]; then
    FORCETARGET+=HOSTCC=\"icc -xhost\"
fi

#disable threading for ppc64le since it uses OPENMP
echo arch is "$arch"
if [[ "$arch" == "ppc64le" ]]; then
if [[ ${GCCVERSIONGT5} != 1 ]]; then
    echo gcc version 6 and later needed for ppc64le
    exit 1
fi
    THREADOPT="0"
else
    THREADOPT="1"
fi

#we want openblas to use pthreads and not openmp.
#but NWChem and OpenBLAS both use USE_OPENMP
#disable USE_OPENMP if set and re-enable it later
if [[  ! -z "${USE_OPENMP}" ]]; then
    unset USE_OPENMP
    NWCHEM_USE_OPENMP=1
fi
echo make $FORCETARGET  LAPACK_FPFLAGS=$LAPACK_FPFLAGS_VAL  INTERFACE64=$sixty4_int BINARY=$binary NUM_THREADS=128 NO_CBLAS=1 NO_LAPACKE=1 DEBUG=0 USE_THREAD=$THREADOPT  libs netlib -j4
if [[ ${_FC} == xlf ]]; then
 make FC="xlf -qextname" $FORCETARGET  LAPACK_FPFLAGS="$LAPACK_FPFLAGS_VAL"  INTERFACE64="$sixty4_int" BINARY="$binary" NUM_THREADS=128 NO_CBLAS=1 NO_LAPACKE=1 DEBUG=0 USE_THREAD="$THREADOPT" libs netlib -j4
else
 make $FORCETARGET  LAPACK_FPFLAGS="$LAPACK_FPFLAGS_VAL"  INTERFACE64="$sixty4_int" BINARY="$binary" NUM_THREADS=128 NO_CBLAS=1 NO_LAPACKE=1 DEBUG=0 USE_THREAD="$THREADOPT" libs netlib -j4
fi

mkdir -p ../../lib
cp libopenblas.a ../../lib/libnwc_openblas.a
#make PREFIX=. install
if [[  ! -z "${NWCHEM_USE_OPENMP}" ]]; then
    export USE_OPENMP=1
fi
if [[ -n ${FCORG} ]]; then
    FC=${FCORG}
fi


#!/bin/bash

# Common message functions.

# Define colours
if [ -t 1 ]; then
  GREEN='\033[1;32m'
  RED='\033[1;31m'
  YELLOW='\033[1;93m'
  BOLD='\033[1m'
  NC='\033[0m' # No Color
fi

error(){
  printf "$RED"'Error'"$NC"'['"$GREEN"'%s'"$NC"']: %s\n' "$(basename "${0}")" "$@"
}

warning(){
  printf "$YELLOW"'Warning'"$NC"'['"$GREEN"'%s'"$NC"']: %s\n' "$(basename "${0}")" "$@"
  __warning_count=$((${__warning_count:-0}+1))
}

# Script functions

beep(){
  # Attempt to make a beep using the motherboard printer.
  # Useful for trying to announce that a task is done on a machine without other speakers.
  # This function will fail quietly if we have no motherboard speaker for whatever reason.
  if [ -w "/dev/tty1" ]; then
    # Default number
    local count
    count=1
    local count_limit
    count_limit=25
    if grep -Pq "^\d{1,}$" <<< "$1" ; then
      if [ "${1}" -gt "$count_limit" ]; then
        # Cap out at a certain number of beeps to prevent accidental typos.
        # If you really want to beep over 15 times, call beep multiple times
        warning "$(printf "Capping beep count at ${BOLD}%s${NC}" "${count_limit}")"
        count=$count_limit
      elif [ "${1}" -gt 0 ]; then
        count=$1
      fi
    fi
    local i
    i=0
    while [ "$i" -lt "$count" ]; do
      echo -e "\07" > /dev/tty1
      i=$((i + 1))
      # Add a small beep to be able to tell individual beeps apart.
      sleep .1
    done
  else
    error "$(printf "${GREEN}%s${NC} is not writable. Cannot attempt a beep." "/dev/tty1")"
    return 1
  fi
}

beep "${1}"


<filename>remove-residual-package-files.sh
#!/bin/sh
sudo dpkg --purge `dpkg --get-selections | grep deinstall | cut -f1`
echo "Done."


#!/bin/bash
base64 --decode --ignore-garbage <<< $DEPLOY_MACHINE_PUBKEY > ~/.ssh/known_hosts
base64 --decode --ignore-garbage <<< $DEPLOY_MACHINE_KEY > ~/.ssh/id_rsa
chmod 400 ~/.ssh/id_rsa

scp -o "BatchMode yes" -P $DEPLOY_MACHINE_PORT -r $TRAVIS_BUILD_DIR/build/* $DEPLOY_MACHINE_USER@$DEPLOY_MACHINE_HOST:$DEPLOY_DIR


<filename>modules/qmail_asf/files/apmail/bin/remove-forwarder.sh
#!/bin/sh

# Usage $0 << space separated list of forwarding accounts to remove >>
#
# NOTE: remove the account from ldap first or a cron will regenerate .qmail-foo!

cd ~apmail || ( echo "Can't cd ~apmail: $?" && exit 1 )

while [ -n "$1" ]
do
    [ -f .qmail-$1 ] && rm -f .qmail-$1 .qmail-$1-default .qmail-$1-owner \
        || echo $1 not found. >&2
    shift;
done


#!/bin/sh

set -e

# install packages
apt-get update

extensions -i bz2 gd imagick mbstring mcrypt mysql redis sqlite3 xml zip

apt-get clean -y

# update permissions to allow rootless operation
/usr/local/bin/permissions


<reponame>stillson/scripts
#!/bin/sh

openssl enc -d -chacha -a -md sha1 -in $1.enc -out $1.dec


<reponame>patrickrand/gamma
#!/bin/bash

WARNING_OVER=50
CRITICAL_OVER=70
DIR=/
while [[ $# > 0 ]]
do
    arg="$1"
    case $arg in
        -w|--warn)
            WARNING_OVER="$2"
            shift
            ;;
        -c|--crit)
            CRITICAL_OVER="$2"
            shift
            ;;
        -*)
            echo "{\"code\": -1, \"message\": \"unrecognized argument ${arg}\"}"
            exit -1
            ;;
         *)
             DIR="$arg"
    esac
    shift
done

USAGE=$(df ${DIR} | awk '{if (NR == 2) print $5}')
USAGE="${USAGE%?}"
function is_gte {
    echo $(awk -v a=$1 -v b=$2 'BEGIN{print (a>b)?1:0}')
}

if [[ $(is_gte "$USAGE" "$CRITICAL_OVER") = 1 ]]; then
    CODE=2
elif [[ $(is_gte "$USAGE" "$WARNING_OVER") = 1 ]]; then
    CODE=1
else
    CODE=0
fi

MESSAGE="${USAGE}% of disk mounted at ${DIR} currently in use"
echo "{\"code\": $CODE, \"message\": \"${MESSAGE}\"}"


<filename>update_changes.sh
#!/bin/bash
#
# taken from: https://github.com/poldracklab/fmriprep/blob/master/update_changes.sh
# Collects the pull-requests since the latest release and
# aranges them in the CHANGES.rst.txt file.
#
# This is a script to be run before releasing a new version.
#
# Usage /bin/bash update_changes.sh 1.0.1
#

# Setting      # $ help set
set -u         # Treat unset variables as an error when substituting.
set -x         # Print command traces before executing command.

# Check whether the Upcoming release header is present
head -1 CHANGELOG.rst | grep -q Upcoming
UPCOMING=$?
if [[ "$UPCOMING" == "0" ]]; then
    head -n3  CHANGELOG.rst >> newchanges
fi

# Elaborate today's release header
HEADER="$1 ($(date '+%B %d, %Y'))"
echo $HEADER >> newchanges
echo $( printf "%${#HEADER}s" | tr " " "=" ) >> newchanges
echo "" >> newchanges

# Search for PRs since previous release
git log --grep="Merge pull request" `git describe --tags --abbrev=0`..HEAD --pretty='format:  * %b %s' | sed  's/Merge pull request \#\([^\d]*\)\ from\ .*/(\#\1)/' >> newchanges
echo "" >> newchanges
echo "" >> newchanges

# Add back the Upcoming header if it was present
if [[ "$UPCOMING" == "0" ]]; then
    tail -n+4 CHANGELOG.rst >> newchanges
else
    cat CHANGELOG.rst >> newchanges
fi

# Replace old CHANGES.rst with new file
mv newchanges CHANGELOG.rst


#!/bin/bash

# cd inst/js_raws
npx webpack
cd ../htmlwidgets/lib/dipterixThreeBrain-1.0.1
rm *.main.js*


#!/bin/bash
set -euo pipefail

# Determine configuration
if [ "$TRAVIS_OS_NAME" == osx ]; then
  FOREIGN_TARGET=i686-apple-darwin
else
  FOREIGN_TARGET=i686-unknown-linux-gnu
fi
export CARGO_EXTRA_FLAGS="--all-features"
export RUSTC_EXTRA_FLAGS="-D warnings"

# Prepare
echo "Build and install miri"
./miri build --all-targets --locked
./miri install # implicitly locked
echo

# Test
function run_tests {
    ./miri test --locked
    # "miri test" has built the sysroot for us, now this should pass without
    # any interactive questions.
    test-cargo-miri/run-test.py
}

echo "Test host architecture"
run_tests
echo

echo "Test foreign architecture ($FOREIGN_TARGET)"
MIRI_TEST_TARGET="$FOREIGN_TARGET" run_tests
echo


#!/bin/sh
#
#  Copyright 1999-2020 ImageMagick Studio LLC, a non-profit organization
#  dedicated to making software imaging solutions freely available.
#
#  You may not use this file except in compliance with the License.  You may
#  obtain a copy of the License at
#
#    https://imagemagick.org/script/license.php
#
#  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.
#
#  Convenience script to verify the ImageMagick build before you install.  For
#  example:
#
#    magick.sh convert -size 640x480 gradient:black-yellow gradient.png

top_srcdir='/home/ec2-user/ImageMagick-7.0.10-41'
top_builddir='/home/ec2-user/ImageMagick-7.0.10-41'

MAGICK_CODER_MODULE_PATH='/home/ec2-user/ImageMagick-7.0.10-41/coders'
MAGICK_CONFIGURE_SRC_PATH='/home/ec2-user/ImageMagick-7.0.10-41/config'
MAGICK_CONFIGURE_BUILD_PATH='/home/ec2-user/ImageMagick-7.0.10-41/config'
MAGICK_FILTER_MODULE_PATH='/home/ec2-user/ImageMagick-7.0.10-41/filters'
DIRSEP=':'

PATH="${top_builddir}/utilities:${PATH}"

if test -n "$VERBOSE"
then
  echo "$@"
fi
env \
  LD_LIBRARY_PATH="${top_builddir}/MagickCore/.libs:${top_builddir}/MagickWand/.libs${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" \
  MAGICK_CODER_MODULE_PATH="${MAGICK_CODER_MODULE_PATH}" \
  MAGICK_CONFIGURE_PATH="${MAGICK_CONFIGURE_BUILD_PATH}${DIRSEP}${MAGICK_CONFIGURE_SRC_PATH}" \
  MAGICK_FILTER_MODULE_PATH="${MAGICK_FILTER_MODULE_PATH}" \
  PATH="${PATH}" \
  "$@"


<reponame>Rajatsharma07/Master-Thesis<gh_stars>0

# Trigger MBM without data augmentation for A->W Scenario
python3 main/main.py --lambda_loss=0.50 --batch_size=16 --architecture="Xception" --resize=299  --epochs=40 --combination="Amazon_to_Webcam" --output_classes=31 --save_model --save_weights

# Trigger CDAN without data augmentation for A->W Scenario
python3 main/main.py --lambda_loss=0.50 --batch_size=16 --architecture="Xception" --resize=299  --epochs=40 --combination="Amazon_to_Webcam" --output_classes=31 --save_model --save_weights --technique

# Trigger MBM with data augmentation for A->W Scenario
python3 main/main.py --lambda_loss=0.50  --batch_size=16 --architecture="Xception" --resize=299  --epochs=40 --combination="Amazon_to_Webcam" --output_classes=31 --save_model --save_weights --augment

# Trigger Pruned MBM without data augmentation for A->W Scenario
python3 main/main.py --lambda_loss=0.50 --batch_size=16 --architecture="Xception" --resize=299  --epochs=40 --combination="Amazon_to_Webcam" --output_classes=31 --save_model --save_weights --prune --prune_val=0.1


#!/bin/sh -e

COLLECTOR_HOME="$(dirname $0)"
export COLLECTOR_HOME

PYTHONPATH="${COLLECTOR_HOME}":"${PYTHONPATH}"
export PYTHONPATH

DJANGO_SETTINGS_MODULE=tests.settings
export DJANGO_SETTINGS_MODULE

cd "${COLLECTOR_HOME}"

django-admin syncdb -v 0

nosetests --with-coverage --cover-erase --cover-html --cover-package=collector "$@"


<gh_stars>1-10
#!/usr/bin/env bash

set -eu

TEMPS_DIRECTORY="temps"
mkdir -p $TEMPS_DIRECTORY

KEYSTORE_FILENAME="kafka.keystore.jks"
VALIDITY_IN_DAYS=3650
DEFAULT_TRUSTSTORE_FILENAME="kafka.truststore.jks"
TRUSTSTORE_WORKING_DIRECTORY="truststore"
KEYSTORE_WORKING_DIRECTORY="keystore"

CA_CERT_FILE="$TEMPS_DIRECTORY/ca-cert"
KEYSTORE_SIGN_REQUEST="$TEMPS_DIRECTORY/cert-file"
KEYSTORE_SIGN_REQUEST_SRL="$TEMPS_DIRECTORY/ca-cert.srl"
KEYSTORE_SIGNED_CERT="$TEMPS_DIRECTORY/cert-signed"

COUNTRY=$COUNTRY
STATE=$STATE
OU=$ORGANIZATION_UNIT
CN=$HOSTNAME
LOCATION=$CITY
PASS=$PASSWORD

function file_exists_and_exit() {
  echo "'$1' cannot exist. Move or delete it before"
  echo "re-running this script."
  exit 1
}

if [ -e "$KEYSTORE_WORKING_DIRECTORY" ]; then
  file_exists_and_exit $KEYSTORE_WORKING_DIRECTORY
fi

if [ -e "$CA_CERT_FILE" ]; then
  file_exists_and_exit $CA_CERT_FILE
fi

if [ -e "$KEYSTORE_SIGN_REQUEST" ]; then
  file_exists_and_exit $KEYSTORE_SIGN_REQUEST
fi

if [ -e "$KEYSTORE_SIGN_REQUEST_SRL" ]; then
  file_exists_and_exit $KEYSTORE_SIGN_REQUEST_SRL
fi

if [ -e "$KEYSTORE_SIGNED_CERT" ]; then
  file_exists_and_exit $KEYSTORE_SIGNED_CERT
fi

echo "Welcome to the Kafka SSL keystore and trust store generator script."

trust_store_file=""
trust_store_private_key_file=""

  if [ -e "$TRUSTSTORE_WORKING_DIRECTORY" ]; then
    file_exists_and_exit $TRUSTSTORE_WORKING_DIRECTORY
  fi

  mkdir $TRUSTSTORE_WORKING_DIRECTORY
  echo
  echo "OK, we'll generate a trust store and associated private key."
  echo
  echo "First, the private key."
  echo

  openssl req -new -x509 -keyout $TRUSTSTORE_WORKING_DIRECTORY/ca-key \
    -out $TRUSTSTORE_WORKING_DIRECTORY/ca-cert -days $VALIDITY_IN_DAYS -nodes \
    -subj "/C=$COUNTRY/ST=$STATE/L=$LOCATION/O=$OU/CN=$CN"

  trust_store_private_key_file="$TRUSTSTORE_WORKING_DIRECTORY/ca-key"

  echo
  echo "Two files were created:"
  echo " - $TRUSTSTORE_WORKING_DIRECTORY/ca-key -- the private key used later to"
  echo "   sign certificates"
  echo " - $TRUSTSTORE_WORKING_DIRECTORY/ca-cert -- the certificate that will be"
  echo "   stored in the trust store in a moment and serve as the certificate"
  echo "   authority (CA). Once this certificate has been stored in the trust"
  echo "   store, it will be deleted. It can be retrieved from the trust store via:"
  echo "   $ keytool -keystore <trust-store-file> -export -alias CARoot -rfc"

  echo
  echo "Now the trust store will be generated from the certificate."
  echo

  keytool -keystore $TRUSTSTORE_WORKING_DIRECTORY/$DEFAULT_TRUSTSTORE_FILENAME \
    -alias CARoot -import -file $TRUSTSTORE_WORKING_DIRECTORY/ca-cert \
    -noprompt -dname "C=$COUNTRY, ST=$STATE, L=$LOCATION, O=$OU, CN=$CN" -keypass $PASS -storepass $PASS

  trust_store_file="$TRUSTSTORE_WORKING_DIRECTORY/$DEFAULT_TRUSTSTORE_FILENAME"

  echo
  echo "$TRUSTSTORE_WORKING_DIRECTORY/$DEFAULT_TRUSTSTORE_FILENAME was created."

  # don't need the cert because it's in the trust store.
  # rm $TRUSTSTORE_WORKING_DIRECTORY/$CA_CERT_FILE

echo
echo "Continuing with:"
echo " - trust store file:        $trust_store_file"
echo " - trust store private key: $trust_store_private_key_file"

mkdir $KEYSTORE_WORKING_DIRECTORY

echo
echo "Now, a keystore will be generated. Each broker and logical client needs its own"
echo "keystore. This script will create only one keystore. Run this script multiple"
echo "times for multiple keystores."
echo
echo "     NOTE: currently in Kafka, the Common Name (CN) does not need to be the FQDN of"
echo "           this host. However, at some point, this may change. As such, make the CN"
echo "           the FQDN. Some operating systems call the CN prompt 'first / last name'"

# To learn more about CNs and FQDNs, read:
# https://docs.oracle.com/javase/7/docs/api/javax/net/ssl/X509ExtendedTrustManager.html

keytool -keystore $KEYSTORE_WORKING_DIRECTORY/$KEYSTORE_FILENAME \
  -alias localhost -validity $VALIDITY_IN_DAYS -genkey -keyalg RSA \
   -noprompt -dname "C=$COUNTRY, ST=$STATE, L=$LOCATION, O=$OU, CN=$CN" -keypass $PASS -storepass $PASS

echo
echo "'$KEYSTORE_WORKING_DIRECTORY/$KEYSTORE_FILENAME' now contains a key pair and a"
echo "self-signed certificate. Again, this keystore can only be used for one broker or"
echo "one logical client. Other brokers or clients need to generate their own keystores."

echo
echo "Fetching the certificate from the trust store and storing in $CA_CERT_FILE."
echo

keytool -keystore $trust_store_file -export -alias CARoot -rfc -file $CA_CERT_FILE -keypass $PASS -storepass $PASS

echo
echo "Now a certificate signing request will be made to the keystore."
echo
keytool -keystore $KEYSTORE_WORKING_DIRECTORY/$KEYSTORE_FILENAME -alias localhost \
  -certreq -file $KEYSTORE_SIGN_REQUEST -keypass $PASS -storepass $PASS

echo
echo "Now the trust store's private key (CA) will sign the keystore's certificate."
echo
openssl x509 -req -CA $CA_CERT_FILE -CAkey $trust_store_private_key_file \
  -in $KEYSTORE_SIGN_REQUEST -out $KEYSTORE_SIGNED_CERT \
  -days $VALIDITY_IN_DAYS -CAcreateserial
# creates $KEYSTORE_SIGN_REQUEST_SRL which is never used or needed.

echo
echo "Now the CA will be imported into the keystore."
echo
keytool -keystore $KEYSTORE_WORKING_DIRECTORY/$KEYSTORE_FILENAME -alias CARoot \
  -import -file $CA_CERT_FILE -keypass $PASS -storepass $PASS -noprompt
rm $CA_CERT_FILE # delete the trust store cert because it's stored in the trust store.

echo
echo "Now the keystore's signed certificate will be imported back into the keystore."
echo
keytool -keystore $KEYSTORE_WORKING_DIRECTORY/$KEYSTORE_FILENAME -alias localhost -import \
  -file $KEYSTORE_SIGNED_CERT -keypass $PASS -storepass $PASS

echo
echo "All done!"
echo
echo "Deleting intermediate files. They are:"
echo " - '$KEYSTORE_SIGN_REQUEST_SRL': CA serial number"
echo " - '$KEYSTORE_SIGN_REQUEST': the keystore's certificate signing request"
echo "   (that was fulfilled)"
echo " - '$KEYSTORE_SIGNED_CERT': the keystore's certificate, signed by the CA, and stored back"
echo "    into the keystore"

rm $KEYSTORE_SIGN_REQUEST_SRL
rm $KEYSTORE_SIGN_REQUEST
rm $KEYSTORE_SIGNED_CERT


<filename>docker-build/add-ons/tomcat/entrypoint.sh
#!/bin/sh

# Simple script to set configure the tutorial
#
if [ "$HOSTNAME" ]
then
  printf 'setting protocol and hostname in web.xml and spa-demo.js'
  sed -i "s+http://localhost+$HOSTNAME+g" /usr/local/tomcat/webapps/ROOT/WEB-INF/web.xml
  sed -i "s+@@service_location@@+$HOSTNAME+g" /usr/local/tomcat/webapps/ROOT/script/spa-demo.js
else
  printf 'HOSTNAME is not set\n'
fi
if [ "$BASEURL" ]
then
  printf 'setting base_url in index.html\n'
  sed -i "s+{base_url}+$BASEURL+g" /usr/local/tomcat/webapps/ROOT/index.html
else
  printf 'BASEURL is not set\n'
fi
if [ "$WEBCLIENTID" ]
then
  printf 'setting web clientId in index.html\n'
  sed -i "s+{web-sdk-client_id}+$WEBCLIENTID+g" /usr/local/tomcat/webapps/ROOT/index.html
else
  printf 'WEBCLIENTID is not set\n'
fi
if [ "$KONGLOCATION" ]
then
  printf 'setting Kong location\n'
  sed -i "s+@@kong_location@@+$KONGLOCATION+g" /usr/local/tomcat/webapps/ROOT/index.html
  sed -i "s+@@kong_location@@+$KONGLOCATION+g" /usr/local/tomcat/webapps/ROOT/script/spa-demo.js
else
  sed -i "s+@@kong_location@@+http://localhost:8090+g" /usr/local/tomcat/webapps/ROOT/index.html
  sed -i "s+@@kong_location@@+http://localhost:8090+g" /usr/local/tomcat/webapps/ROOT/script/spa-demo.js
fi
if [ "$OIDC_PUBLIC_CLIENT_ID" ]
then
  printf 'setting the public OIDC client_id\n'
  sed -i "s+@@oidc_public_client_id@@+$OIDC_PUBLIC_CLIENT_ID+g" /usr/local/tomcat/webapps/ROOT/script/spa-demo.js

  if [ "$OIDC_CONFIG_ENDPOINT" ]
  then
    printf 'setting the OIDC config endpoint\n'
    sed -i "s+@@oidc_config_endpoint@@+$OIDC_CONFIG_ENDPOINT+g" /usr/local/tomcat/webapps/ROOT/script/spa-demo.js
  else
    printf 'the OIDC config endpoint has not been configured, setting default\n'
    sed -i "s+@@oidc_config_endpoint@@+https://oauth2.loginid.io/.well-known/openid-configuration+g" /usr/local/tomcat/webapps/ROOT/script/spa-demo.js
  fi

  if [ "$OIDC_REDIRECT_PUBLIC_CLIENT" ]
  then
    printf 'setting the OIDC redirect_uri\n'
    sed -i "s+@@oidc_public_client_redirect@@+$OIDC_REDIRECT_PUBLIC_CLIENT+g" /usr/local/tomcat/webapps/ROOT/script/spa-demo.js
  else
    printf 'the OIDC redirect_uri has not been configured, setting default\n'
    sed -i "s+@@oidc_public_client_redirect@@+http://localhost/oidc.html+g" /usr/local/tomcat/webapps/ROOT/script/spa-demo.js
  fi

  if [ "$OIDC_SCOPE" ]
  then
    printf 'setting the OIDC scope\n'
    sed -i "s+@@oidc_scope@@+$OIDC_SCOPE+g" /usr/local/tomcat/webapps/ROOT/script/spa-demo.js
  else
    printf 'the OIDC scope has not been configured, setting default\n'
    sed -i "s+@@oidc_scope@@+openid+g" /usr/local/tomcat/webapps/ROOT/script/spa-demo.js
  fi

else
  printf 'the public OIDC client_id has not been configured. The client will be disabled\n'
fi

# configures the listen port for tomcat
#
if [ "$PORT" ]
then
  printf 'setting port\n'
  sed -i "s/@@port@@"/${PORT}/g /usr/local/tomcat/conf/server.xml
else
    printf 'setting default port: 80\n'
    sed -i "s/@@port@@"/80/g /usr/local/tomcat/conf/server.xml
fi

# run the original tomcat entry point command as specified in tomcat's Dockerfile
#
sh /usr/local/tomcat/bin/catalina.sh run


#!/bin/bash
basepath=`cat ../targetDir.txt`
interval=`cat ../syncTime.txt`
ssh=`cat ../ssh.txt`

while [ 1 = 1 ]
do
	scp -r $basepath $ssh:~/;
	sleep $interval;
done


#!/usr/bin/env bash

if [[ "$#" -ne 1 ]]; then
    echo "Expected argument of AWS_PROFILE"
    exit 1
fi

AWS_PROFILE="$1"
export AWS_PROFILE

if [ -d virtual-environments ]; then
    (cd virtual-environments && git pull --ff-only)
else
    git clone https://github.com/actions/virtual-environments
fi

BUILD_DIRECTORY="./build"
TEMPLATE_DIRECTORY="./virtual-environments/images/linux"
UPSTREAM_TEMPLATE="${TEMPLATE_DIRECTORY}/ubuntu1804.json"
BUILDER_FILE="./builder-definition.json"
VARIABLES_FILE="./variables.json"

mkdir -p "$BUILD_DIRECTORY"
rsync -aP --delete "${TEMPLATE_DIRECTORY}/" "${BUILD_DIRECTORY}/"
sed '/waagent/ d' -i "${BUILD_DIRECTORY}/scripts/installers/configure-environment.sh"

jq . < "$UPSTREAM_TEMPLATE" |
    jq --argjson builder "$(< "$BUILDER_FILE")" --argjson variables "$(< "$VARIABLES_FILE")" '. | .builders = [$builder] | .variables = $variables' |
    jq '. | del(."sensitive-variables") | del(.provisioners | last)' > "${BUILD_DIRECTORY}/packer-template.tmp.json"

(
    cd "$BUILD_DIRECTORY" || exit 1
    packer build packer-template.tmp.json
)


<filename>install.sh
#!/bin/sh

mkdir bin
mkdir tmp

printf "IMPACTA version control: \n\n" > version.txt
git log --pretty=format:'%h : %s' --graph >> version.txt
printf "\n\n (Archis made this)" >> version.txt

cd setup
make debug


<filename>bash/scripts/notify.sh
#!/bin/sh
NOTIFY_TEXT=$(zenity --entry --text "Notification Dropper" --title "input text" --width 500)
echo "$NOTIFY_TEXT" | while read NOTIFY_TEXT; do notify-send "$USER" "$NOTIFY_TEXT"; done


<reponame>shrishankit/prisma<gh_stars>1000+
#!/bin/bash

export PRISMA_HOST=localhost

cd postgres
docker-compose up -d
sleep 5s
../deploySchemas.sh relational_v1.1
cd ..
./fetchSchemas.sh relational_v1.1
./dumpPostgres.sh
cd postgres
docker-compose down
cd ..

cd mongodb
docker-compose up -d
sleep 5s
../deploySchemas.sh document
cd ..
./fetchSchemas.sh document
cd mongodb
docker-compose down
cd ..

cd mysql
docker-compose up -d
sleep 5s
../deploySchemas.sh relational_v1.1
cd ..
./dumpMysql.sh
cd mysql
docker-compose down
cd ..


#!/system/bin/sh
# Do NOT assume where your module will be located.
# ALWAYS use $MODDIR if you need to know where this script
# and module is placed.
# This will make sure your module will still work
# if Magisk change its mount point in the future
MODDIR=${0%/*}
# This script will be executed in post-fs-data mode

#Copy original fonts.xml to the MODDIR to overwrite dummy file
cp /system/etc/fonts.xml $MODDIR/system/etc

#Change fonts.xml file
# これだと置き換わらない
# sed -i '@lang="zh-Hans">@,@family>@s@NotoSansCJK-Regular.ttc@Mengshen-Handwritten.ttf@g' $MODDIR/system/etc/fonts.xml

#jp
sed -i 's@NotoSansCJK-Regular.ttc@Mengshen-Handwritten.ttf@g' $MODDIR/system/etc/fonts.xml
sed -i 's@NotoSerifCJK-Regular.ttc@Mengshen-Handwritten.ttf@g' $MODDIR/system/etc/fonts.xml

#Goodbye, SomcUDGothic
sed -i 's@SomcUDGothic-Light.ttf@null.ttf@g' $MODDIR/system/etc/fonts.xml
sed -i 's@SomcUDGothic-Regular.ttf@null.ttf@g' $MODDIR/system/etc/fonts.xml

#Goodbye, OnePlus Font
sed -i 's@OpFont-@Roboto-@g' $MODDIR/system/etc/fonts.xml

#Copy fonts_slate.xml for OnePlus
opslate=fonts_slate.xml
if [ -e /system/etc/$opslate ]; then
    cp /system/etc/$opslate $MODDIR/system/etc

	#Change fonts_slate.xml file
	sed -i 's@NotoSansCJK-Regular.ttc@Mengshen-Handwritten@g' $MODDIR/system/etc/$opslate
	sed -i 's@SlateForOnePlus-Thin.ttf@Mengshen-Handwritten@g' $MODDIR/system/etc/$opslate
fi

#Copy fonts_base.xml for OnePlus OxygenOS 11+
oos11=fonts_base.xml
if [ -e /system/etc/$oos11 ]; then
    cp /system/etc/$oos11 $MODDIR/system/etc

	#Change fonts_slate.xml file
	sed -i 's@NotoSansCJK-Regular.ttc@Mengshen-Handwritten@g' $MODDIR/system/etc/$oos11
	sed -i 's@NotoSerifCJK-Regular.ttc@Mengshen-Handwritten@g' $MODDIR/system/etc/$oos11
fi


<reponame>LauraLangdon/atmo
# /bin/bash

set -e

LIB="/tmp/wasmerio/linux-amd64/libwasmer.so"

if [ $(uname -m) != x86_64 ]
then
	LIB="/tmp/wasmerio/linux-aarch64/libwasmer.so"
fi

echo "using $LIB"

cp $LIB /usr/local/lib

rm -rf /tmp/wasmerio


<filename>concourse/scripts/unit_tests_gpcloud.bash
#!/bin/bash -l

set -exo pipefail

CWDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

function gen_env(){
	cat > ~/run_unit_tests.sh <<-EOF
	set -exo pipefail

	source /opt/gcc_env.sh
	cd "\${1}/gpdb_src/gpAux/extensions/gpcloud"
	make test
	EOF

	chmod a+x ~/run_unit_tests.sh
}

function run_unit_tests() {
	bash -e ~/run_unit_tests.sh $(pwd)
}

function _main() {
	time gen_env

	time run_unit_tests
}

_main "$@"


<filename>rdocker-compose.sh
#!/bin/bash
#rdocker-compose.sh
#usage rdocker-compose <docker-compose command>
#allows the use of a seperate docker_host varible on docker-compose commands without always using it

ARGS=$@ DOCKER_HOST=$RDOCKER_HOST bash -c 'docker-compose $ARGS'


<reponame>shijiansu/microservice-java-dubbo<filename>dubbo-first-try/4_dubbo-registry-nacos/dubbo-provider-nacos/run-stop.sh
#!/bin/bash
FILE=./application.pid
if [[ -f "$FILE" ]]; then
  kill "$(cat "$FILE")" || true
fi


#!/bin/bash
# Modified
rtabmap-kitti_dataset \
      --Optimizer/GravitySigma 0.3 \
      --Rtabmap/DetectionRate 2.0 \
      --RGBD/OptimizeMaxError 1.0 \
      --Odom/ScanKeyFrameThr 0.8 \
      --OdomF2M/ScanMaxSize 10000 \
      --OdomF2M/ScanSubtractRadius 0.5 \
      --GFTT/MinDistance 7 \
      --GFTT/QualityLevel 0.01 \
      --Vis/MaxFeatures 1500 \
      --Kp/MaxFeatures 750 \
      --Mem/STMSize 30 \
      --Mem/RehearsalSimilarity 0.2 \
      --OdomF2M/MaxSize 3000 \
      --Rtabmap/PublishRAMUsage true \
      --Rtabmap/CreateIntermediateNodes true \
      --gt "/home/stuede/Messdaten/kitti_odom_dataset/data/poses/00.txt" \
      "/home/stuede/Messdaten/kitti_odom_dataset/data/sequences/00"

# Original
rtabmap-kitti_dataset \
       --Rtabmap/PublishRAMUsage true\
       --Rtabmap/DetectionRate 2\
       --Rtabmap/CreateIntermediateNodes true\
       --RGBD/LinearUpdate 0\
       --GFTT/QualityLevel 0.01\
       --GFTT/MinDistance 7\
       --OdomF2M/MaxSize 3000\
       --Mem/STMSize 30\
       --Kp/MaxFeatures 750\
       --Vis/MaxFeatures 1500\
       --gt "~/Messdaten/kitti_odom_dataset/data/poses/00.txt"\
       ~/Messdaten/kitti_odom_dataset/data/sequences/00


<gh_stars>1-10
#!/bin/sh
#Gather dotfiles from the running FreeBSD system
#

mkdir -p ~/dotfiles/config
cp -r ~/.config/deadbeef ~/dotfiles/config
cp -r ~/.config/i3status ~/dotfiles/config
cp -r ~/.config/ranger ~/dotfiles/config
cp -r ~/.config/i3 ~/dotfiles/config
cp -r ~/.config/lxterminal ~/dotfiles/config
cp ~/.cshrc_public_version ~/dotfiles/.cshrc
cp ~/.cshrc_root_public_version ~/dotfiles/root_cshrc
cp -r ~/.irssi  ~/dotfiles
#cp -r ~/.local  ~/dotfiles
cp ~/.login_conf  ~/dotfiles
cp ~/.login  ~/dotfiles
cp ~/.profile  ~/dotfiles
cp ~/.shrc  ~/dotfiles
#cp -r ~/.ssh  ~/dotfiles
cp -r ~/.vim  ~/dotfiles
cp ~/.vimrc  ~/dotfiles
cp ~/.xinitrc  ~/dotfiles


<filename>bin/packer/scripts/ec2-provision.sh<gh_stars>10-100
#!/bin/bash

sudo chmod +x /home/centos/000-provision.sh
sudo /home/centos/000-provision.sh

echo 'export PATH=$PATH:/usr/local/go/bin' >> /home/centos/.bash_profile
echo 'export GOPATH=/gopath' >> /home/centos/.bash_profile
chown centos /home/centos/.bash_profile

sudo mkdir -p /gopath/src/github.com/advantageous/
sudo chown centos /gopath/src/github.com/advantageous/
git clone https://github.com/advantageous/systemd-cloud-watch.git /gopath/src/github.com/advantageous/systemd-cloud-watch

sudo chown -R centos /gopath


#!/usr/bin/env bash

# ########################################################################### #
#
# Generate the debian repository and sign it with a given GPG key
#
# ########################################################################### #

TMP_PROGRAM_VERSION="0.2";

# ............................................................................ #
# Prerequisites:
# - gnu utils (apt-get install coreutils)
# - find (apt-get install findutils)
# - sed (apt-get install sed)
# - gpg, GPG key creator (apt-get install gnupg2)
# - aptly, debian repo creator (installation: https://www.aptly.info/download/)
# - wget, http download utility (apt-get install wget)
# - jq, json utility (apt-get install jq)
# - haveged, entropy generator (apt-get install haveged)

# TODO: what happens when there is a clobber of the file during attempt to
#       download it, do we error out and how?

# ............................................................................ #
# turn on tracing of error, this will bubble up all the error codes
# basically this allows the ERR trap is inherited by shell functions
set -o errtrace;
# turn on quiting on first error
set -o errexit;
# error out on undefined variables
set -o nounset;
# propagate pipe errors
set -o pipefail;
# debugging
#set -o xtrace;

# ........................................................................... #
# get script name
TMP_SCRIPT_NAME=$(basename "${0}");
# get full path of the script folder
TMP_SCRIPT_FOLDER="$(cd $(dirname $0); pwd)";
# artly plugin display name, extracted from environment otherwise set to ""
ARTLY_PLUGIN=${ARTLY_PLUGIN:-""}
# aptly script path
ARTLY_SCRIPT_PATH="${ARTLY_SCRIPT_PATH:-}";

# ........................................................................... #
# variables to store script arguments in
# static defaults are set here
# dynamic ones, which are based on other passed in parameters are set in
# process_script_arguments
# TODO: figure out a better way, prolly use -z
TMP_OPTION_OUTPUT_FOLDER="";
TMP_OPTION_REPOSITORY_NAME="";
TMP_OPTION_REPOSITORY_COMPONENT="";
TMP_OPTION_REPOSITORY_DISTRIBUTION="";
TMP_OPTION_SECRET_KEY_FILE="";
declare -a TMP_OPTION_PACKAGE_ENTITIES;
TMP_OPTION_REPOSITORY_ARCHITECTURES="";
TMP_OPTION_REPOSITORY_LABEL="";
TMP_OPTION_REPOSITORY_ORIGIN="";
TMP_OPTION_REPOSITORY_DESCRIPTION="";
TMP_OPTION_PUBLIC_KEY_FILE="";
TMP_OPTION_RECREATE=0;
TMP_OPTION_GPG="";
TMP_OPTION_WORK_FOLDER="";
TMP_OPTION_MACHINE_READABLE=0;

TMP_OPTION_VERBOSE=0;
TMP_OPTION_QUIET=0;
TMP_OPTION_NO_COLOR=0;
TMP_OPTION_DEBUG=0;
TMP_OPTION_VERSION=0;

# verbosity
TMP_WGET_VERBOSITY="";
TMP_GPG_VERBOSITY="";
TMP_RM_VERBOSITY="";
TMP_MKDIR_VERBOSITY="";
TMP_MV_VERBOSITY="";
TMP_CP_VERBOSITY="";
TMP_CHMOD_VERBOSITY="";
TMP_SHRED_VERBOSITY="";

# template for the work folder name
TMP_WORK_FOLDER_NAME_TEMPLATE="/tmp/artly-make-debian-repository.XXXXXXXXXX";

# folder for downloaded packages and copied
TMP_SOURCE_FOLDER="";
# file containing all package enteties (folders, files) to import after
# they been scanned and imported
TMP_PACKAGE_LIST_FILE="";

# aptly work, rootdir and config file
# also the log file for the package import process
TMP_APTLY_IMPORT_LOG="";
TMP_APTLY_WORK_FOLDER=""
TMP_APTLY_ROOTDIR_FOLDER="";
TMP_APTLY_CONFIG_FILE="";

# bin folder for the gpg wrapper
TMP_BIN_FOLDER="";

# keyrings file paths, keyid of the imported key file, imported packages count
TMP_PUBLIC_KEY_FILE="";
TMP_KEYRING_FILE="";
TMP_SECRET_KEYRING_FILE="";
TMP_KEYID="";
TMP_IMPORTED_PACKAGES_COUNT="";

# flag to track if we created the output folder, necessary because of the
# error trapping removing the folder when we did not create it
# default to 0 so this way we do not remove the folder
TMP_CREATED_OUTPUT_FOLDER=0;

# ........................................................................... #
# print script usage
function usage {

    local script_display_name;

    if [ "${ARTLY_PLUGIN}" == "" ]; then
        script_display_name="${TMP_SCRIPT_NAME}";
    else
        script_display_name="${ARTLY_PLUGIN}";
    fi

    echo "\
${script_display_name} - generate and sign Debian package repository

Usage: ${script_display_name} [OPTIONS]

Generate GPG keyring and import it's private, public and keyid into output
folder. Key parameters can be provided on using arguments, though there are
reasonable (though incomplete) defaults.

To understand Debian repository format please read:
https://wiki.debian.org/RepositoryFormat

Options:

    -o, --output-folder <path>
        Repository output folder.

    -n, --name
        Repository name.

    -d, --distribution
        Repository distribution.

    -c, --component
        Repository component.

    -k, --secret-key-file <path>
        Secret key file path. Secret PGP key to sign the repository with.

    -p, --package-location <path>
        Semi-optional, path to local package files or a folders to be scanned
        recursively for packages to import into the repository.

        If you want to specify multiple files of folder quote the argument
        like so: --package-location \"./folder1 /folder2\".

        You can also specify this argument multiple times:
        --package-location \"./folder1 /folder2\" --package-location ./folder3

        IMPORTANT: at least one --package-location or --package-url needs to be
        specified.

    -u, --package-url <url>
        Semi-optional, URL of the package to download and import to the
        repository.

        Same as with --package-location/-p you can specify multiple URLs
        within quotes and can specify --package-url/-u argument multiple times.

        IMPORTANT: at least one --package-location or --package-url needs to be
        specified.

    -a, --architectures
        Optional, repository architectures to publish. By default set to
        'amd64,i386,all,source' which publishes \"amd64\", \"i386\"
        architectures, architecture-independent \"all\" packages and source
        packages. (see Notes Sections for explanation).

        Multiple values should be comma separated without spaces if you do not
        quote them (example -a amd64,i686). Quote the argument \"amd64, i686\"
        if you have spaces.

    --label
        Optional, repository label.

    --origin
        Optional, repository origin.

    --description
        Optional, repository description. If omitted, filled out by aptly
        with it's friendly \"Generated by aptly\" message.

    --public-key <path>
        Optional, file path to the exported public key of the secret key used
        to sign the repository. By default set to \"public.asc\" which means it
        will be placed inside the output folder.

        Common recommended key extension is \".asc\".

        Also the key path must be relative to the output folder and not start
        with \"/\" or contain any \"..\" parts.

    --gpg <gpg path>
        Optional, use the gpg executable specified by <gpg path>. By default
        set to the first gpg executable found on the PATH using \"type -P gpg\"
        command.

    --machine-readable
        Optional, print out colon separated output. This only prints out
        repository information.

    --recreate
        Optional, delete previous output folder by the same name before
        creating it again. Useful when you want to recreate the keys without
        having to do manual removal.

    --work-folder <path>
        Optional, work folder path, needed to generate the keyrings. By default
        the work folder name is created by mktemp using following template
        \"${TMP_WORK_FOLDER_NAME_TEMPLATE}\".

    -v, --verbose
        Optional, turn on verbose output.

    -q, --quiet
        Optional, be as quiet as possible. This really only print the very
        final output and not any \"work in progress\" messages.

    --no-color
        Optional, do not colorize output.

    --debug
        Optional, turn on debug. Currently this means that the work folder is
        not deleted after the script is done so it can be used for inspection.
        Also turn on --verbose/-b option.

    --version
        Print version.

    -h, --help
        show help for this script.

Notes:

    Currently aptly 0.9.7 is unable to publish a repository if all the debian
    packages are architecture independent (a.k.a \"all\" architecture)
    See: https://github.com/smira/aptly/issues/165
    As such we have to force specifying architecture and defaulting it to
    VERY common ones.
";

}

# ........................................................................... #
# ERR EXIT INT TERM signals trap handler which clears the ERR trap, prints out
# script, status code line number of the error then exit
# :{1}: line on which error occured
# :{2}: status code of the errors
# :{3}: signal code of the error
# :globals: ERR EXIT INT TERM
# :error: any errors that occure when trap for ERR EXIT INT TERM is removed
# :trap ERR: clears ERR trap
# :return 0: on success, when no errors occured
# :exit 1: anything code propagated when trap for ERR EXIT INT TERM is removed
function trap_handler {
    # get error line and error description
    local error_line="${1}";
    local exit_code="${2}";
    local error_signal="${3}";

    local frame=0;
    local frame_expression;
    local indent="";

    # clear all traps so we do not hit recusions
    clear_error_traps;

    if [ "${error_signal}" == "ERR" ]; then
        # print out error code
        echo "!! Error in script : $(caller | cut -d' ' -f2)" >&2;
        echo "!! Error exit code : ${exit_code}" >&2;
        echo "!! Error line      : ${error_line}" >&2;
        echo "!! Error signal    : ${error_signal}" >&2;

        echo "----- begin stack trace ----";
        # turn off errtrace and errexit so we can can stop iterating over frames
        # when caller does not return 0 error code
        set +o errtrace;
        set +o errexit;
        while frame_expression=$(caller $frame); do
            echo "${indent}${frame_expression}";
            indent="${indent} ";
            ((frame++));
        done
        # turn exit flags back on
        set -o errtrace;
        set -o errexit;
        echo "----- end stack trace   ----";

        echo "Unexpected script error, deleting output and work folders as \
needed.">&2;
        remove_temporary_directories_and_files;
        exit 1;
    elif [ "${error_signal}" == "TERM" ]; then
        echo "Unexpected script termination, deleting output and work folders \
as needed.">&2;
        remove_temporary_directories_and_files;
        exit 1;
    elif [ "${error_signal}" == "INT" ]; then
        echo "Unexpected script interruption, deleting output and work \
folders as needed.">&2;
        remove_temporary_directories_and_files;
    elif [ "${error_signal}" == "EXIT" ]; then
        if [ ${exit_code} -ne 0 ]; then
            echo "Unexpected script exit, deleting output and work \
folders as needed.">&2;
            remove_temporary_directories_and_files;
        fi
    fi
}

# ............................................................................ #
# clear all (ERR EXIT INT TERM) error traps
function clear_error_traps {
    # clear all traps so we do not hit recusions
    trap - ERR EXIT INT TERM;
}

# ........................................................................... #
# check commands, parse scripts, and run the install/setup steps
function begin () {

    # handle script errors by trapping ERRR
    trap 'trap_handler ${LINENO} $? ERR' ERR;
    trap 'trap_handler ${LINENO} $? EXIT' EXIT;
    trap 'trap_handler ${LINENO} $? INT' INT;
    trap 'trap_handler ${LINENO} $? TERM' TERM;

    # check for commands we use and error out if they are not found
    check_commands;

    # process script arguments
    process_script_arguments "$@";

    # run script arguments (--version for example)
    maybe_run_script_arguments;

    # validate script arguments and set default
    validate_and_default_arguments;

    # enable color, if they are supported
    if [ $TMP_OPTION_NO_COLOR == 1 ]; then
        disable_color_vars;
    else
        maybe_enable_color_vars;
    fi

    # log script paths and various information
    log_script_info;

    # create folders
    create_folders;

    # download packages
    generate_package_list;

    # create aptly config
    create_aptly_config;

    # create new repository
    create_new_repository;

    # import debian packages into the repository
    import_debian_packages_into_repository;

    # create keyrings with an imported secret key file
    create_keyrings;

    # create gpg.conf with with keyring information
    create_gpg_config_file;

    # create gpg executable
    create_gpg_wrapper;

    # publish repository
    publish_repository;

    # export public key;
    export_public_key

    # if not debugging remove the work folder
    if [ ${TMP_OPTION_DEBUG} -eq 0 ]; then
        remove_work_folder;
    fi

    # print repository information
    print_repository_information
}

# ........................................................................... #
# checks for all the commands required for setup and activate
# this does not include the python commands we install
function check_commands {

    local current_aptly_version;
    local required_aptly_version;

    # check for bash 4 or greater
    cmd_exists_at_least_bash4_or_abort;

    # check gnu getop
    cmd_exists_gnu_getopt_or_abort;

    # check for a whole set of commands
    cmds_exists_or_abort \
        "echo" "basename" "dirname" "mkdir" "rm" "rev" "cut" "grep" \
        "find" "sed" "shred" "wget" "jq" "aptly";

    # get current aptly version and compare it to the one we want
    current_aptly_version="$(aptly version | sed 's/aptly version: //g')"
    required_aptly_version="0.9.7";
    version_lte "${required_aptly_version}" "${current_aptly_version}" \
    || abort "Aptly version ${current_aptly_version} is below required \
version ${required_aptly_version}" 1;

}

# ........................................................................... #
# get script params and store them
function process_script_arguments {
    local short_args;
    local long_args="";
    local processed_args;

    short_args="o: n: d: c: k: p: u: a: v q h";
    long_args+="output-folder: name: distribution: component: ";
    long_args+="secret-key-file: package-location: package-url: ";
    long_args+="architectures: label: origin: description: public-key: ";
    long_args+="gpg: recreate machine-readable work-folder: verbose quiet ";
    long_args+="debug version help";

    # if no arguments given print usage
    if [ $# -eq 0 ]; then
        # print usage to stderr since no valid command was provided
        clear_error_traps;
        usage 1>&2;
        echo "No arguments given">&2;
        exit 2;
    fi

    # process the arguments, if failed then print out all unknown arguments
    # and exit with code 2
    processed_args=$(get_getopt "${short_args}" "${long_args}" "$@") \
    || {
        clear_error_traps;
        echo "Unknown argument(s) given: ${processed_args}"; \
        exit 2;
       }

    # set the processed arguments into the $@
    eval set -- "${processed_args}";

    # go over the arguments
    while [ $# -gt 0 ]; do
        case "$1" in

            # store output folder path
            --output-folder | -o)
                TMP_OPTION_OUTPUT_FOLDER="${2}";
                shift;
                ;;

            # store repository name
            --name | -n)
                TMP_OPTION_REPOSITORY_NAME="${2}";
                shift;
                ;;

            # store repository distribution
            --distribution | -d)
                TMP_OPTION_REPOSITORY_DISTRIBUTION="${2}";
                shift;
                ;;

            # store repository component
            --component | -c)
                TMP_OPTION_REPOSITORY_COMPONENT="${2}";
                shift;
                ;;

            # store secret key file path
            --secret-key-file | -k)
                TMP_OPTION_SECRET_KEY_FILE="${2}";
                shift;
                ;;

            # store package location in an array
            --package-location | -p)
                TMP_OPTION_PACKAGE_ENTITIES+=("${1}:${2}")
                shift;
                ;;

            # store package url in an array
            --package-url | -u)
                TMP_OPTION_PACKAGE_ENTITIES+=("${1}:${2}")
                shift;
                ;;

            # store repository architectures
            --architectures | -a)
                TMP_OPTION_REPOSITORY_ARCHITECTURES="${2}";
                shift;
                ;;

            # store repository label
            --label)
                TMP_OPTION_REPOSITORY_LABEL="${2}";
                shift;
                ;;

            # store repository origin
            --origin)
                TMP_OPTION_REPOSITORY_ORIGIN="${2}";
                shift;
                ;;

            # store repository description
            --description)
                TMP_OPTION_REPOSITORY_DESCRIPTION="${2}";
                shift;
                ;;

            # store exported public key
            --public-key)
                TMP_OPTION_PUBLIC_KEY_FILE="${2}";
                shift;
                ;;

            # store gpg executable path
            --gpg)
                TMP_OPTION_GPG="${2}";
                shift;
                ;;

            # store recreate flag
            --recreate)
                TMP_OPTION_RECREATE=1;
                ;;

            # store work folder path
            --work-folder)
                TMP_OPTION_WORK_FOLDER="${2}";
                shift
                ;;

            # store machine readable flag
            --machine-readable)
                TMP_OPTION_MACHINE_READABLE=1;
                ;;

            # store verbose flag
            --verbose | -v)
                TMP_OPTION_VERBOSE=1;
                ;;

            # store quiet flag
            --quiet | -q)
                TMP_OPTION_QUIET=1;
                ;;

            # store no color flag
            --no-color)
                TMP_OPTION_NO_COLOR=1;
                ;;

            # store debug flag
            --debug)
                TMP_OPTION_DEBUG=1;
                ;;

            # store version flag
            --version)
                TMP_OPTION_VERSION=1;
                ;;

            # show usage and quit with code 0
            --help | -h)
                usage;
                exit 0;
                ;;

            # argument end marker
            --)
                # pop the marker of the stack
                shift;
                # there should not be any trailing arguments
                if [ "${#}" -gt 0 ]; then
                    # print usage to stderr exit with code 2
                    clear_error_traps;
                    usage 1>&2;
                    echo "Unknown arguments(s) given: ${@}">&2;
                    exit 2;
                else
                    # if it 0 then break the loop, so the shift at the end
                    # of the for loop did not cause an error
                    break;
                fi
                ;;

            # unknown argument: anything that starts with -
            -*)
                # print usage to stderr, exit with code 2
                clear_error_traps;
                usage 1>&2;
                echo "Unknown argument(s) given: ${1}">&2;
                exit 2;
                ;;

            *)
                # print usage to stderr since no valid command was provided
                clear_error_traps;
                usage 1>&2;
                echo "No arguments given.">&2;
                exit 2;
                ;;
        esac
        shift;
    done

}

# ............................................................................ #
# run functionality specific only to some arguments.
# these are independent arguments not specific to rest of scrip functionality
# (for example, --version)
function maybe_run_script_arguments {

    # check if asked to print version
    if [ "${TMP_OPTION_VERSION}" -eq 1 ]; then
        print_version;
        exit;
    fi

}

# ............................................................................ #
# print out version
function print_version {

    local artly_arguments;

    if [ "${TMP_OPTION_MACHINE_READABLE}" -eq 1 ]; then
        echo "artly-make-debian-repository-version:${TMP_PROGRAM_VERSION}";
        artly_arguments="--machine-readable";
    else
        echo "Artly Make Debian Repository version: ${TMP_PROGRAM_VERSION}";
        artly_arguments="";
    fi

    # print out artly version if the script was run as an Artly plugin
    if [ "${ARTLY_SCRIPT_PATH}" != "" ]; then
        "${ARTLY_SCRIPT_PATH}" \
            ${artly_arguments} \
            --version;
    fi

}

# ........................................................................... #
# validate the set script arguments and set all default values that are
# not set at the top of the script when variable containing them are declared
function validate_and_default_arguments {

    local public_key_check_bad_parts_check;

    # check if repository name is specified, if not abort with message
    if [ "${TMP_OPTION_REPOSITORY_NAME}" == "" ]; then
        abort "Please specify repository name using --name/-n" 1;
    fi

    # check if repository distribution is specified, if not abort with message
    if [ "${TMP_OPTION_REPOSITORY_DISTRIBUTION}" == "" ]; then
        abort \
            "Please specify repository distribution using --distribution/-d" 1;
    fi

    # check if repository component is specified, if not abort with message
    if [ "${TMP_OPTION_REPOSITORY_COMPONENT}" == "" ]; then
        abort "Please specify repository component using --component/-c" 1;
    fi

    # set the default to the common "amd64, all,source" see usage notes for
    # explanation
    if [ "${TMP_OPTION_REPOSITORY_ARCHITECTURES}" == "" ]; then
        TMP_OPTION_REPOSITORY_ARCHITECTURES="amd64,i386,all,source";
    fi

    # check if keyfile is specified, if not abort with message
    if [ "${TMP_OPTION_SECRET_KEY_FILE}" == "" ]; then
        abort "Please specify secret key file using --secret-key-file/-k" 1;
    fi

    # check if the TMP_OPTION_PACKAGE_ENTITIES is empty, if so then no
    # package entries were specified.
    if [ ${#TMP_OPTION_PACKAGE_ENTITIES[@]} -eq 0 ]; then
        abort "Please specify at least one package source using --package-url \
or --package-location" 1;
    fi

    # check if output folder is specified, if not abort with message
    if [ "${TMP_OPTION_OUTPUT_FOLDER}" == "" ]; then
        abort "Please specify output folder using --output-folder/-o" 1;
    fi

    # create a default work folder using a mktemp and
    # TMP_WORK_FOLDER_NAME_TEMPLATE template
    if [ "${TMP_OPTION_WORK_FOLDER}" == "" ]; then
        TMP_OPTION_WORK_FOLDER="$(\
          mktemp \
            --directory \
            --dry-run \
            ${TMP_WORK_FOLDER_NAME_TEMPLATE}
        )";
    fi

    # default virtualenv to gpg executable
    if [ "${TMP_OPTION_GPG}" == "" ]; then
        TMP_OPTION_GPG="$(type -P gpg)";
    fi
    # check if gpg we have found exists
    cmds_exists_or_abort "${TMP_OPTION_GPG}";

    # public key to export, set default if not set
    # also check for ../
    if [ "${TMP_OPTION_PUBLIC_KEY_FILE}" == "" ]; then
        TMP_OPTION_PUBLIC_KEY_FILE="public.asc";
    else
        # get pipe error code safe (using || true) error code of the grep
        # for bad patterns
        public_key_check_bad_parts_check=$(\
            echo "${TMP_OPTION_PUBLIC_KEY_FILE}" \
            | grep \
                --extended-regexp \
                "/\.\.|\.\./|^/" \
            1>/dev/null \
            2>/dev/null;
            echo $?) \
        || true;

        # if we found the patterns grep would exit with 0 as such abort
        if [ ${public_key_check_bad_parts_check} -eq 0 ]; then
            abort "Please specify exported public key path that does not \
start with / and without \"..\" parts" 1
        fi
    fi
    # set TMP_PUBLIC_KEY_FILE to the full path
    TMP_PUBLIC_KEY_FILE="${TMP_OPTION_OUTPUT_FOLDER}/${TMP_OPTION_PUBLIC_KEY_FILE}";

    # if debug then turn on verbosity
    if [ ${TMP_OPTION_DEBUG} -eq 1 ]; then
        TMP_OPTION_VERBOSE=1;
    fi

    # if verbose the set gpg, rm, mkdir verbosity
    if [ ${TMP_OPTION_VERBOSE} -eq 1 ]; then
        TMP_WGET_VERBOSITY="--verbose"
        TMP_GPG_VERBOSITY="--verbose";
        TMP_RM_VERBOSITY="--verbose";
        TMP_MKDIR_VERBOSITY="--verbose";
        TMP_MV_VERBOSITY="--verbose";
        TMP_CP_VERBOSITY="--verbose";
        TMP_CHMOD_VERBOSITY="--verbose";
        TMP_SHRED_VERBOSITY="--verbose";
    else
        TMP_WGET_VERBOSITY="";
        TMP_GPG_VERBOSITY="";
        TMP_RM_VERBOSITY="";
        TMP_MKDIR_VERBOSITY="";
        TMP_MV_VERBOSITY="";
        TMP_CP_VERBOSITY="";
        TMP_CHMOD_VERBOSITY="";
        TMP_SHRED_VERBOSITY="";
    fi

    # if quiet, set verbosity to 0 and enforce the quietest options for
    # those utilities that have it (gpg, rm, mkdir, mv, chmod)
    if [ ${TMP_OPTION_QUIET} -eq 1 ]; then
        TMP_OPTION_VERBOSE=0;

        TMP_WGET_VERBOSITY="--quiet";
        TMP_GPG_VERBOSITY="--quiet";
        TMP_RM_VERBOSITY="";
        TMP_MKDIR_VERBOSITY="";
        TMP_MV_VERBOSITY="";
        TMP_CP_VERBOSITY="";
        TMP_CHMOD_VERBOSITY="--quiet";
        TMP_SHRED_VERBOSITY="";
    fi

    # packages
    TMP_SOURCE_FOLDER="${TMP_OPTION_WORK_FOLDER}/packages_source";
    TMP_PACKAGE_LIST_FILE="${TMP_OPTION_WORK_FOLDER}/package_entities.txt";

    # gpg error log, only available after work folder has been created
    TMP_APTLY_IMPORT_LOG="${TMP_OPTION_WORK_FOLDER}/aptly_import.log"
    # work and roodir folder and config file for aptly
    TMP_APTLY_WORK_FOLDER="${TMP_OPTION_WORK_FOLDER}/aptly"
    TMP_APTLY_ROOTDIR_FOLDER="${TMP_APTLY_WORK_FOLDER}/rootdir";
    TMP_APTLY_CONFIG_FILE="${TMP_APTLY_WORK_FOLDER}/aptly.conf";

    # home dir use to "sandbox" execution of gpg
    TMP_GPG_HOMEDIR_FOLDER="${TMP_OPTION_WORK_FOLDER}/gpg_homedir";
    # gpg.conf options file
    TMP_GPG_CONF_FILE="${TMP_GPG_HOMEDIR_FOLDER}/gpg.conf";
    # bin folder for the gpg script
    TMP_BIN_FOLDER="${TMP_OPTION_WORK_FOLDER}/bin";

}

# ........................................................................... #
# log paths and various scripts information
function log_script_info {

    log_verbose "Repository Name          : ${TMP_OPTION_REPOSITORY_NAME}";
    log_verbose "Repository Distribution  : ${TMP_OPTION_REPOSITORY_DISTRIBUTION}";
    log_verbose "Repository Component     : ${TMP_OPTION_REPOSITORY_COMPONENT}";
    log_verbose "Repository Architectures : ${TMP_OPTION_REPOSITORY_ARCHITECTURES}";
    log_verbose "Secret Key file          : ${TMP_OPTION_SECRET_KEY_FILE}";
    log_verbose "Output folder            : ${TMP_OPTION_OUTPUT_FOLDER}";
    log_verbose "Repository Label         : ${TMP_OPTION_REPOSITORY_LABEL}";
    log_verbose "Repository Origin        : ${TMP_OPTION_REPOSITORY_ORIGIN}";
    if [ "${TMP_OPTION_REPOSITORY_DESCRIPTION}" == "" ]; then
        log_verbose "Repository Description   : ${TMP_OPTION_REPOSITORY_DESCRIPTION}";
    fi
    log_verbose "Recreate                 : $(humanize_bool ${TMP_OPTION_RECREATE})";
    log_verbose "GPG executable           : ${TMP_OPTION_GPG}";
    log_verbose "GPG version              : $(gpg_version ${TMP_OPTION_GPG})";
    log_verbose "Public Key                : ${TMP_PUBLIC_KEY_FILE}";
    log_verbose "Work folder              : ${TMP_OPTION_WORK_FOLDER}";
    log_verbose "GPG homedir              : ${TMP_GPG_HOMEDIR_FOLDER}";
    log_verbose "gpg.conf                 : ${TMP_GPG_CONF_FILE}";
    log_verbose "Debug                    : $(humanize_bool ${TMP_OPTION_DEBUG})";

    for package_entity in "${TMP_OPTION_PACKAGE_ENTITIES[@]}"; do
        package_type="$(echo ${package_entity} | cut -d':' -f1)";
        package_location="$(echo ${package_entity} | cut -d':' -f2-)";
        log_verbose "${package_type} : ${package_location}";
    done

}

# ........................................................................... #
# remove all the temporary folders and files if debug is that
# this removes output and work folder
function remove_temporary_directories_and_files {

    # if debug is NOT set "force" remove output and work folder
    # BUT!!! only remove the output folder if we created it. this helps not to
    # remove it when we remove is attempted from error handling
    if [ ${TMP_OPTION_DEBUG} -eq 0 ]; then
        if [ ${TMP_CREATED_OUTPUT_FOLDER} -eq 1 ]; then
            # remove the work for this script folder if exist
            if [ -d "${TMP_OPTION_OUTPUT_FOLDER}" ]; then
                rm \
                    ${TMP_RM_VERBOSITY} \
                    --recursive \
                    "${TMP_OPTION_OUTPUT_FOLDER}";
                log_unquiet "Removed output folder: \
${TMP_OPTION_OUTPUT_FOLDER}";
            fi
        else
            log_unquiet "Did not remove the output folder, \
since we did not create it.";
        fi

        # always remove work folder
        remove_work_folder;
    fi

}

# ........................................................................... #
# create output, work, homedir folder removing them if needed
# also homedir folder permissions are set at 700
function create_folders {

    # create output folder
    create_output_folder

    # remove work folder if exists, forcing removal if recreate flag is set
    remove_work_folder;
    # create work folder
    mkdir \
        ${TMP_MKDIR_VERBOSITY} \
        --parent \
        "${TMP_OPTION_WORK_FOLDER}";
    log_unquiet "Created work folder: ${TMP_OPTION_WORK_FOLDER}";

    # create source folder for the packages
    mkdir \
        --parent \
        "${TMP_SOURCE_FOLDER}";

    # create aptly work folder
    mkdir \
        --parent \
        "${TMP_APTLY_WORK_FOLDER}";

    # create aptly rootdir
    mkdir \
        --parent \
        "${TMP_APTLY_ROOTDIR_FOLDER}";

    # create bin folder for gpg executable
    mkdir \
        ${TMP_MKDIR_VERBOSITY} \
        --parent \
        "${TMP_BIN_FOLDER}";

}

# ........................................................................... #
# create output folder, remove it if already exists and recreate is true
# otherwise abort suggesting recreate option
function create_output_folder {

    if [ -d "${TMP_OPTION_OUTPUT_FOLDER}" ]; then

        if [ ${TMP_OPTION_RECREATE} -eq 1 ]; then
            # remove the output folder
            rm \
                ${TMP_RM_VERBOSITY} \
                --recursive \
                "${TMP_OPTION_OUTPUT_FOLDER}";
            log_unquiet "Removed output folder: ${TMP_OPTION_OUTPUT_FOLDER}";

            # create output folder
            mkdir \
                ${TMP_MKDIR_VERBOSITY} \
                --parent \
                "${TMP_OPTION_OUTPUT_FOLDER}";

            # set a flag that we created the folder
            TMP_CREATED_OUTPUT_FOLDER=1;

            log_unquiet "Created output folder: ${TMP_OPTION_OUTPUT_FOLDER}";

        else
            abort "Output folder already exists: ${TMP_OPTION_OUTPUT_FOLDER}
Consider --recreate option." 1;
        fi

    else
        # create output folder
        mkdir \
            ${TMP_MKDIR_VERBOSITY} \
            --parent \
            "${TMP_OPTION_OUTPUT_FOLDER}";

        # set a flag that we created the folder
        TMP_CREATED_OUTPUT_FOLDER=1;

        log_unquiet "Created output folder: ${TMP_OPTION_OUTPUT_FOLDER}";
    fi
}

# ........................................................................... #
# Remove work folder if it is exists
function remove_work_folder {

    # remove the work for this script folder if exist
    if [ -d "${TMP_OPTION_WORK_FOLDER}" ]; then
        # shred all the files in the gpg homedir folder, cause private keys
        # and keyrings
        shred_recursively \
           "${TMP_SHRED_VERBOSITY}" \
           "${TMP_GPG_HOMEDIR_FOLDER}";

        rm \
            ${TMP_RM_VERBOSITY} \
            --recursive \
            "${TMP_OPTION_WORK_FOLDER}";

        log_unquiet "Shredded and removed work folder: \
${TMP_OPTION_WORK_FOLDER}";

    fi

}

# ........................................................................... #
# retrieve package from various locations into the source folder for import
# do not clobber files if the already exist
function generate_package_list {

    local package_type;
    local package_locations;
    local package_file;

    # go over each package entity and get it's type and locations
    for package_entities_entry in "${TMP_OPTION_PACKAGE_ENTITIES[@]}"; do

        package_type="$(echo ${package_entities_entry} | cut -d':' -f1)";
        package_locations="$(echo ${package_entities_entry} | cut -d':' -f2-)";

        # go over each location and add it to the TMP_PACKAGE_LIST_FILE
        # download files as necessary and do validation on the paths
        for package_location in ${package_locations}; do
            case "${package_type}" in

                # validate the package_location exists and add it the package
                # list. if this is a folder aptly will scan the folder
                # recursively so just add this locations
                --package-location | -p)
                    if [ ! -e "${package_location}" ]; then
                        abort "Following file or folder specified by ${package_type} is missing: ${package_location}" 1;
                    fi
                    echo "${package_location}" >> "${TMP_PACKAGE_LIST_FILE}";
                    ;;

                # if a url then download to the source folder, without
                # clobbering existing file.
                # create path to the downloaded package in the source folder
                # and record it into the package list
                --package-url | -u)
                    wget \
                        --no-clobber \
                        --directory-prefix="${TMP_SOURCE_FOLDER}" \
                        "${package_location}" \
                    || abort "URL specified by ${package_type} could not be retrieved: ${package_location}" 1;

                    package_file="${TMP_SOURCE_FOLDER}/$(basename ${package_location})";
                    # record package entity
                    echo "${package_file}" >> "${TMP_PACKAGE_LIST_FILE}";
                    ;;

            esac;
        done;
    done;

    # if file does not exist then abort this should never happen, apparently
    if [ ! -e "${TMP_PACKAGE_LIST_FILE}" ]; then
        abort "No packages entries available to import" 1;
    fi

}

# ........................................................................... #
# generate default config for aptly using aptly, adjust the rootDir to proper
# pathing (aptly messes it up) and set the architecture
function create_aptly_config {

    local rootdir_lineno;
    local dot_aptly_conf_file;

    # note: since there is no option to config to specify where the config
    # should be generated and it always generates in $HOME/.aptly.conf
    # additionally, if $HOME/.aptly.conf does already exist stderr is poluted
    # with a message about creating .aptly.conf which presents an issue for
    # logging error. As such we will first create our own .aptly.conf with an
    # empty json object so it is read why 'aptly show' config is ran hence
    # preventing it from poluting stderr. Then we will redirect the output of
    # 'aptly show config' to our custom aptly.conf in TMP_APTLY_CONFIG_FILE.
    dot_aptly_conf_file="${TMP_APTLY_WORK_FOLDER}/.aptly.conf"
    echo "{}" > "${dot_aptly_conf_file}";
    HOME="${TMP_APTLY_WORK_FOLDER}" \
        aptly config show \
        1>"${TMP_APTLY_CONFIG_FILE}" \
    || abort "failed to generate \"aptly.conf\": ${TMP_APTLY_CONFIG_FILE}" 1;

    update_aptly_config_rootdir;
}

# ........................................................................... #
# update aptly.conf rootdir to point TMP_APTLY_ROOTDIR_FOLDER
function update_aptly_config_rootdir {
    # remove the dummy .aptly.conf
    rm \
        ${TMP_RM_VERBOSITY} \
        --force \
        "${dot_aptly_conf_file}" \
    || abort "failed to remove dummy \".aptly.conf\"" 1;

    cat "${TMP_APTLY_CONFIG_FILE}" \
    | jq \
        ".rootDir=\"${TMP_APTLY_ROOTDIR_FOLDER}\"" \
    > "${TMP_APTLY_CONFIG_FILE}.tmp" \
    || abort "failed to update aptly.conf \"rootDir\"" 1;

    mv \
        ${TMP_MV_VERBOSITY} \
        --force \
        "${TMP_APTLY_CONFIG_FILE}.tmp" \
        "${TMP_APTLY_CONFIG_FILE}";

}

# ........................................................................... #
# create repository with components, distribution using aptly
function create_new_repository {

    # aptly has no verbosity setting so we are forced to do redirects
    # setup verbosity redirects for stderr and stdout
    if [ ${TMP_OPTION_VERBOSE} -eq 1 ]; then
        # create 2 handles. 3 goes to stdout, 4 to stderr
        # this way verbosity is printed to their approper
        exec 3>&1;
    else
        exec 3>/dev/null;
    fi

    # create an aptly repository
    aptly \
        -config="${TMP_APTLY_CONFIG_FILE}" \
        repo create \
            -component="${TMP_OPTION_REPOSITORY_COMPONENT}" \
            -distribution="${TMP_OPTION_REPOSITORY_DISTRIBUTION}" \
            "${TMP_OPTION_REPOSITORY_NAME}" \
    1>&3 \
    || abort "failed to create debian repository" 1;

    # close out stdout and stderr verbosity file descriptors
    exec 3>&-;

}

# ........................................................................... #
# add debian packages from origin folder to the repository, replacing existing
# all packages
function import_debian_packages_into_repository {

    # aptly has no verbosity setting so we are forced to do redirects
    # setup verbosity redirects for stderr and stdout
    if [ ${TMP_OPTION_VERBOSE} -eq 1 ]; then
        # create 2 handles. 3 goes to stdout, 4 to stderr
        # this way verbosity is printed to their approper
        exec 3>&1;
    else
        exec 3>/dev/null;
    fi

    # go over package sources and add them to the aptly repository
    while read package_source; do
        log_verbose "package source ${package_source}";
        aptly \
            -config="${TMP_APTLY_CONFIG_FILE}" \
            repo add \
                "${TMP_OPTION_REPOSITORY_NAME}" \
                "${package_source}" \
        1>>"${TMP_APTLY_IMPORT_LOG}" \
        || abort_with_log \
             "${TMP_APTLY_IMPORT_LOG}" \
             "failed to import packages" 1;

        # cat the processing log out if successful and verbose is on
        if [ ${TMP_OPTION_VERBOSE} -eq 1 ]; then
            cat "${TMP_APTLY_IMPORT_LOG}";
        fi

    done < "${TMP_PACKAGE_LIST_FILE}";

    # close out stdout and stderr verbosity file descriptors
    exec 3>&-;

}

# create a gpg keyring using our custome keyring  script with our custom config
# and homedir we will specify it to aptly using PATH. this is currently the
# only way to specify a custom gpg "binary" since aptly does not take it as
# parameter TODO: we should do a PR to aptly
function create_keyrings {

    local keyring_type;
    local keyring_file;
    local make_keyring_output_file;

    make_keyring_info_file="${TMP_OPTION_WORK_FOLDER}/keyring.info"

    "${TMP_SCRIPT_FOLDER}/artly-make-keyring.sh" \
      --output-folder "${TMP_GPG_HOMEDIR_FOLDER}" \
      --key-file "${TMP_OPTION_SECRET_KEY_FILE}" \
      --gpg "${TMP_OPTION_GPG}" \
      --recreate \
      --quiet \
      --machine-readable \
    > "${make_keyring_info_file}" \
    || abort "failed to create a keyring from key file: ${TMP_OPTION_SECRET_KEY_FILE}" 1;

    while read config_line; do
        # get the config key value and value
        config_key="$(echo ${config_line} | cut -d':' -f1)";
        config_value="$(echo ${config_line} | cut -d':' -f2)";
        # assign config values to their respective variables based on
        # config key
        case "$config_key" in
            keyring)
                TMP_KEYRING_FILE="${config_value}";
                ;;
            secret-keyring)
                TMP_SECRET_KEYRING_FILE="${config_value}";
                ;;
            imported-keyid)
                TMP_KEYID="${config_value}";
                ;;
        esac;
    done \
    < "${make_keyring_info_file}";
}

# ........................................................................... #
# create gpg.config file.
# force use of the keyring files and keyid we have
# set gpg.config permissions to 600
function create_gpg_config_file {

# in >=gpg2.1 specifying either or both primary-keyring and keyring in the
# config file has proven to a terrible idea.
#
# For some commands like --list-keys issued during "aptly repo publish" issued
# by aptly having both primary-keyring and keyring settings in the config
# causes gpg to exit with exit code 2 (GPG_ERR_UNKNOWN_PACKET)
#
# in another case, also during "aptly repo publish" signing of the Release file
# the --keyring argument is given to gpg by aptly it also cause gpg to exit
# with code 2 when either primary-keyring or keyring are specified in the
# config
#
#
# So far no good reason for this been found has been found
# only error message seen is:
# gpg: keyblock resource '<some path>/gpg_homedir/pubring.kbx': File exists
#
# As such we will avoid coding these setting in the config file until more
# information is forth comming and rely on sandboxing due to specification
# of --homedir and the fact that only one key is every imported into it
#
# Below are the settings that were used before:
#   no-default-keyring
#   primary-keyring ${TMP_KEYRING_FILE}
#   keyring ${TMP_KEYRING_FILE}
#   secret-keyring ${TMP_SECRET_KEYRING_FILE}
#
# Debug note, add before the gpg binary to see the gpg commands issued:
#   strace -f -s99999 -e trace=clone,execve

    cat >"${TMP_GPG_CONF_FILE}" <<EOF
default-key ${TMP_KEYID}
EOF

    # print out file if verbose
    cat_verbose "${TMP_GPG_CONF_FILE}";

    # change permission gor gpg.conf to the 600 for additional safety
    chmod \
        ${TMP_CHMOD_VERBOSITY} \
        600 \
        "${TMP_GPG_CONF_FILE}";

}

# ........................................................................... #
# create gpg executable to be used by apt publish repo on the PATH
# this script exists mostly because call to the gpg executable is hardcoded
# in aptly to 'gpg'. However currently aptly support for >=gpg 2.1 has some
# issues and not all distros us <gpg 2.1 we need to create a wrapper
# _CUSTOM_GPG_PATH passes in the unmodified PATH which is necessary to look up
# the 'gpg' executable by the same name without getting into an infinite loop
# which would be create if the wrapper which is also name 'gpg' is found on the
# PATH when it is run inside the wrapper.
function create_gpg_wrapper {

    cat >"${TMP_BIN_FOLDER}/gpg" <<EOF
#!/usr/bin/env bash

PATH="\${_CUSTOM_GPG_PATH}" \\
${TMP_OPTION_GPG} \\
    ${TMP_GPG_VERBOSITY} \\
    --options "${TMP_GPG_CONF_FILE}" \\
    --homedir "${TMP_GPG_HOMEDIR_FOLDER}" \\
    \${@};
EOF

    # make the script executable
    chmod \
        ${TMP_CHMOD_VERBOSITY} \
        u+x \
        "${TMP_BIN_FOLDER}/gpg";
}

# ........................................................................... #
# publish the repository, signing it with secret keyid from GPG_KEYID_FILE
# use our custom built gpg script
function publish_repository {

    local formated_architectures;

    # aptly has no verbosity setting so we are forced to do redirects
    # setup verbosity redirects for stderr and stdout
    if [ ${TMP_OPTION_VERBOSE} -eq 1 ]; then
        # create 2 handles. 3 goes to stdout, 4 to stderr
        # this way verbosity is printed to their approper
        exec 3>&1;
    else
        exec 3>/dev/null;
    fi

    # strip any extra whitespace after commans and quote all the architecures
    formated_architectures=$(\
        echo "${TMP_OPTION_REPOSITORY_ARCHITECTURES}" \
        | sed 's/ *//g' \
    );

    # run aptly publish using our gpg wrapper
    # for _CUSTOM_GPG_PATH explanation see create_gpg_wrapper
    _CUSTOM_GPG_PATH="${PATH}" \
    PATH="${TMP_BIN_FOLDER}:${PATH}" \
    aptly \
        -config="${TMP_APTLY_CONFIG_FILE}" \
        publish repo \
            -architectures="${formated_architectures}" \
            -keyring="${TMP_KEYRING_FILE}" \
            -secret-keyring="${TMP_SECRET_KEYRING_FILE}" \
            -gpg-key="${TMP_KEYID}" \
            -label="${TMP_OPTION_REPOSITORY_LABEL}" \
            -origin="${TMP_OPTION_REPOSITORY_ORIGIN}" \
            "${TMP_OPTION_REPOSITORY_NAME}" \
    1>&3 \
    || abort "failed to sign and publish the repository" 1;

    # if description is specified then go over Release and InRelease files
    # in the disttribution and replace the first instance of the "Description:"
    # with "Description:" + TMP_OPTION_REPOSITORY_DESCRIPTION
    if [ "${TMP_OPTION_REPOSITORY_DESCRIPTION}" != "" ]; then
        for release_file in "Release" "InRelease"; do
            sed \
                --in-place \
                "s/^Description:.*/Description: ${TMP_OPTION_REPOSITORY_DESCRIPTION}/" \
                "${TMP_APTLY_ROOTDIR_FOLDER}/public/dists/${TMP_OPTION_REPOSITORY_DISTRIBUTION}/${release_file}";
        done;
    fi

    # close out stdout and stderr verbosity file descriptors
    exec 3>&-;

    # get the count of imported pacakes and store it in
    # TMP_IMPORTED_PACKAGES_COUNT
    TMP_IMPORTED_PACKAGES_COUNT="$(get_repository_package_count)";

    # copy the "public" repository folder inside aptly rootdir to ubuntu folder
    # of the repository output folder

    cp \
        ${TMP_CP_VERBOSITY} \
        --recursive \
        "${TMP_APTLY_ROOTDIR_FOLDER}"/public \
        --no-target-directory \
        "${TMP_OPTION_OUTPUT_FOLDER}" \
    || abort "failed to copy repository to: ${TMP_OPTION_OUTPUT_FOLDER}" 1;

    log_unquiet "Copied repository to output folder: \
${TMP_OPTION_OUTPUT_FOLDER}";

}

# ........................................................................... #
# export public key to public.asc file in output folder
function export_public_key {

    local gpg_error_log;

    # setup verbosity redirects for stdout using a file descriptor
    if [ ${TMP_OPTION_VERBOSE} -eq 1 ]; then
        exec 3>&1;
    else
        exec 3>/dev/null;
    fi

    gpg_error_log="${TMP_OPTION_WORK_FOLDER}/gpg_error.log";

    # export armored public key using the keyid in the keyid file to
    # TMP_OPTION_PUBLIC_KEY_FILE. use --batch so it does not prompt, because it does.
    # so not for the sadness: if gpg fails to export the key it will actuallly
    # print 'gpg: WARNING: nothing exported' to stderr but will still exit
    # with code 0, effectively telling us all is good. As such we will need to
    # do our own check, checking if the file itself was generated
    "${TMP_OPTION_GPG}" \
        ${TMP_GPG_VERBOSITY} \
        --options "${TMP_GPG_CONF_FILE}" \
        --homedir "${TMP_GPG_HOMEDIR_FOLDER}" \
        --batch \
        --export \
        --armor \
        --output "${TMP_PUBLIC_KEY_FILE}" \
        "${TMP_KEYID}"; #\
    1>&3 \
    2>"${gpg_error_log}" \
    || abort_with_log \
        "${gpg_error_log}" \
        "failed to export armored public key to ${TMP_PUBLIC_KEY_FILE}" 1;

    # check if public key file was actually created and if not abort
    if [ ! -f "${TMP_PUBLIC_KEY_FILE}" ]; then
        abort_with_log \
        "${gpg_error_log}" \
        "failed to export armored public key to ${TMP_PUBLIC_KEY_FILE}" 1;
    fi

}

# ........................................................................... #
# get count of imported packages
function get_repository_package_count {

    aptly \
        -config="${TMP_APTLY_CONFIG_FILE}" \
        repo show \
            "${TMP_OPTION_REPOSITORY_NAME}" \
    2>/dev/null \
    | grep "Number of packages: " \
    | cut \
        --delimiter ':' \
        --fields 2 \
    | cut \
        --characters 2;

}

# ........................................................................... #
# print out repository information
function print_repository_information {

    local keyring="${TMP_OPTION_OUTPUT_FOLDER}/";
    keyring="${keyring}$(basename ${TMP_KEYRING_FILE})"

    local secret_keyring="${TMP_OPTION_OUTPUT_FOLDER}/";
    secret_keyring="${secret_keyring}$(basename ${TMP_SECRET_KEYRING_FILE})";

    if [ ${TMP_OPTION_MACHINE_READABLE} -eq 1 ]; then
        echo "repository-name:${TMP_OPTION_REPOSITORY_NAME}";
        echo "repository-distribution:${TMP_OPTION_REPOSITORY_DISTRIBUTION}";
        echo "repository-component:${TMP_OPTION_REPOSITORY_COMPONENT}";
        echo "repository-architectures:${TMP_OPTION_REPOSITORY_ARCHITECTURES}";
        echo "repository-folder:${TMP_OPTION_OUTPUT_FOLDER}";
        echo "repository-label:${TMP_OPTION_REPOSITORY_LABEL}";
        echo "repository-origin:${TMP_OPTION_REPOSITORY_ORIGIN}";
        echo "repository-package-count:${TMP_IMPORTED_PACKAGES_COUNT}";
        echo "public-key:${TMP_PUBLIC_KEY_FILE}";
    else
        log_unquiet "Repository Name           : ${TMP_OPTION_REPOSITORY_NAME}";
        log_unquiet "Repository Distribution   : ${TMP_OPTION_REPOSITORY_DISTRIBUTION}";
        log_unquiet "Repository Component      : ${TMP_OPTION_REPOSITORY_COMPONENT}";
        log_unquiet "Repository Architectures  : ${TMP_OPTION_REPOSITORY_ARCHITECTURES}";
        log_unquiet "Repository Folder         : ${TMP_OPTION_OUTPUT_FOLDER}";
        log_unquiet "Repository Label          : ${TMP_OPTION_REPOSITORY_LABEL}";
        log_unquiet "Repository Origin         : ${TMP_OPTION_REPOSITORY_ORIGIN}";
        log_unquiet "GPG version               : $(gpg_version ${TMP_OPTION_GPG})";
        log_unquiet "Public Key                : ${TMP_PUBLIC_KEY_FILE}";
        log_unquiet "Repository Package Count  : ${TMP_IMPORTED_PACKAGES_COUNT}";
    fi
}

# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ #
# import utils.sh
if [ -f "${TMP_SCRIPT_FOLDER}/utils.sh" ]; then
    source "${TMP_SCRIPT_FOLDER}/utils.sh"
else
    echo "
Could not load required '${TMP_SCRIPT_FOLDER}/utils.sh' module.$

" >&2;
    exit 1;
fi

# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ #
begin "$@";


#!/bin/sh
echo "$(date): executed script - 15 min"


<gh_stars>1-10
#!/bin/sh

scp * pi@192.168.1.4:
ssh -t -t 192.168.1.4 -l pi << 'ENDSSH'
sudo rm -rf "/var/lib/bluetooth/*"
sudo hciconfig hci0 reset
python test1.py
sleep 1
ENDSSH


<reponame>cameronperot/GraphEvolve.jl
#!/bin/bash

cd ./build
python3 -m http.server --bind localhost


#!/bin/sh

cache="./cache.db"
urls="./urls.yaml"
config="./urlwatch.yaml"

options=" --urls $urls --cache $cache --config $config"

if [ "$1" = "-v" ]; then
    ./urlwatch $options -v
    exit
fi

if [ "$1" = "edit" ]; then
    ./urlwatch $options --edit
    exit
fi

if [ "$1" = "test" ]; then
    ./urlwatch $options --test-filter $2
    exit
fi

#./urlwatch --urls ./urls.yaml --config ./urlwatch.yaml


<filename>upload_package_conda.sh
#!/bin/bash

condapath="${HOME}/opt/miniconda3"

# upload packages to conda
echo "Uploading conda package ..."
anaconda login
find $condapath/conda-bld -name "*${version}*.tar.bz2" | while read file
do
    echo $filech
    anaconda upload $file
done

echo "Uploading conda package done!"


<reponame>openeuler-mirror/A-Tune-Collector
#!/bin/sh
# Copyright (c) 2020 Huawei Technologies Co., Ltd.
# A-Tune is licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#     http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# Create: 2020-02-24

lsmod | grep hinic &>/dev/null
ret=$?
[ $ret -ne 0 ] && echo "disable" && exit 0

value=$(cat /sys/bus/pci/drivers/hinic/module/parameters/rx_buff)
echo "$value"


<filename>download_glove.sh
#!/bin/bash
# This script install the Glove dataset
echo "Start downloding the Glove dataset... this may take a while..."
mkdir res
cd ./res
mkdir data
cd data
mkdir glove && cd glove
wget http://nlp.stanford.edu/data/glove.6B.zip
unzip glove.6B.zip
rm glove.6B.zip
cd ..
echo "Bye bye !"


<gh_stars>0
export ANDROID_SDK_ROOT=~/Android/Sdk
export PATH="$PATH:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/tools/bin"

# Use bundled version of Java since Android development only supports Java 8
export JAVA_HOME="/opt/android-studio/jre"
export PATH="$PATH:$JAVA_HOME/bin"


<filename>testscripts/pqt.new.sh<gh_stars>0
#!/bin/sh
date
./conf/deviceid.sh conf/pqt_single.conf
echo 'pqt';sudo ./rvs -c conf/pqt_single.conf -d 3; date


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

#exit if any command fails
set -e

dotnet build