Add horizontal aggregate shell script

Add horizontal aggregate shell script

#!/bin/bash
#
# Description: Run calc_horizontal_aggregate.py over a bunch of files
#

function usage {
    echo "USAGE: bash $0 outdir infiles"
    echo "   outdir:       Output directory"
    echo "   infiles:      Input file names"
    exit 1
}

python=/g/data/e14/dbi599/miniconda3/envs/cmip/bin/python
script_dir=/home/599/dbi599/ocean-analysis/data_processing
outdir=$1
shift
infiles=($@)
basin_file=/g/data/e14/dbi599/CMIP6/CMIP/CSIRO-ARCCSS/ACCESS-CM2/historical/r1i1p1f1/Ofx/basin/gn/v20191108/basin_Ofx_ACCESS-CM2_historical_r1i1p1f1_gn.nc
volume_file=/g/data/fs38/publications/CMIP6/CMIP/CSIRO-ARCCSS/ACCESS-CM2/historical/r1i1p1f1/Ofx/volcello/gn/v20191108/volcello_Ofx_ACCESS-CM2_historical_r1i1p1f1_gn.nc

for infile in "${infiles[@]}"; do
    filename=`echo ${infile} | rev | cut -d / -f 1 | rev`
    outfile=`echo ${filename} | sed s:so_:so-globe-zonal-mean_:`
    command="${python} ${script_dir}/calc_horizontal_aggregate.py ${infile} sea_water_salinity zonal mean ${outdir}/${outfile} --basin ${basin_file} globe --weights ${volume_file}"
    echo ${command}
    ${command}
    echo ${outdir}/${outfile}
done

error: pathspec 'data_processing/calc_horizontal_aggregate.sh' did not match any file(s) known to git


fix bug of installer

fix bug of installer

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/j4ve1in/dotfiles.git/'


Add a release tool to SVN.

Add a release tool to SVN.

git-svn-id: 86a4f41f9d0383640198789122b520d4105b319a@10717 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf

#!/bin/sh -x

svn export http://svn.openlayers.org/tags/openlayers/release-$VERSION OpenLayers-$VERSION
cd OpenLayers-$VERSION/build
./build.py
mkdir /osgeo/openlayers/docs/api/$VERSION
cd ..
cp build/OpenLayers.js /osgeo/openlayers/docs/api/$VERSION
cp -a img/ /osgeo/openlayers/docs/api/$VERSION
cp -a theme/ /osgeo/openlayers/docs/api/$VERSION

