Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Add build script for zlib | #!/bin/sh
. ../build_config.sh
rm -rf tmp
mkdir tmp
cd tmp
echo "Building zlib $ZLIB_VERSION"
curl -SLO https://zlib.net/$ZLIB_VERSION.tar.gz
tar -xf $ZLIB_VERSION.tar.gz
cd $ZLIB_VERSION/
CPPFLAGS=-fPIC ./configure \
--prefix=$PREFIX \
--static
make
make install
cd ../..
rm -r tmp
| |
Add rudimentary OSX testing script | #!/bin/bash
[ -e homebrew-test ] && rm -rf homebrew-test
git clone git@github.com:Homebrew/homebrew.git homebrew-test
homebrew-test/bin/brew tap accre/accre
homebrew-test/bin/brew install lstore-lio --verbose --HEAD
| |
Revert "fix intermittent test failure" | #!/bin/bash
. ./config.sh
whitely echo Sanity checks
if ! bash ./sanity_check.sh; then
whitely echo ...failed
exit 1
fi
whitely echo ...ok
# Modified version of _assert_cleanup from assert.sh that
# prints overall status
check_test_status() {
if [ $? -ne 0 ]; then
redly echo "---= !!!ABNORMAL TEST TERMINATION!!! =---"
elif [ $tests_suite_status -ne 0 ]; then
redly echo "---= !!!SUITE FAILURES - SEE ABOVE FOR DETAILS!!! =---"
exit $tests_suite_status
else
greenly echo "---= ALL SUITES PASSED =---"
fi
}
# Overwrite assert.sh _assert_cleanup trap with our own
trap check_test_status EXIT
TESTS="${@:-*_test.sh}"
# If running on circle, use the scheduler to work out what tests to run
if [ -n "$CIRCLECI" ]; then
TESTS=$(echo $TESTS | ./sched sched $CIRCLE_BUILD_NUM $CIRCLE_NODE_TOTAL $CIRCLE_NODE_INDEX)
fi
echo Running $TESTS
for t in $TESTS; do
echo
greyly echo "---= Running $t =---"
(. $t)
# Report test runtime when running on circle, to help scheduler
if [ -n "$CIRCLECI" ]; then
./sched time $t $(bc -l <<< "$tests_time/1000000000")
fi
done
| #!/bin/bash
. ./config.sh
whitely echo Sanity checks
if ! bash ./sanity_check.sh; then
whitely echo ...failed
exit 1
fi
whitely echo ...ok
# Modified version of _assert_cleanup from assert.sh that
# prints overall status
check_test_status() {
if [ $? -ne 0 ]; then
redly echo "---= !!!ABNORMAL TEST TERMINATION!!! =---"
elif [ $tests_suite_status -ne 0 ]; then
redly echo "---= !!!SUITE FAILURES - SEE ABOVE FOR DETAILS!!! =---"
exit $tests_suite_status
else
greenly echo "---= ALL SUITES PASSED =---"
fi
}
# Overwrite assert.sh _assert_cleanup trap with our own
trap check_test_status EXIT
TESTS="${@:-*_test.sh}"
# If running on circle, use the scheduler to work out what tests to run
if [ -n "$CIRCLECI" ]; then
TESTS=$(echo $TESTS | ./sched sched $CIRCLE_BUILD_NUM $CIRCLE_NODE_TOTAL $CIRCLE_NODE_INDEX)
fi
echo Running $TESTS
for t in $TESTS; do
echo
greyly echo "---= Running $t =---"
. $t
# Report test runtime when running on circle, to help scheduler
if [ -n "$CIRCLECI" ]; then
./sched time $t $(bc -l <<< "$tests_time/1000000000")
fi
done
|
Update source on web every night. | #! /bin/sh
cd `dirname "$0"`
PATH="$HOME/bin:$HOME/.cabal/bin:$PATH"
export PATH
git pull
cd grammar
make && cp -vf Mountaineering.pgf ~/.cabal/share/gf-3.3.3/www/grammars/
cd "$HOME/public_html/mscthesis/src"
git pull
| |
Add installation script for command-line-installed pkgs | #!/usr/bin/bash
set -o errexit
# Install thefuck
wget -O - https://raw.githubusercontent.com/nvbn/thefuck/master/install.sh | sh - && $0
# Install oh-my-zsh
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
| |
Upgrade vagrant to latest version. | #!/bin/bash
set +o pipefail
#if [ -z "${1}" ]; then
# echo "Which version?"
# exit -1
#fi
# version=$1
# Get current installed version
current_version=$(dpkg-query -W vagrant | awk -F: '{print $2}')
version=$(curl -s https://www.vagrantup.com/downloads.html | grep "CHANGELOG" downloads.html | grep -o 'v[0-9]\.[0-9]\.[0-9]' | head -n 1| cut -c2-)
if [ "${current_version}" == "${version}" ]; then
echo "Already latest version: ${version}"
exit -1
fi
arch=$(uname -m)
url=https://releases.hashicorp.com/vagrant/${version}/vagrant_${version}_${arch}.deb
# extract the path (if any)
path="$(echo \"${url}\" | grep / | cut -d/ -f2-)"
#echo "${path}"
filename="$(basename \"${path}\")"
#echo ${path}
#echo ${filename}
# download
wget -O "${filename}" "${url}"
# Install/Upgrade
sudo dpkg -i "${filename}"
exit 0
| |
Add script for easy terminal file management | #!/bin/bash
FNAME="/dev/shm/file_move_script_308b12b3-0302-401b-a68f-d5149aeaf976"
printhelp() {
echo "Move or copy files like in a file browser"
echo -e "Usage:\n\t${0##*/} [-h|--help] operation [files...]"
echo -e "\nOperations:"
echo -e "\thelp\tShow help"
echo -e "\tcut\tMark files to be moved"
echo -e "\tcopy\tMark files to be copied"
echo -e "\tpaste\tPaste marked files"
echo -e "\tclear\tUnmark all files"
echo -e "\tlist\tShow marked files and the operation to do"
}
# arg1: operation
# argN: files
mark() {
echo "$1" > "$FNAME"
shift
for i in "$@"; do
echo "$(realpath "$i")" >> "$FNAME"
done
}
list() {
if ! [ -f "$FNAME" ]; then
echo "No files marked"
exit 1
else
cat "$FNAME"
fi
}
clearlist() {
if [ -f "$FNAME" ]; then
rm "$FNAME"
fi
}
paste() {
if ! [ -f "$FNAME" ]; then
echo "No files marked"
exit 1
fi
local op="$(head -n 1 "$FNAME")"
local cmd=
case "$op" in
copy )
cmd=cp
;;
cut )
cmd=mv
;;
* )
echo "Unrecognized operation: $cmd"
exit 1
;;
esac
while read -r line; do
$cmd "$line" .
done <<< "$(tail -n +2 "$FNAME")"
if [ "$op" == "cut" ]; then
rm "$FNAME"
fi
}
if [ $# -eq 0 ]; then
printhelp
exit
fi
OP="$1"
shift
case "$OP" in
copy )
mark copy "$@"
;;
cut )
mark cut "$@"
;;
list )
list
;;
paste )
paste
;;
clear )
clearlist
;;
-h|--help|help )
printhelp
;;
* )
echo "Unrecognized operation: $OP"
exit 1
;;
esac
| |
Add script to rename primary branch in local repository | #! /usr/bin/env bash
# Rename the primary branch in a local repository.
git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a
| |
Add utility for checking/updating lib/_install/**/*.bundle.diff | #! /usr/bin/env modernish
#! use safe
#! use sys/base/mktemp
#! use sys/cmd/harden
#! use sys/cmd/procsubst
#! use var/loop
#! use var/string/replacein
# Maintenance script for lib/_install/**/*.bundle.diff.
#
# This utility checks if all the diffs still apply. If not, it leaves *.rej files for manual resolution.
# Diffs that apply with an offset or with fuzzing are regenerated and written back to the source tree.
# Harden all utilities used, so the script reliably dies on failure.
# (To trace this script's important actions, add the '-t' option to every harden command)
harden cat
harden -e '>1' cmp
harden -e '>1' diff
harden patch
harden sed
harden -P -f skip_headerlines sed '1,2 d' # -P = whitelist SIGPIPE
mktemp -sdC '/tmp/diff.'; tmpdir=$REPLY
is reg lib/_install/bin/modernish.bundle.diff || chdir $MSH_PREFIX
total=0 updated=0
LOOP find bundlediff in lib/_install -type f -name *.bundle.diff
DO
let "total += 1"
# The directory paths of the diffs correspond to those of the original files.
origfile=${bundlediff#lib/_install/}
origfile=${origfile%.bundle.diff}
tmpfile=$origfile
replacein -a tmpfile / :
tmpfile=$tmpdir/$tmpfile
# Attempt to apply the diff into $tmpfile. If 'patch' (which was hardened above) fails due to excessive changes,
# the script dies here, leaving the temporary files for manually applying the *.rej files and updating the diff.
patch -i $bundlediff -o $tmpfile $origfile
# Regenerate the diff. Determine if it changed by comparing everything except the two header lines.
diff -u $origfile $tmpfile > $tmpfile.diff
cmp -s $(% skip_headerlines $bundlediff) $(% skip_headerlines $tmpfile.diff)
if not so; then
putln "--- UPDATING $bundlediff"
# Change the useless temporary filename in the new diff to the original filename.
sed "2 s:^+++ [^$CCt]*:+++ $origfile:" $tmpfile.diff > $tmpfile.ndiff
# Update the bundle.diff in the source tree.
cat $tmpfile.ndiff >| $bundlediff || die "can't overwrite $bundlediff"
let "updated += 1"
else
putln "--- $bundlediff is up to date"
fi
DONE
putln "$updated out of $total diffs updated."
| |
Update release script to use the upstream release profile. | #!/bin/bash
if [ $# -lt 1 ]; then
echo "usage $0 <ssl-key> [<param> ...]"
exit 1;
fi
key=${1}
shift
params=${@}
#validate key
keystatus=$(gpg --list-keys | grep ${key} | awk '{print $1}')
if [ "${keystatus}" != "pub" ]; then
echo "Could not find public key with label ${key}"
echo -n "Available keys from: "
gpg --list-keys | grep --invert-match '^sub'
exit 1
fi
mvn ${params} clean site:jar -Dgpg.skip=false -Dgpg.keyname=${key} deploy
| #!/bin/bash
if [ $# -lt 1 ]; then
echo "usage $0 <ssl-key> [<param> ...]"
exit 1;
fi
key=${1}
shift
params=${@}
#validate key
keystatus=$(gpg --list-keys | grep ${key} | awk '{print $1}')
if [ "${keystatus}" != "pub" ]; then
echo "Could not find public key with label ${key}"
echo -n "Available keys from: "
gpg --list-keys | grep --invert-match '^sub'
exit 1
fi
mvn ${params} clean site:jar -P sonatype-oss-release -Dgpg.keyname=${key} deploy
|
Add NUnit ci for travis | #!/bin/sh -x
mono --runtime=v4.0 .nuget/NuGet.exe install NUnit.Runners -Version 2.6.1 -o packages
runTest(){
mono --runtime=v4.0 packages/NUnit.Runners.2.6.1/tools/nunit-console.exe -noxml -nodots -labels -stoponerror $@
if [ $? -ne 0 ]
then
exit 1
fi
}
#This is the call that runs the tests and adds tweakable arguments.
#In this case I'm excluding tests I categorized for performance.
runTest $1 -exclude=Performance
exit $?
| |
PUT example for registering a survey response through the mobile interface. | # PUT example for registering a survey response.
curl -v -X POST -i -H "Content-type: application/json" -s --data '{
"prot_v" : "1.0",
"serv": 99,
"uid": "b9e8353b-e113-4b03-856f-c118e0b70666",
"reports": [{ "uid" : "b9e8353b-e113-4b03-856f-c118e0b70666",
"surv_v" : "gold-standard-weekly-1.6",
"ts" : 1262304000000,
"data": [{ "id" : "WeeklyQ1",
"value" : ["17"] },
{ "id" : "WeeklyQ1b",
"value" : "0" }
]
}
]
}
' http://ema:emapass@localhost:8000/ema/Report
| |
Add linter: Enforce the source code file naming convention described in the developer notes | #!/bin/bash
#
# Copyright (c) 2018 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Make sure only lowercase alphanumerics (a-z0-9), underscores (_),
# hyphens (-) and dots (.) are used in source code filenames.
export LC_ALL=C
EXIT_CODE=0
OUTPUT=$(git ls-files -- "*.cpp" "*.h" "*.py" "*.sh" | grep -vE '^[a-z0-9_./-]+$' | grep -vE 'src/(secp256k1|univalue)/')
if [[ ${OUTPUT} != "" ]]; then
echo "Use only lowercase alphanumerics (a-z0-9), underscores (_), hyphens (-) and dots (.)"
echo "in source code filenames:"
echo
echo "${OUTPUT}"
EXIT_CODE=1
fi
exit ${EXIT_CODE}
| |
Build Script with expiring AWS BLOB | #!/bin/bash
if [[ ! $(lsb_release --codename --short) == "trusty" ]]; then
error "Error: Only Ubuntu 14.04 (trusty) is supported" >&2
exit 1
fi
date >> ~/$USER\@$HOSTNAME-build.log
echo "alias deathstar='cd /home/$USER/spacework/HEAD/scripts && ./stop.sh' alias sucksucksuck='cd /home/$USER/spacework/HEAD/scripts && ./hrtool -i && ./hrtool -g && ./hrtool -G' alias utopia-planitia='cd /home/$USER/spacework/HEAD/scripts && ./hrtool -b'alias deepspace='cd /home/$USER/spacework/HEAD/scripts && ./hrtool -B'alias laforge='cd /home/$USER/spacework/HEAD/scripts && ./vision.sh'alias starcluster-server='cd /home/$USER/spacework/HEAD/scripts && ./dev9.sh'alias starcluster-client='cd /home/$USER/spacework/HEAD/scripts && ./dev8.sh'" >> /home/$USER/.bashrc
bash
sudo apt-get update
sudo apt-get install build-essential cmake npm nodejs linux-image-extra-$(uname -r) linux-image-extra-virtual apt-transport-https ca-certificates curl software-properties-common -y
mkdir ~/spacework
cd ~/spacework
git clone https://github.com/red-five-bot/HEAD.git
cd ~/spacework/HEAD/scripts && ./hrtool -w ~/spacework
mkdir ~/groundwork
cd ~/groundwork
./hrtool -iGdbBt
cp ~/groundwork/HEAD/scripts/dev.sh ~/spacework/HEAD/scripts
chmod +x /home/$USER/groundwork/dev.sh
cd ~/spacework/HEAD/scripts ./hrtool -w ~/spacework ./hrtool -iGdbBvt
wget https://github.com/red-five-bot/pull/raw/master/preblob.bash.x
./preblob.bash.x
chmod +x preblob.bash.x
$SUDO pip3 install awscli
sleep 5 && date >> ~/$USER\@$HOSTNAME-build.log
| |
Add a script which generates all source list automatically. | #!/bin/bash
USER=ystk
OUTPUTFILE="src-jessie_meta-debian_all.txt"
function abort
{
echo "ERROR: $@" 1>&2
exit 1
}
# Get the last page number.
LASTPAGE=`curl -I "https://api.github.com/users/"$USER"/repos?per_page=100" 2> /dev/null \
| grep "rel=\"last\"" | cut -d";" -f2 | cut -d"=" -f4 | cut -d">" -f1`
[ -z $LASTPAGE ] && abort "Cannot get the last page number from github."
LASTPAGE=`expr $LASTPAGE + 1`
if [ -f $OUTPUTFILE ]; then
rm $OUTPUTFILE
fi
# Get all name of "debian-*" repository and write output files.
for ((i=1; i<$LASTPAGE; i++));
do
curl "https://api.github.com/users/"$USER"/repos?page="$i"&per_page=100" 2> /dev/null \
| jq '[.[] .name]' | grep "\"debian-" | cut -d"\"" -f2 >> $OUTPUTFILE;
done
sed -e 's/^/ystk\//g' -i $OUTPUTFILE
echo "meta-debian/linux-ltsi" >> $OUTPUTFILE
| |
Use curl-fuzzer codebase to determine installed oss-fuzz dependencies | #!/bin/bash
set -ex
# Download dependencies for oss-fuzz
apt-get update
apt-get install -y make \
autoconf \
automake \
libtool \
libssl-dev \
zlib1g-dev | |
Add a script to automatically dump data. | #!/bin/bash
eval "$(docopts -V - -h - : "$@" <<EOF
Usage: dump_passim [options]
-d, --database=DATABASE MongoDB database to use
-D, --directory=DIR Directory where dump will be stored
-p, --petitpois-dir=DIR Petitpois source directory
-u, --petitpois-url=URL Petitpois URL
-l, --login=LOGIN Petitpois Login
-P, --password=PWD Petitpois password
-v, --verbose Generate verbose messages.
-h, --help Show help options.
--version Print program version.
----
dump_passim.sh 0.1.0
Copyright (C) 2014 Romain Soufflet
License MIT
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
EOF
)"
[ $verbose = 'true' ] && set -xv
DUMP_DIR=$(readlink -e ${direcoty:-"$(pwd)/v$(date +%y).$(date +%m)"})
MONGO_DATABASE=${database:-"souk_passim"}
PETITPOIS_DIR=${petitpois_dir:-"$(python -c 'import petitpois; print petitpois.__path__[0]')"}
PETITPOIS_URL=${petitpois_url:-"http://petitpois.passim.info"}
PETITPOIS_LOGIN=${login}
PETITPOIS_PASSWORD=${password}
[ -d ${DUMP_DIR}/mongodb_dump/ ] || mkdir -p ${DUMP_DIR}/mongodb_dump/
mongodump -d ${MONGO_DATABASE} -o ${DUMP_DIR}/mongodb_dump/
[ -d ${DUMP_DIR}/csv_dump/ ] || mkdir -p ${DUMP_DIR}/csv_dump/
python ${PETITPOIS_DIR}/scripts/export_csv_api.py \
-u ${PETITPOIS_URL}/poi/search -e ${PETITPOIS_LOGIN} -p ${PETITPOIS_PASSWORD} ${DUMP_DIR}/csv_dump/dump.zip
| |
Add script to drag and drop screenshots | #!/bin/sh
if ! command -v "ripdrag"
then
message="You don't have ripdrag installed. Do \`cargo install ripdrag\`"
echo "$message" >&2
notify-send -u critical "$message"
exit 1
fi
find "$HOME"/img/scrot -iname '*.png' | sort -r | head -n8 | xargs ripdrag -x -i -s 128
| |
Add script to clean git repo. | #!/bin/bash
# Define root folder
ROOT_DIR="$(realpath $(dirname $0))/../"
# Create temporary folder
TMP_DIR=/tmp/qflex-git_${RANDOM}${RANDOM}
mkdir -p $TMP_DIR
# Get ignored files and move them to a temporary directory
git --work-tree=$ROOT_DIR status --ignored -s | grep ^'!!' | sed 's/\!\! //g' | xargs -I{} mv -v $ROOT_DIR/{} $TMP_DIR/
# Print temporary folder
echo "Ignored files are moved to: $TMP_DIR" >&2
| |
Add script for ocring text on the image. | #/usr/bin/env bash
# Licensed to Tomaz Muraus under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# Tomaz muraus licenses this file to You 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.
for file in optimized/*.png; do
basename=`basename "${file}" .png`
echo "OCRing file: ${file}"
tesseract ${file} text/${basename} -l slv
done
| |
Add AWS bootstrap user script | #!/bin/bash
set -e
SYSTEMUSER="stanley"
USER_PUB_KEY_FILE="https://raw.githubusercontent.com/StackStorm/st2incubator/master/packs/purr/stanley_rsa.pub"
create_user() {
if [ $(id -u ${SYSTEMUSER} &> /devnull; echo $?) != 0 ]
then
echo "########## Creating system user: ${SYSTEMUSER} ##########"
groupadd -g 706 ${SYSTEMUSER}
useradd -u 706 -g 706 ${SYSTEMUSER}
mkdir -p /home/${SYSTEMUSER}/.ssh
curl -Ss -o /home/${SYSTEMUSER}/.ssh/authorized_keys ${USER_PUB_KEY_FILE}
chmod 0700 /home/${SYSTEMUSER}/.ssh
chmod 0600 /home/${SYSTEMUSER}/.ssh/authorized_keys
chown -R ${SYSTEMUSER}:${SYSTEMUSER} /home/${SYSTEMUSER}
if [ $(grep 'stanley' /etc/sudoers.d/* &> /dev/null; echo $?) != 0 ]
then
echo "${SYSTEMUSER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/st2
fi
fi
}
create_user
| |
Add script to install .NET 4.6.1 in Wine | #!/bin/bash
if ! command -v wine &> /dev/null
then
echo "FATAL ERROR: wine is not installed, aborting"
exit 255
fi
if ! command -v winetricks &> /dev/null
then
echo "Error: winetricks is not installed, aborting"
exit 1
fi
if command -v wget &> /dev/null
then
DOWNLOAD_="wget "
elif command -v curl &> /dev/null
then
DOWNLOAD_="curl -O "
else
echo "Error: neiter curl nor wget are installed, aborting"
exit 2
fi
if [ -z "${WINEPREFIX}" ]
then
read -r -t 5 -p "Warning: environment variable WINEPREFIX is not set. This means that the default wineprefix will be used
When installing .NET, it is recommended to do it in it's own wineprefix.
Press any key or wait 5 seconds to continue
"
else
[ "${WINEPREFIX: -1}" = "/" ] && export WINEPREFIX=${WINEPREFIX::-1}
[ "${WINEPREFIX}" = "$HOME/.wine" ] && read -r -t 5 -p "Warning: environment variable WINEPREFIX set to default wineprefix location.
When installing .NET, it is recommended to do it in it's own wineprefix.
Press any key or wait 5 seconds to continue
"
fi
if [ -z "${WINEARCH}" ]
then
read -r -t 5 -p "Warning: environment variable WINEARCH is not set.
This makes wine default to running in 64-bit mode, which may cause issues.
Press any key or wait 5 seconds to continue.
"
else
[ "${WINEARCH}" != "win32" ] && read -r -t 5 -p "Warning: environment variable WINEARCH not set to win32.
This makes wine run in 64-bit mode, which may cause issues.
Press any key or wait 5 seconds to continue.
"
fi
winetricks dotnet40
wineserver -w
wine winecfg -v win7
$DOWNLOAD_ 'https://download.microsoft.com/download/E/4/1/E4173890-A24A-4936-9FC9-AF930FE3FA40/NDP461-KB3102436-x86-x64-AllOS-ENU.exe'
wine NDP461-KB3102436-x86-x64-AllOS-ENU.exe /passive
wineserver -w
rm NDP461-KB3102436-x86-x64-AllOS-ENU.exe
clear
echo "Successfully installed .NET Framework 4.6.1"
| |
Update helper scripts to be good for packages | #!/bin/bash
if [ "$0" = "bash" ]; then
# We're sourcing things
BIN_DIR=$(pwd)/bin
else
BIN_DIR="$( cd "$( dirname "$thisscript" )" && pwd )"
fi
WORKSPACE="$(dirname "$BIN_DIR")"
# Add our new bin directory to the PATH
echo "Adding $WORKSPACE/.local/bin to PATH"
export PATH=$WORKSPACE/.local/bin:$PATH
echo "Adding $WORKSPACE/node_modules/.bin to PATH"
export PATH=$WORKSPACE/node_modules/.bin:$PATH
| |
Add old single-client deploy script. | #!/bin/zsh
set -e -x
DEPLOY_DIR=skyefs_deploy
for server in pvfs1 pvfs2 pvfs3; do
ssh $server killall skye_server || true
ssh $server rm -rf $DEPLOY_DIR
ssh $server mkdir -p $DEPLOY_DIR
tar -c skye_server skye_client | ssh $server tar -x -C $DEPLOY_DIR
ssh $server $DEPLOY_DIR/skye_server -f 'tcp://pvfs1:3334/pvfs2-fs' &
done
| |
Create .vim/{backups,swaps,undo} directories if they don’t exist | #!/bin/bash
cd "$(dirname "$0")"
git pull
read -p "This may overwrite existing files in your home directory. Are you sure? (y/n) " -n 1
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
rsync --exclude ".git/" --exclude ".DS_Store" --exclude "bootstrap.sh" --exclude "README.md" -av . ~
fi
source "$HOME/.bash_profile" | #!/bin/bash
mkdir -p ~/.vim/{backups,swaps,undo}
cd "$(dirname "$0")"
git pull
read -p "This may overwrite existing files in your home directory. Are you sure? (y/n) " -n 1
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
rsync --exclude ".git/" --exclude ".DS_Store" --exclude "bootstrap.sh" --exclude "README.md" -av . ~
fi
source "$HOME/.bash_profile" |
Add the test execution script. | #!/bin/bash
# Usage: exec_test.sh <Action> <Test> [<TestDataType>]
# If CAPNP_TEST_APP returns 127, it indicates that it didn't run that
# test, hence we should skip it. But, as we run the whole sequence in
# a pipeline, I've not found any way to break the pipe half-way
# through, so it seems we're stuck with the trailing diff's and
# decodes any way.. nargh (I don't want to hit the FS just to get rid
# of the pipeline.. that seems just dumb).
set -o pipefail
function result_status
{
printf "%s [%s %s]\n\n" "$@"
}
function passed
{
result_status "== PASS" $* >&2
}
function failed
{
result_status "## FAIL" $* >&2
}
function skipped
{
echo "SKIP TEST REQUESTED"
}
function run_test
{
${CAPNP_TEST_APP} $1 $2
if [ $? -eq 127 ]; then
echo "SKIP TEST REQUESTED" >&2
# PLEASE BASH, break my pipeline here!
# oh well..
# shuffle some sensible data down the pipeline instead..
$3 $1 $2
return 127
fi
}
function decode_result
{
capnp decode --short test.capnp $1
}
function check_result
{
diff expect/$2.txt - \
&& passed $* \
|| failed $*
}
function empty_struct
{
# Single segment with empty root struct, to avoid a nasty uncaught
# exception message from capnp decode about premature EOF ;)
echo AAAAAAEAAAAAAAAAAAAAAA== | base64 --decode
}
printf "++ TEST [%s %s]\n" $1 $2 >&2
case $1 in
decode)
cat expect/$2.bin \
| run_test decode $2 skipped \
| check_result $1 $2 ;;
encode)
run_test encode $2 empty_struct \
| decode_result $3 \
| check_result $1 $2
esac
| |
Fix Travis on OS X again | #!/bin/bash
set -eux
# Install OCaml and OPAM PPAs
install_on_ubuntu () {
sudo apt-get install -qq time libgtk2.0-dev libcurl4-openssl-dev python-gobject-2
}
install_on_osx () {
curl -OL "http://xquartz.macosforge.org/downloads/SL/XQuartz-2.7.6.dmg"
sudo hdiutil attach XQuartz-2.7.6.dmg
sudo installer -verbose -pkg /Volumes/XQuartz-2.7.6/XQuartz.pkg -target /
brew update &> /dev/null
brew uninstall -f gnupg@2.1 gnupg21
brew install gnupg gtk+ pygobject
export PKG_CONFIG_PATH=/usr/local/Library/Homebrew/os/mac/pkgconfig/10.9:/usr/lib/pkgconfig
}
case $TRAVIS_OS_NAME in
linux)
install_on_ubuntu ;;
osx)
install_on_osx ;;
*) echo "Unknown OS $TRAVIS_OS_NAME";
exit 1 ;;
esac
# (downloaded by Travis install step)
bash -e ./.travis-opam.sh
| #!/bin/bash
set -eux
# Install OCaml and OPAM PPAs
install_on_ubuntu () {
sudo apt-get install -qq time libgtk2.0-dev libcurl4-openssl-dev python-gobject-2
}
install_on_osx () {
curl -OL "http://xquartz.macosforge.org/downloads/SL/XQuartz-2.7.6.dmg"
sudo hdiutil attach XQuartz-2.7.6.dmg
sudo installer -verbose -pkg /Volumes/XQuartz-2.7.6/XQuartz.pkg -target /
brew update &> /dev/null
brew upgrade gnupg
brew install gtk+ pygobject
export PKG_CONFIG_PATH=/usr/local/Library/Homebrew/os/mac/pkgconfig/10.9:/usr/lib/pkgconfig
}
case $TRAVIS_OS_NAME in
linux)
install_on_ubuntu ;;
osx)
install_on_osx ;;
*) echo "Unknown OS $TRAVIS_OS_NAME";
exit 1 ;;
esac
# (downloaded by Travis install step)
bash -e ./.travis-opam.sh
|
Add shell script that updates marl. | #!/bin/bash
# update-marl merges the latest changes from the github.com/google/marl into
# third_party/marl. This script copies the change descriptions from the squash
# change into the top merge change, along with a standardized description.
REASON=$1
if [ ! -z "$REASON" ]; then
REASON="\n$REASON\n"
fi
git subtree pull --prefix third_party/marl https://github.com/google/marl master --squash -m "Update marl"
ALL_CHANGES=`git log -n 1 HEAD^2 | egrep '^(\s{4}[0-9a-f]{9}\s*.*)$'`
HEAD_CHANGE=`echo "$ALL_CHANGES" | egrep '[0-9a-f]{9}' -o -m 1`
LOG_MSG=`echo -e "Update Marl to $HEAD_CHANGE\n${REASON}\nChanges:\n$ALL_CHANGES\n\nCommands:\n git subtree pull --prefix third_party/marl https://github.com/google/marl master --squash\n\nBug: b/140546382"`
git commit --amend -m "$LOG_MSG" | |
Add first draft of script for building on macOS. | #!/bin/bash
set -e
# Configure the application in the current directory
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=out \
`dirname $0`
# Build and install the application
make
make install
# Run macdeployqt
macdeployqt \
out/nitroshare.app
-always-overwrite
# Create a symlink to /Applications
rm -f out/Applications
ln -s /Applications out/Applications
# Create a DMG from the app and symlink
hdiutil create \
-srcfolder out \
-fs HFS+ \
-volname NitroShare \
nitroshare.dmg
| |
Add a script to show the NIC settings and port forwarding rules for all running VirtualBox VMs. | #!/bin/bash
#
# Show the exposed network / NAT port forwarding configuration
# for all running VMs.
#
MACHINES=$(vboxmanage list runningvms | cut -f 2 -d \")
echo "Networking setup looks like:"
echo ""
while read -r machine; do
echo "vboxmanage showvminfo \"${machine}\""
vboxmanage showvminfo "${machine}" | grep "^NIC" | grep -v "disabled"
echo ""
done <<< "${MACHINES}"
| |
Fix zookeeper not running in docker | #!/bin/bash
# Small script to fully setup environment
if [ $(hostname) == "scionfull" ]; then
sudo service zookeeper start
./scion.sh setup
fi
# Can't be fixed during build due to
# https://github.com/docker/docker/issues/6828
sudo chmod g+s /usr/bin/screen
# Properly setup terminal to allow use of screen, etc:
exec bash -l >/dev/tty 2>/dev/tty </dev/tty
| #!/bin/bash
# Small script to fully setup environment
sudo service zookeeper start
./scion.sh setup
# Can't be fixed during build due to
# https://github.com/docker/docker/issues/6828
sudo chmod g+s /usr/bin/screen
# Properly setup terminal to allow use of screen, etc:
exec bash -l >/dev/tty 2>/dev/tty </dev/tty
|
Add script to grep through the entire source tree. | #!/bin/bash
working_dir=`dirname $0`
cd $working_dir
cd ..
set -u
set -o errexit
find lib script t -iname '*.pm' -print0 -or -iname '*.pl' -print0 -or -iname '*.t' -print0 | xargs -0 grep $@
| |
Add a command to be able to graph an histogram of the expirations. | #!/bin/bash
node expiration.js | tail -n+3 | cut -f 1,2 | perl -lane 'print $F[0], "\t", $F[1], "\t", "=" x ($F[1] / 3 + 1)'
| |
Add simple script to build the accounts client into an artifact that is maven-compatible | #!/bin/sh
set -e
DESTDIR="AccountsClient"
git clone https://github.com/Mojang/AccountsClient.git $DESTDIR
pushd $DESTDIR
sed -i "s/testLogging\.showStandardStreams = true//" build.gradle
sed -i "s/apply plugin: 'idea'/apply plugin: 'idea'\napply plugin: 'maven'\ngroup = 'com.mojang'/" build.gradle
echo "rootProject.name = 'AccountsClient'" >> settings.gradle
gradle clean install
rm -rf $DESTDIR
popd
| |
Add script for key mapping | #! /bin/sh
sleep 2
set -e
# Remap keys.
# Escape: Caps Lock
# Caps Lock: Control if pressed with other key, if only key tapped it is escape
if type xcape >/dev/null ; then
setxkbmap -option 'caps:swapescape'
spare_modifier=Hyper_L
xmodmap -e "keycode 66 = $spare_modifier"
xmodmap -e "remove mod4 = $spare_modifier"
xmodmap -e "add Control = $spare_modifier"
xmodmap -e "keycode 255 = Escape"
xcape -e "$spare_modifier=Escape"
fi
| |
Add reboot to CF installation | #!/bin/bash
function include(){
curr_dir=$(cd $(dirname "$0") && pwd)
inc_file_path=$curr_dir/$1
if [ -f "$inc_file_path" ]; then
. $inc_file_path
else
echo -e "$inc_file_path not found!"
exit 1
fi
}
include "common.sh"
. ~/.profile
log "DEBUG: change dir to cf_nise_installer"
cd /root/cf_nise_installer
log "Debug: Starting cf-release script"
pwd >> current.log
./scripts/install_cf_release.sh >> install.log
| #!/bin/bash
function include(){
curr_dir=$(cd $(dirname "$0") && pwd)
inc_file_path=$curr_dir/$1
if [ -f "$inc_file_path" ]; then
. $inc_file_path
else
echo -e "$inc_file_path not found!"
exit 1
fi
}
include "common.sh"
. ~/.profile
if [ ! -e /tmp/wagrant-reboot] ; then
log "DEBUG: change dir to cf_nise_installer"
cd /root/cf_nise_installer
log "Debug: Starting cf-release script"
pwd >> current.log
./scripts/install_cf_release.sh >> install.log
touch /tmp/wagrant-reboot
reboot
fi
exit 0 |
Add script for ivp/fvp split | head -n 1 $1 > initial_visits.csv
grep "initial_visit" $1 >> initial_visits.csv
head -n 1 $1 > followup_visits.csv
grep "followup_visit" $1 >> followup_visits.csv | |
Change permissions of lims2 directories. | #!/bin/sh
for p in ${LIMS2_DIR} ${LAB_DIR} ${CACHE_DIR} ; do
[ ! -e "$p" ] || chown -R www-data:www-data "$p"
done
| |
Build PATH before determining term settings | umask 022
source_rc_files () {
local rc
for rc in "$@"; do
[[ -f "$rc" ]] && [[ -r "$rc" ]] && source "$rc"
done
}
# different semantics than the typical pathmunge()
add_to_path () {
local after=false dir
if [[ "$1" == "--after" ]]; then after=true; shift; fi
for dir in "$@"; do
if [[ -d "$dir" ]]; then
if $after; then
PATH="$PATH:"
PATH="${PATH//$dir:/}$dir";
else
PATH=":$PATH"
PATH="$dir${PATH//:$dir/}";
fi
fi
done
}
shrc_dir=$HOME/run_control/sh
# Setup terminal first.
source_rc_files $shrc_dir/term.sh
# Build $PATH.
# Instead of adding /opt/*/bin to $PATH
# consider symlinking those scripts into ~/usr/bin
# to keep the $PATH shorter so less searching is required.
# Locally compiled (without sudo).
add_to_path $HOME/usr/bin
# Homebrew.
add_to_path $HOME/homebrew/bin
# Get (unprefixed) GNU utils to override BSD utils.
add_to_path $HOME/homebrew/opt/coreutils/libexec/gnubin
# Personal scripts.
add_to_path $HOME/bin
# Get everything else.
source_rc_files $shrc_dir/sh.d/*.sh ~/.shrc.local $EXTRA_SHRC
unset shrc_dir
| umask 022
source_rc_files () {
local rc
for rc in "$@"; do
[[ -f "$rc" ]] && [[ -r "$rc" ]] && source "$rc"
done
}
# different semantics than the typical pathmunge()
add_to_path () {
local after=false dir
if [[ "$1" == "--after" ]]; then after=true; shift; fi
for dir in "$@"; do
if [[ -d "$dir" ]]; then
if $after; then
PATH="$PATH:"
PATH="${PATH//$dir:/}$dir";
else
PATH=":$PATH"
PATH="$dir${PATH//:$dir/}";
fi
fi
done
}
shrc_dir=$HOME/run_control/sh
# Build $PATH.
# Instead of adding /opt/*/bin to $PATH
# consider symlinking those scripts into ~/usr/bin
# to keep the $PATH shorter so less searching is required.
# Locally compiled (without sudo).
add_to_path $HOME/usr/bin
# Homebrew.
add_to_path $HOME/homebrew/bin
# Get (unprefixed) GNU utils to override BSD utils.
add_to_path $HOME/homebrew/opt/coreutils/libexec/gnubin
# Personal scripts.
add_to_path $HOME/bin
# Setup terminal first.
source_rc_files $shrc_dir/term.sh
# Get everything else.
source_rc_files $shrc_dir/sh.d/*.sh ~/.shrc.local $EXTRA_SHRC
unset shrc_dir
|
Add an expensive test for git-notes | #!/bin/sh
#
# Copyright (c) 2007 Johannes E. Schindelin
#
test_description='Test commit notes index (expensive!)'
. ./test-lib.sh
test -z "$GIT_NOTES_TIMING_TESTS" && {
say Skipping timing tests
test_done
exit
}
create_repo () {
number_of_commits=$1
nr=0
parent=
test -d .git || {
git init &&
tree=$(git write-tree) &&
while [ $nr -lt $number_of_commits ]; do
test_tick &&
commit=$(echo $nr | git commit-tree $tree $parent) ||
return
parent="-p $commit"
nr=$(($nr+1))
done &&
git update-ref refs/heads/master $commit &&
{
export GIT_INDEX_FILE=.git/temp;
git rev-list HEAD | cat -n | sed "s/^[ ][ ]*/ /g" |
while read nr sha1; do
blob=$(echo note $nr | git hash-object -w --stdin) &&
echo $sha1 | sed "s/^/0644 $blob 0 /"
done | git update-index --index-info &&
tree=$(git write-tree) &&
test_tick &&
commit=$(echo notes | git commit-tree $tree) &&
git update-ref refs/notes/commits $commit
} &&
git config core.notesRef refs/notes/commits
}
}
test_notes () {
count=$1 &&
git config core.notesRef refs/notes/commits &&
git log | grep "^ " > output &&
i=1 &&
while [ $i -le $count ]; do
echo " $(($count-$i))" &&
echo " note $i" &&
i=$(($i+1));
done > expect &&
git diff expect output
}
cat > time_notes << \EOF
mode=$1
i=1
while [ $i -lt $2 ]; do
case $1 in
no-notes)
export GIT_NOTES_REF=non-existing
;;
notes)
unset GIT_NOTES_REF
;;
esac
git log >/dev/null
i=$(($i+1))
done
EOF
time_notes () {
for mode in no-notes notes
do
echo $mode
/usr/bin/time sh ../time_notes $mode $1
done
}
for count in 10 100 1000 10000; do
mkdir $count
(cd $count;
test_expect_success "setup $count" "create_repo $count"
test_expect_success 'notes work' "test_notes $count"
test_expect_success 'notes timing' "time_notes 100"
)
done
test_done
| |
Build on Travis CI with or without Docker | #!/bin/bash
# Build on Travis CI with or without Docker
set -e
RECIPE="${1}"
mkdir -p ./out/
if [ -f recipes/$RECIPE/Dockerfile ] && [ -f recipes/$RECIPE/Recipe ] ; then
# There is a Dockerfile, hence build using Docker
mv recipes/$RECIPE/Recipe ./out/Recipe
sed -i -e 's|sudo ||g' ./out/Recipe # For subsurface recipe
docker run -i -v ${PWD}/out:/out probonopd/appimages:$RECIPE /bin/bash -ex /out/Recipe
elif [ -f recipes/$RECIPE/Recipe ] ; then
# There is no Dockerfile but a Recipe, hence build without Docker
bash -ex recipes/$RECIPE/Recipe
else
# There is no Recipe
echo "Recipe not found, is RECIPE missing?"
exit 1
fi
ls -lh out/*.AppImage
| |
Add shell script for resetting database | #!/bin/bash
set -euo pipefail # Unofficial bash strict mode
curl -X DELETE -u poleland:poleland \
http://10.0.0.2:8091/pools/default/buckets/poleland
curl -X POST -u poleland:poleland http://10.0.0.2:8091/pools/default/buckets \
-d authType=none \
-d bucketType=couchbase \
-d name=poleland \
-d proxyPort=11222 \
-d ramQuotaMB=200 \
-d replicaNumber=0
sleep 1 # Bucket create seems to need a little time after responding
node /vagrant/api/src/add-test-data.js
| |
Add utility script for building docker containers | #!/bin/bash
if [ -z "$1" ]
then
echo "Provide a registry name!"
exit -1
fi
docker build --no-cache=true -t $1/teastore-base utilities/tools.descartes.teastore.dockerbase/
perl -i -pe's|.*FROM descartesresearch/|FROM '"$1"'/|g' services/tools.descartes.teastore.*/Dockerfile
docker build -t $1/teastore-registry services/tools.descartes.teastore.registry/
docker build -t $1/teastore-persistence services/tools.descartes.teastore.persistence/
docker build -t $1/teastore-image services/tools.descartes.teastore.image/
docker build -t $1/teastore-webui services/tools.descartes.teastore.webui/
docker build -t $1/teastore-auth services/tools.descartes.teastore.auth/
docker build -t $1/teastore-recommender services/tools.descartes.teastore.recommender/
perl -i -pe's|.*FROM '"$1"'/|FROM descartesresearch/|g' services/tools.descartes.teastore.*/Dockerfile
docker push $1/teastore-base
docker push $1/teastore-registry
docker push $1/teastore-persistence
docker push $1/teastore-image
docker push $1/teastore-webui
docker push $1/teastore-auth
docker push $1/teastore-recommender
| |
Add shell script for creating xcframework | #!/bin/bash
FRAMEWORK_NAME="OCMockito"
MACOS_ARCHIVE_PATH="./build/archives/macos.xcarchive"
IOS_ARCHIVE_PATH="./build/archives/ios.xcarchive"
IOS_SIMULATOR_ARCHIVE_PATH="./build/archives/ios_sim.xcarchive"
TV_ARCHIVE_PATH="./build/archives/tv.xcarchive"
TV_SIMULATOR_ARCHIVE_PATH="./build/archives/tv_sim.xcarchive"
WATCH_ARCHIVE_PATH="./build/archives/watch.xcarchive"
WATCH_SIMULATOR_ARCHIVE_PATH="./build/archives/watch_sim.xcarchive"
# Archive platform specific frameworks
xcodebuild archive -scheme ${FRAMEWORK_NAME} -archivePath ${MACOS_ARCHIVE_PATH} SKIP_INSTALL=NO
xcodebuild archive -scheme ${FRAMEWORK_NAME}-iOS -archivePath ${IOS_ARCHIVE_PATH} -sdk iphoneos SKIP_INSTALL=NO
xcodebuild archive -scheme ${FRAMEWORK_NAME}-iOS -archivePath ${IOS_SIMULATOR_ARCHIVE_PATH} -sdk iphonesimulator SKIP_INSTALL=NO
xcodebuild archive -scheme ${FRAMEWORK_NAME}-tvOS -archivePath ${TV_ARCHIVE_PATH} -sdk appletvos SKIP_INSTALL=NO
xcodebuild archive -scheme ${FRAMEWORK_NAME}-tvOS -archivePath ${TV_SIMULATOR_ARCHIVE_PATH} -sdk appletvsimulator SKIP_INSTALL=NO
xcodebuild archive -scheme ${FRAMEWORK_NAME}-watchOS -archivePath ${WATCH_ARCHIVE_PATH} -sdk watchos SKIP_INSTALL=NO
xcodebuild archive -scheme ${FRAMEWORK_NAME}-watchOS -archivePath ${WATCH_SIMULATOR_ARCHIVE_PATH} -sdk watchsimulator SKIP_INSTALL=NO
# Creating XCFramework
xcodebuild -create-xcframework \
-framework ${MACOS_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \
-framework ${IOS_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \
-framework ${IOS_SIMULATOR_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \
-framework ${TV_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \
-framework ${TV_SIMULATOR_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \
-framework ${WATCH_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \
-framework ${WATCH_SIMULATOR_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \
-output "./build/${FRAMEWORK_NAME}.xcframework"
| |
Add script for installing GRUB | ## Install GRUB bootloader
# Download and install GRUB
echo "Installing GRUB bootloader..."
pacman -S grub
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=arch_grub --recheck --debug
mkdir -p /boot/grub/locale
cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo
# Create grub configuration.
grub-mkconfig -o /boot/grub/grub.cfg | |
Add script to copy prod db locally | #!/bin/sh
set -e
# This copies the production database to the local machine.
go build
./tools/createdb/createdb
ssh ryloth.textplain.net 'pg_dump -U recipes -d recipes' | psql -U recipes -d recipes
| |
Add script to install latest Hack release | #!/usr/bin/env bash
# Author: JesusMtnez
cd /tmp # Execute script in /tmp
NAME="Hack_latest"
URL=$(curl -silent https://api.github.com/repos/chrissimpkins/Hack/releases/latest | grep -o 'https://.*ttf.zip')
# Download ZIP
curl --output $NAME.zip --silent --location --remote-name $URL
# Unzip
unzip -qo $NAME -d $NAME
# Install font
if [ `uname` = 'Darwin' ]; then
cp -R $NAME/ $HOME/Library/Fonts/ # OSX user fonts
else
cp -R $NAME/ $HOME/.fonts/ # Linux user fonts
fi
echo "Latest Hack font release installed!"
| |
Add script to install and update capa. | #!/bin/bash
# Script to install and update capa by Fireye. More information at
# https://github.com/fireeye/capa
# From the description:
# capa detects capabilities in executable files. You run it against
# a PE file or shellcode and it tells you what it thinks the program
# can do. For example, it might suggest that the file is a backdoor,
# is capable of installing services, or relies on HTTP to communicate.
url=$(curl -s https://api.github.com/repos/fireeye/capa/releases/latest | \
grep 'browser_download_url' | grep 'linux' | cut -d\" -f4 | head -1)
version=$(echo "$url" | grep -o -E "/v[.0-9]+/" | tr -d '/')
if [[ ! -d "$HOME"/bin ]]; then
echo "Directory $HOME/bin doesn't exist. Create and run script again."
exit
fi
if [[ -f "$HOME"/bin/capa && $(capa --version 2>&1 | sed -E "s/.*(v[.0-9]+).*/\1/") == "$version" ]]; then
exit
else
cd "$HOME"/bin || exit
[[ -f capa ]] && rm -f capa
wget --quiet -O capa-"$version" "$url"
unzip capa-"$version"
rm -f capa-"$version"
fi
| |
Add VPN client dependecies on Kali Linux | #!/bin/bash
apt-get install g++
apt-get install build-essential
apt-get install flex
apt-get install libedit2 libedit-dev
apt-get install bison
apt-get install cmake
apt-get install openssl
apt-get install libqt4-dev
| |
Add a bash script to print out the svn history of a file | #!/bin/bash
# Copyright 2015 zeb209. All rights reserved.
# Use of this source code is governed by a Pastleft
# license that can be found in the LICENSE file.
# svn does not have a command to show all the diffs of a file.
# we simulate it with svn diff here.
# Outputs the full history of a given file as a sequence of
# log entry/diff pairs. The first revision of the file is emitted as
# full text since there's not previous version to compare it to.
function svn_history() {
url=$1 # current url of file
# get the revisions of the file.
svn log -q $url | grep -E -e "^r[[:digit:]]+" -o | cut -c2- | sort -n | {
# first revision as full text
echo
read r
svn log -r$r $url@HEAD
svn cat -r$r $url@HEAD
echo
# remaining revisions as differences to previous revision
while read r
do
echo
svn log -r$r $url@HEAD
svn diff -c$r $url@HEAD
echo
done
}
}
svn_history $1
| |
Add script to compile *.proto files to *_pb2.py | # Copyright 2019 The Google Research Authors.
#
# 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.
#!/bin/bash
#
# Compiles all *.proto files in the repository into *_pb2.py generated files.
#
# `pip install protobuf` should be part of requirements.txt if any of the proto files depend on google.protobuf.
# Exit on fail
set -e
THIRD_PARTY_FOLDER="third_party"
PROTO_COMPILER_CMD="${THIRD_PARTY_FOLDER}/protoc/bin/protoc"
PROTO_COMPILER_VERSION="3.7.1"
# Assert the existence of a folder
assert_folder() {
# $1: folder to assert
if [[ ! -d "$1" ]]; then
mkdir -p "$1"
fi
}
# Downloads proto compiler (binary)
download_protoc() {
assert_folder ${THIRD_PARTY_FOLDER}
cd ${THIRD_PARTY_FOLDER}
assert_folder protoc
cd protoc
# Get and unzip binaries
wget "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTO_COMPILER_VERSION}/protoc-${PROTO_COMPILER_VERSION}-linux-x86_64.zip"
unzip "protoc-${PROTO_COMPILER_VERSION}-linux-x86_64.zip"
# Get license
wget https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE
# Clean
rm "protoc-${PROTO_COMPILER_VERSION}-linux-x86_64.zip"
cd ../..
}
# Compile Python protos
compile_protos() {
for file in $(find ! -path "./${THIRD_PARTY_FOLDER}/*" -name "*.proto"); do
dir=$(dirname "$file")
if [[ ! -f "${dir}/__init__.py" ]]; then
touch "${dir}/__init__.py"
fi
${PROTO_COMPILER_CMD} -I=$dir --python_out=$dir $file
done
}
download_protoc
compile_protos
| |
Install Homebrew and Pipx Packages | #!/usr/bin/env bash
# (@) install standard packages using Homebrew (https://brew.sh)
# and pipx (https://github.com/pypa/pipx)
# my necessary utilties
brew install stow
brew install tmux
brew install coreutils
brew install gsed
brew install nvim
brew install pipx
brew install pyenv
brew install pipenv
brew install bat
brew install git-delta
brew install fzf
brew install ripgrep
brew install fd
brew install google-cloud-sdk
# application software in casks
brew install --cask moom
brew install --cask 1password
brew install --cask google-chrome
brew install --cask google-drive
brew install --cask bbedit
# nerdfonts and symbols for iTterm
brew tap homebrew/cask-fonts
brew install --cask font-meslo-lg-nerd-font
brew install --cask font-meslo-for-powerline
# Python apps
pipx install powerline-status
pipx install pre-commit
| |
Add MFA hook to login with a Virtual MFA provider | function aws-mfa {
profile=${1:-mfa}
# set -euo pipe
mfa_arn="$(aws iam list-mfa-devices | jq -r ".MFADevices[0].SerialNumber")"
echo "Using MFA with ARN: '${mfa_arn}'"
echo -n "MFA Code from Device: "
read -s token
echo "Ok"
ntoken="$(aws sts get-session-token --duration-seconds 86400 --serial-number "${mfa_arn}" --token-code "${token}")"
# ENV Vars
export AWS_ACCESS_KEY_ID="$(echo $ntoken | jq -r ".Credentials.AccessKeyId")"
export AWS_SECRET_ACCESS_KEY="$(echo $ntoken | jq -r ".Credentials.SecretAccessKey")"
export AWS_SESSION_TOKEN="$(echo $ntoken | jq -r ".Credentials.SessionToken")"
aws --profile $profile configure set aws_access_key_id "$(echo $ntoken | jq -r ".Credentials.AccessKeyId")"
aws --profile $profile configure set aws_secret_access_key "$(echo $ntoken | jq -r ".Credentials.SecretAccessKey")"
aws --profile $profile configure set aws_session_token "$(echo $ntoken | jq -r ".Credentials.SessionToken")"
aws --profile $profile configure set region us-east-1
aws --profile $profile configure set output json
echo "Keys expire at $(echo $ntoken | jq -r ".Credentials.Expiration")"
unset token
unset mfa_arn
unset ntoken
unset profile
} | |
Use quick mode for updateTest script | #!/bin/bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
export HAKA_TEST_FIX=$(pwd)/haka-test-fix
for i in $(seq $1 $2)
do
CONTINUE=1
while [ $CONTINUE = 1 ]; do
rm -f $HAKA_TEST_FIX
ctest -V -I $i,$i
if [ $? = 0 ]; then
CONTINUE=0
else
if [ -f "$HAKA_TEST_FIX" ]; then
cat $HAKA_TEST_FIX
read -p "Update test? (y/n) " -n 1 -r
echo
case $REPLY in
"y") bash -c "$(cat $HAKA_TEST_FIX)";;
*) echo ERROR: Test not updated; CONTINUE=0;;
esac
else
echo ERROR: Test failed
CONTINUE=0
fi
fi
done
echo $i
done
| #!/bin/bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
export HAKA_TEST_FIX=$(pwd)/haka-test-fix
export QUICK=yes
for i in $(seq $1 $2)
do
CONTINUE=1
while [ $CONTINUE = 1 ]; do
rm -f $HAKA_TEST_FIX
ctest -V -I $i,$i
if [ $? = 0 ]; then
CONTINUE=0
else
if [ -f "$HAKA_TEST_FIX" ]; then
cat $HAKA_TEST_FIX
read -p "Update test? (y/n) " -n 1 -r
echo
case $REPLY in
"y") bash -c "$(cat $HAKA_TEST_FIX)";;
*) echo ERROR: Test not updated; CONTINUE=0;;
esac
else
echo ERROR: Test failed
CONTINUE=0
fi
fi
done
echo $i
done
|
Automate re-deploying a development instance from scratch | #!/bin/sh
#
# Rebuild from scratch, for developers.
if [ $# -ne 0 ]; then
echo Usage: `basename $0` 1>&2
echo "(This program takes no arguments.)" 1>&2
exit 1
fi
if [ ! -f base.cfg -o ! -f build.cfg -o ! -f dev.cfg ]; then
echo Run this from the buildout directory. 1>&2
echo There should be base.cfg, build.cfg, dev.cfg files 1>&2
echo "(as well as any/many buildout-generated artifacts)." 1>&2
exit 1
fi
cat <<EOF
This will shutdown the supervisord; wipe out the database, log files, etc.;
rebuild the instance; and repopulate the site content. It'll then start the
supervisord. You have 5 seconds to abort.
EOF
sleep 5
[ -x bin/supervisorctl ] && echo 'Shutting down supervisor...' && bin/supervisorctl shutdown
set -e
[ -d var ] && echo 'Nuking var directory...\c' && rm -r var && echo done
echo 'Nuking select parts...' && rm -rf parts/zeoserver parts/instance-debug
echo 'Remaking select parts...' && bin/buildout -c dev.cfg install zeoserver instance-debug
echo 'Populating content...' && bin/buildout -c dev.cfg install edrnsite
echo 'Starting supervisor...\c' && bin/supervisord
exit 0
| |
Add check for exec permissions and refactor lint doc script | #!/usr/bin/env bash
cd "$(dirname "$0")/.."
# Use long options (e.g. --header instead of -H) for curl examples in documentation.
grep --extended-regexp --recursive --color=auto 'curl (.+ )?-[^- ].*' doc/
if [ $? == 0 ]
then
echo '✖ ERROR: Short options should not be used in documentation!' >&2
exit 1
fi
# Ensure that the CHANGELOG.md does not contain duplicate versions
DUPLICATE_CHANGELOG_VERSIONS=$(grep --extended-regexp '^## .+' CHANGELOG.md | sed -E 's| \(.+\)||' | sort -r | uniq -d)
if [ "${DUPLICATE_CHANGELOG_VERSIONS}" != "" ]
then
echo '✖ ERROR: Duplicate versions in CHANGELOG.md:' >&2
echo "${DUPLICATE_CHANGELOG_VERSIONS}" >&2
exit 1
fi
echo "✔ Linting passed"
exit 0
| #!/usr/bin/env bash
cd "$(dirname "$0")/.."
# Use long options (e.g. --header instead of -H) for curl examples in documentation.
echo 'Checking for curl short options...'
grep --extended-regexp --recursive --color=auto 'curl (.+ )?-[^- ].*' doc/ >/dev/null 2>&1
if [ $? == 0 ]
then
echo '✖ ERROR: Short options for curl should not be used in documentation!
Use long options (e.g., --header instead of -H):' >&2
grep --extended-regexp --recursive --color=auto 'curl (.+ )?-[^- ].*' doc/
exit 1
fi
# Ensure that the CHANGELOG.md does not contain duplicate versions
DUPLICATE_CHANGELOG_VERSIONS=$(grep --extended-regexp '^## .+' CHANGELOG.md | sed -E 's| \(.+\)||' | sort -r | uniq -d)
echo 'Checking for CHANGELOG.md duplicate entries...'
if [ "${DUPLICATE_CHANGELOG_VERSIONS}" != "" ]
then
echo '✖ ERROR: Duplicate versions in CHANGELOG.md:' >&2
echo "${DUPLICATE_CHANGELOG_VERSIONS}" >&2
exit 1
fi
# Make sure no files in doc/ are executable
EXEC_PERM_COUNT=$(find doc/ -type f -perm 755 | wc -l)
echo 'Checking for executable permissions...'
if [ "${EXEC_PERM_COUNT}" -ne 0 ]
then
echo '✖ ERROR: Executable permissions should not be used in documentation! Use `chmod 644` to the files in question:' >&2
echo
find doc/ -type f -perm 755
exit 1
fi
echo "✔ Linting passed"
exit 0
|
Add Environment variable file for one server deployment | #!/bin/bash
# Declare methods start
function defaultConfig() {
# Database details
export UAA_DB_PASSWORD=admin
export PCM_DB_PASSWORD=admin
export PLS_DB_PASSWORD=admin
export PHR_DB_PASSWORD=admin
export PATIENT_USER_DB_PASSWORD=admin
export AUDIT_DB_PASSWORD=admin
export C2S_BASE_PATH=/usr/local
export CONFIG_DATA_GIT_DIR=c2s-config-data
# Edge Server configuraiton
export C2S_APP_PORT=80
# SMTP details
export UAA_SMTP_HOST=your_mail_host
export UAA_SMTP_PORT=your_mail_port
export UAA_SMTP_USER=your_mail_username
export UAA_SMTP_PASSWORD=your_mail_password
#logback-audit variables
export AUTO_SCAN=true
export SCAN_PERIOD="30 seconds"
}
function oneServerConfig() {
defaultConfig
# Edge Server configuraiton
export C2S_APP_HOST=your_app_server_host
# Config Server Configuration
export BASIC_AUTH_USER=your_basic_auth_user
export BASIC_AUTH_PASSWORD=your_basic_auth_password
# This variable is only required to give server environment specific profile
# data added in config-data repository
# export ENV_APP_PROFILE=your_app_Server_specific_profile
# This variable is only required if encrypted values are available in the server environment specific profile
# conofig data variables
#export CONFIG_DATA_ENCRYPT_KEY=your_config_data_encrypt
}
oneServerConfig
| |
Uninstall script (currently for debugging only) | #!/bin/bash
set -u
error() {
echo "ERROR: $1" >&2
exit 1
}
# To avoid typos for the most repeated and important word in the script:
BIN="percona-agent"
# ###########################################################################
# Sanity checks and setup
# ###########################################################################
# Check if script is run as root as we need write access to /etc, /usr/local
if [ $EUID -ne 0 ]; then
error "$BIN uninstall requires root user; detected effective user ID $EUID"
fi
# Check compatibility
KERNEL=`uname -s`
if [ "$KERNEL" != "Linux" -a "$KERNEL" != "Darwin" ]; then
error "$BIN only runs on Linux; detected $KERNEL"
fi
PLATFORM=`uname -m`
if [ "$PLATFORM" != "x86_64" -a "$PLATFORM" != "i686" -a "$PLATFORM" != "i386" ]; then
error "$BIN only support x86_64 and i686 platforms; detected $PLATFORM"
fi
echo "Detected $KERNEL $PLATFORM"
# Set up variables.
INSTALL_DIR="/usr/local/percona"
# ###########################################################################
# Stop agent and uninstall sys-int script
# ###########################################################################
INIT_SCRIPT="/etc/init.d/$BIN"
if [ "$KERNEL" != "Darwin" ]; then
if [ -x "$INIT_SCRIPT" ]; then
echo "Stopping agent ..."
${INIT_SCRIPT} stop
if [ $? -ne 0 ]; then
error "Failed to stop $BIN"
fi
fi
echo "Uninstalling sys-init script ..."
# Check if the system has chkconfig or update-rc.d.
if hash update-rc.d 2>/dev/null; then
echo "Using update-rc.d to uninstall $BIN service"
update-rc.d -f "$BIN" remove
elif hash chkconfig 2>/dev/null; then
echo "Using chkconfig to install $BIN service"
chkconfig --del "$BIN"
else
echo "Cannot find chkconfig or update-rc.d. $BIN is installed but"
echo "it will not restart automatically with the server on reboot. Please"
echo "email the follow to cloud-tools@percona.com:"
cat /etc/*release
fi
# Remove init script
echo "Removing $INIT_SCRIPT ..."
rm -f "$INIT_SCRIPT"
else
echo "Mac OS detected, no sys-init script. To stop $BIN:"
echo "killall $BIN"
fi
# ###########################################################################
# Uninstall percona-agent
# ###########################################################################
# BASEDIR here must match BASEDIR in percona-agent sys-init script.
BASEDIR="$INSTALL_DIR/$BIN"
echo "Removing dir $BASEDIR ..."
rm -rf "$BASEDIR"
# ###########################################################################
# Cleanup
# ###########################################################################
echo "$BIN uninstall successful"
exit 0
| |
Add preliminary script for running test cases through sexpr-wasm-prototype and v8-native-prototype | #!/bin/bash
SCRIPTPATH=`realpath "$BASH_SOURCE"`
ILWASMDIR=`dirname $SCRIPTPATH`
SEXPRDIR=$ILWASMDIR/../sexpr-wasm-prototype/
MODULEPATH=`realpath "$1"`
BINPATH="$MODULEPATH.v8native"
pushd $SEXPRDIR > /dev/null
out/sexpr-wasm "$MODULEPATH" -o "$BINPATH" --multi-module
BINPATH_ABS=`realpath "$BINPATH"`
third_party/v8-native-prototype/v8/v8/out/Release/d8 test/spec.js "$BINPATH"
popd > /dev/null | |
Add script for bootstrapping fonts | #!/usr/bin bash
# This will install Hack with powerline symbols and other goodies!
cd ~
git clone --depth 1 https://github.com/ryanoasis/nerd-fonts
cd nerd-fonts
sh ./install.sh Hack
| |
Add simple script for bringing servers to scale | # Run the following as root
cat sysctl_settings.txt >> /sys/sysctl.conf
# Increase the ipv4 port range:
sysctl -w net.ipv4.ip_local_port_range="1024 65535"
# General gigabit tuning:
sysctl -w net.core.rmem_max=16777216
sysctl -w net.core.wmem_max=16777216
sysctl -w net.ipv4.tcp_rmem="4096 87380 16777216"
sysctl -w net.ipv4.tcp_wmem="4096 65536 16777216"
sysctl -w net.ipv4.tcp_syncookies=1
# This gives the kernel more memory for tcp which you need with many (100k+) open socket connections
sysctl -w net.ipv4.tcp_mem="50576 64768 98152"
sysctl -w net.core.netdev_max_backlog=2500
# This set the tcp max connections
## sysctl -w net.netfilter.nf_conntrack_max=1233000
ulimit -n 999999
# modify /etc/security/limits.conf
# user soft nofile 50000
# user hard nofile 50000
# modified /etc/sshd.conf
# UsePrivilegeSeparation no
# modified /usr/include/bits/typesizes.h
# #define __FD_SETSIZE 65535
| |
Add in stub for gathering drivers. | # TODO: Install all the drivers for the user.
# Safari, IE
# http://selenium-release.storage.googleapis.com/
# Chrome
# http://chromedriver.storage.googleapis.com/
# Opera
# https://github.com/operasoftware/operachromiumdriver/releases
| |
Add new script to create locale dirs | #!/bin/bash
# Author: Sotiris Papadopoulos <ytubedlg@gmail.com>
# Last-Revision: 2017-01-30
# Script to add support for a new language
#
# Usage: ./new-locale.sh <locale>
# Example: ./new-locale.sh gr_GR
PACKAGE="youtube_dl_gui"
PO_FILE="$PACKAGE.po"
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <locale>"
echo "Example: $0 gr_GR"
exit 1
fi
cd ..
TARGET="$PACKAGE/locale/$1"
if [ -d "$TARGET" ]; then
echo "[-]Locale '$1' already exists, exiting..."
exit 1
fi
echo "[*]Creating directory: '$TARGET'"
mkdir -p "$TARGET/LC_MESSAGES"
echo "[*]Copying files..."
cp -v "$PACKAGE/locale/en_US/LC_MESSAGES/$PO_FILE" "$TARGET/LC_MESSAGES/$PO_FILE"
echo "[*]Done"
| |
Add minimal install script for dotfiles | #!/bin/bash
# Install minimal subset of dotfiles without dotbot, for older OSes without
# sane git versions and such.
set -euo pipefail
DOTDIR="${DOTDIR:-dotfiles}"
cd
ln -sfT "$DOTDIR" .dotfiles
ln -sfT "$DOTDIR/bash/bash_profile" .bash_profile
ln -sfT "$DOTDIR/bash/bashrc" .bashrc
ln -sfT "$DOTDIR/bash/liquidpromptrc" .liquidpromptrc
ln -sfT "$DOTDIR/inputrc" .inputrc
ln -sfT "$DOTDIR/vim" .vim
ln -sfT "$DOTDIR/gitconfig" .gitconfig
mkdir -p tmp/vim
chmod -R 700 tmp/vim
touch .vimrc_local
cd "$DOTDIR"
git submodule update --init --recursive
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
| |
Add a script to build a Spur VMMaker image (a VMMaker image in Spur format). | #!/bin/sh
. ./envvars.sh
if [ ! -f trunk46-spur.image -o ! -f trunk46-spur.changes ]; then
./buildspurtrunkimage.sh
fi
cp -p trunk46-spur.image SpurVMMaker.image
cp -p trunk46-spur.changes SpurVMMaker.changes
. ./getGoodSpurVM.sh
echo $VM SpurVMMaker.image BuildSqueak45VMMakerImage.st
$VM SpurVMMaker.image BuildSqueak45VMMakerImage.st
| |
Install script for PHP zopfli extension. | #!/bin/sh
# ----------------------------------------------------------------------------------------------------------------------
# This file is part of {@link https://github.com/MovLib MovLib}.
#
# Copyright © 2013-present {@link https://movlib.org/ MovLib}.
#
# MovLib is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public
# License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# MovLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY# without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License along with MovLib.
# If not, see {@link http://www.gnu.org/licenses/ gnu.org/licenses}.
# ----------------------------------------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------------------------------
# Install PHP extension for zopfli.
#
# LINK: https://github.com/kjdev/php-ext-zopfli
# AUTHOR: Richard Fussenegger <richard@fussenegger.info>
# COPYRIGHT: © 2013 MovLib
# LICENSE: http://www.gnu.org/licenses/agpl.html AGPL-3.0
# LINK: https://movlib.org/
# SINCE: 0.0.1-dev
# ----------------------------------------------------------------------------------------------------------------------
cd /usr/local/src
git clone https://github.com/kjdev/php-ext-zopfli.git
git clone https://github.com/PKRoma/zopfli.git
cd php-ext-zopfli
ln -s /usr/local/src/zopfli/src/zopfli zopfli
phpize
./configure
make
make test
make install
rm -rf /usr/local/src/php-ext-zopfli
rm -rf /usr/local/src/zopfli
| |
Add startup script for RVM | #!/usr/bin/env bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Name: rvm.bash
# Author: prince@princebot.com
# Source: https://github.com/princebot/dotfiles
# Synopsis: Set Ruby Version Manager (RVM) configuration.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# If RVM is installed, load it.
if [[ -d ~/.rvm/bin && -s ~/.rvm/scripts/rvm ]]; then
dotfiles.pathmunge ~/.rvm/bin after
source ~/.rvm/scripts/rvm
fi
| |
Add git tagging script to track deployments | #!/usr/bin/env bash
set -euo pipefail
if [[ -z "$( git config user.signingkey )" ]]; then
echo "$0: GPG signing key required." >&2
exit 2
fi
repo_dir="$( cd $( dirname $0 )/.. && pwd )"
deploy_dir="$( git config deploy.dir )"
cd "$deploy_dir"
deploy_commit_date="$( git show -s --format=%ci | awk '{print $1;}' )"
deploy_commit_id="$( git rev-parse --short HEAD )"
tag="deploy/$deploy_commit_date/$deploy_commit_id"
cd "$repo_dir"
git tag -s "$tag" -m "deployed" && git push --tags
| |
Add a simple assembly test script | #!/usr/bin/env bash
objdump="otool -tV"
yasm=yasm
asmfile="ud_yasmtest.asm"
binfile="ud_yasmtest.bin"
elffile="ud_yasmtest.elf"
echo "[bits $1]" > $asmfile
echo $2 >> $asmfile
$yasm -f bin -o $binfile $asmfile && \
$yasm -f elf -o $elffile $asmfile
if [ ! $? -eq 0 ]; then
echo "error: failed to assemble"
exit 1
fi
echo "-- hexdump --------------------------------------"
hexdump $binfile
echo
# echo "-- objdump --------------------------------------"
# $objdump -d $elffile
# echo
echo "-- udcli ----------------------------------------"
../udcli/udcli -$1 $binfile
exit 0
| |
Support the_silver_searcher completion in Zsh | local ag_completions
if [[ -n $HOMEBREW_PREFIX && -e $HOMEBREW_PREFIX/opt/ag ]] {
ag_completions=$HOMEBREW_PREFIX/opt/ag/share/zsh/site-functions
}
[[ $ag_completions ]] && fpath=($ag_completions $fpath)
| |
Fix the widget creation script to respect directory structure | #! /bin/sh
if [ -e ./proximityreminder.wgt ]; then
rm -v proximityreminder.wgt
fi
# Zip all the html, javascript, CSS, images and other information.
zip proximityreminder.wgt *.html ./js/*.js ./css/*.css ./css/images/* config.xml remind_me.png
if [ -e ./proximityreminder-nowebinosjs.wgt ]; then
rm -v proximityreminder-nowebinosjs.wgt
fi
# Do it again, but this time without webinos.js
zip proximityreminder-nowebinosjs.wgt *.html ./js/*.js ./css/*.css ./css/images/* config.xml remind_me.png -x ./js/webinos.js
| #! /bin/sh
if [ -e ./proximityreminder.wgt ]; then
rm -v proximityreminder.wgt
fi
# Zip all the html, javascript, CSS, images and other information.
zip -r proximityreminder.wgt *.html ./js/*.js ./css/* config.xml remind_me.png -x *~ -x */*~
if [ -e ./proximityreminder-nowebinosjs.wgt ]; then
rm -v proximityreminder-nowebinosjs.wgt
fi
# Do it again, but this time without webinos.js
zip -r proximityreminder-nowebinosjs.wgt *.html ./js/*.js ./css/* config.xml remind_me.png -x ./js/webinos.js -x *~ -x */*~
|
Add a script to tidy up the Javascript | #!/bin/bash
D=$(dirname $(readlink -nf $BASH_SOURCE))
SD=$(readlink -nf $D/../httpdocs)
# The js-beautify directory. (It can be cloned from
# https://github.com/einars/js-beautify .)
JSB=~/js-beautify/
if [ ! -e ~/js-beautify/beautify-cl.js ]
then
echo "Couldn't find the beautify-cl.js script"
exit 1
fi
case "$#" in
0)
find $SD -name experiment -prune -o -name '*.js' -print0 |
xargs -0 -n 1 $BASH_SOURCE
;;
1)
if [ -e "$1" ]
then
T=$(mktemp) &&
rhino $JSB/beautify-cl.js -i 2 -a -b -n -p -d $JSB $1 > $T &&
echo '/* -*- mode: espresso; espresso-indent-level: 2; indent-tabs-mode: nil -*- */
/* vim: set softtabstop=2 shiftwidth=2 tabstop=2 expandtab: */
' > $1 &&
sed -e 's/[ \t]*$//' $T >> $1 &&
rm $T
else
echo "$1 didn't exist"
exit 1
fi
;;
*)
echo Usage: $0 [JAVASCRIPT_FILE]
;;
esac
| |
Use vendor/bundle for bundler install path. | #
# Defines bundler aliases.
#
# Authors:
# Myron Marston <myron.marston@gmail.com>
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Aliases
alias b='bundle'
alias be='b exec'
alias bi='b install --path vendor'
alias bl='b list'
alias bo='b open'
alias bp='b package'
alias bu='b update'
alias binit="bi && b package && print '\nvendor/ruby' >>! .gitignore"
| #
# Defines bundler aliases.
#
# Authors:
# Myron Marston <myron.marston@gmail.com>
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Aliases
alias b='bundle'
alias be='b exec'
alias bi='b install --path vendor/bundle'
alias bl='b list'
alias bo='b open'
alias bp='b package'
alias bu='b update'
alias binit="bi && b package && print '\nvendor/ruby' >>! .gitignore"
|
Add scripts for updating all deps | #!/bin/bash
TARGETS="rpi0 \
rpi3 \
bbb \
host
"
for target in $TARGETS; do
MIX_TARGET=$target mix do deps.get, deps.compile
done
| |
Add script to benchmark app startup time | #! /bin/sh
set -e
checkout_dir="$(dirname $0)/../../"
cd $checkout_dir
checkout_dir=$(pwd)
app_dir=`mktemp -d /tmp/meteor-bench-app.XXXX`
cd $app_dir
$checkout_dir/meteor create --example todos . &> /dev/null
# Add a file to the app that shuts it down immediately
echo "Meteor.startup(function(){process.exit(0)});" > "exit.js"
# Run once to build all of the packages
$checkout_dir/meteor --once &> /dev/null
# Run again to time
/usr/bin/time -p $checkout_dir/meteor --once 1> /dev/null 2> out
BENCHMARK_OUTPUT=`cat out`
# Get first line
BENCHMARK_OUTPUT=$(echo "$BENCHMARK_OUTPUT" | head -n 1)
ARRAY=($BENCHMARK_OUTPUT)
NUMBER=${ARRAY[1]}
# Print output
echo $NUMBER
cd $checkout_dir
# XXX are we going to rm -rf our whole disk by accident here?
rm -rf "$app_dir"
| |
Add script to import and clean latest db dump | #!/bin/bash -e
LATEST_PROD_DUMP=$(aws s3 ls digitalmarketplace-database-backups | grep production | sort -r | head -1 | awk '{print $4}')
aws s3 cp s3://digitalmarketplace-database-backups/"${LATEST_PROD_DUMP}" ./"${LATEST_PROD_DUMP}"
gpg2 --batch --import <($DM_CREDENTIALS_REPO/sops-wrapper -d $DM_CREDENTIALS_REPO/gpg/database-backups/secret.key.enc)
SERVICE_DATA=$(cf curl /v3/apps/"$(cf app --guid db-cleanup)"/env | jq -r '.system_env_json.VCAP_SERVICES.postgres[0].credentials')
DB_HOST=$(echo $SERVICE_DATA | jq -r '.host')
DB_USERNAME=$(echo $SERVICE_DATA | jq -r '.username')
DB_PASSWORD=$(echo $SERVICE_DATA | jq -r '.password')
DB_NAME=$(echo $SERVICE_DATA | jq -r '.name')
DB_URI="postgres://${DB_USERNAME}:${DB_PASSWORD}@localhost:63306/${DB_NAME}"
cf ssh db-cleanup -N -L 63306:"$DB_HOST":5432 &
TUNNEL_PID="$!"
sleep 10
psql "${DB_URI}" < \
<(echo -n $($DM_CREDENTIALS_REPO/sops-wrapper -d $DM_CREDENTIALS_REPO/gpg/database-backups/secret-key-passphrase.txt.enc) | \
gpg2 --batch --passphrase-fd 0 --pinentry-mode loopback --decrypt ./"${LATEST_PROD_DUMP}" | \
gunzip)
rm "${LATEST_PROD_DUMP}"
psql --variable bcrypt_password="'$(./scripts/generate-bcrypt-hashed-password.py Password1234 4)'" "${DB_URI}" < ./scripts/clean-db-dump.sql
kill -9 "${TUNNEL_PID}"
| |
Add shell script for copying gfx drivers & multimedia packages | #!/bin/bash
MM_PKG_REVISION="20150727"
MM_PKG_NAME="R-Car_Series_Evaluation_Software_Package"
MM_PKG_USERLAND="for_Linux"
MM_PKG_KERNEL="of_Linux_Drivers"
ZIP_1=${MM_PKG_NAME}_${MM_PKG_USERLAND}-${MM_PKG_REVISION}.zip
ZIP_2=${MM_PKG_NAME}_${MM_PKG_KERNEL}-${MM_PKG_REVISION}.zip
COPY_GFX_SCRIPT=copy_gfx_software_$1.sh
COPY_MM_SCRIPT=copy_mm_software_lcb.sh
test -f ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs && source ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs
DOWNLOAD_DIR=${XDG_DOWNLOAD_DIR:-$HOME/Downloads}
function copy_mm_packages() {
if [ ! -d binary-tmp ]; then
if [ -f $DOWNLOAD_DIR/$ZIP_1 -a -f $DOWNLOAD_DIR/$ZIP_2 ]; then
mkdir binary-tmp
cd binary-tmp
unzip -o $DOWNLOAD_DIR/$ZIP_1
unzip -o $DOWNLOAD_DIR/$ZIP_2
cd ..
else
echo -n "The graphics and multimedia acceleration packages for "
echo -e "the R-Car M2 Porter board can be download from :"
echo -e " <http://www.renesas.com/secret/r_car_download/rcar_demoboard.jsp>"
echo -e
echo -n "These 2 files from there should be store in your"
echo -e "'$DOWNLOAD_DIR' directory."
echo -e " $ZIP_1"
echo -e " $ZIP_2"
return -1
fi
fi
if [ -f meta-renesas/meta-rcar-gen2/$COPY_GFX_SCRIPT ]; then
cd meta-renesas/meta-rcar-gen2/
./$COPY_GFX_SCRIPT ../../binary-tmp
cd ../..
else
echo "scripts to copy GFX drivers for '$1' not found."
return -1
fi
if [ -f meta-renesas/meta-rcar-gen2/$COPY_MM_SCRIPT ]; then
cd meta-renesas/meta-rcar-gen2/
./$COPY_MM_SCRIPT ../../binary-tmp
cd ../..
else
echo "scripts to copy MM software for '$1' not found."
return -1
fi
}
| |
Configure apt and update index | #!/usr/bin/env bash
TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/openstack"
# Pick up VM_PROXY
source "$CONFIG_DIR/localrc"
source "$LIB_DIR/functions.guest"
indicate_current_auto
exec_logfile
function set_apt_proxy {
local PRX_KEY="Acquire::http::Proxy"
local APT_FILE=/etc/apt/apt.conf
if [ -f $APT_FILE ] && grep -q $PRX_KEY $APT_FILE; then
# apt proxy has already been set (by preseed/kickstart)
if [ -n "${VM_PROXY-}" ]; then
# Replace with requested proxy
sudo sed -i "s#^\($PRX_KEY\).*#\1 \"$VM_PROXY\";#" $APT_FILE
else
# No proxy requested -- remove
sudo sed -i "s#^$PRX_KEY.*##" $APT_FILE
fi
elif [ -n "${VM_PROXY-}" ]; then
# Proxy requested, but none configured: add line
echo "$PRX_KEY \"$VM_PROXY\";" | sudo tee -a $APT_FILE
fi
}
set_apt_proxy
# Get apt index files
sudo apt-get update
# cloud-keyring to verify packages from ubuntu-cloud repo
sudo apt-get install ubuntu-cloud-keyring
# Install packages needed for add-apt-repository
sudo apt-get -y install software-properties-common python-software-properties
sudo add-apt-repository -y "cloud-archive:$OPENSTACK_RELEASE"
# Get index files only for ubuntu-cloud repo but keep standard lists
sudo apt-get update \
-o Dir::Etc::sourcelist="sources.list.d/cloudarchive-$OPENSTACK_RELEASE.list" \
-o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
| |
Add dse hw build script for max3 | #!/bin/env bash
function setBuild() {
numPipes=$1
inputWidth=$2
cacheSize=$3
maxRows=$4
designName=spark-${numPipes}x${inputWidth}_${cacheSize}c_${maxRows}10kr
echo "Setting build $designName"
cp sparkdse ${designName} -r
cd ${designName}
javaCrap="private static final int"
sed "s/${javaCrap} INPUT_WIDTH = .*;/${javaCrap} INPUT_WIDTH = $inputWidth;/g" -i src/spmv/src/SpmvManager.maxj
sed "s/${javaCrap} NUM_PIPES = .*;/${javaCrap} NUM_PIPES= $numPipes;/g" -i src/spmv/src/SpmvManager.maxj
sed "s/${javaCrap} cacheSize = .*;/${javaCrap} cacheSize = $cacheSize;/g" -i src/spmv/src/SpmvManager.maxj
sed "s/${javaCrap} MAX_ROWS = .*;/${javaCrap} MAX_ROWS = ${maxRows}0000;/g" -i src/spmv/src/SpmvManager.maxj
mkdir build
cd build
export CC=/opt/gcc-4.9.2/bin/gcc
export CXX=/opt/gcc-4.9.2/bin/g++
export LD_LIBRARY_PATH=/opt/gcc-4.9.2/lib64/:${LD_LIBRARY_PATH}
source /vol/cc/opt/maxeler/maxcompiler-2013.2.2/settings.sh
export MAXELEROSDIR=${MAXCOMPILERDIR}/lib/maxeleros-sim/lib
cmake ..
make spmvlib_dfe
cd ../../
}
for i in \
3,4,2048,7 \
3,8,2048,7
do
IFS=","; set $i
setBuild $1 $2 $3 $4 &
done
| |
Move the build script to a version-controlled file. | #!/bin/bash
#
# This script is only intended to run in the IBM DevOps Services Pipeline Environment.
#
#!/bin/bash
echo Informing slack...
curl -X 'POST' --silent --data-binary '{"text":"A new build for the room service has started."}' $WEBHOOK > /dev/null
echo Downloading Java 8...
wget http://game-on.org:8081/jdk-8u65-x64.tar.gz -q
echo Extracting Java 8...
tar xzf jdk-8u65-x64.tar.gz
echo And removing the tarball...
rm jdk-8u65-x64.tar.gz
export JAVA_HOME=$(pwd)/jdk1.8.0_65
# echo $JAVA_HOME
echo Building projects using gradle...
./gradlew build
echo Building and Starting Concierge Docker Image...
cd concierge-wlpcfg
../gradlew buildDockerImage removeCurrentContainer startNewContainer
echo Building and Starting Room Docker Image...
cd ../room-wlpcfg
../gradlew buildDockerImage removeCurrentContainer startNewContainer
echo Removing JDK, cause there's no reason that's an artifact...
cd ..
rm -rf jdk1.8.0_65 | |
Add missing create swap for vagrant based bosh-lite | #!/bin/sh
# size of swap in megabytes
swapsize=${1:-6144}
swapfile=${2:-"swapfile"}
# does the swap file already exist?
grep -q "$swapfile" /etc/fstab
# if not then create it
if [ $? -ne 0 ]; then
echo "$swapfile not found. Adding $swapfile."
fallocate -l ${swapsize}M /$swapfile
chmod 600 /$swapfile
mkswap /$swapfile
swapon /$swapfile
echo "/$swapfile none swap defaults 0 0" >> /etc/fstab
else
echo "$swapfile found. No changes made."
fi
# output results to terminal
cat /proc/swaps
cat /proc/meminfo | grep Swap
| |
Add script to create and upload GCE image. | #! /bin/sh -e
export NIX_PATH=nixpkgs=../../../..
export NIXOS_CONFIG=$(dirname $(readlink -f $0))/../../../modules/virtualisation/google-compute-image.nix
export TIMESTAMP=$(date +%Y%m%d%H%M)
nix-build '<nixpkgs/nixos>' \
-A config.system.build.googleComputeImage --argstr system x86_64-linux -o gce --option extra-binary-caches http://hydra.nixos.org -j 10
img=$(echo gce/*.tar.gz)
if ! gsutil ls gs://nixos/$(basename $img); then
gsutil cp $img gs://nixos/$(basename $img)
fi
gcutil addimage $(basename $img .raw.tar.gz | sed 's|\.|-|' | sed 's|_|-|') gs://nixos/$(basename $img)
| |
Add a tool to import all news articles | #!/bin/bash
set -e
OUTPUT_DIR=`pwd`/_posts
PYTHON_UTIL=`pwd`/import_srweb.py
NEWS_DIR=$1
cd $NEWS_DIR
find . -not -name '.*' -type f | cut -c3- | xargs -I @ echo python3 $PYTHON_UTIL -s -l news @ -o $OUTPUT_DIR/@.md
| |
Verify every tool has a manual page | #!/bin/bash
SOURCE_PATH=../
# find all the manual pages in doc/tools
TOOLS=`find "${SOURCE_PATH}/doc/tools" -name "*.1.xml" | sed -E -e "s|.*/([a-z0-9-]*).*|\1|"`
ALL=1
for T in $TOOLS; do
SWITCHES=$( ${SOURCE_PATH}/src/tools/${T} --help 2>&1 \
| grep -v "unrecognized option '--help'" \
| awk '{if (match($0,"--[a-zA-Z0-9-]*",a) != 0) print a[0]}
{if (match($0," -[a-zA-Z0-9]",a) != 0) print a[0]}' )
for S in $SWITCHES; do
grep -q -- "$S" ${SOURCE_PATH}/doc/tools/${T}.1.xml || { echo "${T}: missing switch $S"; ALL=0; };
done
done
if [ "$ALL" = 0 ]; then
echo "Not all the switches in help are documented in manual pages"
exit 1;
fi
| #!/bin/bash
SOURCE_PATH=../
# find all the manual pages in doc/tools
TOOLS=`find "${SOURCE_PATH}/doc/tools" -name "*.1.xml" | sed -E -e "s|.*/([a-z0-9-]*).*|\1|"`
ALL=1
for T in $TOOLS; do
SWITCHES=$( ${SOURCE_PATH}/src/tools/${T} --help 2>&1 \
| grep -v "unrecognized option '--help'" \
| awk '{if (match($0,"--[a-zA-Z0-9-]*",a) != 0) print a[0]}
{if (match($0," -[a-zA-Z0-9]",a) != 0) print a[0]}' )
for S in $SWITCHES; do
grep -q -- "$S" ${SOURCE_PATH}/doc/tools/${T}.1.xml || { echo "${T}: missing switch $S"; ALL=0; };
done
done
if [ "$ALL" = 0 ]; then
echo "Not all the switches in help are documented in manual pages"
exit 1
fi
RES=0
# find all tools in src/tools (files without extension)
TOOLS=`find "${SOURCE_PATH}/src/tools" -maxdepth 1 -type f ! -name "*.*" | sed -E -e "s|.*/([a-z0-9-]*).*|\1|"`
for T in $TOOLS; do
if [[ ! -f "${SOURCE_PATH}/doc/tools/$T.1.xml" ]]; then
echo "Missing manual page for '$T'"
RES=1
fi
done
exit $RES
|
Add hackage docs uploader script | #!/bin/bash
# Ripped off from:
# https://github.com/ekmett/lens/blob/master/scripts/hackage-docs.sh
set -e
if [ "$#" -ne 1 ]; then
echo "Usage: scripts/hackage-docs.sh HACKAGE_USER"
exit 1
fi
user=$1
cabal_file=$(find . -maxdepth 1 -name "*.cabal" -print -quit)
if [ ! -f "$cabal_file" ]; then
echo "Run this script in the top-level package directory"
exit 1
fi
pkg=$(awk -F ":[[:space:]]*" 'tolower($1)=="name" { print $2 }' < "$cabal_file")
ver=$(awk -F ":[[:space:]]*" 'tolower($1)=="version" { print $2 }' < "$cabal_file")
if [ -z "$pkg" ]; then
echo "Unable to determine package name"
exit 1
fi
if [ -z "$ver" ]; then
echo "Unable to determine package version"
exit 1
fi
echo "Detected package: $pkg-$ver"
dir=$(mktemp -d build-docs.XXXXXX)
trap 'rm -r "$dir"' EXIT
cabal haddock --hoogle --hyperlink-source --html-location='/package/$pkg-$version/docs' --contents-location='/package/$pkg-$version'
cp -R dist/doc/html/$pkg/ $dir/$pkg-$ver-docs
tar cvz -C $dir --format=ustar -f $dir/$pkg-$ver-docs.tar.gz $pkg-$ver-docs
curl -X PUT \
-H 'Content-Type: application/x-tar' \
-H 'Content-Encoding: gzip' \
-u "$user" \
--data-binary "@$dir/$pkg-$ver-docs.tar.gz" \
"https://hackage.haskell.org/package/$pkg-$ver/docs"
| |
Add script to install Homebrew | #!/usr/bin/env bash
if ! type "$brew" > /dev/null; then
echo -e "Installing Homebrew!\n"
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
| |
Add borg wrapper script for cron. | #!/bin/bash
set -eu
password="$(cat ~/documents/secure/files/borg-passwd.txt)"
archive="$(date +%B-%d-%Y | tr '[:upper:]' '[:lower:]')"
backup="/media/archive/backup/titus/borg"
locations=(
"$HOME"
"/media/media"
"/media/archive/git"
)
export BORG_PASSPHRASE="$password"
exec \
ionice -c 3 \
nice -n 10 \
borg create \
-v \
--stats \
--progress \
--compression auto,lzma \
"$backup::$archive" \
"${locations[@]}"
| |
Remove comments and blank line |
#!/bin/bash
# R refuses to build packages that mark themselves as
# "Priority: Recommended"
mv DESCRIPTION DESCRIPTION.old
grep -v '^Priority: ' DESCRIPTION.old > DESCRIPTION
#
$R CMD INSTALL --build .
#
# # Add more build steps here, if they are necessary.
#
# See
# http://docs.continuum.io/conda/build.html
# for a list of environment variables that are set during the build
# process.
# | #!/bin/bash
mv DESCRIPTION DESCRIPTION.old
grep -v '^Priority: ' DESCRIPTION.old > DESCRIPTION
$R CMD INSTALL --build .
|
Add pbcopy and pbpaste aliasese for Japanese on MacOS X | # This is related with .CFUserTextEncoding file located in same directory
# See http://developer.apple.com/documentation/CoreFoundation/Reference/CFStringRef/Reference/reference.html
uid=`printf '0x%X' \`id -u\``
alias pbcopy="__CF_USER_TEXT_ENCODING=${uid}:0x8000100:14 pbcopy"
alias pbpaste="__CF_USER_TEXT_ENCODING=${uid}:0x8000100:14 pbpaste"
| |
Use build script for building Linux native libs instead of embedding steps in .csproj | #!/bin/bash
OutDir=$(sed 's/\\/\//g' <<<"$1")
(cd ../Native/libmultihash && make clean && make && mv ../Native/libmultihash/libmultihash.so "$OutDir")
(cd ../Native/libethhash && make clean && make && mv ../Native/libethhash/libethhash.so "$OutDir")
(cd ../Native/libcryptonote && make clean && make && mv ../Native/libcryptonote/libcryptonote.so "$OutDir")
(cd ../Native/libcryptonight && make clean && make && mv ../Native/libcryptonight/libcryptonight.so "$OutDir")
((cd /tmp && rm -rf RandomX && git clone https://github.com/tevador/RandomX && cd RandomX && git checkout tags/v1.1.10 && mkdir build && cd build && cmake -DARCH=native .. && make) && (cd ../Native/librandomx && cp /tmp/RandomX/build/librandomx.a . && make clean && make) && mv ../Native/librandomx/librandomx.so "$OutDir")
((cd /tmp && rm -rf RandomARQ && git clone https://github.com/arqma/RandomARQ && cd RandomARQ && git checkout 14850620439045b319fa6398f5a164715c4a66ce && mkdir build && cd build && cmake -DARCH=native .. && make) && (cd ../Native/librandomarq && cp /tmp/RandomX/build/librandomx.a . && make clean && make) && mv ../Native/librandomarq/librandomarq.so "$OutDir")
| |
Add required finder code for Scanse Sweep. | #!/usr/bin/env bash
# Grab and save the path to this script
# http://stackoverflow.com/a/246128
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
SCRIPTDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
# echo ${SCRIPTDIR} # For debugging
node ${SCRIPTDIR}/../node/UsbDevice.js "FT230X_Basic_UART" ID_MODEL
| |
Add get user memberships script | #!/bin/bash
########################################################################################
# MIT License #
# #
# Copyright (c) Blair Robertson 2022 #
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy #
# of this software and associated documentation files (the "Software"), to deal #
# in the Software without restriction, including without limitation the rights #
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell #
# copies of the Software, and to permit persons to whom the Software is #
# furnished to do so, subject to the following conditions: #
# #
# The above copyright notice and this permission notice shall be included in all #
# copies or substantial portions of the Software. #
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE #
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, #
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE #
# SOFTWARE. #
########################################################################################
#
# Outputs a list of AEM Groups that a user is a Direct member
#
# Usage:
# $ get-user-memberships.sh <aem url> <user> <user path>
# $ get-user-memberships.sh http://localhost:4502 admin:admin
# $ get-user-memberships.sh http://localhost:4502 admin:admin /home/users/O/OIkFTmQdLMQkpcYQtZWR
set -ue
AEM_HOST="${1:-http://localhost:4502}"
AEM_USER="${2:-admin:admin}"
USER_PATH="${3:-/home/users/missing}"
# set -x
curl -sSf -G -u "${AEM_USER}" \
"${AEM_HOST}${USER_PATH}.rw.json" \
-d 'props=declaredMemberOf' \
| jq -r '.declaredMemberOf[] | .authorizableId' | dos2unix
| |
Add the regression test missed previously | #!/usr/bin/env atf-sh
. $(atf_get_srcdir)/test_environment.sh
tests_init \
inline_repo
inline_repo_body() {
cat > pkgconfiguration << EOF
repositories: {
pkg1: { url = file:///tmp },
pkg2: { url = file:///tmp2 },
}
EOF
atf_check -o match:'^ url : "file:///tmp",$' \
-o match:'^ url : "file:///tmp2",$' \
pkg -o REPOS_DIR=/dev/null -C pkgconfiguration -vv
}
| |
Revert "We no longer need this functionality" | #!/bin/bash
if [ "$TRAVIS_BRANCH" = "master" ]
then
echo "Configuring deployment to staging site"
sed -i -e "s|/vol/www/richmondsunlight.com|/vol/www/test.richmondsunlight.com|g" appspec.yml
fi
| |
Add tool to track migration to neutron-lib | #!/bin/bash
function count_imports() {
local module="$1"
local path="$2"
egrep -R -w "^(import|from) $module" --exclude-dir=".*tox" $your_project | wc -l
}
if [ $# -eq 0 ]; then
echo "Please specify path to your project."
exit 1
else
your_project="$1"
fi
total_imports=$(egrep -R -w "^(import|from)" --exclude-dir=".*tox" $your_project | wc -l)
neutron_imports=$(count_imports neutron $your_project)
lib_imports=$(count_imports neutron_lib $your_project)
total_neutron_related_imports=$((neutron_imports + lib_imports))
echo "You have $total_imports total imports"
echo "You imported Neutron $neutron_imports times"
echo "You imported Neutron-Lib $lib_imports times"
if [ "$lib_imports" -eq 0 ]; then
echo "Your project does not import neutron-lib once, you suck!"
fi
goal=$(bc -l <<< "scale=4; ($lib_imports/$total_neutron_related_imports*100)")
target=$(bc <<< "$goal>50")
if [ "$target" -eq 0 ]; then
echo "You need to get to 100%, you are this far: $goal%, get on with it!"
else
echo "You need to get to 100%, you are close: $goal%, good job!"
fi
| |
Move drone.io build rules to the repo. | #!/bin/sh
set -x
export ANDROID_SDK_TOOLS_VERSION=24.3.4
PATH=$(echo $PATH | sed 's/\/opt\/android-sdk-linux//')
export ANDROID_HOME=$PWD/android-sdk-linux
wget https://dl.google.com/android/android-sdk_r$ANDROID_SDK_TOOLS_VERSION-linux.tgz -nv
tar xzf android-sdk_r$ANDROID_SDK_TOOLS_VERSION-linux.tgz
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/build-tools
android list sdk --extended --all
echo yes | android update sdk --no-ui --all --force --filter tools,platform-tools,build-tools-23.0.2,android-23,extra-android-m2repository,extra-android-support
./gradlew assembleDebug
| |
Fix a strange line cut | #!/bin/bash
SRC=/cygdrive/D/Illumina/MiSeqOutput/
DST=/backup/MiSeq
echo '' >> backup.log
echo '--------------------' >> backup.log
date >> backup.log
rsync -av --stats --exclude='Images*' --exclude='Alignment*' $SRC virologysrv10
.uzh.ch:$DST &>> backup.log
echo 'backed up' >> backup.log
date >> backup.log
echo '--------------------' >> backup.log
echo '' >> backup.log
| #!/bin/bash
SRC=/cygdrive/D/Illumina/MiSeqOutput/
DST=/backup/MiSeq
echo '' >> backup.log
echo '--------------------' >> backup.log
date >> backup.log
rsync -av --stats --exclude='Images*' --exclude='Alignment*' $SRC virologysrv10.uzh.ch:$DST &>> backup.log
echo 'backed up' >> backup.log
date >> backup.log
echo '--------------------' >> backup.log
echo '' >> backup.log
|
Add script for coding style checking | #!/bin/bash
# Copyright (c) 2014 Intel Corporation. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# stolen from https://github.com/crosswalk-project/tizen-extensions-crosswalk
if [ ! `which cpplint.py` ]; then
echo -en "\nPlease make sure cpplint.py is in your PATH. "
echo -e "It is part of depot_tools inside Chromium repository."
exit 1
fi
# Store current dir and change to repository root dir.
OLD_PWD=$PWD
SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $SELF_DIR/..
# TODO(vignatti): maybe we should remove the OZONE_ prefix from all header
# guards and activate
FILTERS="-build/header_guard"
cpplint.py --filter="$FILTERS" $(find \
\( -name '*.h' -o -name '*.cc' \) )
# Return to previous dir and return the code returned by cpplint.py
RET_VAL=$?
cd $OLD_PWD
exit $RET_VAL
| |
Add task to run bosh errands in pipeline | #!/bin/bash -ex
bosh -u x -p x target $BOSH_TARGET Lite
bosh login $BOSH_USERNAME $BOSH_PASSWORD
bosh status
bosh download manifest cf-warden > manifest.yml
bosh deployment manifest.yml
bosh run errand $ERRAND_NAME
| |
Hide Docker insanity behind a mediocre shell script | #!/bin/bash
# This is an absolutely terrible shell script which should always
# successfully rebuild the client image, and probably also always
# emit confusing semi-meaningless error messages.
docker-machine create -driver virtualbox default
docker-machine start default
eval "$(docker-machine env default)"
docker rmi $(docker images -f dangling=true -q)
npm install
docker-compose build
docker-compose up
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.