Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Add a script to extract syntax tree from beam files.
#!/bin/bash # # Extract abstract syntax tree from a beam file compiled with # debug_info flag. # # ./ast.sh misc.beam erl_file=$1 erl_script=$(cat <<EOF {ok, {_, [{abstract_code, {_, AST}}]}} = beam_lib:chunks("${erl_file}", [abstract_code]), io:format("~p~n", [AST]), init:stop(0). EOF ) erl -noinput -eval "${erl_script}"
Add prepare router script for all in one cluster
#!/bin/bash echo "Creating router user" echo \ '{"kind":"ServiceAccount","apiVersion":"v1","metadata":{"name":"router"}}' \ | oc create -f - echo "Add router user" oc patch scc privileged --type=json -p '[{"op": "add", "path": "/users/0", "value":"system:serviceaccount:default:router"}]'
Disable SIP on 10.11 (for VMware)
#!/bin/sh date > /etc/box_build_time OSX_VERS=$(sw_vers -productVersion | awk -F "." '{print $2}') # Set computer/hostname COMPNAME=osx-10_${OSX_VERS} scutil --set ComputerName ${COMPNAME} scutil --set HostName ${COMPNAME}.vagrantup.com # Packer passes boolean user variables through as '1', but this might change in # the future, so also check for 'true'. if [ "$INSTALL_VAGRANT_KEYS" = "true" ] || [ "$INSTALL_VAGRANT_KEYS" = "1" ]; then echo "Installing vagrant keys for $USERNAME user" mkdir "/Users/$USERNAME/.ssh" chmod 700 "/Users/$USERNAME/.ssh" curl -L 'https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub' > "/Users/$USERNAME/.ssh/authorized_keys" chmod 600 "/Users/$USERNAME/.ssh/authorized_keys" chown -R "$USERNAME" "/Users/$USERNAME/.ssh" fi # Create a group and assign the user to it dseditgroup -o create "$USERNAME" dseditgroup -o edit -a "$USERNAME" "$USERNAME"
#!/bin/sh date > /etc/box_build_time OSX_VERS=$(sw_vers -productVersion | awk -F "." '{print $2}') # Set computer/hostname COMPNAME=osx-10_${OSX_VERS} scutil --set ComputerName ${COMPNAME} scutil --set HostName ${COMPNAME}.vagrantup.com # Packer passes boolean user variables through as '1', but this might change in # the future, so also check for 'true'. if [ "$INSTALL_VAGRANT_KEYS" = "true" ] || [ "$INSTALL_VAGRANT_KEYS" = "1" ]; then echo "Installing vagrant keys for $USERNAME user" mkdir "/Users/$USERNAME/.ssh" chmod 700 "/Users/$USERNAME/.ssh" curl -L 'https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub' > "/Users/$USERNAME/.ssh/authorized_keys" chmod 600 "/Users/$USERNAME/.ssh/authorized_keys" chown -R "$USERNAME" "/Users/$USERNAME/.ssh" fi # Create a group and assign the user to it dseditgroup -o create "$USERNAME" dseditgroup -o edit -a "$USERNAME" "$USERNAME" if [ "$OSX_VERS" = "11" ]; then nvram boot-args=rootless=0 reboot fi
Add command line to compile query stats
#!/bin/sh cat /var/log/manticore/query.log | sed '/ (0,[0-9][0-9]\+)\] \[/!d; /_index\] *$/d; s/\[... \(...\) \?\([0-9]\+\) [0-9.:]\+ \([0-9]\+\)\].*\] \[\([a-z]\+\)\(_main\)\?_index[^]]*\] \?\(.*\)$/\2 \1 \3,\4,\6/'
Add script for comparing benchmark results
#!/bin/bash ##################################################### # cmpbench - script for comparing benchmark results # # args: # - $1: path to package that will be benchmarked, # optional, defaults to: plugins/kvscheduler ##################################################### set -euo pipefail SCRIPT_DIR="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))" BENCH_PKG_DIR=${1:-${SCRIPT_DIR}/../plugins/kvscheduler} [ -z ${OUTPUT_DIR-} ] && OUTPUT_DIR=/tmp/bench mkdir -p "$OUTPUT_DIR" OLD_BENCH="${OUTPUT_DIR}/old.txt" NEW_BENCH="${OUTPUT_DIR}/new.txt" CMP_BENCH="${OUTPUT_DIR}/cmp.txt" CMP_BENCH_IMG="${OUTPUT_DIR}/cmp.svg" function benchtest() { cd "$BENCH_PKG_DIR" go test -run=NONE -bench=. -benchmem -benchtime=3s } BENCH_PKG=$(go list $BENCH_PKG_DIR) echo "-> running cmpbench for package: $BENCH_PKG" [ -f "${OLD_BENCH}" ] && grep -q "pkg: $BENCH_PKG" $OLD_BENCH || { rm -f $OLD_BENCH $NEW_BENCH $CMP_BENCH $CMP_BENCH_IMG echo "-> creating old bench.." echo "--------------------------------------------------------------" benchtest | tee $OLD_BENCH echo "--------------------------------------------------------------" echo "old bench at: $OLD_BENCH" echo "run this script again for comparing with new benchmark" exit 0 } echo "-> found old bench at: $OLD_BENCH" echo "--------------------------------------------------------------" cat $OLD_BENCH echo "--------------------------------------------------------------" echo "-> creating new bench.." echo "--------------------------------------------------------------" benchtest | tee $NEW_BENCH echo "--------------------------------------------------------------" echo "-> new bench at: $OLD_BENCH" echo "-> comparing benchmarks.." if ! which benchcmp >/dev/null; then echo "-> downloading benchcmp.." go get golang.org/x/tools/cmd/benchcmp fi if ! which benchviz >/dev/null; then echo "-> downloading benchviz.." go get github.com/ajstarks/svgo/benchviz fi echo "--------------------------------------------------------------" benchcmp $OLD_BENCH $NEW_BENCH | tee $CMP_BENCH echo "--------------------------------------------------------------" cat $CMP_BENCH | benchviz -title="$BENCH_PKG" > $CMP_BENCH_IMG echo "-> bench comparison image at: $CMP_BENCH_IMG" if [ -t 1 ]; then exo-open $CMP_BENCH_IMG; fi
Add memory checking in unit test
#!/bin/bash VALGRIND_OPTS="--show-reachable=yes --leak-check=full" export PATH=.:${PATH} for cmd in $@; do \valgrind ${VALGRIND_OPTS} ${cmd} done
Add script for updating mavros
#!/bin/bash # # Script to update mavros following instruction in https://dev.px4.io/en/ros/mavros_installation.html # Usage: source update_mavros.sh # Remove existing mavros cd ~/catkin_ws/src rm -rf mavros cd ~/catkin_ws wstool init src rosinstall_generator --rosdistro kinetic mavlink | tee /tmp/mavos.rosinstall rosinstall_generator --upstream mavros | tee /tmp/mavros.rosinstall wstool merge -t src /tmp/mavros.rosinstall wstool update -t src if ! rosdep install --from-paths src --ignore-src --rosdistro kinetic -y; then # (Use echo to trim leading/trailing whitespaces from the unsupported OS name unsupported_os=$(echo $(rosdep db 2>&1| grep Unsupported | awk -F: '{print $2}')) rosdep install --from-paths src --ignore-src --rosdistro kinetic -y --os ubuntu:xenial fi catkin build
Add poly dir and converter
#!/usr/sh IDS=$1 rm *.geojson for ID in $IDS ; do wget "http://polygons.openstreetmap.fr/?id=$ID&params=0" -O /dev/null # Call the generator wget "http://polygons.openstreetmap.fr/get_geojson.py?id=$ID&params=0" -O $ID.geojson done # Merge geojson cat *.geojson | \ sed -e 's/^{"type":"GeometryCollection","geometries":\[{"type":"MultiPolygon","coordinates":\[//' -e 's/]}]}$/,/' >> $2.tmp echo '{"type":"GeometryCollection","geometries":[{"type":"MultiPolygon","coordinates":[' > $2.geojson cat $2.tmp | tr -d '\n' | sed -e 's/,$//' >> $2.geojson echo ']}]}' >> $2.geojson # Convert ot KML ogr2ogr -f "KML" -lco COORDINATE_PRECISION=7 $2.kml $2.geojson rm *.geojson $2.tmp
Add wrapper script to make it easier to install repositories from the command line. This will be used by child containers.
#!/bin/sh # start Galaxy /usr/bin/supervisord sleep 60 python ./scripts/api/install_tool_shed_repositories.py --api admin -l http://localhost:8080 --tool-deps --repository-deps $1 exit_code=$? if [ $exit_code != 0 ] ; then exit $exit_code fi # stop everything supervisorctl stop all
Add script to copy hud files from GameTracking DB
#!/bin/bash # Copy all resource files cp -r ../GameTracking/tf/tf/tf2_misc_dir/resource . # Only get the scripts directly related to the hud cp ../GameTracking/tf/tf/tf2_misc_dir/scripts/hudlayout.res scripts/ cp ../GameTracking/tf/tf/tf2_misc_dir/scripts/hudanimations_tf.txt scripts/ cp ../GameTracking/tf/tf/tf2_misc_dir/scripts/hudanimations_manifest.txt scripts/
Add heloer to flash boot0 only
#!/bin/sh # # Simple script to replace boot0.bin in an existing image. # set -ex out="$1" boot0="$2" if [ -z "$out" ]; then echo "Usage: $0 /dev/sdX [<boot0.bin>]" exit 1 fi if [ -z "$boot0" ]; then boot0="../blobs/boot0.bin" fi boot0_position=8 # KiB boot0_size=$(wc -c $boot0) pv "$boot0" | dd conv=notrunc bs=1k seek=$boot0_position count=32 oflag=direct of="$out" sync
Add tool to automatically create list of known sites
#!/bin/sh known_domains='known_domains.txt' #Establish all the domains we know about from configuration cat data/sites/* data/transition-sites/* $known_domains | grep -o -i -E '[a-zA-Z0-9-]*\.[a-zA-Z0-9-]*\.?[a-zA-Z0-9-]*\.?[a-zA-Z0-9-]*\.?[a-zA-Z0-9-]{1,61}\.\w{2,6}' | sort | uniq
Add a script to provide Git tips.
#!/usr/bin/env bash #============================================================================= # Copyright (c) 2010 Insight Software Consortium. All rights reserved. # See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. # # This software is distributed WITHOUT ANY WARRANTY; without even # the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR # PURPOSE. See the above copyright notices for more information. #============================================================================= # This script makes optional suggestions for working with git. if test "$(git config color.ui)" != "auto"; then cat << EOF You may want to enable color output from Git commands with git config --global color.ui auto EOF fi if ! bash -i -c 'echo $PS1' | grep -q '__git_ps1'; then cat << EOF A dynamic, informative Git shell prompt can be obtained by sourcing the git bash-completion script in your ~/.bashrc. Set the PS1 environmental variable as suggested in the comments at the top of the bash-completion script. You may need to install the bash-completion package from your distribution to obtain the script. EOF fi if ! git config merge.tool >/dev/null; then cat << EOF A merge tool can be configured with git config merge.tool <toolname> For more information, see git help mergetool EOF fi if ! git config hooks.uncrustify >/dev/null; then cat << EOF ITK comes with a pre-commit hook to help committed code to conform to the ITK Style Guidelines (See Documentation/Style.pdf). When committing code, it can be passed through uncrustify (http://uncrustify.sourceforge.net). However, this feature is disabled by default. To enable this feature, git config --bool hooks.uncrustify true EOF fi echo "Done."
Add environment variables for our container registry
# Export an environment variable with our docker registry export ZENJOY_CONTAINER_REGISTRY="d5kixmzg.gra7.container-registry.ovh.net" export ZCR=$ZENJOY_CONTAINER_REGISTRY
Add script to update the changelog
#!/bin/bash NOW=$(date +'%Y-%m-%d') sed "s/# Next/\\$(printf '# Next\\\n\\\n# '"[$VERSION] - $NOW")/" Changelog.md > tmpCHANGELOG.md mv -f tmpCHANGELOG.md Changelog.md
Add docker script + readme update
mode=$1 case "$mode" in "mongoshell" ) docker run -it --link mongo:mongo --rm mongo sh -c 'exec mongo "$MONGO_PORT_27017_TCP_ADDR:$MONGO_PORT_27017_TCP_PORT/test"' exit 3 ;; "up" ) docker=$(docker ps) if [ $? -eq 1 ]; then echo "Either docker is not installed, not running or your internet is down :(" exit 3 fi docker stop $(docker ps -a -q) docker rm $(docker ps -a -q) docker pull mongo:latest docker run -v "$(pwd)":/data --name mongo -d mongo mongod --smallfiles docker pull node:latest docker run --name node -v "$(pwd)":/data --link mongo:mongo -w /data -p 8082:8082 node bash ;; "ssh" ) docker run -it -v "$(pwd)":/data --link mongo:mongo -w /data -p 3000:3000 node bash ;; esac
Add apache password to domain web root
# Copyright © 2019 Feature.su. All rights reserved. # Licensed under the Apache License, Version 2.0 if [ -z $3 ] then echo "Usage for create apache password: sh add-apache-pass-to-www.sh domain.name.without.www user pass" else if [ -d /var/www/$1 ] then mkdir -p /etc/httpd/htpasswd/ htpasswd -b -c /etc/httpd/htpasswd/$1 $2 $3 chmod 600 /etc/httpd/htpasswd/$1 chown $1:$1 /etc/httpd/htpasswd/$1 echo "Use VHostHtpasswd $1" >> /etc/httpd/conf.modules.d/11-domains.conf systemctl reload httpd else echo "Domain $1 NOT exists"; fi fi
Use Expect to run the CLI
#!/usr/bin/expect -f set timeout -1 cd $env(REACT_NATIVE_VERSION) spawn ./node_modules/bugsnag-react-native-cli/bin/cli init expect "Do you want to continue anyway?" send -- "Y\r" expect "If you want the latest version of @bugsnag/react-native hit enter, otherwise type the version you want" send -- latest\r expect "What is your Bugsnag API key?" send -- 12312312312312312312312312312312\r expect "Do you want to automatically upload source maps as part of the Xcode build?" send -- y expect "Do you want to automatically upload source maps as part of the Gradle build?" send -- y # TODO Remove once BAGP is released for real expect "If you want the latest version of the Bugsnag Android Gradle plugin hit enter, otherwise type the version you want" send -- v5.5.0-alpha01\r expect "If you want the latest version of @bugsnag/source-maps hit enter, otherwise type the version you want" send -- latest\r expect eof
Add iterm config for ssh tab color.
# Usage: # source iterm2.zsh # iTerm2 window/tab color commands # Requires iTerm2 >= Build 1.0.0.20110804 # http://code.google.com/p/iterm2/wiki/ProprietaryEscapeCodes tab-color() { echo -ne "\033]6;1;bg;red;brightness;$1\a" echo -ne "\033]6;1;bg;green;brightness;$2\a" echo -ne "\033]6;1;bg;blue;brightness;$3\a" } tab-reset() { echo -ne "\033]6;1;bg;*;default\a" } # Change the color of the tab when using SSH # reset the color after the connection closes color-ssh() { if [[ -n "$ITERM_SESSION_ID" ]]; then trap "tab-reset" INT EXIT if [[ "$*" =~ "production|ec2-.*compute-1" ]]; then tab-color 255 0 0 else tab-color 0 255 0 fi fi ssh $* } compdef _ssh color-ssh=ssh alias ssh=color-ssh
Add script to run mpi tests in CPUs with fewer cores
#!/bin/bash go build -o /tmp/gosl/t_mpi00_main t_mpi00_main.go && mpirun --oversubscribe -np 8 /tmp/gosl/t_mpi00_main tests="t_mpi01_main t_mpi02_main t_mpi03_main t_mpi04_main" for t in $tests; do go build -o /tmp/gosl/$t "$t".go && mpirun --oversubscribe -np 3 /tmp/gosl/$t done
Add a script to generate sha256sums from Gitian output
#!/usr/bin/env bash export LC_ALL=C set -euo pipefail help_message() { echo "Output sha256sums from Gitian build output." echo "Usage: $0 AssetDirectory > sha256sums" } if [ "$#" -ne 1 ]; then echo "Error: Expects 1 argument: AssetDirectory" exit 1 fi case $1 in -h|--help) help_message exit 0 ;; esac # Trim off preceding whitespace that exists in the manifest trim() { sed 's/^\s*//' } # Get the hash of the source tarball and output that first cat "$1"/linux/bitcoin-abc-*linux-res.yml | grep -E "bitcoin-abc-[0-9.]+.tar.gz" | trim # Output hashes of all of the binaries cat "$1"/linux/bitcoin-abc-*linux-res.yml | grep -E "bitcoin-abc-[0-9.]+.*-linux-.*.tar.gz" | trim cat "$1"/win/bitcoin-abc-*win-res.yml | grep -E -- "bitcoin-abc-[0-9.]+-win.*.(exe|tar.gz|zip)" | trim cat "$1"/osx/bitcoin-abc-*osx-res.yml | grep -E -- "bitcoin-abc-[0-9.]+-osx.*.(dmg|tar.gz)" | trim
Add script to check for code conventions.
#!/bin/bash # # Scan for mandatory code conventions. # SOURCE="${BASH_SOURCE[0]}" DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" ROOT="$DIR/../.." # # Scan a file for tabs. Fail if any tab is found. # function rejectTabs { f=$1 TAB_OCCURRENCES=`grep -n "$(printf '\t')" $f` TAB_COUNT=$(echo -n $TAB_OCCURRENCES | wc -c) if [ "$TAB_COUNT" -gt 0 ] then echo $TAB_OCCURRENCES echo "ERROR: Code convention violated: Found a tab in " $f exit 1 fi } # # Fail if any javascript, java, scala, build/deploy.xml or markdown file has a tab # function checkForTabs { #root directory to scan root=$1 for f in $(find "$root" -name "*.js" -o -name "*.java" -o -name "*.scala" -o -name "build.xml" -o -name "deploy.xml" -o -name "*.md" \ | grep -Fv resources/swagger-ui \ | grep -Fv consul/ui/static \ | grep -Fv node_modules \ | grep -Fv site-packages) do rejectTabs $f done } # # Fail if there are any symlinks found with the exception of wsk and wskadmin # function checkForLinks { #root directory to scan root=$1 for f in $(find "$root" -type l | grep -v node_modules | grep -v bin/wsk) do echo "Rejecting because of symlink $f" ls -l $f exit 1 done } checkForTabs "$ROOT" checkForLinks "$ROOT"
Add vector envelope examples with h2
#!/bin/bash #geoc vector envelope -i naturalearth.gpkg -l places -o envelope.db -r envelope #geoc vector envelopes -i naturalearth.gpkg -l countries -o envelope.db -r envelopes geoc vector defaultstyle --color "#0066FF" -o 0.15 -g linestring > envelope.sld geoc vector defaultstyle --color navy -o 0.15 -g polygon > envelopes.sld geoc map draw -f vector_envelope.png -b "-180,-90,180,90" \ -l "layertype=layer file=naturalearth.gpkg layername=ocean style=ocean.sld" \ -l "layertype=layer file=naturalearth.gpkg layername=countries style=countries.sld" \ -l "layertype=layer dbtype=h2 database=envelope.db layername=envelope style=envelope.sld" \ -l "layertype=layer dbtype=h2 database=envelope.db layername=envelopes style=envelopes.sld"
Add script to check if an input trace ended in a violation
#!/bin/bash trace=$1 if [ "$trace" == "" ]; then echo 1>&2 "Usage: $0 <Path to trace file>" exit 1 fi result=`grep InvariantViolation $trace` if [ "$result" == "" ]; then echo "No invariant violation" else echo $result fi
Create a docker memlimits file for core 3.0.
#!/bin/bash set -x MEMLIMIT='' SWAPLIMIT='' CLIENTTHREADS='' CONNECTIONS='' while [[ $# -gt 0 ]] do key="$1" case $key in -m|--memory) MEMLIMIT="$2" shift shift ;; -s|--swap) SWAPLIMIT="$2" shift shift ;; --clientThreads) CLIENTTHREADS="$2" shift shift ;; --connections) CONNECTIONS="$2" shift shift ;; esac done if [[ "$MEMLIMIT" -ne "" ]] && [[ "$SWAPLIMIT" -ne "" ]]; then MEMARG="--memory=${MEMLIMIT}m --memory-swap=${SWAPLIMIT}m" fi if [[ "$CLIENTTHREADS" -ne "" ]]; then CLIENTTHREADSARG="--clientThreads $CLIENTTHREADS" fi if [[ "$CONNECTIONS" -ne "" ]]; then CONNECTIONSARG="--connections $CONNECTIONS" fi dotnet ~/src/aspnet-benchmarks/src/BenchmarksDriver/bin/Release/netcoreapp2.1/BenchmarksDriver.dll \ --server $SERVER_URL \ --client $CLIENT_URL \ --no-clean \ --jobs https://raw.githubusercontent.com/brianrob/benchmarks/master/src/Benchmarks/benchmarks.te.core-3.0.json \ --scenario Plaintext-AspNetCore \ --arg "$MEMARG" \ $CLIENTTHREADSARG \ $CONNECTIONSARG \
Add script to check for basic configuration settings (specific to our cluster)
#!/bin/bash DOCKER=`which docker` if [ -z "$DOCKER" ]; then echo "Docker is missing" fi DOCKER_VERSION=`$DOCKER --version` if [ z"$DOCKER_VERSION" != z"Docker version 1.8.3, build f4bf5c7" ]; then echo "Wrong Docker version, please use 1.8.3" fi if ! pip freeze | grep -q kazoo; then echo "Please install python-kazoo" fi if ! route -n | grep -q 192.168.46; then echo "Please add routing: sudo route add -net 192.168.46.0/24 dev eth0" fi if ! grep -q -e '\<bigfoot.eurecom.fr\>' /etc/resolv.conf; then echo "Please add bigfoot.eurecom.fr to the search list in /etc/resolv.conf" fi echo "If nothing is printed above this line, all dependencies are ok"
Add script to install terminal-based tools
#!/bin/sh source "${BASH_SOURCE%/*}/functions.lib" print_start autojump install autojump print_start bat install bat print_start csvkit install csvkit print_start diff-so-fancy install diff-so-fancy print_start fd install fd print_start htop install htop print_start httpie install httpie print_start jq install jq print_start ncdu install ncdu print_start noti install noti print_start q install q print_start siege install siege print_start the_silver_searcher install the_silver_searcher print_start tldr install tldr print_start unrar install unrar print_start fzf install fzf $(brew --prefix)/opt/fzf/install
Delete .libs when done copying
cd vendor/onig CPPFLAGS="$1" CFLAGS="$1" ./configure make clean make cp .libs/libonig.a ../../src/libonig.a cp oniguruma.h ../../src/oniguruma.h
cd vendor/onig CPPFLAGS="$1" CFLAGS="$1" ./configure make clean make cp .libs/libonig.a ../../src/libonig.a cp oniguruma.h ../../src/oniguruma.h rm -fr .libs
Add script to support /cluster bumping
#!/usr/bin/env bash # Copyright 2022 The Kubernetes 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. set -o xtrace set -o errexit set -o nounset set -o pipefail CLOUD_PROVIDER_PATH="${CLOUD_PROVIDER_PATH:-$GOPATH/src/k8s.io/cloud-provider-gcp}" KUBERNETES_PATH="${KUBERNETES_PATH:-$GOPATH/src/k8s.io/kubernetes}" cd "${CLOUD_PROVIDER_PATH}" rm -rf cluster cp -R "${KUBERNETES_PATH}/cluster" ./ rm -rf cluster/images rm -rf cluster/README.md git checkout cluster/addons/pdcsi-driver git checkout cluster/OWNERS git checkout cluster/addons/cloud-controller-manager git checkout cluster/bin/kubectl git checkout cluster/clientbin.sh git checkout cluster/common.sh git checkout cluster/gce/manifests/cloud-controller-manager.manifest git checkout cluster/gce/manifests/pdcsi-controller.yaml git checkout cluster/kubectl.sh git checkout cluster/util.sh for f in $(git ls-files -m | grep -e '\.sh$'); do gawk -i inplace '{ gsub(/source "\$\{KUBE_ROOT\}\/hack\/lib\/util\.sh"$/, "source \"${KUBE_ROOT}/cluster/util.sh\"") }; { print }' $f ; done for new_owner_file in $(git ls-files --others --exclude-standard | grep -e 'OWNERS$'); do rm $new_owner_file done for build_file in $(git ls-files -d | grep BUILD); do git checkout $build_file done echo " Please review all remaning chagnes. We want to keep: * Custom kubectl * PDSCI plugin * Enabled CCM * Credential provider specific code (look for credential sidecar) * Bumped master size * Bumped node size * Enabled ENABLE_DEFAULT_STORAGE_CLASS * Restore 'cluster/util.sh' instead of 'hack/lib/util.sh' This might not be the whole list of changes that needs to be reverted. "
Stop pinning mozlog to 2.1.
# 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/. set -e servo_root="$1" objdir="$2" shift 2 cd $objdir/.. test -d _virtualenv || virtualenv _virtualenv test -d $servo_root/src/test/wpt/metadata || mkdir -p $servo_root/src/test/wpt/metadata test -d $servo_root/src/test/wpt/prefs || mkdir -p $servo_root/src/test/wpt/prefs source _virtualenv/bin/activate if [[ $* == *--update-manifest* ]]; then (python -c "import html5lib" &>/dev/null) || pip install html5lib fi (python -c "import mozlog" &>/dev/null) || pip install mozlog==2.1 #Temporary fix for broken tree (python -c "import wptrunner" &>/dev/null) || pip install 'wptrunner==1.0' python $servo_root/src/test/wpt/run.py \ --config $servo_root/src/test/wpt/config.ini \ --binary $objdir/../servo \ --log-mach - \ "$@"
# 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/. set -e servo_root="$1" objdir="$2" shift 2 cd $objdir/.. test -d _virtualenv || virtualenv _virtualenv test -d $servo_root/src/test/wpt/metadata || mkdir -p $servo_root/src/test/wpt/metadata test -d $servo_root/src/test/wpt/prefs || mkdir -p $servo_root/src/test/wpt/prefs source _virtualenv/bin/activate if [[ $* == *--update-manifest* ]]; then (python -c "import html5lib" &>/dev/null) || pip install html5lib fi (python -c "import wptrunner" &>/dev/null) || pip install 'wptrunner==1.0' python $servo_root/src/test/wpt/run.py \ --config $servo_root/src/test/wpt/config.ini \ --binary $objdir/../servo \ --log-mach - \ "$@"
Add in a converter to the Jargon File-like format
#!/bin/sh DICT_SET=$1 if [ "x${DICT_SET}" = "x" ]; then echo "Euch! Shucks! I need a set to process (in definitions/)" echo "" echo "Valid sets:" echo " $(ls definitions/ | tr "\n" " ")" exit 1 fi find definitions -type f | while read x; do echo ":$(basename ${x}):" fmt "${x}" | sed 's/^/ /g' echo "" done
Add a new profil for CI
# LICENCE : CloudUnit is available under the Affero Gnu Public License GPL V3 : https://www.gnu.org/licenses/agpl-3.0.html # but CloudUnit is licensed too under a standard commercial license. # Please contact our sales team if you would like to discuss the specifics of our Enterprise license. # If you are not sure whether the GPL is right for you, # you can always test our software under the GPL and inspect the source code before you contact us # about purchasing a commercial license. # LEGAL TERMS : "CloudUnit" is a registered trademark of Treeptik and can't be used to endorse # or promote products derived from this project without prior written permission from Treeptik. # Products or services derived from this software may not be called "CloudUnit" # nor may "Treeptik" or similar confusing terms appear in their names without prior written permission. # For any questions, contact us : contact@treeptik.fr #!/bin/bash if [ "$1" != "-y" ]; then echo "Voulez-vous vraiment supprimer tous les conteneurs et recréer la plate-fome CU ? [y/n]" read PROD_ASW if [ "$PROD_ASW" != "y" ] && [ "$PROD_ASW" != "n" ]; then echo "Entrer y ou n!" exit 1 elif [ "$PROD_ASW" = "n" ]; then exit 1 fi fi echo -e "\nRemoving containers\n" docker rm -v $(docker ps -a | grep "Dead" | awk '{print $1}') docker rm -v $(docker ps -q --filter="status=exited") docker rm -vf $(docker ps -aq --filter "label=origin=cloudunit") docker-compose -f docker-compose-prod.yml stop docker-compose -f docker-compose-prod.yml rm -f # delete all NONE images docker rmi $(docker images | grep "<none>" | awk '{print $3}') docker rmi $(docker images | grep "johndoe" | awk '{print $3}') echo -e "\nStarting the platform\n" /home/admincu/cloudunit/cu-platform/start-platform-int.sh echo -e "\nRunning services\n" /home/admincu/cloudunit/cu-services/run-services.sh
Add gfal plugin setup script in cms contrib.
#!/usr/bin/env bash # Sets up gfal plugins for use in a CMSSW environment. # In fact, all plugins seem to work out of the box except for the xrootd plugin. # Therefore, all other plugins are symlinked into a specified directy, and a precompiled xrootd # plugin is copied from eos through a CERNBox link. # Tested with SCRAM_ARCH's slc{6,7}_amd64_gcc{630,700} and CMSSW 9 and 10. # Arguments: # 1. the absolute path to the new gfal plugin directory # 2. (optional) the path to the initial gfal plugin directory, defaults to $GFAL_PLUGIN_DIR action() { local dst_dir="$1" if [ -z "$dst_dir" ]; then 2>&1 echo "please provide the path to the new GFAL_PLUGIN_DIR" return "1" fi local src_dir="$2" if [ -z "$src_dir" ]; then echo "using default the GFAL_PLUGIN_DIR at '$GFAL_PLUGIN_DIR' as source for plugins" src_dir="$GFAL_PLUGIN_DIR" fi # check of the src_dir exists if [ ! -d "$src_dir" ]; then 2>&1 echo "source directory '$src_dir' does not exist" return "1" fi # create the dst_dir if required mkdir -p "$dst_dir" if [ "$?" != "0" ]; then return "1" fi # symlink all plugins ( \ cd "$dst_dir" && \ ln -s $src_dir/libgfal_plugin_*.so . && \ rm -f libgfal_plugin_xrootd.so ) # download the precompiled xrootd plugin, use either wget or curl local plugin_url="https://cernbox.cern.ch/index.php/s/qgrogVY4bwcuCXt/download" if [ ! -z "$( type curl 2> /dev/null )" ]; then ( \ cd "$dst_dir" && \ curl "$plugin_url" > ibgfal_plugin_xrootd.so ) elif [ ! -z "$( type wget 2> /dev/null )" ]; then ( \ cd "$dst_dir" && \ wget "$plugin_url" && \ mv download libgfal_plugin_xrootd.so ) else 2>&1 echo "could not download xrootd plugin, neither wget nor curl installed" return "1" fi # export the new GFAL_PLUGIN_DIR export GFAL_PLUGIN_DIR="$dst_dir" echo "new GFAL_PLUGIN_DIR is '$GFAL_PLUGIN_DIR'" } action "$@"
Add setup script for OS X
#!/bin/bash # Install Xcode command line tools xcode-select --install # Install Homebrew if not installed if [[ -z `which brew` ]]; then echo "Installing Homebrew..." ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" && brew update && brew doctor fi # Some useful tools in Homebrew brew install bash brew install bash-completion brew install cmake brew install htop-osx brew install wget brew install macvim # Install Homebrew Cask echo "Installing Homebrew Cask..." brew install caskroom/cask/brew-cask && brew cask update && brew cask doctor # Install applications with Homebrew Cask brew cask install iterm2 brew cask install firefox brew cask install dropbox brew cask install evernote brew cask install mendeley-desktop
Add script to release mware lib locally
#!/usr/bin/env bash set -eu git stash git pull git checkout tags/mware_lib-0.1.3 cd ./middleware/ ./gradlew clean install git checkout master git stash pop
Add convenience script for deleting /data and adding /data/nostart-* files
#! /bin/bash sudo rm -rf /data/* sudo touch /data/nostart-carbon sudo touch /data/nostart-logstash sudo touch /data/nostart-elasticsearch sudo mkdir /data/system/ sudo touch /data/system/is-slave
Add PR summary generator script
#!/usr/bin/env sh if [ -z $1 ] then echo "pr2relnotes.sh: prints list of pull requests merged since <tag>" echo " usage: $0 <tag> [pull-request-url (default: https://github.com/lrascao/rebar3_appup_plugin/pull/)]" exit 0 fi export url=${2:-"https://github.com/lrascao/rebar3_appup_utils/pull/"} git log --merges --pretty=medium $1..HEAD | \ awk -v url=$url ' # first line of a merge commit entry /^commit / {mode="new"} # merge commit default message / +Merge pull request/ { page_id=substr($4, 2, length($4)-1); mode="started"; next; } # line of content including title mode=="started" && / [^ ]+/ { print "- [" substr($0, 5) "](" url page_id ")"; mode="done" }'
Add OpenSSL script to remove passphrase from private keys
#!/bin/bash ## Remove a pass phrase from a key ## Optionally create a copy of the same removing the pass phrase. # # http://www.akadia.com/services/ssh_test_certificate.html # https://serversforhackers.com/self-signed-ssl-certificates # https://www.sslshopper.com/article-most-common-openssl-commands.html # A blank passphrase: change with your own PASSPHRASE='' if [[ "$#" -ne 2 ]] then echo "Syntax: $(basename "$0") KEYFILE_PASSPHRASE_PROTECTED KEYFILE_PASSPHRASE_FREE" echo "Iillegal number of arguments!" exit 1 fi KEYFILE_PASSPHRASE_PROTECTED="$1" KEYFILE_PASSPHRASE_FREE="$2" if [ "$KEYFILE_PASSPHRASE_FREE" == "$KEYFILE_PASSPHRASE_PROTECTED" ] then echo "Syntax: $(basename "$0") KEYFILE_PASSPHRASE_PROTECTED KEYFILE_PASSPHRASE_FREE" echo "Protected and free key files must be different!" exit 1 fi echo "#### PEM pass phrase free Private Key file in $KEYFILE_PASSPHRASE_FREE" openssl rsa -in "$KEYFILE_PASSPHRASE_PROTECTED" -out "$KEYFILE_PASSPHRASE_FREE" -passin pass:$PASSPHRASE
Add script for purging local S3 cache
#!/bin/bash # # Removes CHI cache files older than 3 (or $ARGV[1]) days # set -e PWD="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" MC_ROOT="$PWD/../" S3_CACHE_ROOT="$MC_ROOT/data/cache/s3_downloads/" S3_CACHE_DEFAULT_DIR="$S3_CACHE_ROOT/Default/" if [ ! -z "$1" ]; then if [[ ! "$1" =~ ^-?[0-9]+$ ]]; then echo "Max. age in days is not an integer." exit 1 fi MAX_AGE_DAYS="$1" else MAX_AGE_DAYS="3" fi # # --- # if [ ! -d "$S3_CACHE_DEFAULT_DIR" ]; then echo "S3 cache 'Default' directory does not exist at: $S3_CACHE_DEFAULT_DIR" exit 1 fi # Verify that the directory has the "0", "1", "2", ..., "e", "f" directory structure if [ ! -d "$S3_CACHE_DEFAULT_DIR/0" ]; then echo "S3 cache 'Default' directory doesn't look like it contains CHI cache: $S3_CACHE_DEFAULT_DIR" exit 1 fi find "$S3_CACHE_DEFAULT_DIR" -type f -mtime "+$MAX_AGE_DAYS" -exec rm {} \; exit 0
Add support to add users to wheel group
#!/usr/bin/env bash # Support to add users to the wheel group and allow root permissions. By # default this should be avoided for the admin user to provide better security. if SUDO_WHEEL_MEMBERS=$(mdata-get sudo_wheel_members >/dev/null 2>&1); then # Create wheel group and ignore if it already exists groupadd -g 100 wheel || true # Add entry for wheel group echo '%wheel ALL=(ALL) NOPASSWD: ALL' > /opt/local/etc/sudoers.d/wheel # Parse space sperated list and add users to wheel group for member in ${SUDO_WHEEL_MEMBERS}; do # Verify if user exists if id ${member} >/dev/null 2>&1; then usermod -G wheel,$(groups ${member} | tr ' ' ',') ${member} fi done fi
Create script for testing LLVM with gasnet.
#!/usr/bin/env bash # # Test gasnet configuration with CHPL_LLVM=llvm and pass --llvm flag to # compiler on linux64. CWD=$(cd $(dirname $0) ; pwd) source $CWD/common-gasnet.bash source $CWD/common-llvm.bash $CWD/nightly -cron -llvm
Add bash-it custom function to download latest pivnet-rc.
#!/bin/bash function download_latest_pivnet_rc() { bucket="pivnet-cli" version_file=$(mktemp -t pivnet-current-version.XXXXXXXX) download_file=$(mktemp -t pivnet-rc-latest.XXXXXXXX) # shellcheck disable=SC2064 trap "rm -rf ${version_file} ${download_file}" EXIT system_uname=$(uname -a) if [[ ${system_uname} == *"Ubuntu"* ]]; then my_os="linux" elif [[ ${system_uname} == *"Darwin"* ]]; then my_os="darwin" else echo "Unrecognized system uname: ${system_uname} - exiting" return fi echo -n "Getting current version... " aws s3 cp "s3://${bucket}/current-version" "${version_file}" 1>/dev/null echo "complete" current_version=$(cat "${version_file}") : "${current_version:?"most recent version not found"}" echo "Current version: ${current_version}" echo -n "Downloading to ${download_file}... " aws s3 cp "s3://${bucket}/pivnet-${my_os}-amd64-${current_version}" "${download_file}" 1>/dev/null echo "complete" echo -n "Installing to /usr/local/bin/pivnet-rc... " cp "${download_file}" /usr/local/bin/pivnet-rc chmod +x /usr/local/bin/pivnet-rc echo "complete" rm -rf "${version_file}" "${download_file}" }
Add a script to beat Eclipse into submission
#!/bin/sh # Use this script to add the files necessary to force Eclipse to use the sezpoz # annotator (it would not be necessary if Eclipse's compiler would follow the # rules set out by the Java specification). for path in $(find . -name pom.xml) do case $path in ./envisaje/*|./sandbox/*) continue ;; esac # skip aggregator modules grep -e '<modules>' $path > /dev/null && continue directory=${path%/pom.xml} factorypath=$directory/.factorypath test -f $factorypath || cat > $factorypath << EOF <factorypath> <factorypathentry kind="VARJAR" id="M2_REPO/net/java/sezpoz/sezpoz/1.9/sezpoz-1.9.jar" enabled="true" runInBatchMode="true"/> </factorypath> EOF prefs=$directory/.settings/org.eclipse.jdt.core.prefs test -f $prefs || { mkdir -p $directory/.settings cat > $prefs << EOF #$(date) eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.processAnnotations=enabled org.eclipse.jdt.core.compiler.source=1.6 EOF echo "Do not forget to commit $prefs even if it is ignored by Git" } done
Add missing script for build
#/bin/sh grep "k8s.io/helm" go.mod | sed -n -e "s/.*k8s.io\/helm \(v[.0-9]*\).*/\1/p"
Add script action to download sample files
##only run on the first headnode lhost=$(hostname) if [[ $lhost != *"hn0"* ]] then exit 1 fi ##setup directories rm -rf ~/weather_temp mkdir ~/weather_temp cd ~/weather_temp ##download sample files from NOAA ftp -inpv ftp.ncdc.noaa.gov << EOF user anonymous jfennessy@blue-granite.com cd /pub/data/ghcn/daily/by_year mget 2015.csv.gz 2014.csv.gz 2016.csv.gz close bye EOF ##unzip files gunzip ~/weather_temp/* ##upload to HDFS hadoop fs -rm -r /data/weather/daily hadoop fs -mkdir -p /data/weather/daily hadoop fs -put ~/weather_temp/* /data/weather/daily ##clean up file system rm -rf ~/weather_temp ##add a section here to copy to ADL -- use a parameter to drive branch ##TODO
Add script for backing up an InfluxDB database
#!/bin/sh # 2017 Tero Paloheimo # This is a script for backing up an InfluxDB database and uploads the backup # to a user specified remote host. # SSH key authentication without a password MUST be in place before running # this script. # Change these values as needed BEFORE running! target_host=example.com target_user=myuser target_directory=/home/mydir usage() { echo "A script for backing up InfluxDB metastore and database data." echo "Example: $0 env_logger" } if [ $# -eq 0 ] || [ "$1" = '-h' ]; then usage exit 1 fi db_name=$1 backup_dir="/tmp/influx_backup_${db_name}" backup_file_name="influxdb_${db_name}_$(date -Iminutes).tar.xz" mkdir ${backup_dir} echo "Backing up metastore" influxd backup ${backup_dir} if [ $? -ne 0 ]; then echo "Error: metastore backup failed, stopping." >&2 rm -rf ${backup_dir} exit 1 fi echo "Backing up database ${db_name}" influxd backup -database ${db_name} ${backup_dir} if [ $? -ne 0 ]; then echo "Error: database ${db_name} backup failed, stopping." >&2 rm -rf ${backup_dir} exit 1 fi cd /tmp || exit 1 tar -cJf "./${backup_file_name}" ${backup_dir} if [ $? -ne 0 ]; then echo "Error: backup directory compression failed, stopping." >&2 rm -rf ${backup_dir} exit 1 fi rm -rf ${backup_dir} echo "Uploading file to ${target_host}:${target_directory}" if [ $(scp "./${backup_file_name}" "${target_user}@${target_host}:${target_directory}/") ]; then echo "File upload failed." else echo "File upload succeeded!" fi rm "./${backup_file_name}"
Bring back script to generate coverage reports
#!/bin/sh APPBASE_INFO=appbase.info APPTEST_INFO=apptest.info APPTOTAL_INFO=apptotal.info make distclean rm -rf $APPBASE_INFO $APPTEST_INFO html make -j 5 PROFILE=1 all test lcov --capture --initial --base-directory . --directory . --output-file $APPBASE_INFO ( cd test && ./test ) lcov --capture --base-directory . --directory . --output-file $APPTEST_INFO lcov --base-directory . --directory . --output-file $APPTOTAL_INFO \ --add-tracefile $APPBASE_INFO --add-tracefile $APPTEST_INFO lcov --remove $APPTOTAL_INFO '/usr/*' --output-file $APPTOTAL_INFO lcov --remove $APPTOTAL_INFO 'newsbeuter/test/*' --output-file $APPTOTAL_INFO rm -rf html genhtml -o html $APPTOTAL_INFO
Create run file in master branch.
function init(){ switch_repo_to_dev_branch run_cloud9_setup_scripts } function run_cloud9_setup_scripts(){ local called_from_directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" local setup_script_name_and_path=$(printf "%s/z_scripts/setup_c9_to_work_on_repo.bash" $called_from_directory) bash $setup_script_name_and_path } function switch_repo_to_dev_branch(){ local called_from_directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $called_from_directory git checkout develop cd $GOPATH } init
Fix path to node binaries
#!/usr/bin/env bash export NODE_HOME=$HOME/node mkdir ${NODE_HOME} if [ "${TRAVIS_OS_NAME}" == "osx" ]; then curl https://s3.amazonaws.com/mapbox/apps/install-node/v2.0.0/run | NV=4.4.2 NP=darwin-x64 OD=${NODE_HOME} sh else curl https://s3.amazonaws.com/mapbox/apps/install-node/v2.0.0/run | NV=4.4.2 NP=linux-x64 OD=${NODE_HOME} sh fi export PATH="${NODE_HOME}:$PATH" node --version npm --version which node
#!/usr/bin/env bash NODE_HOME=$HOME/node export NODE_HOME mkdir ${NODE_HOME} if [ "${TRAVIS_OS_NAME}" == "osx" ]; then curl https://s3.amazonaws.com/mapbox/apps/install-node/v2.0.0/run | NV=4.4.2 NP=darwin-x64 OD=${NODE_HOME} sh else curl https://s3.amazonaws.com/mapbox/apps/install-node/v2.0.0/run | NV=4.4.2 NP=linux-x64 OD=${NODE_HOME} sh fi PATH="${NODE_HOME}/bin:$PATH" export PATH node --version npm --version which node
Add github support to Dockerfile
#!/bin/bash echo "Fetching notebooks from" $GIT_REPO git clone $GIT_REPO /home/notebooks echo "Running Notebook" /opt/conda/bin/jupyter notebook --ip='*' --notebook-dir=/home/notebooks --port=8888 --no-browser
Add GnuPG verified phpunit script
#!/usr/bin/env bash clean=1 # Delete phpunit.phar after the tests are complete? gpg --fingerprint D8406D0D82947747293778314AA394086372C20A if [ $? -ne 0 ]; then echo -e "\033[33mDownloading PGP Public Key...\033[0m" gpg --recv-keys D8406D0D82947747293778314AA394086372C20A # Sebastian Bergmann <sb@sebastian-bergmann.de> gpg --fingerprint D8406D0D82947747293778314AA394086372C20A if [ $? -ne 0 ]; then echo -e "\033[31mCould not download PGP public key for verification\033[0m" exit fi fi if [ "$clean" -eq 1 ]; then # Let's clean them up, if they exist if [ -f phpunit.phar ]; then rm -f phpunit.phar fi if [ -f phpunit.phar.asc ]; then rm -f phpunit.phar.asc fi fi # Let's grab the latest release and its signature if [ ! -f phpunit.phar ]; then wget https://phar.phpunit.de/phpunit.phar fi if [ ! -f phpunit.phar.asc ]; then wget https://phar.phpunit.de/phpunit.phar.asc fi # Verify before running gpg --verify phpunit.phar.asc phpunit.phar if [ $? -eq 0 ]; then echo echo -e "\033[33mBegin Unit Testing\033[0m" # Run the testing suite phpunit --configuration phpunit.xml.dist # Cleanup if [ "$clean" -eq 1 ]; then echo -e "\033[32mCleaning Up!\033[0m" rm -f phpunit.phar rm -f phpunit.phar.asc fi else echo chmod -x phpunit.phar mv phpunit.phar /tmp/bad-phpunit.phar mv phpunit.phar.asc /tmp/bad-phpunit.phar.asc echo -e "\033[31mSignature did not match! PHPUnit has been moved to /tmp/bad-phpunit.phar\033[0m" exit 1 fi
Add script to tag repo with the version number in the VERSION file
#!/bin/bash # Tag the master and debian branch HEADs with the version in ./VERSION, # according to format specified in ./debian/gbp.conf VERSION=$(cat VERSION | tr -d '\n') # Retag master and debian git tag -f -a master/${VERSION} master -m "Tagged master branch with version $version" #git tag -f -a debian/${VERSION} debian -m "Tagged debian branch with version $version"
Add script to run multiple commands in multiple directories
#!/bin/bash # # Usage: [... dirs] run [... command] # Exmaple: ./fordirs.sh dir1 dir2 dirs* run ls -a if [ -z "$2" ] then echo "Usage is ./runDirs" exit 1 fi directories=() run=() found_run=false for var in "$@" do if [ "$found_run" = true ] then run+=("$var") else if [ "$var" = "run" ] then found_run=true else directories+=("$var") fi fi done if [ -z $run ] then echo "Need to supply run command" exit 1 fi for d in "${directories[@]}" do test -d "$d" || continue # Do something with $dir... echo "---> $d" cd "$d" "${run[@]}" cd .. done
Add regression test for the new "round-robin reading" feature.
#!/bin/sh # $FreeBSD$ name="test" base=`basename $0` us0=45 us1=`expr $us0 + 1` us2=`expr $us0 + 2` ddbs=2048 nblocks1=1024 nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)` src=`mktemp /tmp/$base.XXXXXX` || exit 1 dst=`mktemp /tmp/$base.XXXXXX` || exit 1 dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us0 || exit 1 mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us1 || exit 1 mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us2 || exit 1 graid3 label -r $name /dev/md${us0} /dev/md${us1} /dev/md${us2} || exit 1 dd if=${src} of=/dev/raid3/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 dd if=/dev/raid3/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then echo "FAIL" else echo "PASS" fi graid3 stop $name mdconfig -d -u $us0 mdconfig -d -u $us1 mdconfig -d -u $us2 rm -f ${src} ${dst}
Create bash script for importing git repositories
#!/bin/bash shy init shy author name "git2shy importer" IFS=$'\n' for line in $(git rev-list --first-parent --reverse --pretty=oneline HEAD); do sha1=$(echo $line | cut -d " " -f 1) msg=$(echo $line | cut -d " " -f 2-) git checkout $sha1 shy add . shy commit "$msg (import $sha1 from git)" done
Add script to create index by URL using hardlinks
#!/bin/sh # # Before: # > df -i /mnt/datavolume/zoomhub/ # Filesystem Inodes IUsed IFree IUse% Mounted on # /dev/xvdb1 6553600 1192855 5360745 19% /mnt/datavolume # CONTENT_BY_ID='/mnt/datavolume/zoomhub/data/content-by-id' CONTENT_BY_URL='/mnt/datavolume/zoomhub/data/content-by-url' for target in $CONTENT_BY_ID/*.json ; do content=$(cat "$target") contentID=$(printf "$content" | json 'id') contentURL=$(printf "$content" | json url) targetHash=$(printf "$contentURL" | sha256sum | tr -d '[:space:]-') linkName="$CONTENT_BY_URL/$targetHash.json" echo "Processing: $contentID" ln $target $linkName done
Add --exclude integer,parse_iso8601 (temporarily) to make Travis pass until uninitialized read issue in FormatISO8601DateTime is fixed
#!/usr/bin/env bash # # Copyright (c) 2019 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. export LC_ALL=C.UTF-8 export CONTAINER_NAME=ci_native_fuzz_valgrind export PACKAGES="clang-8 llvm-8 python3 libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev valgrind" export NO_DEPENDS=1 export RUN_UNIT_TESTS=false export RUN_FUNCTIONAL_TESTS=false export RUN_FUZZ_TESTS=true export FUZZ_TESTS_CONFIG="--exclude integer,parse_iso8601 --valgrind" export GOAL="install" export SYSCOIN_CONFIG="--enable-fuzz --with-sanitizers=fuzzer CC=clang-8 CXX=clang++-8" # Use clang-8, instead of default clang on bionic, which is clang-6 and does not come with libfuzzer on aarch64
Add script to setup python test environment.
#!/bin/bash CTYPES_VERSION=1.0.2 curl -kL https://raw.github.com/saghul/pythonz/master/pythonz-install | bash . $HOME/.pythonz/etc/bashrc sudo apt-get install -y \ build-essential \ zlib1g-dev \ libbz2-dev \ libssl-dev \ libreadline-dev \ libncurses5-dev \ libsqlite3-dev \ libgdbm-dev \ libdb-dev \ libexpat-dev \ libpcap-dev \ liblzma-dev \ libpcre3-dev pythonz install 2.4.6 2.5.6 2.6.9 2.7.8 3.1.5 3.2.5 3.3.5 3.4.1 cd /tmp wget https://dl.dropboxusercontent.com/u/20387324/ctypes-1.0.2.tar.gz tar -xzf ctypes-${CTYPES_VERSION}.tar.gz cd ctypes-${CTYPES_VERSION} $HOME/.pythonz/pythons/CPython-2.4.6/bin/python setup.py install cd - rm -rf ctypes*
Add a really simple "integration" test
#!/bin/bash # TODO: I'm going to regret writing this in bash, convert to mocha _exit() { node examples/server.js delete echo "OK" } trap "_exit" 0 node examples/server.js out=$(node client.js simple-service) if [[ "${out}" != "{\"A\":{\"foo\":\"bar\"}}" ]]; then echo "Unexpected output: ${out}" echo "FAIL" exit 1 fi
Check in notes on migration so others can view if they want
sudo -u postgres /usr/bin/createdb observatory -E UTF8 -l en_US.UTF8 -T template0 sudo -u postgres /usr/bin/psql -c "ALTER USER postgres PASSWORD 'zaq12wsxcde34rfv'" sudo -u postgres psql < /vagrant/production/obs.dump.sql sudo -u www-data /var/www/Observatory/observatory/manage.py migrate dashboard --noinput sudo -u www-data /var/www/Observatory/observatory/manage.py migrate todo --fake --noinput sudo -u www-data rsync /vagrant/production/screenshots/screenshots/* /var/www/Observatory/observatory/media/screenshots/ -vzP
Add scipt for DY with one norm regularizor
Idx_dataset="1 2 3 4 5 6" for idx in $Idx_dataset do /usr/local/MATLAB/R2012a/bin/matlab -r "cd ..; datasetId = $idx; Exp_DY_one_norm_H; exit;" & done
Add function to grep docker-compose logs
dc_grep(){ if [[ ! "$1" == "" ]]; then if [[ ! "$2" == "" ]]; then watch 'docker-compose logs '"$1"' | grep '"$2"' | sed "s/^[^|]*|[^\ ]*\ .*\]/\n==>/" | tail' else watch 'docker-compose logs | grep '"$1"' | sed "s/^[^|]*|[^\ ]*\ .*\]/\n==>/" | tail' fi else watch 'docker-compose logs | sed "s/^[^|]*|[^\ ]*\ .*\]/\n==>/" | tail' fi }
Add a script that checks tmux version
#!/usr/bin/env bash VERSION="$1" UNSUPPORTED_MSG="$2" get_tmux_option() { local option=$1 local default_value=$2 local option_value=$(tmux show-option -gqv "$option") if [ -z "$option_value" ]; then echo "$default_value" else echo "$option_value" fi } # Ensures a message is displayed for 5 seconds in tmux prompt. # Does not override the 'display-time' tmux option. display_message() { local message="$1" # display_duration defaults to 5 seconds, if not passed as an argument if [ "$#" -eq 2 ]; then local display_duration="$2" else local display_duration="5000" fi # saves user-set 'display-time' option local saved_display_time=$(get_tmux_option "display-time" "750") # sets message display time to 5 seconds tmux set-option -gq display-time "$display_duration" # displays message tmux display-message "$message" # restores original 'display-time' value tmux set-option -gq display-time "$saved_display_time" } # this is used to get "clean" integer version number. Examples: # `tmux 1.9` => `19` # `1.9a` => `19` get_digits_from_string() { local string="$1" local only_digits="$(echo "$string" | tr -dC '[:digit:]')" echo "$only_digits" } tmux_version_int() { local tmux_version_string=$(tmux -V) echo "$(get_digits_from_string "$tmux_version_string")" } unsupported_version_message() { if [ -n "$UNSUPPORTED_MSG" ]; then echo "$UNSUPPORTED_MSG" else echo "Error! This Tmux version is unsupported. Please install Tmux version $VERSION or greater!" fi } exit_if_unsupported_version() { local current_version="$1" local supported_version="$2" if [ "$current_version" -lt "$supported_version" ]; then display_message "$(unsupported_version_message)" exit 1 fi } main() { local supported_version_int="$(get_digits_from_string "$VERSION")" local current_version_int="$(tmux_version_int)" exit_if_unsupported_version "$current_version_int" "$supported_version_int" } main
Add script for purging local S3 cache
#!/bin/bash # # Removes CHI cache files older than 3 (or $ARGV[1]) days # set -e PWD="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" MC_ROOT="$PWD/../" S3_CACHE_ROOT="$MC_ROOT/data/cache/s3_downloads/" S3_CACHE_DEFAULT_DIR="$S3_CACHE_ROOT/Default/" if [ ! -z "$1" ]; then if [[ ! "$1" =~ ^-?[0-9]+$ ]]; then echo "Max. age in days is not an integer." exit 1 fi MAX_AGE_DAYS="$1" else MAX_AGE_DAYS="3" fi # # --- # if [ ! -d "$S3_CACHE_DEFAULT_DIR" ]; then echo "S3 cache 'Default' directory does not exist at: $S3_CACHE_DEFAULT_DIR" exit 1 fi # Verify that the directory has the "0", "1", "2", ..., "e", "f" directory structure if [ ! -d "$S3_CACHE_DEFAULT_DIR/0" ]; then echo "S3 cache 'Default' directory doesn't look like it contains CHI cache: $S3_CACHE_DEFAULT_DIR" exit 1 fi find "$S3_CACHE_DEFAULT_DIR" -type f -mtime "+$MAX_AGE_DAYS" -exec rm {} \; exit 0
Add BMP reading example script.
#!/bin/sh set -e echo -- Bitmap header echo BMP signature: "$(xx -r --char 2)" echo File size: "$(xx -r --uint32)" echo Reserved fields: "$(xx -r --uint16 2)" echo Absolute offset to start of image data: "$(xx -r --uint32)" echo echo -- BITMAPINFOHEADER header echo Header size: "$(xx -r --uint32)" echo Image size \(width x height\): "$(xx -r --int32 2)" echo Number of planes in image: "$(xx -r --uint16)" echo Bits per pixel: "$(xx -r --uint16)" echo Compression type: "$(xx -r --uint32)" image_data_size="$(xx -r --uint32)" echo Size of image data in bytes: "$image_data_size" echo Image resolution in PPM: "$(xx -r --uint32 2)" echo Number of colors in image: "$(xx -r --uint32)" echo Number of important colors in image: "$(xx -r --uint32)" echo echo -- Image data \(pixels\) xx -r --uint8 "$image_data_size"
Add a script to setup PYTHONPATH
if [ -n "$ZSH_VERSION" ]; then THIS_DIR=$(dirname $(readlink -f "${(%):-%N}")) elif [ -n "$BASH_VERSION" ]; then THIS_DIR=$(dirname $(readlink -f "${BASH_SOURCE[0]}")) fi ROOT_DIR=$(cd "$THIS_DIR/.." && pwd) export PYTHONPATH="$ROOT_DIR:$PYTHONPATH"
Add script to run integration tests
#!/bin/bash set -e export VERSION=1 mkdir -p /tmp/receipts-target mkdir -p /tmp/receipts-target-tests export AUTH_TOKEN_SECRET="anything" export USE_OCR_STUB=true docker-compose down echo "==== Assembly ====" docker-compose run assembly echo "==== Build docker image ====" docker-compose build app echo "==== Integration tests ====" set +e docker-compose run integration-tests if [ $? -ne 0 ] then echo "Integrtion tests failed" docker-compose logs app exit 1 fi set -e echo "Integration tests passed succesfully!"
Add function to shrink pdf
shrinkpdf() { OUTPUT="${2:-output.pdf}" \gs -sDEVICE=pdfwrite -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$OUTPUT" "$1" }
Add script to build dist package
#!/usr/bin/env bash set -euo pipefail # This script is used to build the distribution archives for SolidInvoice. export SOLIDINVOICE_ENV=prod export SOLIDINVOICE_DEBUG=0 NODE_ENVIRONMENT=production REPO=https://github.com/SolidInvoice/SolidInvoice.git BRANCH=${1:-} VERSION=${2:-} if [ -z $BRANCH ] then echo "Enter branch or tag name to checkout: " read branch BRANCH=${branch} fi if [ -z $VERSION ] then echo "Enter version number: " read version VERSION=${version} fi ROOT_DIR=$( dirname $(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)) BUILD_DIR="$ROOT_DIR/build" DIST_DIR="$BUILD_DIR/dist/" function semverParse() { local RE='[^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([0-9A-Za-z-]*\)' #MAJOR eval $2=`echo $1 | sed -e "s#$RE#\1#"` #MINOR eval $3=`echo $1 | sed -e "s#$RE#\2#"` #MINOR eval $4=`echo $1 | sed -e "s#$RE#\3#"` #SPECIAL eval $5=`echo $1 | sed -e "s#$RE#\4#"` } function generateRelease() { rm -Rf ../build/* mkdir -p "${BUILD_DIR}" mkdir -p "$DIST_DIR" cd "${BUILD_DIR}" git clone --branch "${BRANCH}" "${REPO}" "./SolidInvoice" cd "./SolidInvoice" composer config --no-plugins allow-plugins.symfony/flex true composer install -o -n --no-dev -vvv yarn --pure-lockfile php bin/console assets:install yarn build php bin/console fos:js-routing:dump --callback=define php bin/console bazinga:js-translation:dump --merge-domains public rm -Rf node_modules chmod -R 0777 var rm -Rf .env echo "SOLIDINVOICE_ENV=$SOLIDINVOICE_ENV" >> .env echo "SOLIDINVOICE_DEBUG=$SOLIDINVOICE_DEBUG" >> .env zip -r SolidInvoice-$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH$VERSION_SPECIAL.zip ./ mv SolidInvoice-$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH$VERSION_SPECIAL.zip "${DIST_DIR}" tar -zcvf SolidInvoice-$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH$VERSION_SPECIAL.tar.gz ./ mv SolidInvoice-$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH$VERSION_SPECIAL.tar.gz "${DIST_DIR}" cd ../ && rm -Rf "./SolidInvoice" } semverParse $VERSION VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION_SPECIAL generateRelease
Add UserData script for Peach to run a single Pit
#!/bin/bash -ex @import(userdata/common.sh)@ # Essential Packages # The following packages are part of the FuzzingOS base image: #sudo apt-get --yes --quiet update #sudo apt-get --yes --quiet upgrade #sudo apt-get --yes --quiet build-dep firefox #sudo apt-get --yes --quiet install \ # python python-pip python-dev git mercurial s3cmd # Peach #sudo apt-get --yes --quiet install \ # libxml2-dev libxslt1-dev lib32z1-dev xterm #sudo pip install \ # Twisted==14.0.0 lxml==3.3.5 psutil==2.1.1 pyasn1==0.1.7 tlslite==0.4.6 # FuzzManager #sudo pip install \ # Django==1.7.1 numpy==1.9.1 djangorestframework==2.4.4 requests>=2.5.0 lockfile>=0.8 # Add GitHub as a known host ssh-keyscan github.com >> /root/.ssh/known_hosts # Setup deploy keys for Peach @import(userdata/keys/github.peach.sh)@ cd /home/ubuntu # Target desscription for Firefox @import(userdata/targets/mozilla-inbound-linux64-asan.sh)@ # Checkout Peach retry git clone -v --depth 1 git@peach:MozillaSecurity/peach.git cd peach retry git clone -v --depth 1 git@pits:MozillaSecurity/pits.git Pits pip -q install -r requirements.txt retry python scripts/userdata.py -sync # Checkout and setup FuzzManager retry git clone -v --depth 1 https://github.com/MozillaSecurity/FuzzManager.git Peach/Utilities/FuzzManager pip install -r Peach/Utilities/FuzzManager/requirements.txt @import(userdata/loggers/fuzzmanager.local.sh)@ # Ensure proper permissions chown -R ubuntu:ubuntu /home/ubuntu # Run Peach as user "ubuntu" # Example: # ./laniakea.py -create-on-demand -image-args min_count=1 max_count=1 -tags Name=peach -userdata userdata/peach.sh -userdata-macros TARGET_PIT=Pits/Targets/Laniakea/firefox.xml FUZZING_PIT=Pits/Files/MP4/fmp4.xml FILE_SAMPLE_PATH=./Resources/Samples/mp4 su -c "screen -t peach -dmS peach xvfb-run python ./peach.py -target @TARGET_PIT@ \ -pit @FUZZING_PIT@ \ -macro FileSampleMaxFileSize=-1 Strategy=rand.RandomMutationStrategy StrategyParams=SwitchCount=1000,MaxFieldsToMutate=$(($RANDOM % 50)) FileSamplePath=@FILE_SAMPLE_PATH@" ubuntu
Add 9795 install script (temp)
#!/bin/bash -xe # fix default umask of 0002 for hadoop data dir errors sudo sh -c 'echo "umask 0022" >> /etc/profile' # install some basic packages we need sudo apt-get -y install ant ant-optional git libev-dev libyaml-dev lsof python-dev python-setuptools python-pip rsync screen wamerican # install some python modules that we need sudo pip install blist cql decorator flaky futures nose-test-select pycassa # install/upgrade the latest cassandra-driver in pypi, including pre-releases #sudo pip install --pre --upgrade cassandra-driver # install python-driver from cassandra-test branch - this branch will get releases merged, as well as unreleased dev features git clone -b cassandra-test https://github.com/datastax/python-driver.git sudo pip install -e python-driver # ..use the latest ccm HEAD git clone -b cqlsh_fixes https://github.com/tjake/ccm.git sudo pip install -e ccm
Add alias to reload pow completely.
function pow_reload() { sudo pow --install-system pow --install-local sudo launchctl unload -w /Library/LaunchDaemons/cx.pow.firewall.plist sudo launchctl load -w /Library/LaunchDaemons/cx.pow.firewall.plist launchctl unload -w ~/Library/LaunchAgents/cx.pow.powd.plist launchctl load -w ~/Library/LaunchAgents/cx.pow.powd.plist }
Add a simple Linux/Puppet script to kickstart Puppet on Debian-based hosts
#!/bin/sh -x export PATH=/var/lib/gems/1.8/bin:$PATH which puppet if [ $? -ne 0 ]; then apt-get update apt-get install -y ruby1.8 \ ruby1.8-dev \ libopenssl-ruby1.8 \ rubygems gem install puppet --no-ri --no-rdoc fi puppet apply --verbose --modulepath=./modules manifests/site.pp
Use fd-find as FZF engine if both are installed
#!/bin/zsh # If fzf and fd-find do not exist => exit ! [ -f "$HOME/.fzf.zsh" ] && return 0 ! [ -f "$HOME/.cargo/bin/fd" ] && return 0 # Use fd-find as FZF engine export FZF_DEFAULT_COMMAND='fd --type file --color=always' export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" export FZF_ALT_C_COMMAND='fd --type directory --color=always' export FZF_DEFAULT_OPTS="--ansi"
Add a basic script which can be used to submit the sparkcaller JAR.
#!/bin/sh spark-submit --class com.github.sparkcaller.SparkCaller \ --executor-memory 16G \ --driver-memory 6G \ sparkcaller-1.0.jar \ $@
Send ntpdate output to syslog
#!/bin/sh NOTSYNCED="true" SERVER=`cat /cf/conf/config.xml | grep timeservers | cut -d">" -f2 | cut -d"<" -f1` while [ "$NOTSYNCED" = "true" ]; do ntpdate $SERVER if [ "$?" = "0" ]; then NOTSYNCED="false" fi sleep 5 done # Launch -- we have net. killall ntpd 2>/dev/null sleep 1 /usr/local/sbin/ntpd -s -f /var/etc/ntpd.conf
#!/bin/sh NOTSYNCED="true" SERVER=`cat /cf/conf/config.xml | grep timeservers | cut -d">" -f2 | cut -d"<" -f1` while [ "$NOTSYNCED" = "true" ]; do ntpdate -s $SERVER if [ "$?" = "0" ]; then NOTSYNCED="false" fi sleep 5 done # Launch -- we have net. killall ntpd 2>/dev/null sleep 1 /usr/local/sbin/ntpd -s -f /var/etc/ntpd.conf
Add a script for creating a service account to auto-deploy Prow.
#!/bin/bash # Copyright 2019 The Kubernetes 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. set -o errexit set -o nounset set -o pipefail # This script will create a 'prow-deployer' GCP service account with permissions # to deploy to the GKE cluster and load a service account key into the cluster's # test-pods namespace. This should only be done when the Prow instance is using a # separate build cluster and only trusted jobs are running in the service cluster. # Setting up a deployer service account is necessary for Prow to update itself with # a postsubmit job. # To use, point your kubeconfig at the correct cluster context and specify gcp # PROJECT and service account DESCRIPTION environment variables. gcloud beta iam service-accounts create prow-deployer --project="${PROJECT}" --description="${DESCRIPTION}" --display-name="Prow Self Deployer SA" gcloud projects add-iam-policy-binding "${PROJECT}" --member="serviceAccount:prow-deployer@${PROJECT}.iam.gserviceaccount.com" --role roles/container.developer gcloud iam service-accounts keys create prow-deployer-sa-key.json --project="${PROJECT}" --iam-account="prow-deployer@${PROJECT}.iam.gserviceaccount.com" kubectl create secret generic -n test-pods prow-deployer-service-account --from-file=service-account.json=prow-deployer-sa-key.json rm prow-deployer-sa-key.json
Add configuration script to turn on notifications
#!/bin/bash # # Ceilometer depends on having notifications enabled for all monitored # services. This script demonstrates the configuration changes needed # in order to enable the rabbit notifier for the supported services. bindir=$(dirname $0) devstackdir=${bindir}/../../devstack devstack_funcs=${devstackdir}/functions if [ ! -f "$devstack_funcs" ] then echo "Could not find $devstack_funcs" exit 1 fi source ${devstack_funcs} CINDER_CONF=/etc/cinder/cinder.conf if ! grep -q "notification_driver=cinder.openstack.common.notifier.rabbit_notifier" $CINDER_CONF then echo "notification_driver=cinder.openstack.common.notifier.rabbit_notifier" >> $CINDER_CONF fi QUANTUM_CONF=/etc/quantum/quantum.conf if ! grep -q "notification_driver=quantum.openstack.common.notifier.rabbit_notifier" $QUANTUM_CONF then echo "notification_driver=quantum.openstack.common.notifier.rabbit_notifier" >> $QUANTUM_CONF fi # For nova we set both the rabbit notifier and the special ceilometer # notifier that forces one more poll to happen before an instance is # removed. NOVA_CONF=/etc/nova/nova.conf if ! grep -q "notification_driver=ceilometer.compute.nova_notifier" $NOVA_CONF then echo "notification_driver=ceilometer.compute.nova_notifier" >> $NOVA_CONF fi if ! grep -q "notification_driver=nova.openstack.common.notifier.rabbit_notifier" $NOVA_CONF then echo "notification_driver=nova.openstack.common.notifier.rabbit_notifier" >> $NOVA_CONF fi # SPECIAL CASE # Glance does not use the openstack common notifier library, # so we have to set a different option. GLANCE_CONF=/etc/glance/glance-api.conf iniuncomment $GLANCE_CONF DEFAULT notifier_strategy iniset $GLANCE_CONF DEFAULT notifier_strategy rabbit
Add script to toggle builtin laptop keyboard
#!/bin/bash set -o errexit set -o nounset function builtin-keyboard-id() { xinput --list | grep "AT Translated" | sed 's/.*id=\([0-9]*\).*/\1/' } function is-disabled() { xinput --list --long | grep -A 1 "id=$1" | grep -q disabled } id="$(builtin-keyboard-id)" if is-disabled "$id"; then echo "Enabling $id" xinput enable "$id" else echo "Disabling $id" xinput disable "$id" fi
Add eu-central-1 base AMIs to faster-bootstrap
#!/usr/bin/env bash # # (c) Copyright 2017 Cloudera, Inc. # # 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. # These are base AMIs for various operating systems that the Cloudera Director # team uses for their own testing in the eu-central-1 region. While they are # considered good choices, we cannot guarantee that they will always work. declare -A BASE_AMIS=( # ["centos64"]="ami-b3bf2f83 pv ec2-user /dev/sda1" - does not exist in eu-central-1 # ["centos65"]="ami-b6bdde86 pv ec2-user /dev/sda" - does not exist in eu-central-1 ["centos67"]="ami-2bf11444 hvm centos /dev/sda1" ["centos72"]="ami-9bf712f4 hvm centos /dev/sda1" ["rhel64"]="ami-58eadc45 pv ec2-user /dev/sda1" ["rhel65"]="ami-6aeadc77 pv ec2-user /dev/sda1" ["rhel66"]="ami-fa0538e7 hvm ec2-user /dev/sda1" ["rhel67"]="ami-8e96ac93 hvm ec2-user /dev/sda1" ["rhel71"]="ami-38d2d625 hvm ec2-user /dev/sda1" ["rhel72"]="ami-b6688dd9 hvm ec2-user /dev/sda1" ["rhel73"]="ami-e4c63e8b hvm ec2-user /dev/sda1" )
Add tacker installation to odl-sfc
MYDIR=$(dirname $(readlink -f "$0")) CLIENT=$(echo python-python-tackerclient_*_all.deb) CLIREPO="tacker-client" # Function checks whether a python egg is available, if not, installs function chkPPkg () { PKG="$1" IPPACK=$(python - <<'____EOF' import pip from os.path import join for package in pip.get_installed_distributions(): print(package.location) print(join(package.location, *package._get_metadata("top_level.txt"))) ____EOF ) echo "$IPPACK" | grep -q "$PKG" if [ $? -ne 0 ];then pip install "$PKG" fi } function envSetup () { apt-get install -y python-all debhelper chkPPkg stdeb chkCrudini } # Function installs python-tackerclient from github function deployTackerClient() { cd $MYDIR git clone -b 'SFC_refactor' https://github.com/trozet/python-tackerclient.git $CLIREPO cd $CLIREPO python setup.py --command-packages=stdeb.command bdist_deb cd "deb_dist" CLIENT=$(echo python-python-tackerclient_*_all.deb) cp $CLIENT $MYDIR dpkg -i "${MYDIR}/${CLIENT}" } envSetup deployTackerClient
Replace 127.0.0.1:5252 endpoint url with PUBLIC_ENDPOINT during deployment
#!/usr/bin/with-contenv bash # Update OpenAPI documentation to match PUBLIC_ENDPOINT server url sed -i 's|'"http://127.0.0.1:5252"'|'"${PUBLIC_ENDPOINT}"'|g' /docs/resto-api.json sed -i 's|'"http://127.0.0.1:5252"'|'"${PUBLIC_ENDPOINT}"'|g' /docs/resto-api.html
Add a bash script for generating html for the MSA dropdown.
#! /bin/bash if [ $# -ne 1 ]; then echo "usage: ./convert-msaxlsx.sh <xlsx-filename>" exit 1 fi # https://github.com/dilshod/xlsx2csv (this gracefully handles unicode nastiness, thankfully). pip install xlsx2csv xlsx2csv -d '|' $1 tmp-msa.csv echo '<select name="hmda_chart_2_msa" id="hmda_chart_2_msa"> <option selected value="CBSA00000">U.S. Total</option>' > msa-dropdown.html awk -F "|" '{ if(NR>1){print("<option value=\"CBSA"$1"\">"$2"</option>")}}' tmp-msa.csv >> msa-dropdown.html echo '</select>' >> msa-dropdown.html echo 'successfully created msa-dropdown.html' # cleanup tmp file rm -f tmp-msa.csv
Switch powerline font to Ubuntu Mono to match Vimrc
#!/bin/bash set -eou pipefail IFS=$'\n\t' mkdir -p ~/.local/share/fonts cd ~/.local/share/fonts REPO="https://github.com/ryanoasis/nerd-fonts/blob/0.6.0/patched-fonts" URL="$REPO/DejaVuSansMono/Regular/complete/DejaVu%20Sans%20Mono%20for%20Powerline%20Nerd%20Font%20Complete.ttf" FILE=$(sed 's/%20/ /g' <<<${URL##*/}) if [[ ! -e "$FILE" ]]; then curl -fLo "$FILE" "${URL}?raw=true" fi
#!/bin/bash set -eou pipefail IFS=$'\n\t' mkdir -p ~/.local/share/fonts cd ~/.local/share/fonts REPO="https://github.com/ryanoasis/nerd-fonts/blob/0.8.0/patched-fonts" URL="$REPO/UbuntuMono/Regular/complete/Ubuntu%20Mono%20derivative%20Powerline%20Nerd%20Font%20Complete.ttf" FILE=$(sed 's/%20/ /g' <<<${URL##*/}) if [[ ! -e "$FILE" ]]; then curl -fLo "$FILE" "${URL}?raw=true" sudo fc-cache -f -v fi
Install Rails after installing all Rubies
#!/bin/bash # Install Preferred Ruby versions. Populate them by using chruby and Ruby to # generate a list of Rubies to install. # (Very helpful reference: https://robm.me.uk/ruby/2013/11/20/ruby-enp.html) # # $ chruby | ruby -pe '$_.gsub!(/^[^\w]+|-p[0-9]+/, "").gsub!("-", " ")' < ~/.dotfiles/ruby/rubies.txt # get current directory CHRUBY_DIR=$(dirname $BASH_SOURCE) # This file read requires a while loop (as apposed to for loops used elsewhere # in the dotfiles) due to there being spaces in the rubies.txt file. We want to # read the file in whole line by line, not have a new line created on a space. while read ruby_version; do if [ "$ruby_version" == "ruby 1.8.7" ]; then # Reference for no more support of 1.8.7 with ruby-install: # http://stackoverflow.com/questions/21891402/chruby-install-ruby-1-8-7 echo "$ruby_version is unsupported by ruby-install. Skipping..." else ruby-install $ruby_version fi done < $CHRUBY_DIR/rubies.txt chruby $(cat ~/.ruby-version) gem install bundler
#!/bin/bash # Install Preferred Ruby versions. Populate them by using chruby and Ruby to # generate a list of Rubies to install. # (Very helpful reference: https://robm.me.uk/ruby/2013/11/20/ruby-enp.html) # # $ chruby | ruby -pe '$_.gsub!(/^[^\w]+|-p[0-9]+/, "").gsub!("-", " ")' < ~/.dotfiles/ruby/rubies.txt # get current directory CHRUBY_DIR=$(dirname $BASH_SOURCE) # This file read requires a while loop (as apposed to for loops used elsewhere # in the dotfiles) due to there being spaces in the rubies.txt file. We want to # read the file in whole line by line, not have a new line created on a space. while read ruby_version; do if [ "$ruby_version" == "ruby 1.8.7" ]; then # Reference for no more support of 1.8.7 with ruby-install: # http://stackoverflow.com/questions/21891402/chruby-install-ruby-1-8-7 echo "$ruby_version is unsupported by ruby-install. Skipping..." else ruby-install $ruby_version fi done < $CHRUBY_DIR/rubies.txt chruby $(cat ~/.ruby-version) gem install bundler gem install rails
Fix bug in setup script
#!/usr/bin/env bash cd ~ & \ git clone https://github.com/allen-garvey/bash-dotfiles.git bash_dotfiles & \ touch .bash_profile & \ echo -e 'DOTFILES_DIR="${HOME}/bash_dotfiles/";\nexport DOTFILES_DIR;\nsource "${DOTFILES_DIR}aliases_osx.bash"\n' >> .bash_profile;
#!/usr/bin/env bash cd ~ && \ git clone https://github.com/allen-garvey/bash-dotfiles.git bash_dotfiles && \ touch .bash_profile && \ echo -e 'DOTFILES_DIR="${HOME}/bash_dotfiles/";\nexport DOTFILES_DIR;\nsource "${DOTFILES_DIR}aliases_osx.bash"\n' >> .bash_profile
Remove missing brew tap homebrew/php.
#!/bin/bash set -e # Directory where this script is located. SCRIPT_DIR=$( cd $(dirname $0); pwd -P) # Directory where external dependencies will be handled. DEPS_DIR="$SCRIPT_DIR/deps" mkdir -p "$DEPS_DIR" pushd "$DEPS_DIR" if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get -qq update sudo apt-get install --no-install-recommends \ cmake \ doxygen \ graphviz \ python-dev \ ruby-dev \ php-dev \ liblua5.3-dev \ octave-pkg-dev \ openjdk-8-jdk \ r-base \ r-cran-rcpp \ -y; fi if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew tap homebrew/php brew update brew install \ swig \ lua fi # Compile and install Swig-3.0.12 from source. wget https://github.com/swig/swig/archive/rel-3.0.12.tar.gz tar xf rel-3.0.12.tar.gz pushd swig-rel-3.0.12 ./autogen.sh ./configure make sudo make install popd popd
#!/bin/bash set -e # Directory where this script is located. SCRIPT_DIR=$( cd $(dirname $0); pwd -P) # Directory where external dependencies will be handled. DEPS_DIR="$SCRIPT_DIR/deps" mkdir -p "$DEPS_DIR" pushd "$DEPS_DIR" if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get -qq update sudo apt-get install --no-install-recommends \ cmake \ doxygen \ graphviz \ python-dev \ ruby-dev \ php-dev \ liblua5.3-dev \ octave-pkg-dev \ openjdk-8-jdk \ r-base \ r-cran-rcpp \ -y; fi if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update brew install \ swig \ lua fi # Compile and install Swig-3.0.12 from source. wget https://github.com/swig/swig/archive/rel-3.0.12.tar.gz tar xf rel-3.0.12.tar.gz pushd swig-rel-3.0.12 ./autogen.sh ./configure make sudo make install popd popd
Use a branch as an alias of the latest release
#!/bin/bash set -e bundle install --path "${HOME}/bundles/${JOB_NAME}" npm install npm test # Create a new tag if the version file has been updated and a tag for that # version doesn't already exist # Are we on master branch, we shouldn't push tags for version bump branches MASTER_SHA=`git rev-parse origin/master` HEAD_SHA=`git rev-parse HEAD` if [ "$MASTER_SHA" == "$HEAD_SHA" ]; then # get the version from the version file VERSION_TAG="v`cat VERSION.txt`" # check to make sure the tag doesn't already exist if ! git rev-parse $VERSION_TAG >/dev/null 2>&1; then echo "Creating new tag: $VERSION_TAG" git tag $VERSION_TAG git push origin $VERSION_TAG fi fi
#!/bin/bash set -e bundle install --path "${HOME}/bundles/${JOB_NAME}" npm install npm test # Create a new tag if the version file has been updated and a tag for that # version doesn't already exist # Are we on master branch, we shouldn't push tags for version bump branches MASTER_SHA=`git rev-parse origin/master` HEAD_SHA=`git rev-parse HEAD` if [ "$MASTER_SHA" == "$HEAD_SHA" ]; then # get the version from the version file VERSION_TAG="v`cat VERSION.txt`" # check to make sure the tag doesn't already exist if ! git rev-parse $VERSION_TAG >/dev/null 2>&1; then echo "Creating new tag: $VERSION_TAG" git tag $VERSION_TAG git push origin $VERSION_TAG # Alias branch for the most recently released tag, for easier diffing git push origin master:latest-release fi fi
Stop script if command fails
# read version gitsha=$(git rev-parse HEAD) version=$(cat package.json | jq .version | sed -e 's/^"//' -e 's/"$//') gulp build # swap to head so we don't commit compiled file to master along with tags git checkout head # add the compiled files, commit and tag! git add vlui*.* -f git commit -m "release $version $gitsha" git tag -am "Release v$version." "v$version" # now swap back to the clean master and push the new tag git checkout master git push --tags # Woo hoo! Now the published tag contains compiled files which works great with bower.
set -e # read version gitsha=$(git rev-parse HEAD) version=$(cat package.json | jq .version | sed -e 's/^"//' -e 's/"$//') gulp build # swap to head so we don't commit compiled file to master along with tags git checkout head # add the compiled files, commit and tag! git add vlui*.* -f git commit -m "release $version $gitsha" git tag -am "Release v$version." "v$version" # now swap back to the clean master and push the new tag git checkout master git push --tags # Woo hoo! Now the published tag contains compiled files which works great with bower.
Use v prefix in tags
#!/bin/bash set -eu python2 -m unittest python3 -m unittest version=$(python -c 'import snorky; print(snorky.version)') git tag -a "$version" python3 setup.py register -r pypi python3 setup.py sdist upload -r pypi
#!/bin/bash set -eu python2 -m unittest python3 -m unittest version=$(python -c 'import snorky; print(snorky.version)') git tag -a "v${version}" python3 setup.py register -r pypi python3 setup.py sdist upload -r pypi
Tweak teardown test function style
function setup() { mount_dir=$(mktemp -d) $SPARSEBUNDLEFS -s -f -D $TEST_BUNDLE $mount_dir & for i in {0..50}; do # FIXME: Find actual mount callback in fuse? grep -q "bundle has" $test_output_file && break || sleep 0.1 done pid=$! dmg_file=$mount_dir/sparsebundle.dmg } function test_dmg_exists_after_mounting() { ls -l $dmg_file test -f $dmg_file } function test_dmg_has_expected_size() { size=$(ls -dn $dmg_file | awk '{print $5; exit}') test $size -eq 1099511627776 } function teardown() { umount $mount_dir rm -Rf $mount_dir }
function setup() { mount_dir=$(mktemp -d) $SPARSEBUNDLEFS -s -f -D $TEST_BUNDLE $mount_dir & for i in {0..50}; do # FIXME: Find actual mount callback in fuse? grep -q "bundle has" $test_output_file && break || sleep 0.1 done pid=$! dmg_file=$mount_dir/sparsebundle.dmg } function test_dmg_exists_after_mounting() { ls -l $dmg_file test -f $dmg_file } function test_dmg_has_expected_size() { size=$(ls -dn $dmg_file | awk '{print $5; exit}') test $size -eq 1099511627776 } function teardown() { umount $mount_dir rm -Rf $mount_dir }
Drop stable12 and add stable15
#!/bin/sh currentDir=$(pwd) if [[ -d /tmp/nextcloud-documentation ]] then rm -rf /tmp/nextcloud-documentation fi # fetch documentation repo git clone git@github.com:nextcloud/documentation.git /tmp/nextcloud-documentation cd /tmp/nextcloud-documentation for branch in stable12 stable13 stable14 master do git checkout $branch cd $currentDir # download current version of config.sample.php curl -o /tmp/config.sample.php https://raw.githubusercontent.com/nextcloud/server/$branch/config/config.sample.php # use that to generate the documentation php convert.php --input-file=/tmp/config.sample.php --output-file=/tmp/nextcloud-documentation/admin_manual/configuration_server/config_sample_php_parameters.rst cd /tmp/nextcloud-documentation # invokes an output if something has changed status=$(git status -s) if [ -n "$status" ]; then echo "Push $branch" git commit -am 'generate documentation from config.sample.php' git push fi # cleanup rm -rf /tmp/config.sample.php done
#!/bin/sh currentDir=$(pwd) if [[ -d /tmp/nextcloud-documentation ]] then rm -rf /tmp/nextcloud-documentation fi # fetch documentation repo git clone git@github.com:nextcloud/documentation.git /tmp/nextcloud-documentation cd /tmp/nextcloud-documentation for branch in stable13 stable14 stable15 master do git checkout $branch cd $currentDir # download current version of config.sample.php curl -o /tmp/config.sample.php https://raw.githubusercontent.com/nextcloud/server/$branch/config/config.sample.php # use that to generate the documentation php convert.php --input-file=/tmp/config.sample.php --output-file=/tmp/nextcloud-documentation/admin_manual/configuration_server/config_sample_php_parameters.rst cd /tmp/nextcloud-documentation # invokes an output if something has changed status=$(git status -s) if [ -n "$status" ]; then echo "Push $branch" git commit -am 'generate documentation from config.sample.php' git push fi # cleanup rm -rf /tmp/config.sample.php done
Update mac nightly build script
echo "--- Building nightly Mac OS X hoomd package on `date`" # get up to the root of the tree cd .. cd .. # update to the latest rev svn update new_rev=`svnversion .` # up another level out of the source repository cd .. #check the previous version built atrev=`cat mac_old_revision || echo 0` echo "Last revision built was $atrev" echo "Current repository revision is $new_rev" if [ "$atrev" = "$new_rev" ];then echo "up to date" else echo $new_rev > mac_old_revision # build the new package rm -rf build mkdir build cd build cmake -DENABLE_DOXYGEN=OFF -DENABLE_APP_BUNDLE_INSTALL=ON -DBOOST_ROOT=/opt/boost-1.46.0/ -DBoost_NO_SYSTEM_PATHS=ON -DPYTHON_EXECUTABLE=/usr/bin/python ../hoomd/ make package -j6 mv hoomd-*.dmg /Users/joaander/devel/incoming/mac fi echo "--- Done!" echo ""
echo "--- Building nightly Mac OS X hoomd package on `date`" # get up to the root of the tree cd .. cd .. # update to the latest rev git pull origin master new_rev=`git describe` # up another level out of the source repository cd .. #check the previous version built atrev=`cat mac_old_revision || echo 0` echo "Last revision built was $atrev" echo "Current repository revision is $new_rev" if [ "$atrev" = "$new_rev" ];then echo "up to date" else echo $new_rev > mac_old_revision # build the new package rm -rf build mkdir build cd build cmake -DENABLE_DOXYGEN=OFF -DENABLE_APP_BUNDLE_INSTALL=ON -DBOOST_ROOT=/opt/boost-1.48.0/ -DBoost_NO_SYSTEM_PATHS=ON -DPYTHON_EXECUTABLE=/usr/bin/python ../code make package -j6 mv hoomd-*.dmg /Users/joaander/devel/incoming/mac fi echo "--- Done!" echo ""
Fix awk: redirect in coverage_file
#!/bin/bash # This is to be executed by each individual OS test. It only # combines coverage files and reports locally to the given # TeamCity build configuration. set -e set -o pipefail [ -z ${TEMP} ] && TEMP=/tmp # combine all .coverage* files, coverage combine # create ascii report, report_file=$(mktemp $TEMP/coverage.XXXXX) coverage report --rcfile=`dirname $0`/../.coveragerc > "${report_file}" 2>/dev/null # Report Code Coverage for TeamCity, using 'Service Messages', # https://confluence.jetbrains.com/display/TCD8/How+To...#HowTo...-ImportcoverageresultsinTeamCity # https://confluence.jetbrains.com/display/TCD8/Custom+Chart#CustomChart-DefaultStatisticsValuesProvidedbyTeamCity total_no_lines=$(awk '/TOTAL/{printf("%s",$2)}') total_no_misses=$(awk '/TOTAL/{printf("%s",$3)}') total_no_covered=$((${total_no_lines} - ${total_no_misses})) echo "##teamcity[buildStatisticValue key='<CodeCoverageAbsLTotal>' value='""<${total_no_lines}"">']" echo "##teamcity[buildStatisticValue key='<CodeCoverageAbsLCovered>' value='""<${total_no_covered}""'>']" # Display for human consumption and remove ascii file. cat "${report_file}" rm "${report_file}"
#!/bin/bash # This is to be executed by each individual OS test. It only # combines coverage files and reports locally to the given # TeamCity build configuration. set -e set -o pipefail [ -z ${TEMP} ] && TEMP=/tmp # combine all .coverage* files, coverage combine # create ascii report, report_file=$(mktemp $TEMP/coverage.XXXXX) coverage report --rcfile=`dirname $0`/../.coveragerc > "${report_file}" 2>/dev/null # Report Code Coverage for TeamCity, using 'Service Messages', # https://confluence.jetbrains.com/display/TCD8/How+To...#HowTo...-ImportcoverageresultsinTeamCity # https://confluence.jetbrains.com/display/TCD8/Custom+Chart#CustomChart-DefaultStatisticsValuesProvidedbyTeamCity total_no_lines=$(awk '/TOTAL/{printf("%s",$2)}' < "${report_file}") total_no_misses=$(awk '/TOTAL/{printf("%s",$3)}' < "${report_file}") total_no_covered=$((${total_no_lines} - ${total_no_misses})) echo "##teamcity[buildStatisticValue key='<CodeCoverageAbsLTotal>' value='""<${total_no_lines}"">']" echo "##teamcity[buildStatisticValue key='<CodeCoverageAbsLCovered>' value='""<${total_no_covered}""'>']" # Display for human consumption and remove ascii file. cat "${report_file}" rm "${report_file}"
Allow Unauthenticated for clang packages
#!/bin/bash # install updated version of cmake apt-get install --assume-yes software-properties-common add-apt-repository -y ppa:george-edison55/cmake-3.x apt-get update --assume-yes apt-get install --assume-yes cmake cmake --version # This allows us to confirm which version of cmake has been installed.
#!/bin/bash # install updated version of cmake apt-get install --assume-yes software-properties-common add-apt-repository -y ppa:george-edison55/cmake-3.x apt-get update --assume-yes apt-get install --assume-yes cmake cmake --version # This allows us to confirm which version of cmake has been installed. apt-get --allow-unauthenticated upgrade
Upgrade CI images to Docker 20.10.21
#!/bin/bash set -e version="20.10.20" echo "https://download.docker.com/linux/static/stable/x86_64/docker-$version.tgz";
#!/bin/bash set -e version="20.10.21" echo "https://download.docker.com/linux/static/stable/x86_64/docker-$version.tgz";
Add htop to be installed on VM
#!/bin/bash -eux echo "==> Applying updates" yum -y update yum install -y net-tools telnet # reboot echo "Rebooting the machine..." reboot sleep 60
#!/bin/bash -eux echo "==> Applying updates" yum -y update yum install -y net-tools telnet htop # reboot echo "Rebooting the machine..." reboot sleep 60
Add another vector gradient example
#!/bin/bash geoc vector gradientstyle -i naturalearth.gpkg -l countries -f PEOPLE -n 6 -c greens > countries_gradient_green.sld geoc map draw -f vector_gradient_greens.png -l "layertype=layer file=naturalearth.gpkg layername=ocean style=ocean.sld" \ -l "layertype=layer file=naturalearth.gpkg layername=countries style=countries_gradient_green.sld"
#!/bin/bash geoc vector gradientstyle -i naturalearth.gpkg -l countries -f PEOPLE -n 6 -c greens > countries_gradient_green.sld geoc map draw -f vector_gradient_greens.png -l "layertype=layer file=naturalearth.gpkg layername=ocean style=ocean.sld" \ -l "layertype=layer file=naturalearth.gpkg layername=countries style=countries_gradient_green.sld" geoc vector gradientstyle -i naturalearth.gpkg -l countries -f PEOPLE -n 8 -c reds > countries_gradient_red.sld geoc map draw -f vector_gradient_reds.png -l "layertype=layer file=naturalearth.gpkg layername=ocean style=ocean.sld" \ -l "layertype=layer file=naturalearth.gpkg layername=countries style=countries_gradient_red.sld"
Update to reflect batch_event_generator usage
#!/bin/#!/usr/bin/env bash echo "Installing packages" # Install modules sh ./install_packages.sh echo "Generating synthetic users" # Generate 2 fake web site users python3 user_generator.py --n=2 echo "Generating synthetic events" rm *.out # Generate 10 events python3 event_generator.py -x=taxonomy.json --num_e=10 --project_id=$(gcloud config get-value project) cat *.out >> events.json rm *.out echo "Copying events to Cloud Storage" # Set BUCKET to the non-coldline Google Cloud Storage bucket export BUCKET=$(gsutil ls) # Copy events.json into the bucket gsutil cp events.json ${BUCKET}
#!/bin/#!/usr/bin/env bash echo "Installing packages" # Install modules sh ./install_packages.sh echo "Generating synthetic users" # Generate 2 fake web site users python3 user_generator.py --n=10 echo "Generating synthetic events" rm *.out # Generate 10 events python3 batch_event_generator.py --num_e=1000 echo "Copying events to Cloud Storage" # Set BUCKET to the non-coldline Google Cloud Storage bucket export BUCKET=$(gsutil ls) # Copy events.json into the bucket gsutil cp events.json ${BUCKET}
Replace special character stripped by intellij
#!/bin/bash bucket=${1} filename=teamcreds sanitizedFilename=sanitizedTeamCreds aws s3 cp s3://${bucket}/Passwords.csv ./ > /dev/null tail -n +2 Passwords.csv | awk -F "," '{print $1 " " $2}' > ${filename} sed -e "s/ //" ${filename} > ${sanitizedFilename} rm ${filename} echo ${sanitizedFilename}
#!/bin/bash bucket=${1} filename=teamcreds sanitizedFilename=sanitizedTeamCreds aws s3 cp s3://${bucket}/Passwords.csv ./ > /dev/null tail -n +2 Passwords.csv | awk -F "," '{print $1 " " $2}' > ${filename} sed -e "s/ //" ${filename} > ${sanitizedFilename} rm ${filename} echo ${sanitizedFilename}