# First remove all .pyc files from the directory.
  rm tools/*.pyc
  # move single file version
  cp build/OpenLayers.js OpenLayers.js
  rm build/OpenLayers.js

  cd ..
  mkdir OpenLayers-$VERSION/doc/devdocs
  naturaldocs -i OpenLayers-$VERSION/lib -o HTML OpenLayers-$VERSION/doc/devdocs -p OpenLayers-$VERSION/doc_config -s Default OL
  mkdir OpenLayers-$VERSION/doc/apidocs
  naturaldocs -i OpenLayers-$VERSION/lib -o HTML OpenLayers-$VERSION/doc/apidocs -p OpenLayers-$VERSION/apidoc_config -s Default OL

  tar cvfz OpenLayers-$VERSION.tar.gz OpenLayers-$VERSION/
  cp OpenLayers-$VERSION.tar.gz /osgeo/openlayers/docs/download
  zip -9r OpenLayers-$VERSION.zip OpenLayers-$VERSION/

error: pathspec 'tools/mkrelease.sh' did not match any file(s) known to git


some fixes

some fixes

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/tihlde/TIHLDEscripts.git/'


Update users-add.sh

Update users-add.sh

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/kalise/Kubernetes-Lab-Tutorial.git/'


tests: Add an XFail test for issue #694.

#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
#  * Redistributions of source code must retain the above copyright notice, this list of conditions
#    and the following disclaimer.
#  * Redistributions in binary form must reproduce the above copyright notice, this list of
#    conditions and the following disclaimer in the documentation and/or other materials provided
#    with the distribution.
#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
#    may be used to endorse or promote products derived from this software without specific prior
#    written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------

touch 2

BUFFER=$'echo foo>&2'

expected_region_highlight=(
  '1 4 builtin' # echo
  '6 8 default' # foo
  '9 10 redirection' # >&
  '11 11 file-descriptor "issue #694"' # 2 (not path)
)

error: pathspec 'highlighters/main/test-data/fd-target-not-filename.zsh' did not match any file(s) known to git


Add script for adding certificate to build.keychain

#!/usr/bin/env sh

KEY_CHAIN=build.keychain
CERTIFICATE_P12=certificate.p12

# Recreate the certificate from the secure environment variable
echo $CERTIFICATE_UVaDevAppID_P12 | base64 --decode > $CERTIFICATE_P12

#create a keychain
security create-keychain -p travis $KEY_CHAIN

# Make the keychain the default so identities are found
security default-keychain -s $KEY_CHAIN

# Unlock the keychain
security unlock-keychain -p travis $KEY_CHAIN

security import $CERTIFICATE_P12 -k $KEY_CHAIN -P $CERTIFICATE_PASSWORD -T /usr/bin/codesign;

security set-key-partition-list -S apple-tool:,apple: -s -k travis $KEY_CHAIN

# remove certs
rm -fr *.p12

error: pathspec 'build/add-osx-cert.sh' did not match any file(s) known to git


Added a simple external node script for debugging

This just duplicates the functionality of the old external_node script.
This is mainly a bandaid to keep the current course afloat while we
refactor.

#!/bin/bash

set -e
set -u

CERT=$(puppet master --configprint hostcert)
CACERT=$(puppet master --configprint localcacert)
PRVKEY=$(puppet master --configprint hostprivkey)
CERT_OPTIONS="--cert ${CERT} --cacert ${CACERT} --key ${PRVKEY}"

MASTER="https://$(hostname):443"

curl -k -X GET -H "Accept: text/yaml" ${CERT_OPTIONS} ${MASTER}/nodes/${1}

error: pathspec 'scripts/classroom/external_node.sh' did not match any file(s) known to git


Handle a few errors, which lead to a few classes not being documented.

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/Alexpux/Coin3D.git/'


#3199 run db-benchmark-test and scanscan refs[t:3199]

git-svn-id: b5c078ec0b4d3a50497e9dd3081db18a5b4f16e5@28032 c7de825b-a66e-492c-adef-691d508d4ae1

#!/usr/bin/env bash

function usage() {
    echo "run db-benchmark-test"
    echo "[--tokudb=$tokudb"
    echo "[--revision=$revision]"
    echo "[--branch=$branch]"
    echo "[--suffix=$suffix]"
    echo "[--commit=$commit]"
    echo "[--cc=$cc]"
    echo "[--n=$n]"
}

function retry() {
    local cmd
    local retries
    local exitcode
    cmd=$*
    let retries=0
    while [ $retries -le 10 ] ; do
        echo `date` $cmd
        bash -c "$cmd"
        exitcode=$?
        echo `date` $cmd $exitcode $retries
        let retries=retries+1
        if [ $exitcode -eq 0 ] ; then break; fi
        sleep 10
    done
    test $exitcode = 0
}

n=100
cc=gcc44
brtloader=cilk
branch=toku
revision=0
tokudb=tokudb
suffix=.
commit=0
svnserver=https://svn.tokutek.com/tokudb
basedir=$HOME/svn.build
builddir=$basedir/tokudb.build
system=`uname -s | tr [:upper:] [:lower:]`
arch=`uname -m | tr [:upper:] [:lower:]`
hostname=`hostname`
instancetype=""

# parse the command line
while [ $# -gt 0 ] ; do
    arg=$1; shift
    if [[ $arg =~ --(.*)=(.*) ]] ; then
        eval ${BASH_REMATCH[1]}=${BASH_REMATCH[2]}
    else
        usage; exit 1
    fi
done

# require a revision
if [ $revision -eq 0 ] ; then exit 1; fi

# setup the branchrevision string
if [ $branch = "toku" ] ; then
    branchrevision=$revision
else
    branchrevision=`basename $branch`-$revision
fi
if [ $suffix != "." ] ; then branchrevision=$branchrevision-$suffix; fi

# goto the base directory
if [ ! -d $basedir ] ; then mkdir $basedir; fi

pushd $basedir

# update the build directory
if [ ! -d $builddir ] ; then
    retry svn checkout -q $svnserver/tokudb.build
    exitcode=$?
    if [ $exitcode -ne 0 ] ; then exit 1; fi
else
    pushd $builddir
        retry svn update -q
        exitcode=$?
        if [ $exitcode -ne 0 ] ; then exit 1; fi
    popd
fi

date=`date +%Y%m%d`
testresultsdir=$builddir/$date
pushd $builddir
    while [ ! -d $date ] ; do
        mkdir $date
        svn add $date
        svn commit $date -m ""
        if [ $? -eq 0 ] ; then break; fi
        rm -rf $date
        svn remove $date
        svn update -q
    done
popd

gccversion=`$cc --version|head -1|cut -f3 -d" "`

runfile=$testresultsdir/db-benchmark-test-$branchrevision-$cc-$gccversion-$system-$arch-$hostname
if [ "$instancetype" != "" ] ; then runfile=$runfile-$instancetype; fi
rm -rf $runfile

testresult="PASS"
testdir=db-benchmark-test-$branchrevision
rm -rf $testdir

# checkout the tokudb branch
if [ $testresult = "PASS" ] ; then
    retry svn checkout -q https://svn.tokutek.com/tokudb/$branch/$tokudb
    exitcode=$?
    if [ $exitcode != 0 ] ; then testresult="FAIL"; fi
    mv $tokudb $testdir
fi

# build it
if [ $testresult = "PASS" ] ; then
    pushd $testdir/src
        make local -s CC=$cc GCCVERSION=$gccversion BRTLOADER=$brtloader >>$runfile 2>&1
	exitcode=$?
	if [ $exitcode != 0 ] ; then testresult="FAIL"; fi
    popd
    pushd $testdir/db-benchmark-test
        make build.tdb CC=$cc GCCVERSION=$gccversion -s >>$runfile 2>&1
	exitcode=$?
	if [ $exitcode != 0 ] ; then testresult="FAIL"; fi
    popd
fi

# run tests
if [ $testresult = "PASS" ] ; then
    let i=$n
    pushd $testdir/db-benchmark-test
        echo ./db-benchmark-test-tokudb -x $i >>$runfile 2>&1
        ./db-benchmark-test-tokudb -x $i >>$runfile 2>&1
	exitcode=$?
	if [ $exitcode != 0 ] ; then testresult="FAIL"; fi
	echo ./scanscan-tokudb --prelock --prelockflag >>$runfile 2>&1
	./scanscan-tokudb --prelock --prelockflag >>$runfile 2>&1
	exitcode=$?
	if [ $exitcode != 0 ] ; then testresult="FAIL"; fi
	echo ./scanscan-tokudb --prelock --prelockflag >>$runfile 2>&1
	./scanscan-tokudb --prelock --prelockflag >>$runfile 2>&1
	exitcode=$?
	if [ $exitcode != 0 ] ; then testresult="FAIL"; fi
    popd
fi

if [ $testresult = "PASS" ] ; then
    let i=2*$n
    pushd $testdir/db-benchmark-test
        echo ./db-benchmark-test-tokudb -x --norandom $i >>$runfile 2>&1
        ./db-benchmark-test-tokudb -x --norandom $i >>$runfile 2>&1
	exitcode=$?
	if [ $exitcode != 0 ] ; then testresult="FAIL"; fi
	echo ./scanscan-tokudb --prelock --prelockflag >>$runfile 2>&1
	./scanscan-tokudb --prelock --prelockflag >>$runfile 2>&1
	exitcode=$?
	if [ $exitcode != 0 ] ; then testresult="FAIL"; fi
	echo ./scanscan-tokudb --prelock --prelockflag >>$runfile 2>&1
	./scanscan-tokudb --prelock --prelockflag >>$runfile 2>&1
	exitcode=$?
	if [ $exitcode != 0 ] ; then testresult="FAIL"; fi
    popd
fi

if [ $testresult = "PASS" ] ; then
    let i=2*$n
    pushd $testdir/db-benchmark-test
        echo ./db-benchmark-test-tokudb -x --noserial $i >>$runfile 2>&1
        ./db-benchmark-test-tokudb -x --noserial $i >>$runfile 2>&1
	exitcode=$?
	if [ $exitcode != 0 ] ; then testresult="FAIL"; fi
	echo ./scanscan-tokudb --prelock --prelockflag >>$runfile 2>&1
	./scanscan-tokudb --prelock --prelockflag >>$runfile 2>&1
	exitcode=$?
	if [ $exitcode != 0 ] ; then testresult="FAIL"; fi
	echo ./scanscan-tokudb --prelock --prelockflag >>$runfile 2>&1
	./scanscan-tokudb --prelock --prelockflag >>$runfile 2>&1
	exitcode=$?
	if [ $exitcode != 0 ] ; then testresult="FAIL"; fi
    popd
fi

# commit results
if [ $commit != 0 ] ; then
    svn add $runfile
    retry svn commit -m \"$testresult db-benchmark-test $branchrevision $system $arch\" $runfile
fi

popd

exit 0

error: pathspec 'scripts/run.db-benchmark-test.bash' did not match any file(s) known to git


check for empty var in shell script create release request

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/BMC-RLM/brpm_content_framework.git/'


vlan generation script for installation on openstack instances

error: pathspec 'installation_scripts/controller/scripts/extras/gen_vlans.sh' did not match any file(s) known to git


Added script for recycling Gluster PVs.

Added script for recycling Gluster PVs.

#!/bin/bash
# Script to recycle OpenShift Gluster persistent volumes.
# Capabilities include:
# * Recycle a specific PV (-p)
# * Recycle all PVs in failed state (-a)

# Define environment
## Gluster
gluster_node_ip=

## Temporary mount point for gluster volumes
temp_mount=/mnt/gluster

## Counter for the n parameter (do not change)
i=0

# Check prerequisites
## Check if executed as root
if [[ $EUID -ne 0 ]]; then
  echo "ERROR: This script must be run as root. Aborting."
  exit 1
fi

## Check if executed on OSE master
if ! systemctl status atomic-openshift-master >/dev/null 2>&1; then
  echo "ERROR: This script must be run on an OpenShift master. Aborting."
  exit 1
fi

## FIXME: Is this a good idea? Maybe just abort and output command to execute manually.
## Check if executed as OSE system:admin
if [[ "$(oc whoami)" != "system:admin" ]]; then
  echo "Logging in as user system:admin..."
  echo "oc login -u system:admin > /dev/null"
fi

# Define functions
showsyntax() {
  echo "Syntax: $0 -a|-p GLUSTER_PV_NAME"
  echo "  -a :  Recycle all Gluster PVs in failed state."
}

# Get parameters
while getopts ":ap:" opt; do
  case $opt in
    a)
      # Get all PVs in failed state
      persistent_volumes=($(oc get pv --no-headers | grep -i failed | awk '{print $1}'))

      # Exit if there are no PVs to recycle
      if [ ${#persistent_volumes[@]} -eq 0 ] ; then
        echo "INFO: No PVs in failed state. Exiting."
        exit 0
      fi
      ;;
    p)
      # Get specified PVs (multiple are possible)
      requested_pv=$OPTARG

      # Check if the pv really exists
      if ! oc get pv "$requested_pv" >/dev/null 2>&1; then
        echo "ERROR: Provided PV \"$requested_pv\" does not exist." >&2
        exit 1
      fi

      # Add to pv array
      persistent_volumes[$i]=$requested_pv
      i=$((i+1))
      ;;
    \?)
      echo "ERROR: Invalid option -$OPTARG." >&2
      showsyntax
      exit 1
      ;;
    :)
      echo "ERROR: Option -$OPTARG requires an argument." >&2
      showsyntax
      exit 1
      ;;
  esac
done

shift $((OPTIND-1))

if [ -z $persistent_volumes ]; then
  echo "ERROR: Either choose to recycle all PVs (-a) or specify one (-p)." >&2
  showsyntax
  exit 1
fi

# Get confirmation
echo -e "\nPVs to recycle:"
printf '%s\n' "${persistent_volumes[@]}"

echo -e "\nAll data on these PVs will be erased.\nDo you wish to continue?"
select yn in "Yes" "No"; do
  case $yn in
    Yes) break;;
    No)  exit;;
  esac
done

# Recycle procedure for every single PV
for persistent_volume in "${persistent_volumes[@]}"; do

  # Get size of existing PV
  OIFS="$IFS"
  IFS=';'
  pv_info=($(oc get pv "$persistent_volume" -o template --template='{{.spec.capacity.storage}};{{.spec.glusterfs.path}};{{.spec.glusterfs.endpoints}}' 2>/dev/null))
  pv_size=${pv_info[0]}
  pv_path=${pv_info[1]}
  pv_ep=${pv_info[2]}
  IFS="$OIFS"

  # Delete PV in OpenShift
  oc delete pv "$persistent_volume"

  # Mount GlusterFS volume
  mkdir $temp_mount
  mount -t glusterfs ${gluster_node_ip}:${persistent_volume} $temp_mount

  # Delete GlusterFS volume content
  rm -rf ${temp_mount:?}/*

  # Unmount GlusterFS volume
  umount $temp_mount

  # Recreate PV in OpenShift
  cat <<-EOF | oc create -f -
{
    "kind": "PersistentVolume",
    "apiVersion": "v1",
    "metadata": {
        "name": "${persistent_volume}",
    },
    "spec": {
        "capacity": {
            "storage": "${pv_size}"
        },
        "glusterfs": {
            "endpoints": "${pv_ep}",
            "path": "${pv_path}"
        },
        "accessModes": [
            "ReadWriteOnce",
            "ReadWriteMany"
        ],
        "persistentVolumeReclaimPolicy": "Recycle"
    },
}
EOF

done

error: pathspec 'gluster-recycle-pv.sh' did not match any file(s) known to git


Added 3ds Max plug-in release script.

Added 3ds Max plug-in release script.

#!/bin/sh

# This script can be used to package the builds into ZIP files ready for
# release. It should be executed using a bash compatible shell from this
# directory. The zip utility needs to be available (default on Mac OSX.)

mkdir -p releases;
for f in *.dle; do
    release=${f%.*};
    zip -r releases/$release"_v"$1.zip README.txt maxawd $f;
done;

error: pathspec 'exporters/3dsmax/bin/release.sh' did not match any file(s) known to git


Create install_wireguard_synology.sh

Create install_wireguard_synology.sh

# --- Sources ---
# APK - https://github.com/runfalk/synology-wireguard
# https://wiki.archlinux.org/index.php/WireGuard

mkdir /etc/wireguard/
cd /etc/wireguard/

#--- Generate Public and Private keys ---
wg genkey | tee privatekey | wg pubkey > publickey

cat privatekey
cat pubblickey

#--- Generate Preshared Key ---
umask 077
wg genpsk > preshared_key.psk

#--- Figure out eth0 conn name ---
ip a
#Copy the name (in my case it was: "ovs_eth0" but it could be "eth0" )

#--- Create Config file ---
touch wg0.conf

# --- Create Sample Server Config ---
vi wg0.conf

[Interface]
Address = 10.6.0.1/24
PrivateKey = <Private Key from file>
ListenPort = 51820
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o ovs_eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o ovs_eth0 -j MASQUERADE

[Peer]
PublicKey = <Public Key from file>
AllowedIPs = 10.6.0.2/32

#------ CLIENT SIDE CONFIG -----------
cat preshared_key.psk

#--- Config ---
[Interface]
PrivateKey = <Private Key from file>
Address = 10.6.0.3/24
DNS = 10.6.0.1

[Peer]
PublicKey = <Public Key from file>
PresharedKey = < PRE SHARED KEY from file (preshared_key) >
Endpoint = 10.11.1.50:61820
AllowedIPs = 0.0.0.0/0, ::0/0

error: pathspec 'install_wireguard_synology.sh' did not match any file(s) known to git


reload HAproxy only if required but at least every 15min to clean up dynamic ACLs

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/Hoanoho/HSE.git/'


Add webcam time-lapse script

Add webcam time-lapse script

#!/bin/bash
DATE=$(date +"%Y-%m-%d_%H%M%S")
fswebcam -d /dev/video0 -r 1280x960 --no-banner /home/pi/cam0_$DATE.jpg

error: pathspec 'firmware/verification/webcam.sh' did not match any file(s) known to git


First commit

First commit

#!/bin/bash
# Zimbra's mailboxes backup script

# Date of backup creation
date=`date +%Y%m%d-%H%M`

# Backup path
zimbraBackDir="/mnt/remote/zimbra/"

# Directory where backups will be stored named by date
zimbraBackDirWithDate=$zimbraBackDir$date

# Main maillist of company where all useres included
maillist="all-users@example1.com"

# Excluded accounts
exclude=".*trainee.*"

# Another domain whuch need to backup
domain="example2.com"

# Get all addresses from main maillist without excluded accounts
firstList=`/opt/zimbra/bin/zmprov gdl $maillist | grep zimbraMailForwardingAddress: | grep -v "$exclude" | cut -f 2 -d ' ' -s`

# Get all addresses from domain
secondList=`/opt/zimbra/bin/zmprov -l gaa $domain`

# Concatenate lists
zimbraAccounts="$firstList $secondList"

echo "====================================================="
echo "Log of Zimbra's mailboxes backup by $date"
echo "====================================================="

# Check existing of backup path
if ! [ -d "$zimbraBackDir" ]; then

    mkdir "$zimbraBackDir"

fi

# Check existing directory with date
if [ -d "$zimbraBackDirWithDate" ]; then

    echo "Directory with this name is exist"
    exit 1

else

    mkdir "$zimbraBackDirWithDate"
    echo "Directory with backups has been created $zimbraBackDirWithDate"

fi

# In loop script saves each mailbox in a separate zip archive
for account in $zimbraAccounts;

    do

	if /opt/zimbra/bin/zmmailbox -v -z -m $account getRestURL "//?fmt=zip" > $zimbraBackDirWithDate/$account.zip; then

	    filesize=`du -h $zimbraBackDirWithDate/$account.zip`
	    echo "Account has been backuped $account - $filesize"

	else

	    echo "Backup of $account failed"

	fi

    done

# Backups rotation
if ls -dr -1 $zimbraBackDir** | tail -n+11 | xargs rm -rv; then

    echo "Last 6 backups left, old backups have been deleted. List of existing backup directories:"

else

    echo "Nothing has been deleted. List of existing backup directories:"

fi

# Get list of backup directories
ls $zimbraBackDir
exit 0

error: pathspec 'zmmailboxbackup.sh' did not match any file(s) known to git


Update build.sh

Update build.sh

#!/bin/sh
cd 02-Sourcecode/nfscan-server
mvn clean compile package -Dtarget.env=prod

#!/bin/sh
cd 02-Sourcecode/nfscan-server
pwd
mvn clean compile package -Dtarget.env=prod


Increase warning level

Increase warning level

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/xuanran001/xuanran001-infrastructure.git/'


[MB-1105] add AirshipKit to update_library_reference script

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/ipmobiletech/ios-library.git/'


Added Slackware_15.0/WRF/install_wrfv4.4.sh

#!/bin/bash
#
#  Script to install WRF 4.4 along with its dependencies.
#
#  Copyright (C) 2022 Nitish Ragoomundun, Mauritius
#                     lrugratz       com
#                             @gmail.
#
#  Redistribution and use of this script, with or without modification, is
#  permitted provided that the following conditions are met:
#
#  1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

#
#  The script will first install
#  - netCDF C
#  - netCDF Fortran
#  - OpenMPI
#  - JasPer
#  - udunits
#  - ncview
#
#  Then it will proceed with the installation of WRF, with WPS included. The
#  default installation directory is a directory named wrfv3 in the current
#  user's home. This is done so that the user has permission to write to the
#  directory, as it is often required when using the WRF model.
#
#  NOTE:
#
#  * WRF and WPS are installed in the Distributed Memory Parallel mode (dmpar).
#    If you wish to change this option to the corresponding choice must be
#    changed following each call to the configure script.
#
#  * the tarballs. of appropriate versions, for each of the listed smaller
#    programs, WRF and WPS should be in the same directory as this script.
#

PRGNAM=wrfv4

# WRF version
WRF_VER=4.4
WPS_VER=4.4

# netCDF version
NETCDF_VER=4.7.4

# netCDF Fortran version
NETCDF_F_VER=4.5.3

# OpenMPI version
OPENMPI_VER=4.1.0

# JasPer version
JASPER_VER=1.900.1

# udunits version
UDUNITS_VER=2.2.28

# ncview version
NCVIEW_VER=1.93g

# Set number of parallel threads for compilation process
NUMJOBS=${NUMJOBS:-$(( `nproc --all` - 1 ))}
if [ ${NUMJOBS} -le 0 ]; then
  NUMJOBS=1
fi

USERID=`id -u`
GROUPID=`id -g`

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i486 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

if [ "$ARCH" = "x86_64" ]; then
  LIBDIRSUFFIX="64"
else
  LIBDIRSUFFIX=""
fi

CWD=$(pwd)

# Installation directory
OUTPUT=${OUTPUT:-${HOME}}
PKG=${OUTPUT}/${PRGNAM}

export CC=gcc
export CXX=g++
export FC=gfortran
export F77=gfortran
export CFLAGS="-O2 -fPIC -m64"
export CPPFLAGS=-I${PKG}/deps/grib2/include
export CXXFLAGS=-I${PKG}/deps/grib2/include
export FCFLAGS="-O2 -fPIC -m64"
export FFLAGS="-m64"
export LDFLAGS="-L${PKG}/deps/grib2/lib -L/usr/lib${LIBDIRSUFFIX}"

set -e

rm -rf $PKG
mkdir -p $PKG/{DATA,GEOG,WPS,WRF,deps,utils,build}

###  Initialize environment setup script  ###
echo -e "
#  Initialize environment for WRF

" > ${PKG}/env.sh

###  netCDF  ###
echo
echo "---------------------------------------------------------------"
echo "Building netCDF C ${NETCDF_VER} ..."
echo "---------------------------------------------------------------"
echo
mkdir -p $PKG/deps/netcdf
cd $PKG/build
tar xvf $CWD/netcdf-c-${NETCDF_VER}.tar.gz
cd netcdf-c-${NETCDF_VER}
chown -R ${USERID}:${GROUPID} .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  -o -perm 511 \) -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;

./configure --prefix=${PKG}/deps/netcdf \
            --disable-dap \
            --disable-netcdf-4 \
            --disable-shared \
            --build=$ARCH-slackware-linux

make
make install

export NETCDF=${PKG}/deps/netcdf
export PATH=${NETCDF}/bin:${PATH}
export LD_LIBRARY_PATH=${NETCDF}/lib:${LD_LIBRARY_PATH}

echo -e "
export NETCDF=${PKG}/deps/netcdf
export PATH=\$NETCDF/bin:\$PATH
export LD_LIBRARY_PATH=\$NETCDF/lib:\$LD_LIBRARY_PATH
" >> ${PKG}/env.sh

# Update flags
export LDFLAGS=-L${NETCDF}/lib\ ${LDFLAGS}
export CPPFLAGS=-I${NETCDF}/include\ ${CPPFLAGS}
export CXXFLAGS=-I${NETCDF}/include\ ${CXXFLAGS}
export NETCDF_INC=${NETCDF}/include
export NETCDF_LIB=${NETCDF}/lib

echo
echo "---------------------------------------------------------------"
echo "Building netCDF Fortran ${NETCDF_F_VER} ..."
echo "---------------------------------------------------------------"
echo
cd $PKG/build
tar xvf $CWD/netcdf-fortran-${NETCDF_F_VER}.tar.gz
cd netcdf-fortran-${NETCDF_F_VER}
chown -R ${USERID}:${GROUPID} .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  -o -perm 511 \) -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;

./configure --prefix=${PKG}/deps/netcdf \
            --disable-shared \
            --build=$ARCH-slackware-linux

make
make install

###  OpenMPI  ###
echo
echo "---------------------------------------------------------------"
echo "Building OpenMPI ${OPENMPI_VER} ..."
echo "---------------------------------------------------------------"
echo
mkdir -p $PKG/deps/openmpi
cd $PKG/build
tar xvf $CWD/openmpi-${OPENMPI_VER}.tar.bz2
cd openmpi-${OPENMPI_VER}
chown -R ${USERID}:${USERID} .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  -o -perm 511 \) -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;

./configure --prefix=${PKG}/deps/openmpi \
            --sysconfdir=${PKG}/deps/openmpi/etc \
            --enable-mpi1-compatibility \
            --enable-mpi-fortran=yes \
            --build=$ARCH-slackware-linux

make
make install

export PATH=${PKG}/deps/openmpi/bin:${PATH}
export LD_LIBRARY_PATH=${PKG}/deps/openmpi/lib:${LD_LIBRARY_PATH}

echo -e "
export PATH=${PKG}/deps/openmpi/bin:\$PATH
export LD_LIBRARY_PATH=${PKG}/deps/openmpi/lib:\$LD_LIBRARY_PATH
" >> ${PKG}/env.sh

# Update flags
export LDFLAGS=-L${PKG}/deps/openmpi/lib\ ${LDFLAGS}

###  JasPer library  ###
echo
echo "---------------------------------------------------------------"
echo "Installing JasPer library ..."
echo "---------------------------------------------------------------"
echo
mkdir -p $PKG/deps/grib2
cd $PKG/build
unzip $CWD/jasper-${JASPER_VER}.zip
chmod 755 jasper-${JASPER_VER}
cd jasper-${JASPER_VER}
chown -R ${USERID}:${GROUPID} .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  -o -perm 511 \) -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;

./configure --prefix=${PKG}/deps/grib2 \
            --program-prefix= \
            --program-suffix= \
            --build=$ARCH-slackware-linux

make
make install

export JASPERINC=${PKG}/deps/grib2/include
export JASPERLIB=${PKG}/deps/grib2/lib

echo -e "
export JASPERINC=${PKG}/deps/grib2/include
export JASPERLIB=${PKG}/deps/grib2/lib
" >> ${PKG}/env.sh

###  nvciew  ###
echo
echo "---------------------------------------------------------------"
echo "Building udunits ..."
echo "---------------------------------------------------------------"
echo
mkdir -p $PKG/deps/udunits
cd $PKG/build
tar xvf $CWD/udunits-${UDUNITS_VER}.tar.gz
cd udunits-${UDUNITS_VER}
chown -R ${USERID}:${GROUPID} .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  -o -perm 511 \) -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;

./configure --prefix=${PKG}/deps/udunits \
            --disable-shared \
            --build=$ARCH-slackware-linux

make
make install

find $PKG/deps/udunits -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true

UDUNITS=${PKG}/deps/udunits
export PATH=${UDUNITS}/bin:${PATH}
export LD_LIBRARY_PATH=${UDUNITS}/lib:${LD_LIBRARY_PATH}

echo -e "
export PATH=${UDUNITS}/bin:\$PATH
export LD_LIBRARY_PATH=${UDUNITS}/lib:\$LD_LIBRARY_PATH
" >> ${PKG}/env.sh

echo
echo "---------------------------------------------------------------"
echo "Building ncview ..."
echo "---------------------------------------------------------------"
echo
mkdir -p $PKG/utils/ncview/local/lib
cd $PKG/build
tar xvf $CWD/ncview-${NCVIEW_VER}.tar.gz
cd ncview-${NCVIEW_VER}
chown -R ${USERID}:${GROUPID} .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  -o -perm 511 \) -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;

./configure --prefix=${PKG}/utils/ncview \
            --with-netcdf_incdir=${NETCDF}/include \
            --with-netcdf_libdir=${NETCDF}/lib \
            --with-nc-config=${NETCDF}/bin/nc-config \
            --with-udunits_bindir=${UDUNITS}/bin \
            --with-udunits_incdir=${UDUNITS}/include \
            --build=$ARCH-slackware-linux

make
make install

cp -a *.ncmap nc_overlay.* ${PKG}/utils/ncview/local/lib

find $PKG/utils/ncview -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true

export XAPPLRESDIR=${HOME}/.app-defaults
export PATH=${PKG}/utils/ncview/bin:${PATH}
export LD_LIBRARY_PATH=${PKG}/utils/ncview/lib:${LD_LIBRARY_PATH}

echo -e "
export XAPPLRESDIR=${HOME}/.app-defaults
export PATH=${PKG}/utils/ncview/bin:\$PATH
export LD_LIBRARY_PATH=${PKG}/utils/ncview/lib:\$LD_LIBRARY_PATH
" >> ${PKG}/env.sh

rm -rf $PKG/build

###  WRF  ###
echo
echo "---------------------------------------------------------------"
echo "Building WRF ${WRF_VER} ..."
echo "---------------------------------------------------------------"
echo
tar -C $PKG/WRF --strip-components=1 -zxf $CWD/v${WRF_VER}.tar.gz
cd $PKG/WRF
chown -R ${USERID}:${GROUPID} .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  -o -perm 511 \) -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;

# Clean
./clean -a

# Allow build with GRIB2 support
sed -i '251s/FALSE/TRUE/' arch/Config.pl

# Configure with dmpar
WRF_EM_CORE=1 \
WRFIO_NCD_LARGE_FILE_SUPPORT=1 \
NETCDF_classic=1 \
./configure << EOF
34
1
EOF

echo "Compiling WRF using command"
echo "compile -j ${NUMJOBS} em_real &> ${PKG}/WRF/log.compile"
echo "..."
WRF_EM_CORE=1 \
WRFIO_NCD_LARGE_FILE_SUPPORT=1 \
NETCDF_classic=1 \
./compile -j ${NUMJOBS} em_real &> log.compile

# Check if the executables have been successfully produced
if [ -x main/ndown.exe -a -x main/real.exe -a -x main/tc.exe -a -x main/wrf.exe ]; then
  echo
  echo "The executables ${PKG}/WRF/main/{ndown.exe, real.exe, tc.exe, wrf.exe} have been created successfully."
  echo "----------------------------------------------------------------------"
  echo
else
  echo
  echo "Missing executables from the expected set ${PKG}/WRF/main/{ndown.exe, real.exe, tc.exe, wrf.exe}!"
  echo "Interrupting building process."
  echo
  exit 1
fi

###  WPS  ###
echo
echo "---------------------------------------------------------------"
echo "Building WPS ${WPS_VER} ..."
echo "---------------------------------------------------------------"
echo
tar -C $PKG/WPS --strip-components=1 -zxf $CWD/WPS-${WPS_VER}.tar.gz
cd $PKG/WPS
chown -R ${USERID}:${GROUPID} .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  -o -perm 511 \) -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;

# Clean
./clean

# Configure WPS
WRF_DIR=${PKG}/WRF \
./configure << EOF
3
EOF

# Build
echo "Compiling WPS using command"
echo "compile &> ${PKG}/WPS/log.compile"
echo "..."
WRF_DIR=${PKG}/WRF \
./compile &> log.compile

# Check if the executables have been successfully created
if [ -x geogrid/src/geogrid.exe -a -x metgrid/src/metgrid.exe -a -x ungrib/src/ungrib.exe ]; then
  # Check if the files are zero length
  if [ -s geogrid/src/geogrid.exe -a -s metgrid/src/metgrid.exe -a -s ungrib/src/ungrib.exe ]; then
    echo
    echo "The executables ${PKG}/WPS/{geogrid.exe, metgrid.exe, ungrib.exe} have been created successfully."
    echo "----------------------------------------------------------------------"
    echo
  else
    echo
    echo "Executables ${PKG}/WPS/{geogrid.exe, metgrid.exe, ungrib.exe} exist, but are of zero length!"
    echo
    exit 3
  fi
else
  echo
  echo "Missing executables from the expected set ${PKG}/WPS/{geogrid.exe, metgrid.exe, ungrib.exe} !"
  echo
  exit 2
fi

echo
echo "----------------------------------------------------------------------"
echo "Finished installing WRF, WPS and their dependencies in"
echo "${PKG}/"
echo
echo "You may start using WRF by first setting up the environment with the"
echo "env.sh script from the installation directory:"
echo "> source env.sh"
echo
echo "----------------------------------------------------------------------"
echo

exit 0

error: pathspec 'Slackware_15.0/WRF/install_wrfv4.4.sh' did not match any file(s) known to git


Add gource

Add gource

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/unicell/dotfiles.git/'


Update getopts option list to require argument for -a option

#!/bin/bash
RESULTS=~/working/results
SCRIPTS=~/working/scripts
LOGGING=~/working/results/batch/logs

usage() {
cat << EOF

usage $0 options

This script runs dock_variants using with logging. Intended for submitting jobs
on the cluster.

Example: batch_dock.sh -t 10 -l wt_64 -d ~/working/pdb/wt_64 -p C_B

OPTIONS:
  -h  Show this message
  -t  Number of threads (Mandatory)
  -l  Label for output txt files (Mandatory)
  -d  Directory containing PDB files (Mandatory)
  -f  String passed along with --setup_foldtree to dock_variants.py (optional)
  -p  String passed along with --set_partners to dock_variants.py (optional)
  -s  Passes string "--pam64" to dock_variants.py (optional)
  -a  String passed along with --alt_tool to dock_variants.py (optional)
EOF
}
threads=
label=
pdb_dir=
set_partners=
setup_foldtree=
pam64=
pam_tool=
pam_start=0
pam_end=255

while getopts “ht:l:d:f:p:sa:” OPTION
do
    case $OPTION in
        h)
            usage
            exit 1
            ;;
        t)
            threads=$OPTARG
            ;;
        l)
            label=$OPTARG
            ;;
        d)
            pdb_dir=$OPTARG
            ;;
        f)
            setup_foldtree=$OPTARG
            ;;
        p)
            set_partners=$OPTARG
            ;;
        s)
            pam64=True
            ;;
        a)
            pam_tool=$OPTARG
            ;;
        ?)
            usage
            exit
            ;;
    esac
done

# check mandatory arguments have values
if [ -z $threads ] || [ -z $label ]  || [ -z $pdb_dir ]; then
    echo "ERROR: requires three arguments (threads, label, pdb_dir)"
    usage
    exit 1
fi

# parse optional arguments for dock_variants.py
opt_dock_variants_args=""
if [ ! -z $setup_foldtree ]; then
    echo "Adding '--setup_foldtree $setup_foldtree' argument to dock_variants"
    opt_dock_variants_args+=" --setup_foldtree $setup_foldtree"
fi
if [ ! -z $set_partners ]; then
    echo "Adding '--set-partners $set_partners' argument to dock_variants"
    opt_dock_variants_args+=" --set_partners $set_partners"
fi
if [ ! -z $pam64 ]; then
    echo "Passing '--pam64' argument to dock_variants"
    opt_dock_variants_args+=" --pam64"
    pam_end=63
fi
fi p ! -z $pam_tool]; then
    echo "Adding '--alt_tool $pam_tool' argument to dock_variants"
    opt_dock_variants_args+=" --alt_tool $pam_tool"
fi

# don't write to a directory that already exists
results_dir=$RESULTS/batch/$label
if [ -d $results_dir ]; then
    echo "Directory $results_dir already exists, specify a new label"
    exit 1
fi

range=$(($pam_end-$pam_start+1))
step=$(($range/$threads))
remainder=$(($range % $threads))
pids=()

# amount of remainder to distribute to tasks
remainder_plus=$(($remainder/$threads+1))

# set so pam_first is initially pam_start
pam_last=$(($pam_start-1))

# run docking scripts for ranges in parallel
echo "Launching scripts"
i=0
while [ $i -lt $threads ]; do
    if [ $remainder -lt $(($i+1)) ]; then
        remainder_plus=0
    fi
    pam_first=$(($pam_last+1))
    pam_last=$(($pam_first+$step+$remainder_plus-1))
    log_name="$LOGGING/$label"
    log_name+="_pf_$pam_first"
    log_name+="_pl_$pam_last"
    log_name+="_thread_$i" # name for logging stdout and stderr

    out_name=$log_name
    out_name+="_out.txt"

    err_name=$log_name
    err_name+="_err.txt"

    nohup nice -n 10 python $SCRIPTS/dock_variants.py -s=$pam_first -e=$pam_last --output_dir=$results_dir --pdb_dir=$pdb_dir $opt_dock_variants_args > $out_name 2> $err_name &
    pids+=($!)
    i=$(($i+1))
done

sleep 0.5

for pid in ${pids[*]}; do
    wait $pid
done

sleep 0.5

# run CSV script
echo "Writing to CSV"
python $SCRIPTS/results_csv.py $results_dir

echo "Done!"

#!/bin/bash
RESULTS=~/working/results
SCRIPTS=~/working/scripts
LOGGING=~/working/results/batch/logs

usage() {
cat << EOF

usage $0 options

This script runs dock_variants using with logging. Intended for submitting jobs
on the cluster.

Example: batch_dock.sh -t 10 -l wt_64 -d ~/working/pdb/wt_64 -p C_B

OPTIONS:
  -h  Show this message
  -t  Number of threads (Mandatory)
  -l  Label for output txt files (Mandatory)
  -d  Directory containing PDB files (Mandatory)
  -f  String passed along with --setup_foldtree to dock_variants.py (optional)
  -p  String passed along with --set_partners to dock_variants.py (optional)
  -s  Passes string "--pam64" to dock_variants.py (optional)
  -a  String passed along with --alt_tool to dock_variants.py (optional)
EOF
}
threads=
label=
pdb_dir=
set_partners=
setup_foldtree=
pam64=
pam_tool=
pam_start=0
pam_end=255

while getopts “ht:l:d:f:p:sa” OPTION
do
    case $OPTION in
        h)
            usage
            exit 1
            ;;
        t)
            threads=$OPTARG
            ;;
        l)
            label=$OPTARG
            ;;
        d)
            pdb_dir=$OPTARG
            ;;
        f)
            setup_foldtree=$OPTARG
            ;;
        p)
            set_partners=$OPTARG
            ;;
        s)
            pam64=True
            ;;
        a)
            pam_tool=$OPTARG
            ;;
        ?)
            usage
            exit
            ;;
    esac
done

# check mandatory arguments have values
if [ -z $threads ] || [ -z $label ]  || [ -z $pdb_dir ]; then
    echo "ERROR: requires three arguments (threads, label, pdb_dir)"
    usage
    exit 1
fi

# parse optional arguments for dock_variants.py
opt_dock_variants_args=""
if [ ! -z $setup_foldtree ]; then
    echo "Adding '--setup_foldtree $setup_foldtree' argument to dock_variants"
    opt_dock_variants_args+=" --setup_foldtree $setup_foldtree"
fi
if [ ! -z $set_partners ]; then
    echo "Adding '--set-partners $set_partners' argument to dock_variants"
    opt_dock_variants_args+=" --set_partners $set_partners"
fi
if [ ! -z $pam64 ]; then
    echo "Passing '--pam64' argument to dock_variants"
    opt_dock_variants_args+=" --pam64"
    pam_end=63
fi
fi p ! -z $pam_tool]; then
    echo "Adding '--alt_tool $pam_tool' argument to dock_variants"
    opt_dock_variants_args+=" --alt_tool $pam_tool"
fi

# don't write to a directory that already exists
results_dir=$RESULTS/batch/$label
if [ -d $results_dir ]; then
    echo "Directory $results_dir already exists, specify a new label"
    exit 1
fi

range=$(($pam_end-$pam_start+1))
step=$(($range/$threads))
remainder=$(($range % $threads))
pids=()

# amount of remainder to distribute to tasks
remainder_plus=$(($remainder/$threads+1))

# set so pam_first is initially pam_start
pam_last=$(($pam_start-1))

# run docking scripts for ranges in parallel
echo "Launching scripts"
i=0
while [ $i -lt $threads ]; do
    if [ $remainder -lt $(($i+1)) ]; then
        remainder_plus=0
    fi
    pam_first=$(($pam_last+1))
    pam_last=$(($pam_first+$step+$remainder_plus-1))
    log_name="$LOGGING/$label"
    log_name+="_pf_$pam_first"
    log_name+="_pl_$pam_last"
    log_name+="_thread_$i" # name for logging stdout and stderr

    out_name=$log_name
    out_name+="_out.txt"

    err_name=$log_name
    err_name+="_err.txt"

    nohup nice -n 10 python $SCRIPTS/dock_variants.py -s=$pam_first -e=$pam_last --output_dir=$results_dir --pdb_dir=$pdb_dir $opt_dock_variants_args > $out_name 2> $err_name &
    pids+=($!)
    i=$(($i+1))
done

sleep 0.5

for pid in ${pids[*]}; do
    wait $pid
done

sleep 0.5

# run CSV script
echo "Writing to CSV"
python $SCRIPTS/results_csv.py $results_dir

echo "Done!"


add script to restrict changes on default branch to PRs merged in GUI

#!/bin/bash
#
# This hook restricts changes on the default branch to those made with the GUI Pull Request Merge button, or the Pull Request Merge API.
#
DEFAULT_BRANCH=$(git symbolic-ref HEAD)
while read -r oldrev newrev refname; do
  if [[ "${refname}" != "${DEFAULT_BRANCH:=refs/heads/master}" ]]; then
    exit 0
  else
    if [[ "${GITHUB_VIA}" != 'pull request merge button' && \
          "${GITHUB_VIA}" != 'pull request merge api' ]]; then
      echo "Changes to the default branch must be made by Pull Request. Direct pushes, edits, or merges are not allowed."
      exit 1
    else
      exit 0
    fi
  fi
done

error: pathspec 'pre-receive-hooks/restrict-master-to-gui-pr.sh' did not match any file(s) known to git


Update java-chassis.sh

Update java-chassis.sh

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/huawei-microservice-demo/sockshop-demo.git/'