partial rewrite of install.sh

partial rewrite of install.sh

#!/bin/bash
# Copyright (c) 2014, Kevin Walsh. All rights reserved.
#
# 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.

# Multi-purpose script for setting up and running tao and cloudproxy tests.
#
# This script works with the Go implementation of Tao. It assumes all binaries
# have been installed in ./bin (e.g. via `go install`)
#
# If you wish to use the TPM, you must have also followed the directions in
# $TAO_ROOT/Doc/SetupTPM.txt to take ownership of the TPM.

set -e # quit script on first error

# INSTALL BEGIN
# Note: This section of code is removed by install.sh
script_path="go/install.sh"
test_dir=""
test_tpm="no"
verbose="yes"
test_guard="AllowAll"
for arg in "$@"; do
	case "$arg" in
		-notpm)
			test_tpm="no"
			shift
			;;
		-tpm)
			test_tpm="yes"
			shift
			;;
		-acls)
			test_guard="ACLs"
			shift
			;;
		-datalog)
			test_guard="Datalog"
			shift
			;;
		-q)
			verbose="no"
			shift
			;;
		-*)
			echo "Huh? $arg"
			exit 1
			;;
	esac
done
if [ $# -eq 1 ]; then
	test_dir="$1"
fi
if [ ! "$test_dir" ]; then
	echo "Usage: $0 [options] <dir>"
	echo "  Installs tao testing scripts into <dir>, which will be created"
	echo "  if it does not yet exist."
	echo "Options:"
	echo "  -notpm       Use a fake TPM (the default)."
	echo "  -tpm         Use the TPM."
	echo "  -acls        Use ACL-based guards for Tao domain policy."
	echo "  -datalog     Use Datalog-based guards for Tao domain policy."
	echo "  -q           Be more quiet."
	exit 1
fi
if [ -e "$test_dir" -a ! -d "$test_dir" ]; then
	echo "$test_dir: path exists but is not a directory"
	exit 1
fi
mkdir -p "$test_dir"
# canonicalize
root_dir=$(readlink -e "$(dirname $0)/..")
test_dir=$(readlink -e "$test_dir")
if [ "$verbose" == "yes" ]; then
	echo "Installing tao test scripts into: $test_dir"
fi
# sanity checks
if [ ! -f "$root_dir/$script_path" -o ! -d "$test_dir" ]; then
	echo "install failed: could not canonicalize paths"
	exit 1
fi
mkdir -p "$test_dir/scripts"
rm -f "$test_dir/scripts/tao.sh"
sed '/^# INSTALL BEGIN/,/^# INSTALL END/ s/^/## /' "$root_dir/$script_path" \
			>"$test_dir/scripts/tao.sh"
chmod +x "$test_dir/scripts/tao.sh"

cd "$test_dir/scripts/"
perl -p -i -e "s|^export TAO_TEST=undef .*\$|export TAO_TEST="\""$test_dir"\""|" tao.sh
for script in "setup.sh" "start.sh" "restart.sh" "monitor.sh" \
	"test.sh" "refresh.sh" "stop.sh" "clean.sh" "hash.sh" "help.sh" \
	"host.sh" "base64w-encode.sh" "base64w-decode.sh"; do
	rm -f $script
	ln -s tao.sh $script
done
cd "$test_dir"
rm -f bin
ln -s $root_dir/go/bin bin
mkdir -p logs

cat <<END > "$test_dir/tao.env"
# Tao/CloudProxy environment variables"
export TAO_TEST="$test_dir" # Also hardcoded into $test_dir/scripts/*.sh

export TAO_ROOT="$root_dir"
export TAO_USE_TPM="$test_tpm"
export TAO_GUARD="$test_guard"
export TAO_BUILD="\${TAO_ROOT}/src/out/\${TAO_VERSION}/bin"
export TAO_PASS="BogusPass"
export TAO_TPM_PCRS="17, 18"
export GLOG_v=2
export GLOG_logtostderr="no"
export GLOG_alsologtostderr="no"
export GLOG_stderrthreshold=3 # Only log FATAL to stderr.
export GLOG_log_dir="\${TAO_TEST}/logs"

export TAO_HOSTED_PROGRAMS="
\${TAO_TEST}/bin/demo
\${TAO_TEST}/bin/demo_server
\${TAO_TEST}/bin/client
\${TAO_TEST}/bin/server
\${TAO_TEST}/bin/fclient
\${TAO_TEST}/bin/fserver
\${TAO_TEST}/bin/http_echo_server
\${TAO_TEST}/bin/https_echo_server
"

# BEGIN SETUP VARIABLES
# These variables come from $test_dir/scripts/setup.sh
export GOOGLE_HOST_TAO=""
# END SETUP VARIABLES
END

if [ "$verbose" == "yes" ]; then
	cat <<END
Done installing.
  $test_dir/bin               # Link to ${root_dir}/go/bin.
  $test_dir/logs              # Log files.
  $test_dir/scripts           # Useful scripts.
  $test_dir/tao.env           # Environment variables.
Typical next steps:
  cd $test_dir/
  ./scripts/setup.sh          # Create keys, hashes, ACLs, etc.
  ./scripts/start.sh          # Run Tao CA and Linux Tao server.
  ./scripts/test.sh fserver   # Run fserver test.
  ./scripts/stop.sh           # Kill all Tao programs.
  ./scripts/refresh.sh        # Refresh hashes, ACLs, etc.
Run $test_dir/scripts/help.sh for more info.
END
fi

exit 0

# INSTALL END

export TAO_TEST=undef # replaced with path to test dir by install.sh

PATH="${TAO_TEST}/bin:$PATH"

tao_env=${TAO_TEST}/tao.env
if [ ! -f ${tao_env} ]; then
	echo "Missing ${tao_env}"
	exit 1
fi
source ${tao_env}

# log to stderr for admin stuff, otherwise it is really quiet
admin_args="-config_path ${TAO_TEST}/tao.config -policy_pass "$TAO_PASS" -alsologtostderr=1"
admin="tao_admin $admin_args"
if [ "$TAO_USE_TPM" == "yes" ]; then
	linux_host="linux_host -stacked"
else
	linux_host="linux_host -root"
fi
start_hosted="${linux_host} --run -- "
tpm_tao="tpm_tao -alsologtostderr=1"

# nb: cat at the end of pipeline hides exit code of grep -v
all_tao_progs=$(cd ${TAO_TEST}/bin; echo * | grep -v '\.a$' | grep -v 'log_net_server' | cat) # exclude lib*.a
watchfiles="bin/tcca bin/linux_host domain_acls domain_rules tao.config tao.env"

function extract_pid()
{
	childname="$1"
	pid=`echo "$childname" | sed 's/^Success: Program([0-9]\+, ".*", ".*", ".*")::PID(\([0-9]\+\))$/\1/'`
	echo "$pid"
}

# return at most the first 15 chars of argument
# suitable for pgrep -x or pkill -x
# e.g. shortname long_binary_filename ==> long_binary_fil
function shortname()
{
	name="$1"
	echo "\<${name:0:15}\>"
}

function showenv()
{
	cat ${tao_env}
}

function cleanup()
{
	rm -f ${TAO_TEST}/logs/*
	rm -rf ${TAO_TEST}/{*keys,tpm,linux_tao_host,domain_acls,domain_rules,tao.config,user_acls_sig}
	sed -i '/^# BEGIN SETUP VARIABLES/,/^# END SETUP VARIABLES/d' ${tao_env}
	echo "# BEGIN SETUP VARIABLES" >> ${tao_env}
	echo "# These variables come from ${TAO_TEST}/scripts/setup.sh" >> ${tao_env}
	echo 'export GOOGLE_HOST_TAO=""' >> ${tao_env}
	echo "# END SETUP VARIABLES" >> ${tao_env}

	echo "Cleared all Tao configuration data"
}

function stoptests()
{
	echo "Attempting graceful shutdown..."
	(if ${linux_host} --shutdown; then sleep 1; fi ) 2>/dev/null | grep -v "^Aborted$" || true

	echo "Checking for remaining Tao services and processes..."
	# Try to shutdown
	killed=0
	for prog in $all_tao_progs; do
		if pgrep -lx `shortname "$prog"`; then
			pkill -x `shortname "$prog"`
			killed=1
		fi
	done
	if [ $killed -eq 1 ]; then
		sleep 1
		echo "Attempted to kill remaining Tao services and processes"
	else
		echo "No Tao services or processes remaining"
	fi
	rm -f ${TAO_TEST}/linux_tao_host/admin_socket ${TAO_TEST}/*/*_socket
}

function setup()
{
	mkdir -p ${TAO_TEST}/logs

	echo "Creating TaoDomain keys and settings."
	$admin -init ${TAO_ROOT}/run/tao-default-${TAO_GUARD}.config -name testing

	# This sets:
	# $GOOGLE_HOST_TAO # name of underlying host tao, i.e. the TPM (if any)
	# GOOGLE_TAO_TPM, GOOGLE_TAO_PCRS, # more details about TPM (if any)
	# and GOOGLE_TAO_LINUX # name of the LinuxHost
	sed -i '/^# BEGIN SETUP VARIABLES/,/^# END SETUP VARIABLES/d' ${tao_env}
	echo "# BEGIN SETUP VARIABLES" >> ${tao_env}
	echo "# These variables come from ${TAO_TEST}/scripts/setup.sh" >> ${tao_env}
	if [ "$TAO_USE_TPM" == "yes" ]; then
		echo "Creating TPMTao AIK and settings."
		rm -rf ${TAO_TEST}/tpm
		$tpm_tao --path ${TAO_TEST}/tpm --pcrs "$TAO_TPM_PCRS" --create --noshow
		$tpm_tao --path ${TAO_TEST}/tpm --show >> ${tao_env}

		echo "Creating stacked LinuxHost keys and settings."
		rm -rf ${TAO_TEST}/linux_tao_host
		$linux_host --path ${TAO_TEST}/linux_tao_host --create --noshow
		$linux_host --path ${TAO_TEST}/linux_tao_host --show >> ${tao_env}
	else
		echo "Creating root LinuxHost keys and settings."
		rm -rf ${TAO_TEST}/linux_tao_host
		$linux_host --path ${TAO_TEST}/linux_tao_host --pass "$TAO_PASS" --create --noshow
		$linux_host --path ${TAO_TEST}/linux_tao_host --pass "$TAO_PASS" --show >> ${tao_env}
	fi
	echo "# END SETUP VARIABLES" >> ${tao_env}

	refresh
}

function refresh()
{
	source ${tao_env}

	# Set up default execution policy.
	$admin -clear
	if [ "${TAO_GUARD}" == "datalog" ]; then
		# Rule for TPM and PCRs combinations that make for a good OS
		$admin -add "(forall S, TPM, PCRs: TrustedPlatform(TPM) and TrustedKernelPCRs(PCRs) and subprin(S, TPM, PCRs) implies TrustedOS(S))"
		# Rule for OS and program hash that make for a good hosted program
		$admin -add "(forall P, OS, Hash: TrustedOS(OS) and TrustedProgramHash(Hash) and subprin(P, OS, Hash) implies MemberProgram(P))"
		# Rule for programs that can execute
		$admin -add "(forall P: MemberProgram(P) implies Authorized(P, \"Execute\"))"
		# Add the TPM keys, PCRs, and/or LinuxHost keys
		if [ "$TAO_USE_TPM" == "yes" ]; then
			$admin -add 'TrustedPlatform('${GOOGLE_TAO_TPM}')'
			$admin -add 'TrustedKernelPCRs('${GOOGLE_TAO_PCRS}')'
		else
			$admin -add 'TrustedOS('${GOOGLE_TAO_LINUX}')'
		fi
		# Add the program hashes, assuming LinuxHost and LinuxProcessFactory.
		for prog in ${TAO_HOSTED_PROGRAMS}; do
			if [ -f "$prog" ]; then
				proghash=`$admin -quiet -getprogramhash "$prog"`
				$admin -add 'TrustedProgramHash('${proghash}')'
			fi
		done
	else
		for prog in ${TAO_HOSTED_PROGRAMS}; do
			if [ -f "$prog" ]; then
				$admin -canexecute "$prog"
			fi
		done
	fi
	$admin -show

	# TODO(kwalsh) set up fserver user ACLs here.
	#$admin -newusers tmroeder,jlm
	#$admin -signacl ${TAO_ROOT}/run/acls.ascii -acl_sig_path user_acls_sig
	#mkdir -p file_client_files
	#mkdir -p file_server_files
	#mkdir -p file_server_meta

	echo "Tao configuration is ready"
}

function startsvcs()
{
	# TODO(kwalsh) tcca
	# if pgrep -x `shortname tcca` >/dev/null; then
	# 	echo "TCCA service already running";
	# else
	# 	bin/tcca $admin_args &
	# 	sleep 1
	# 	echo "TCCA service now running"
	# fi

	if pgrep -x `shortname linux_host` >/dev/null; then
		echo "LinuxHost service already running";
	else
		if [ "$TAO_USE_TPM" == "yes" ]; then
			${linux_host} --path ${TAO_TEST}/linux_tao_host --service &
		else
			${linux_host} --path ${TAO_TEST}/linux_tao_host -pass "$TAO_PASS" --service &
		fi
		echo "LinuxTao service now running"
	fi
}

function monitor()
{
	echo "Monitoring Tao files..."
	(
		cd ${TAO_TEST}
		while true; do
			inotifywait -e modify -e delete -e attrib $watchfiles >/dev/null 2>&1
			echo "Files have changed, waiting for quiet..."
			sleep 1
			while inotifywait -t 3 -e modify -e delete -e attrib $watchfiles >/dev/null 2>&1; do
				echo "Still waiting for quiet..."
				sleep 1
			done
			echo "Restarting Tao services..."
			refresh
			stoptests
			startsvcs
		done
	)
}

function gethash()
{
	cat "$1" | sha256sum | cut -d' ' -f1 | xxd -r -ps | base64 | tr '/+' '_-' | tr -d '='
	if [ "${PIPESTATUS[0]}" != 0 ]; then false; fi
}

function base64wdecode()
{
	cat "$1" | tr "_-" "/+" | base64 -d
	if [ "${PIPESTATUS[0]}" != 0 ]; then false; fi
}

function base64wencode()
{
	cat "$1" | base64 | tr '/+' '_-' | tr -d '='
	if [ "${PIPESTATUS[0]}" != 0 ]; then false; fi
}

function testpgm()
{
	cd ${TAO_TEST} # These take no params and must be run within test directory
	case "$1" in
		client|server)
			echo "Starting cloudproxy server..."
			server_id=`$start_hosted server --v=2`
			echo "$server_id";
			server_pid=`extract_pid $server_id`
			sleep 2
			tail -f $GLOG_log_dir/server.INFO &
			server_tail_pid=$!
			echo "Starting cloudproxy client..."
			client_id=`$start_hosted client --v=2`
			client_pid=`extract_pid $client_id`
			sleep 2
			tail -f $GLOG_log_dir/client.INFO &
			client_tail_pid=$!
			sleep 2
			echo "Killing cloudproxy server and client..."
			kill $server_pid $client_pid 2>/dev/null
			sleep 2
			kill $server_tail_pid $client_tail_pid 2>/dev/null
			;;
		file|fclient|fserver)
			echo "Clean cloudproxy file server data..."
			rm -f file_server_files/* file_server_meta/* file_client_files/*
			# make some test data too
			echo "test data $RANDOM" >> file_client_files/test
			echo "Starting cloudproxy file server..."
			server_id=`$start_hosted fserver --v=2`
			server_pid=`extract_pid $server_id`
			sleep 2
			tail -f $GLOG_log_dir/fserver.INFO &
			server_tail_pid=$!
			echo "Starting cloudproxy file client..."
			client_id=`$start_hosted fclient --v=2`
			client_pid=`extract_pid $client_id`
			sleep 2
			tail -f $GLOG_log_dir/fclient.INFO &
			client_tail_pid=$!
			sleep 2
			echo "Killing cloudproxy file server and client..."
			kill $server_pid $client_pid 2>/dev/null
			sleep 2
			kill $server_tail_pid $client_tail_pid 2>/dev/null
			;;
		http)
			echo "Starting cloudproxy http echo server..."
			server_id=`$start_hosted http_echo_server --v=2`
			server_pid=`extract_pid $server_id`
			sleep 2
			tail -f $GLOG_log_dir/http_echo_server.INFO &
			tail_pid=$!
			sleep 1
			read -p "Press enter to kill http echo server..."
			echo "Killing cloudproxy http echo server..."
			kill $server_pid 2>/dev/null
			sleep 2
			kill $tail_pid 2>/dev/null
			;;
		https)
			echo "Starting cloudproxy https echo server..."
			server_id=`$start_hosted https_echo_server --v=2`
			server_pid=`extract_pid $server_id`
			sleep 2
			tail -f $GLOG_log_dir/https_echo_server.INFO &
			tail_pid=$!
			sleep 1
			read -p "Press enter to kill https echo server..."
			echo "Killing cloudproxy https echo server..."
			kill $server_pid 2>/dev/null
			sleep 2
			kill $tail_pid 2>/dev/null
			;;
		help|*)
			echo "Available test programs:"
			echo "  server      # cloud client/server test"
			echo "  fserver     # file client/server test"
			echo "  http        # http echo test"
			echo "  https       # https echo test"
			;;
	esac
}

function hostpgm()
{
	prog="$1"
	shift
	echo "Starting hosted program $prog ..."
	prog_id=`$start_hosted "$prog" "$@"`
	echo "TaoExtension: $prog_id"
}

case "$(basename $0)" in
	setup.sh)
		stoptests
		cleanup
		setup
		;;
	start.sh)
		startsvcs
		;;
	restart.sh)
		stoptests
		startsvcs
		;;
	monitor.sh)
		monitor
		;;
	test.sh)
		#refresh
		#startsvcs
		if [ "$#" == "0" ]; then
			testpgm help
		else
			for f in "$@"; do
				testpgm $f
			done
		fi
		;;
	host.sh)
		if [ "$#" == "0" ]; then
			echo "usage: $0 <prog> [arg...]"
		else
			hostpgm "$@"
		fi
		;;
	refresh.sh)
		refresh
		;;
	stop.sh)
		stoptests
		;;
	clean.sh)
		stoptests
		cleanup
		;;
	hash.sh)
		for f in "$@"; do
			gethash $f
		done
		;;
	base64w-encode.sh)
		for f in "$@"; do
			base64wencode $f
		done
		;;
	base64w-decode.sh)
		for f in "$@"; do
			base64wdecode $f
		done
		;;
	help|*)
		cat <<END
Scripts in $TAO_TEST/scripts:
  setup.sh                 # Re-initialize all keys, whitelists, configuration, etc.
  start.sh                 # Start Tao services.
  restart.sh               # Restart Tao services.
  monitor.sh               # Watch binaries and restart Tao services as needed.
  test.sh <test>...        # Run one or more <test> cases. Use test.sh "help" for choices.
  host.sh <prog> [arg...]  # Run <prog> with arguments as hosted program.
  refresh.sh               # Refresh hashes and whitelists, but keep existing keys.
  stop.sh                  # Kill processes, remove logs.
  clean.sh                 # Remove all keys, configuration, logs, etc.
  hash.sh [file...]        # Hash files; use - for stdin.
  base64w-*.sh [file...]   # Encode/decode files; use - for stdin.
END
		exit 0
		;;
esac

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


Make b2d work again

Make b2d work again

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


HOST_DOCKER_SOCK to survive agent upgrade

#!/bin/bash
set -e

trap "exit 1" SIGINT SIGTERM

# This is copied from common/scripts.sh, if there is a change here
# make it in common and then copy here
check_debug()
{
    if [ -n "$CATTLE_SCRIPT_DEBUG" ] || echo "${@}" | grep -q -- --debug; then
        export CATTLE_SCRIPT_DEBUG=true
        export PS4='[${BASH_SOURCE##*/}:${LINENO}] '
        set -x
    fi
}

info()
{
    echo "INFO:" "${@}"
}

error()
{
    echo "ERROR:" "${@}" 1>&2
}

export CATTLE_HOME=${CATTLE_HOME:-/var/lib/cattle}
# End copy

check_debug

CONTAINER="$(hostname)"
if [ "$1" = "run" ]; then
    CONTAINER="rancher-agent"
fi

if [[ "$1" != "inspect-host" && $1 != "--" && "$1" != "state" ]]; then
    RUNNING_IMAGE="$(docker inspect -f '{{.Config.Image}}' ${CONTAINER})"
fi

if [[ -n ${RUNNING_IMAGE} && ${RUNNING_IMAGE} != ${RANCHER_AGENT_IMAGE} ]]; then
    export RANCHER_AGENT_IMAGE=${RUNNING_IMAGE}
fi

launch_volume()
{
    if docker inspect rancher-agent-state >/dev/null 2>&1; then
        return
    fi

    local opts=""

    if [ "${CATTLE_VAR_LIB_WRITABLE}" = "true" ]; then
        opts="-v /var/lib/rancher:/var/lib/rancher"
    else
        opts="-v /var/lib/rancher"
    fi

    docker run \
        --name rancher-agent-state \
        -v /var/lib/cattle \
        -v /var/log/rancher:/var/log/rancher \
        ${opts} ${RANCHER_AGENT_IMAGE} state
}

inspect_host()
{
    docker run --rm --privileged -v /run:/run -v /var/lib:/var/lib ${RANCHER_AGENT_IMAGE} inspect-host
}

launch_agent()
{
    launch_volume

    local var_lib_docker=$(resolve_var_lib_docker)

    if [ -n "$NO_PROXY" ]; then
        export no_proxy=$NO_PROXY
    fi

    docker run \
        -d \
        --name rancher-agent \
        --restart=always \
        --net=host \
        --pid=host \
        --privileged \
        -e CATTLE_AGENT_PIDNS=host \
        -e http_proxy \
        -e https_proxy \
        -e NO_PROXY \
        -e no_proxy \
        -e CATTLE_PHYSICAL_HOST_UUID \
        -e CATTLE_SCRIPT_DEBUG \
        -e CATTLE_ACCESS_KEY \
        -e CATTLE_SECRET_KEY \
        -e CATTLE_AGENT_IP \
        -e CATTLE_HOST_API_PROXY \
        -e CATTLE_SYSTEMD \
        -e CATTLE_URL \
        -e CATTLE_HOST_LABELS \
        -e CATTLE_VOLMGR_ENABLED \
        -e HOST_DOCKER_SOCK \
        -v $HOST_DOCKER_SOCK:/var/run/docker.sock \
        -v /lib/modules:/lib/modules:ro \
        -v ${var_lib_docker}:${var_lib_docker} \
        -v /proc:/host/proc \
        -v /dev:/host/dev \
        --volumes-from rancher-agent-state \
        "${RANCHER_AGENT_IMAGE}" "$@"
}

resolve_var_lib_docker()
{
    local dir="$(docker inspect -f '{{index .Volumes "/var/lib/cattle"}}' rancher-agent-state)"
    echo $(dirname $(dirname $(dirname $dir)))
}

verify_docker_client_server_version()
{
    local client_version=$(docker version |grep Client\ version | cut -d":" -f2)
    info "Checking for Docker version >=" $client_version
    docker version 2>&1 | grep Server\ version >/dev/null || {
        echo "Please ensure Host Docker version is >=${client_version} and container has r/w permissions to docker.sock" 1>&2
        exit 1
    }
    info Found $(docker version 2>&1 | grep Server\ version)
    for i in version info; do
        docker $i | while read LINE; do
            info "docker $i:" $LINE
        done
    done
}

delete_container()
{
    while docker inspect $1 >/dev/null 2>&1; do
        info Deleting container $1
        docker rm -f $1 >/dev/null 2>&1 || true
    done
}

cleanup_agent()
{
    delete_container rancher-agent
}

cleanup_upgrade()
{
    delete_container rancher-agent-upgrade
}

setup_state()
{
    mkdir -p /var/lib/{cattle,rancher/state}

    export CATTLE_STATE_DIR=/var/lib/rancher/state
    export CATTLE_AGENT_LOG_FILE=/var/log/rancher/agent.log
    export CATTLE_CADVISOR_WRAPPER=cadvisor.sh

    if [ "$CATTLE_SYSTEMD" = "true" ]; then
        mkdir -p /run/systemd/system
    fi
}

load()
{
    local content=$(curl -sL $1)

    if [[ "$content" =~ .!/bin/sh.* ]]; then
        eval "$content"
    fi
}

print_token()
{
    local token_file=/var/lib/rancher/state/.registration_token
    local token=

    if [ -e $token_file ]; then
        token="$(<$token_file)"
    fi

    if [ -z "$token" ]; then
        token=$(openssl rand -hex 64)
        mkdir -p $(dirname $token_file)
        echo $token > $token_file
    fi

    info env "TOKEN=$token"
}

register()
{
    ENV=$(./register.py $TOKEN)
    eval "$ENV"

    export CATTLE_AGENT_IP=${CATTLE_AGENT_IP:-${DETECTED_CATTLE_AGENT_IP}}
}

run_bootstrap()
{
    SCRIPT=/tmp/bootstrap.sh
    touch $SCRIPT
    chmod 700 $SCRIPT

    export CATTLE_CONFIG_URL="${CATTLE_CONFIG_URL:-${CATTLE_URL}}"
    export CATTLE_STORAGE_URL="${CATTLE_STORAGE_URL:-${CATTLE_URL}}"

    curl -u ${CATTLE_ACCESS_KEY}:${CATTLE_SECRET_KEY} -s ${CATTLE_URL}/scripts/bootstrap > $SCRIPT

    # Sanity check if this account is really being authenticated as an agent account or the default admin auth
    if curl -f -u ${CATTLE_ACCESS_KEY}:${CATTLE_SECRET_KEY} -s ${CATTLE_URL}/schemas/account >/dev/null 2>&1; then
        error Please re-register this agent
        exit 1
    fi

    info "Starting agent for ${CATTLE_ACCESS_KEY}"
    if [ "$CATTLE_EXEC_AGENT" = "true" ]; then
        exec bash $SCRIPT "$@"
    else
        bash $SCRIPT "$@"
    fi
}

run()
{
    mount --rbind /host/dev /dev
    while true; do
        run_bootstrap "$@" || true
        sleep 5
    done
}

read_rancher_agent_env()
{
    info Reading environment from rancher-agent
    local save=$RANCHER_AGENT_IMAGE
    eval $(docker inspect rancher-agent | jq -r '"export \"" + .[0].Config.Env[] + "\""')
    RANCHER_AGENT_IMAGE=$save
}

print_url()
{
    local url=$(echo "${CATTLE_URL}"| sed -e 's!/v1/scripts.*!/v1!')
    echo $url
}

wait_for()
{
    local url="$(print_url $CATTLE_URL)"
    info "Attempting to connect to: ${url}"
    for ((i=0; i < 300; i++)); do
        if ! curl -f -s ${CATTLE_URL} >/dev/null 2>&1; then
            error ${url} is not accessible
            sleep 2
            if [ "$i" -eq "299" ]; then
                error "Could not reach ${url}. Giving up."
                exit 1
            fi
        else
            info "${url} is accessible"
            break
        fi
    done
}

inspect()
{
    print_token

    if mkdir -p /var/lib/rancher/state >/dev/null 2>&1; then
        info env "CATTLE_VAR_LIB_WRITABLE=true"
    else
        info env "CATTLE_VAR_LIB_WRITABLE=false"
    fi

    if [ -e /var/run/system-docker.sock ]; then
        info env "CATTLE_RANCHEROS=true"
    else
        info env "CATTLE_RANCHEROS=false"
    fi

    if [ -e /run/systemd/system ]; then
        info env "CATTLE_SYSTEMD=true"
    else
        info env "CATTLE_SYSTEMD=false"
    fi
}

setup_env()
{
    if [ "$1" != "upgrade" ]; then
        local env="$(./resolve_url.py $CATTLE_URL)"
        load "$env"
    fi

    info Inspecting host capabilities
    local content=$(inspect_host)

    echo "$content" | grep -v 'INFO: env' || true
    eval $(echo "$content" | grep 'INFO: env' | sed 's/INFO: env//g')

    export CATTLE_SYSTEMD

    info System: ${CATTLE_SYSTEMD}
    info Host writable: ${CATTLE_VAR_LIB_WRITABLE}
    info Token: $(echo $TOKEN | sed 's/........*/xxxxxxxx/g')

    if [[ -z "$CATTLE_ACCESS_KEY" || -z "$CATTLE_SECRET_KEY" ]]; then
        info Running registration
        register
    else
        info Skipping registration
    fi

    info Printing Environment
    env | sort | while read LINE; do
        if [[ $LINE =~ RANCHER.* || $LINE =~ CATTLE.* ]]; then
            info "ENV:" $(echo $LINE | sed 's/\(SECRET.*=\).*/\1xxxxxxx/g')
        fi
    done
}

setup_cattle_url()
{
    if [ "$1" = "register" ]; then
        if [ -z "$RANCHER_URL" ]; then
            info No RANCHER_URL environment variable, exiting
            exit 0
        fi
        CATTLE_URL="$RANCHER_URL"
    elif [ "$1" = "upgrade" ]; then
        read_rancher_agent_env
    else
        CATTLE_URL="$1"
    fi

    if echo $CATTLE_URL | grep -qE '127.0.0.1|localhost'; then
        local gateway=$(docker run --rm --net=host $RANCHER_AGENT_IMAGE -- ip route get 8.8.8.8 | grep via | awk '{print $7}')
        CATTLE_URL=$(echo $CATTLE_URL | sed -e 's/127.0.0.1/'$gateway'/' -e 's/localhost/'$gateway'/')
    fi

    export CATTLE_URL
}

if [ "$#" == 0 ]; then
    error "One parameter required"
    exit 1
fi

if [[ $1 =~ http.* || $1 = "register" || $1 = "upgrade" ]]; then
    echo $http_proxy $https_proxy
    setup_cattle_url $1
    if [ "$1" = "upgrade" ]; then
        info Running upgrade
    else
        info Running Agent Registration Process, CATTLE_URL=$(print_url $CATTLE_URL)
    fi
    verify_docker_client_server_version
    if [ "$1" != "upgrade" ]; then
        wait_for
    fi
    setup_env $1
    cleanup_agent
    ID=$(launch_agent run)
    info Launched Rancher Agent: $ID
elif [ "$1" = "inspect-host" ]; then
    inspect
elif [ "$1" = "state" ]; then
    echo Rancher State
elif [ "$1" = "run" ]; then
    cleanup_upgrade
    setup_state
    run
elif [ "$1" = "--" ]; then
    shift 1
    exec "$@"
fi

#!/bin/bash
set -e

trap "exit 1" SIGINT SIGTERM

# This is copied from common/scripts.sh, if there is a change here
# make it in common and then copy here
check_debug()
{
    if [ -n "$CATTLE_SCRIPT_DEBUG" ] || echo "${@}" | grep -q -- --debug; then
        export CATTLE_SCRIPT_DEBUG=true
        export PS4='[${BASH_SOURCE##*/}:${LINENO}] '
        set -x
    fi
}

info()
{
    echo "INFO:" "${@}"
}

error()
{
    echo "ERROR:" "${@}" 1>&2
}

export CATTLE_HOME=${CATTLE_HOME:-/var/lib/cattle}
# End copy

check_debug

CONTAINER="$(hostname)"
if [ "$1" = "run" ]; then
    CONTAINER="rancher-agent"
fi

if [[ "$1" != "inspect-host" && $1 != "--" && "$1" != "state" ]]; then
    RUNNING_IMAGE="$(docker inspect -f '{{.Config.Image}}' ${CONTAINER})"
fi

if [[ -n ${RUNNING_IMAGE} && ${RUNNING_IMAGE} != ${RANCHER_AGENT_IMAGE} ]]; then
    export RANCHER_AGENT_IMAGE=${RUNNING_IMAGE}
fi

launch_volume()
{
    if docker inspect rancher-agent-state >/dev/null 2>&1; then
        return
    fi

    local opts=""

    if [ "${CATTLE_VAR_LIB_WRITABLE}" = "true" ]; then
        opts="-v /var/lib/rancher:/var/lib/rancher"
    else
        opts="-v /var/lib/rancher"
    fi

    docker run \
        --name rancher-agent-state \
        -v /var/lib/cattle \
        -v /var/log/rancher:/var/log/rancher \
        ${opts} ${RANCHER_AGENT_IMAGE} state
}

inspect_host()
{
    docker run --rm --privileged -v /run:/run -v /var/lib:/var/lib ${RANCHER_AGENT_IMAGE} inspect-host
}

launch_agent()
{
    launch_volume

    local var_lib_docker=$(resolve_var_lib_docker)

    if [ -n "$NO_PROXY" ]; then
        export no_proxy=$NO_PROXY
    fi

    docker run \
        -d \
        --name rancher-agent \
        --restart=always \
        --net=host \
        --pid=host \
        --privileged \
        -e CATTLE_AGENT_PIDNS=host \
        -e http_proxy \
        -e https_proxy \
        -e NO_PROXY \
        -e no_proxy \
        -e CATTLE_PHYSICAL_HOST_UUID \
        -e CATTLE_SCRIPT_DEBUG \
        -e CATTLE_ACCESS_KEY \
        -e CATTLE_SECRET_KEY \
        -e CATTLE_AGENT_IP \
        -e CATTLE_HOST_API_PROXY \
        -e CATTLE_SYSTEMD \
        -e CATTLE_URL \
        -e CATTLE_HOST_LABELS \
        -e CATTLE_VOLMGR_ENABLED \
        -v $HOST_DOCKER_SOCK:/var/run/docker.sock \
        -v /lib/modules:/lib/modules:ro \
        -v ${var_lib_docker}:${var_lib_docker} \
        -v /proc:/host/proc \
        -v /dev:/host/dev \
        --volumes-from rancher-agent-state \
        "${RANCHER_AGENT_IMAGE}" "$@"
}

resolve_var_lib_docker()
{
    local dir="$(docker inspect -f '{{index .Volumes "/var/lib/cattle"}}' rancher-agent-state)"
    echo $(dirname $(dirname $(dirname $dir)))
}

verify_docker_client_server_version()
{
    local client_version=$(docker version |grep Client\ version | cut -d":" -f2)
    info "Checking for Docker version >=" $client_version
    docker version 2>&1 | grep Server\ version >/dev/null || {
        echo "Please ensure Host Docker version is >=${client_version} and container has r/w permissions to docker.sock" 1>&2
        exit 1
    }
    info Found $(docker version 2>&1 | grep Server\ version)
    for i in version info; do
        docker $i | while read LINE; do
            info "docker $i:" $LINE
        done
    done
}

delete_container()
{
    while docker inspect $1 >/dev/null 2>&1; do
        info Deleting container $1
        docker rm -f $1 >/dev/null 2>&1 || true
    done
}

cleanup_agent()
{
    delete_container rancher-agent
}

cleanup_upgrade()
{
    delete_container rancher-agent-upgrade
}

setup_state()
{
    mkdir -p /var/lib/{cattle,rancher/state}

    export CATTLE_STATE_DIR=/var/lib/rancher/state
    export CATTLE_AGENT_LOG_FILE=/var/log/rancher/agent.log
    export CATTLE_CADVISOR_WRAPPER=cadvisor.sh

    if [ "$CATTLE_SYSTEMD" = "true" ]; then
        mkdir -p /run/systemd/system
    fi
}

load()
{
    local content=$(curl -sL $1)

    if [[ "$content" =~ .!/bin/sh.* ]]; then
        eval "$content"
    fi
}

print_token()
{
    local token_file=/var/lib/rancher/state/.registration_token
    local token=

    if [ -e $token_file ]; then
        token="$(<$token_file)"
    fi

    if [ -z "$token" ]; then
        token=$(openssl rand -hex 64)
        mkdir -p $(dirname $token_file)
        echo $token > $token_file
    fi

    info env "TOKEN=$token"
}

register()
{
    ENV=$(./register.py $TOKEN)
    eval "$ENV"

    export CATTLE_AGENT_IP=${CATTLE_AGENT_IP:-${DETECTED_CATTLE_AGENT_IP}}
}

run_bootstrap()
{
    SCRIPT=/tmp/bootstrap.sh
    touch $SCRIPT
    chmod 700 $SCRIPT

    export CATTLE_CONFIG_URL="${CATTLE_CONFIG_URL:-${CATTLE_URL}}"
    export CATTLE_STORAGE_URL="${CATTLE_STORAGE_URL:-${CATTLE_URL}}"

    curl -u ${CATTLE_ACCESS_KEY}:${CATTLE_SECRET_KEY} -s ${CATTLE_URL}/scripts/bootstrap > $SCRIPT

    # Sanity check if this account is really being authenticated as an agent account or the default admin auth
    if curl -f -u ${CATTLE_ACCESS_KEY}:${CATTLE_SECRET_KEY} -s ${CATTLE_URL}/schemas/account >/dev/null 2>&1; then
        error Please re-register this agent
        exit 1
    fi

    info "Starting agent for ${CATTLE_ACCESS_KEY}"
    if [ "$CATTLE_EXEC_AGENT" = "true" ]; then
        exec bash $SCRIPT "$@"
    else
        bash $SCRIPT "$@"
    fi
}

run()
{
    mount --rbind /host/dev /dev
    while true; do
        run_bootstrap "$@" || true
        sleep 5
    done
}

read_rancher_agent_env()
{
    info Reading environment from rancher-agent
    local save=$RANCHER_AGENT_IMAGE
    eval $(docker inspect rancher-agent | jq -r '"export \"" + .[0].Config.Env[] + "\""')
    RANCHER_AGENT_IMAGE=$save
}

print_url()
{
    local url=$(echo "${CATTLE_URL}"| sed -e 's!/v1/scripts.*!/v1!')
    echo $url
}

wait_for()
{
    local url="$(print_url $CATTLE_URL)"
    info "Attempting to connect to: ${url}"
    for ((i=0; i < 300; i++)); do
        if ! curl -f -s ${CATTLE_URL} >/dev/null 2>&1; then
            error ${url} is not accessible
            sleep 2
            if [ "$i" -eq "299" ]; then
                error "Could not reach ${url}. Giving up."
                exit 1
            fi
        else
            info "${url} is accessible"
            break
        fi
    done
}

inspect()
{
    print_token

    if mkdir -p /var/lib/rancher/state >/dev/null 2>&1; then
        info env "CATTLE_VAR_LIB_WRITABLE=true"
    else
        info env "CATTLE_VAR_LIB_WRITABLE=false"
    fi

    if [ -e /var/run/system-docker.sock ]; then
        info env "CATTLE_RANCHEROS=true"
    else
        info env "CATTLE_RANCHEROS=false"
    fi

    if [ -e /run/systemd/system ]; then
        info env "CATTLE_SYSTEMD=true"
    else
        info env "CATTLE_SYSTEMD=false"
    fi
}

setup_env()
{
    if [ "$1" != "upgrade" ]; then
        local env="$(./resolve_url.py $CATTLE_URL)"
        load "$env"
    fi

    info Inspecting host capabilities
    local content=$(inspect_host)

    echo "$content" | grep -v 'INFO: env' || true
    eval $(echo "$content" | grep 'INFO: env' | sed 's/INFO: env//g')

    export CATTLE_SYSTEMD

    info System: ${CATTLE_SYSTEMD}
    info Host writable: ${CATTLE_VAR_LIB_WRITABLE}
    info Token: $(echo $TOKEN | sed 's/........*/xxxxxxxx/g')

    if [[ -z "$CATTLE_ACCESS_KEY" || -z "$CATTLE_SECRET_KEY" ]]; then
        info Running registration
        register
    else
        info Skipping registration
    fi

    info Printing Environment
    env | sort | while read LINE; do
        if [[ $LINE =~ RANCHER.* || $LINE =~ CATTLE.* ]]; then
            info "ENV:" $(echo $LINE | sed 's/\(SECRET.*=\).*/\1xxxxxxx/g')
        fi
    done
}

setup_cattle_url()
{
    if [ "$1" = "register" ]; then
        if [ -z "$RANCHER_URL" ]; then
            info No RANCHER_URL environment variable, exiting
            exit 0
        fi
        CATTLE_URL="$RANCHER_URL"
    elif [ "$1" = "upgrade" ]; then
        read_rancher_agent_env
    else
        CATTLE_URL="$1"
    fi

    if echo $CATTLE_URL | grep -qE '127.0.0.1|localhost'; then
        local gateway=$(docker run --rm --net=host $RANCHER_AGENT_IMAGE -- ip route get 8.8.8.8 | grep via | awk '{print $7}')
        CATTLE_URL=$(echo $CATTLE_URL | sed -e 's/127.0.0.1/'$gateway'/' -e 's/localhost/'$gateway'/')
    fi

    export CATTLE_URL
}

if [ "$#" == 0 ]; then
    error "One parameter required"
    exit 1
fi

if [[ $1 =~ http.* || $1 = "register" || $1 = "upgrade" ]]; then
    echo $http_proxy $https_proxy
    setup_cattle_url $1
    if [ "$1" = "upgrade" ]; then
        info Running upgrade
    else
        info Running Agent Registration Process, CATTLE_URL=$(print_url $CATTLE_URL)
    fi
    verify_docker_client_server_version
    if [ "$1" != "upgrade" ]; then
        wait_for
    fi
    setup_env $1
    cleanup_agent
    ID=$(launch_agent run)
    info Launched Rancher Agent: $ID
elif [ "$1" = "inspect-host" ]; then
    inspect
elif [ "$1" = "state" ]; then
    echo Rancher State
elif [ "$1" = "run" ]; then
    cleanup_upgrade
    setup_state
    run
elif [ "$1" = "--" ]; then
    shift 1
    exec "$@"
fi


fix sync_hooks for Mac

fix sync_hooks for Mac

#!/bin/bash
# A small utility to symlink the files from git-hooks/ with filenames ending
# like .in into the directory .git/hooks/
#
# It's intended this be run once near the start of a project by hand, and then
# subsequently a hook that it installs keeps it running at project checkouts.

# Save current directory so we can come back; change to repo root
STARTED_FROM=`pwd`
cd $(git rev-parse --show-toplevel)

# Sync git-hooks directory entries into .git/hooks/
for file in git-hooks/*.in; do
    filepart=`basename $file .in`
    if [ -e .git/hooks/$filepart -a ! -L .git/hooks/$filepart ]; then
        echo ".git/hooks/$filepart not link-managed; bailing..."
        echo "please examine your .git/hooks/ directory and repair inconsistencies manually"
        cd $STARTED_FROM
        exit 1
    else
        ln -v -s -f `pwd`/$file .git/hooks/$filepart
    fi
done

# Ok, everything went well; restore previous context
cd $STARTED_FROM
exit 0

#!/bin/bash
# A small utility to symlink the files from git-hooks/ with filenames ending
# like .in into the directory .git/hooks/
#
# It's intended this be run once near the start of a project by hand, and then
# subsequently a hook that it installs keeps it running at project checkouts.

# Save current directory so we can come back; change to repo root
STARTED_FROM=`pwd`
cd $(git rev-parse --show-toplevel)

# Sync git-hooks directory entries into .git/hooks/
for file in git-hooks/*.in; do
    filepart=`basename $file .in`
    if [ -e .git/hooks/$filepart -a ! -L .git/hooks/$filepart ]; then
        echo ".git/hooks/$filepart not link-managed; bailing..."
        echo "please examine your .git/hooks/ directory and repair inconsistencies manually"
        cd $STARTED_FROM
        exit 1
    else
        ln -v -s -b -f `pwd`/$file .git/hooks/$filepart
    fi
done

# Ok, everything went well; restore previous context
cd $STARTED_FROM
exit 0


Removed echo'ing tip about user ad-hoc builds, that is a rare case, and is documented in the readme

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


Create setup-coredns.sh

Create setup-coredns.sh

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


Add function to change volume

Add function to change volume

vol() {
    volume=$(((65536 * $1 + 99) / 100))

    pacmd set-sink-volume 0 $volume
}

error: pathspec 'zsh/functions/volume.sh' did not match any file(s) known to git


#396 First working version of Bundles to Repos script

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


Create adduid.sh

Create adduid.sh

#!/bin/bash
function usage(){
	cat <<eof
Usage:
	$0 uid uidNumber mobile
eof
	exit
}
if [[ $# -ne 3 ]];then
	usage
fi
uid=$1
gid=$uid
uidNumber=$2
gidNumber=$uidNumber
mobile=$3

content=$(cat <<eof
dn: uid=$uid,ou=People,dc=auth,dc=beebank,dc=com
changetype: modify
add: objectClass
objectClass: person
-
add: objectClass
objectClass: organizationalPerson
-
add: objectClass
objectClass: posixAccount
-
add: objectClass
objectClass: top
-
add: homeDirectory
homeDirectory: /home/$uid
-
add: gidNumber
gidNumber: $gidNumber
-
add: uidNumber
uidNumber: $uidNumber
-
add: description
description: $uid
-
add: mobile
mobile: $mobile

eof
)

echo "$content"
echo -n "Are you sure?(y/n):"
read ok
[ $ok != "y" ] && echo "canceled" && exit
echo "$content" | ldapmodify -D "cn=admin,dc=beebank,dc=com" -w xxxxx

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


more robust sql import

more robust sql import

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


Ubuntu setup script

Ubuntu setup script

#!/bin/bash
OS=$(lsb_release -si)
if [ "${OS}" != 'Ubuntu' ]; then
    echo 'This script should only be run under Ubuntu.'
    exit
fi
sudo apt-get install --assume-yes puppet git make
git clone git@github.com:istvan-antal/content-creator.git
cd content-creator
make infrastructure

error: pathspec 'bin/install-ubuntu.sh' did not match any file(s) known to git


Update controller.sh

Update controller.sh

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


CI integration

CI integration

#!/bin/bash

if [[ "${TRAVIS_JDK_VERSION}" != "oraclejdk8" ]]; then
    echo "Skipping after_success actions for JDK version \"${TRAVIS_JDK_VERSION}\""
    exit
fi

mvn -B cobertura:cobertura coveralls:report

if [[ -n ${TRAVIS_TAG} ]]; then
    echo "Skipping deployment for tag \"${TRAVIS_TAG}\""
    exit
fi

if [[ ${TRAVIS_BRANCH} != 'master' ]]; then
    echo "Skipping deployment for branch \"${TRAVIS_BRANCH}\""
    exit
fi

if [[ "$TRAVIS_PULL_REQUEST" = "true" ]]; then
    echo "Skipping deployment for pull request"
    exit
fi

# mvn -B deploy --settings maven_deploy_settings.xml -Dmaven.test.skip=true -Dfindbugs.skip=true

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


mysql timeout to 8h

mysql timeout to 8h

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


Make executable

Make executable

#!/bin/sh

unzip test.csv.zip
unzip train.csv.zip

rm test.csv.zip train.csv.zip


Created the startup.sh file

Created the startup.sh file

#!/bin/bash
#Startup script for services on my cloud

# Settings
USERNAME='daniel'
DEMONLOC='/home/daniel/demonsaw/'
INVOCATION="./demonsaw_router"
HISTORY=1024
# End Settings

ME=`whoami`
 as_user() {
   if [ $ME == $USERNAME ] ; then
     bash -c "$1"
   else
     su - $USERNAME -c "$1"
   fi
 }

if pgrep -u $USERNAME -f demonsaw_router > /dev/null
then
        echo "DemonSaw is already running!"
else
        echo "Starting demonsaw..."
        cd $DEMONLOC
        as_user "cd $DEMONLOC && screen -h $HISTORY -dmS demonsaw $INVOCATION"
        sleep 9
        if pgrep -u $USERNAME -f demonsaw_router > /dev/null
        then
                echo "DemonSaw Router is now running."
        else
                echo "Error! Couldn't Validate Demonsaw!"
        fi
fi

echo "Startup Script complete."

exit 0

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


#386 Import source message are now more verbose


add pandoc script to generate pdf

add pandoc script to generate pdf

#!/usr/bin/env bash
# use this to convert markdown to pdf, and markdown supports latex directly
# just use latex in markdown and it will recognize it

# flag to setup debug or not
DEBUG=true

if $DEBUG
then
    echo "the processed original file is: $1"
fi

filename=`basename $1`
#output=$filename".pdf" # modified to a more precise name below

if $DEBUG
then
    echo "filename:$filename"
fi

# try to split "xxx.xxx.xxx" and find the filename without suffix
IFS='.', read -a splited <<< "$filename"

if $DEBUG
then
    echo "the splited parts are as follows:"
    echo "${splited[0]}", "${splited[1]}"
fi

output="${splited[0]}.pdf"    # first splited part is the filename with ".pdf"

if $DEBUG
then
    suffix=${splited[-1]}
    echo "original file suffix is: $suffix"
fi

# use pandoc to generate from markdown(with latex syntax) to pdf
pandoc $1 --latex-engine=xelatex -o $output

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


rough cut of gen-creds.sh nginx auth utility

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


updated/fixed file generation setup

updated/fixed file generation setup

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


adb push progress bar tools

adb push progress bar tools

#!/bin/bash
# show progress bar for adb push or pull
# Copyright 2017 Wanghong Lin
#
# 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.
#

function usage()
{
	echo "$0 source destination"
	exit 1
}

function progressbar()
{
	bar="=================================================="
	barlength=${#bar}
	n=$(($1*barlength/100))
	printf "\r[%-${barlength}s] %d%%" "${bar:0:n}" "$1"
	# echo -ne "\b$1"
}

export -f progressbar

[[ $# < 2 ]] && usage

SRC=$1
DST=$2

[ ! -f $SRC ] && { \
	echo "source file not found"; \
	exit 2; \
}

which adb >/dev/null 2>&1 || { \
	echo "adb doesn't exist in your path"; \
	exit 3; \
}

SIZE=$(ls -l $SRC | awk '{print $5}')
ADB_TRACE=adb adb push $SRC $DST 2>&1 \
	| sed -n '/DATA/p' \
	| awk -v T=$SIZE 'BEGIN{FS="[=:]"}{t+=$7;system("progressbar " sprintf("%d\n", t/T*100))}'

echo

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


preserve PYTHONPATH in peru.sh

preserve PYTHONPATH in peru.sh

#! /bin/bash

# This script runs peru straight out of the repository, for testing.

repo_root=$(dirname $(realpath $BASH_SOURCE))

yaml_path="$repo_root/third-party/PyYAML-3.10/lib3"

export PYTHONPATH="${PYTHONPATH+$PYTHONPATH:}$repo_root:$yaml_path"

"$repo_root/bin/peru" "$@"

#! /bin/bash

# This script runs peru straight out of the repository, for testing.

repo_root=$(dirname $(realpath $BASH_SOURCE))

yaml_path="$repo_root/third-party/PyYAML-3.10/lib3"

PYTHONPATH="$repo_root:$yaml_path" "$repo_root/bin/peru" "$@"


Add grep from oh-my-zsh

Add grep from oh-my-zsh

#
# Color grep results
# Examples: http://rubyurl.com/ZXv
#

GREP_OPTIONS="--color=auto"

# avoid VCS folders (if the necessary grep flags are available)
grep-flag-available() {
    echo | grep $1 "" >/dev/null 2>&1
}
if grep-flag-available --exclude-dir=.cvs; then
    for PATTERN in .cvs .git .hg .svn; do
        GREP_OPTIONS+=" --exclude-dir=$PATTERN"
    done
elif grep-flag-available --exclude=.cvs; then
    for PATTERN in .cvs .git .hg .svn; do
        GREP_OPTIONS+=" --exclude=$PATTERN"
    done
fi
unfunction grep-flag-available

export GREP_OPTIONS="$GREP_OPTIONS"
export GREP_COLOR='1;32'

error: pathspec '.zsh/grep.zsh' did not match any file(s) known to git


added missing file

added missing file

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


manage script

manage script

* fixed issue with bash 4.2 when declaring globals in a function
  (used in make_lookup_table)

* added more files to lookup table

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


Build cli images first

Build cli images first

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


Alias clipboard is added

Alias clipboard is added

#!/bin/bash

# e.g) copy output of ls to clipboard
#  $ ls | clipboard

if type -t xclip 2>&1 >/dev/null ;then
  alias clipboard='xclip -selection clipboard';
else
  echo "xclip is not installed";
fi

error: pathspec 'profile.d/clipboard.sh' did not match any file(s) known to git


Use improved update strategy

Use improved update strategy

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


Conversion script

Conversion script

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


[dec0der] simple tool to echo decoded string in expected format (ASCII, Base64)

#!/bin/bash

# simple command line decoder/enmcoder
# by bl4de <bl4de@wearehackerone.com>
#
# invoke:
# dec0der [FROM] [string]

FROM=$1
STRING=$2

if [[ $FROM == 'ascii' ]]; then
    echo $STRING | xxd -r -p
fi

if [[ $FROM == 'base64' ]]; then
    echo $STRING | base64 -D
fi

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


Fix shortcuts

Fix shortcuts

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


starting with something for jshint

starting with something for jshint

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


[osx] adds gcloud ZSH completions

[osx] adds gcloud ZSH completions

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


Update deploy script to avoid building on pull requests

#!/bin/bash
set -e

if [[ $TRAVIS_PULL_REQUEST == "true" ]]; then
  echo "Not deploying changes on pull request";
  exit 0;
fi

BRANCH=${TRAVIS_BRANCH:-$(git rev-parse --abbrev-ref HEAD)}

if [[ $BRANCH == 'master' ]]; then
  STAGE="prod"
elif [[ $BRANCH == 'develop' ]]; then
  STAGE="dev"
fi

if [ -z ${STAGE+x} ]; then
  echo "Not deploying changes";
  exit 0;
fi

echo "Deploying from branch $BRANCH to stage $STAGE"

if [ $STAGE == 'prod' ] ; then
  FIREBASE_PROJECT=garden-aid-production
else
  FIREBASE_PROJECT=garden-aid-dev
fi

echo 'Running build'
npm run build

echo 'Deploying to firebase'

firebase deploy -P $FIREBASE_PROJECT

#!/bin/bash
set -e

BRANCH=${TRAVIS_BRANCH:-$(git rev-parse --abbrev-ref HEAD)}

if [[ $BRANCH == 'master' ]]; then
  STAGE="prod"
elif [[ $BRANCH == 'develop' ]]; then
  STAGE="dev"
fi

if [ -z ${STAGE+x} ]; then
  echo "Not deploying changes";
  exit 0;
fi

echo "Deploying from branch $BRANCH to stage $STAGE"

if [ $STAGE == 'prod' ] ; then
  BUILD_TASK="build"
  FIREBASE_PROJECT=garden-aid-production
else
  BUILD_TASK="build:dev"
  FIREBASE_PROJECT=garden-aid-dev
fi

echo "Running build: $BUILD_TASK"
npm run $BUILD_TASK

echo 'Deploying to firebase'

firebase deploy -P $FIREBASE_PROJECT


Use rsync instead of scp

Use rsync instead of scp

#!/bin/bash

set -e

HOST=yuca.yunity.org

echo "sending [public] to [$HOST]"

rsync -av --delete public deploy@$HOST:public

#!/bin/bash

set -e

HOST=yuca.yunity.org

echo "sending [public] to [$HOST]"

scp -r public deploy@$HOST:public


Script that imports the enriched airline records we've prepared

#!/bin/bash

# Import our enriched airline data as the 'airlines' collection
mongoimport -d agile_data_science -c airlines --file data/our_airlines_with_wiki.jsonl

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


fix deploy

fix deploy

#!/bin/bash

set -euo pipefail

set +e
if ! git diff-files --quiet --ignore-submodules ; then
  echo "Uncommited changes; stash or commit before deploying"
  exit 1
fi
if ! git diff-index --cached --quiet HEAD --ignore-submodules ; then
  echo "Staged but uncommited changes; commit before deploying"
  exit 2
fi
set -e

PROJECT_NAME="chat"
SERVER="chat"
DATE=$(date +"%Y-%m-%d_%H%M%S")
JAR_NAME=${PROJECT_NAME}-${DATE}.jar
VERSION="0.0.1"
lein uberjar
scp target/${PROJECT_NAME}-${VERSION}-standalone.jar $SERVER:/www/deploys/${PROJECT_NAME}/${JAR_NAME}
ssh flexdb "cd /www/deploys/${PROJECT_NAME} && ln -s ${JAR_NAME} ${PROJECT_NAME}.jar"
git tag "${DATE}"
echo "Update supervisord on remote now"

#!/bin/bash

set -euo pipefail

set +e
if ! git diff-files --quiet --ignore-submodules ; then
  echo "Uncommited changes; stash or commit before deploying"
  exit 1
fi
if ! git diff-index --cached --quiet HEAD --ignore-submodules ; then
  echo "Staged but uncommited changes; commit before deploying"
  exit 2
fi
set -e

PROJECT_NAME="chat"
SERVER="chat"
DATE=$(date +"%Y-%m-%d_%H%M%S")
JAR_NAME=${PROJECT_NAME}-${DATE}.jar
VERSION="0.0.1"
lein uberjar
scp target/${PROJECT_NAME}-${VERSION}-standalone.jar $SERVER:/www/deploys/${PROJECT_NAME}/${JAR_NAME}.jar
ssh flexdb "cd /www/deploys/${PROJECT_NAME}/ && ln -s ${JAR_NAME} ${PROJECT_NAME}.jar"
git tag "${DATE}"
echo "Update supervisord on remote now"


introducing makefileboot

introducing makefileboot

#!/bin/sh

MKFILEBOOTFILE=Makefile
if [ ! -z $1 ]; then
  MKFILEBOOTFILE=$1
fi

if [ -e ./$MKFILEBOOTFILE ]; then
  echo "There's already a ./$MKFILEBOOTFILE in the CWD (`pwd -P`), so this script is aborted."
  exit 1
fi

touch ./$MKFILEBOOTFILE
cat $BUILDING/makefiletemplates/Makefile_singlefolder_apponly > ./$MKFILEBOOTFILE

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


minor correction for docs

minor correction for docs

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


Add a script to count jars

Add a script to count jars

git-svn-id: f25645bd54002203a47bb62c0b0afba5efd98acb@508096 13f79535-47bb-0310-9956-ffa450edef68

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


cleans effective pom of empty lines and maven generated comments

#! /bin/bash

if [ $# -eq 0 ]; then
	echo "Usage: $0 POM_FILE";
fi

currentDir=$( cd "$(dirname "$0")" ; pwd -P );
poms=$@;

pomDir="$currentDir/../poms";
effectivePomDir="$currentDir/../poms/effective";
if [ ! -d $pomDir ]; then
	echo "creating pom directory: $pomDir";
	mkdir $pomDir;
fi
echo "pom directory: $pomDir"

for pom in $poms; do
    echo "creating effective pom for, $pom";
    pomBase=$( basename $pom );
	(mvn -f $pom help:effective-pom -Doutput=$effectivePomDir/$pomBase;
	 sed -i '' -e 's/^<!--.*-->$//' -e '/^[ \t]*$/d' $effectivePomDir/$pomBase;) &
done
wait; # wait for the effective poms to be created

#cd $effectivePomDir;
#for ePom in $poms; do
#	sed -i '' -e 's/^<!--.*-->$//' -e '/^[ \t]*$/d' $ePom &
#done
#wait; # wait for effective poms to be cleaned up a little
#cd ..;

echo "created effective poms"

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


Added prompt_runner for bash PROMPT_COMMAND.

#!/usr/bin/env bash

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

source "$CURRENT_DIR/helpers.sh"
source "$CURRENT_DIR/save.sh"

# check if my tty has a trigger file, if so, run history/buffer save

# setup the PROMPT_COMMAND
# PROMPT_COMMAND="source ~/dev/tmux-resurrect/scripts/prompt_runner.sh; tmxr_runner"

tmxr_runner() {
  if [[ -n "$TMUX" ]]; then
    local pane_id="$(get_pane_id)"
    local pane_tty="$(get_pane_tty "$pane_id")"
    local trigger_file_path="$(resurrect_trigger_file "$pane_id" "$pane_tty")"
    local tmxr_dump_flag=true # dump locally (without tmux send-keys)

    # nothing to do without a trigger!
    [[ ! -f "${trigger_file_path}" ]] && return 0

    # save pane history
    dump_bash_history "$pane_id" "$tmxr_dump_flag"

    # save pane buffer
    dump_pane_buffers "$pane_id" "$tmxr_dump_flag"

    # remove trigger file
    rm "${trigger_file_path}"
  fi

  return 0
}

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


Initial commit of rpm build script

Initial commit of rpm build script

#!/bin/bash

# Execute the following as root to install build tools and create a build user:
# yum install fedora-packager
# useradd -m rpmb
# usermod -a -G mock rpmb

# Then swtich to the rpmb user (su - rpmb) and run this file, altering version.

rpmdev-setuptree

RPMDIR=/home/rpmb/rpmbuild
VERSION=2.1.7-1
SSMDIR=apel-ssm-$VERSION

# Remove old sources and RPMS
rm -f $RPMDIR/SPECS/*
rm -f $RPMDIR/SOURCES/*
rm -f $RPMDIR/SRPMS/*
rm -f $RPMDIR/RPMS/noarch/*

wget --no-check-certificate https://github.com/apel/ssm/archive/$VERSION.tar.gz -O $VERSION

tar xzvf $VERSION
rm $VERSION

mv ssm-$VERSION $SSMDIR

tar czvf $SSMDIR.tar.gz $SSMDIR
cp $SSMDIR.tar.gz $RPMDIR/SOURCES
cp $SSMDIR/apel-ssm.spec $RPMDIR/SPECS

rpmbuild -ba $RPMDIR/SPECS/apel-ssm.spec

# Clean up (note there are both leading and trailing asterisks)
rm -rf *ssm-$VERSION*

error: pathspec 'scripts/ssm-build-rpm.sh' did not match any file(s) known to git


Added script for watching changes

Added script for watching changes

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


Add the authenfication to Google as new behavior. Enables to get access token from Google or custom web service

#!/usr/bin/env bash

##
# Get informations for authentification from yaml file
# @example ([ACCESS_TOKEN]="..." [DEVELOPER_TOKEN]="...")
# @param string $1 Access token (inline mode)
# @param string $2 Developer token (inline mode)
# @return stringableArray
function auth ()
{
    local ACCESS_TOKEN="$1"
    local DEVELOPER_TOKEN="$2"

    if [[ -n "$ACCESS_TOKEN" ]] && [[ -n "$DEVELOPER_TOKEN" ]]; then
        echo -n "([ACCESS_TOKEN]=\"${ACCESS_TOKEN}\" [DEVELOPER_TOKEN]=\"${DEVELOPER_TOKEN}\")"
        return
    fi

    AUTH="$(yamlToArray "${AWQL_AUTH_FILE}")"
    if [ $? -ne 0 ]; then
        echo "AuthenticationError.FILE_INVALID"
        return 1
    fi
    declare -A -r AUTH="$AUTH"

    local AUTH_FILE="${AWQL_AUTH_DIR}/${AUTH[AUTH_TYPE]}/auth.sh"
    local INVALID=0
    local ACCESS=""

    case "${AUTH[AUTH_TYPE]}" in
        ${AUTH_GOOGLE_TYPE})
            ACCESS=$(${AUTH_FILE} -c "${AUTH[CLIENT_ID]}" -s "${AUTH[CLIENT_SECRET]}" -r "${AUTH[REFRESH_TOKEN]}")
            INVALID=$?
            ;;
        ${AUTH_CUSTOM_TYPE})
            ACCESS=$(${AUTH_FILE} "${AUTH[PROTOCOL]}://${AUTH[HOSTNAME]}:${AUTH[PORT]}${AUTH[PATH]}")
            INVALID=$?
            ;;
        *)
            ACCESS="QueryError.UNKNOWN_AWQL_METHOD"
            INVALID=1
            ;;
    esac

    if [[ "$INVALID" -ne 0 ]]; then
        echo "$ACCESS"
        return 1
    fi
    declare -A ACCESS="$ACCESS"

    ACCESS[DEVELOPER_TOKEN]="${AUTH[DEVELOPER_TOKEN]}"

    echo -n "($(declare -p ACCESS | cut -d "(" -f2 | cut -d ")" -f1))"
}

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


Update setup.sh

Update setup.sh

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


Modifying start script

Modifying start script

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


Simple naive installer script

Simple naive installer script

#!/bin/bash

# Usage bootstrap.sh [nds-labs-src-basedir] [-v]
if [[ "$1" == "" || "$1" == "-v" ]]; then
	export LABSDIR=`pwd`
else
	export LABSDIR=$1
fi

export "DEBUGCMD="
export "CWD=`pwd`"
if [[ "${@/-v/}" != "$@" ]]; then
	export "DEBUGCMD=eval echo ${CWD}:"
fi

export PREVDIR=`pwd`

# Ensure Kubernetes has started (locally, for now)
$DEBUGCMD sudo sh ./cluster/k8s/localdev/kube-up-local.sh

# Ensure that the API Server has started (apiserver)
$DEBUGCMD sudo systemctl start apiserver

# Ensure that the API Server is populated
export "CWD=~/apiserver/projects"
cd ${CWD}
$DEBUGCMD sh ./load-projects.sh

cd ~/apiserver/specs
for VARIABLE in clowder dataverse elk
do
	export "CWD=$LABSDIR/../apiserver/specs/$VARIABLE"
	cd ${CWD}
	$DEBUGCMD sh ./load-specs.sh
done

# Ensure that the Web Server has started (nginx)
export "CWD=$LABSDIR/experiments/prototype-gui"
cd ${CWD}
$DEBUGCMD sh ./start-server.sh

# Ensure that dependencies for the GUI are loaded (NPM / Bower packages)
export "CWD=${CWD}/src"
cd ${CWD}
$DEBUGCMD sudo rm -rf bower_components/ node_modules/
$DEBUGCMD docker run --rm -it -v `pwd`:/data digitallyseamless/nodejs-bower-grunt npm install
$DEBUGCMD docker run --rm -it -v `pwd`:/data digitallyseamless/nodejs-bower-grunt bower install

cd $PREVDIR

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


bootstrap exclude idea-osx-sublime-keymap.xml

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


Add gettext

Add gettext

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


Create bootstrap.sh

Create bootstrap.sh

## PRE-REQUISITE
## Must be root
## Must be on Ubuntu 12.04
function do_screen() {
    # $1 - name
    # $2 - command to execute

    if (! screen -ls | grep -q ${SESSION_NAME}); then
        screen -S ${SESSION_NAME} -dm -t $1
    else
        screen -S ${SESSION_NAME} -X screen -t $1
    fi
    sleep 1.5
    screen -S ${SESSION_NAME} -p $1 -X stuff "$2"
}

SESSION_NAME=${SESSION_NAME:-zwift}
export SESSION_NAME=${SESSION_NAME:-zwift}

rm -rf ~/zerocloud
rm -rf /var/www/zwift-ui

# make sure we have base packages
apt-get update
apt-get install -y python-software-properties curl wget xfsprogs parted memcached
# add ubuntu cloud-archive for swift 1.10 and rax zerovm repo
apt-add-repository cloud-archive:havana --yes
echo "deb [arch=amd64] http://packages.zerovm.org/apt/ubuntu/ precise main" > /etc/apt/sources.list.d/zerovm.list
curl -Sks http://packages.zerovm.org/apt/ubuntu/zerovm.pkg.key | apt-key add -
apt-get update
# install the swift packages
apt-get install -y swift-object swift-account swift-container swift-proxy swift
# install ZeroVM Packages
#apt-get install -y zerovm-zmq python-zerocloud
apt-get install -y zerovm-zmq
cd ~
git clone https://github.com/zerovm/zerocloud.git
cd zerocloud
git checkout origin/havana
python setup.py install

# Swift Related Configurations
# disable all swift services so they don't start on boot

for svc in /etc/init/swift*.conf; do

    echo "manual" > /etc/init/$(basename ${svc} .conf).override

done

# lay down a swift config
cat > /etc/swift/swift.conf <<EOF

[swift-hash]
swift_hash_path_suffix=

swift_hash_path_prefix=SOMERANDOMSTRING

EOF

cat > /etc/swift/object-server.conf <<EOF

[DEFAULT]
bind_ip = 0.0.0.0

workers = 2

[pipeline:main]
pipeline = object-query object-server

#pipeline = object-server

[app:object-server]
use = egg:swift#object

[object-replicator]

[object-updater]

[object-auditor]

[filter:object-query]
use = egg:zerocloud#object_query

zerovm_timeout = 360
zerovm_maxpool = 10

zerovm_maxinput = 5368709120
zerovm_maxoutput = 5368709120

EOF

cat > /etc/swift/container-server.conf <<EOF
[DEFAULT]

bind_ip = 0.0.0.0
workers = 2

[pipeline:main]

pipeline = container-server

[app:container-server]
use = egg:swift#container

[container-replicator]

[container-updater]

[container-auditor]
EOF

cat > /etc/swift/account-server.conf <<EOF

[DEFAULT]
bind_ip = 0.0.0.0

workers = 2

[pipeline:main]
pipeline = account-server

[app:account-server]
use = egg:swift#account

[account-replicator]

[account-auditor]

[account-reaper]
EOF

cat > /etc/swift/proxy-server.conf <<EOF

[DEFAULT]
bind_ip = 0.0.0.0

bind_port = 8080
workers = 2

[pipeline:main]

pipeline = cache tempauth proxy-query proxy-server
#pipeline = cache tempauth proxy-server

[app:proxy-server]

account_autocreate = true
allow_account_management = false

use = egg:swift#proxy

[filter:cache]
memcache_serialization_support = 2

memcache_servers = 127.0.0.1:11211

use = egg:swift#memcache

[filter:proxy-query]
use = egg:zerocloud#proxy_query

zerovm_maxinput = 5368709120
zerovm_maxoutput = 5368709120

[filter:tempauth]

use = egg:swift#tempauth
user_admin_admin = admin .admin .reseller_admin

user_test_tester = testing .admin
user_test2_tester2 = testing2 .admin

user_test_tester3 = testing3

EOF

mkdir -p /srv/node/disk1

if [ ! -e /srv/disk.img ]; then

    truncate -s 10G /srv/disk.img
    mkfs.xfs -f -i size=512 -d su=64k,sw=1 /srv/disk.img

fi

if ! (grep -q /srv/disk.img /etc/fstab); then

    echo "/srv/disk.img /srv/node/disk1 xfs loop,defaults,noatime,nodiratime,nobarrier,logbufs=8 0 0" > /etc/fstab

fi

mount -a
chown -R swift: /srv/node/disk1

pushd /etc/swift

for which in object container account; do

    if [ ! -e /etc/swift/${which}.builder ]; then

        swift-ring-builder ${which}.builder create 9 1 0

    fi

    declare -A base_ports=(

        [object]=6000
        [container]=6001

        [account]=6002)

    changed=0

    if (! swift-ring-builder ${which}.builder | grep -q 127.0.0.1); then

        swift-ring-builder ${which}.builder add z1-127.0.0.1:${base_ports[${which}]}/disk1 100

        changed=1

    fi

    if [ ${changed} -eq 1 ]; then

        swift-ring-builder ${which}.builder rebalance

    fi
done

popd

chown -R swift: /etc/swift

# set up apache and the redirects
apt-get install -y apache2-mpm-worker git

cat > /etc/apache2/sites-available/default <<EOF
<VirtualHost *:80>
  ServerAdmin webmaster@localhost
  ProxyRequests Off
  ProxyPreserveHost On
  ProxyVia On
  DocumentRoot /var/www/zwift-ui

  <Directory />
    Options FollowSymLinks
    AllowOverride None
  </Directory>

  <Directory /var/www/zwift-ui>
    Options Indexes FollowSymlinks Multiviews
    AllowOverride None
    Order allow,deny
    allow from all
  </Directory>

  <Location /auth>
    ProxyPass http://localhost:8080/auth
    ProxyPassReverse http://localhost:8080/auth
  </Location>

  <Location /v1>
    ProxyPass http://localhost:8080/v1
    ProxyPassReverse http://localhost:8080/v1
  </Location>

  <Location /open>
    ProxyPass http://localhost:8080/open
    ProxyPassReverse http://localhost:8080/open
  </Location>

  ErrorLog \${APACHE_LOG_DIR}/error.log

  LogLevel warn

  CustomLog \${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
EOF

# turn on some apache mods
a2enmod proxy
a2enmod proxy_http
a2ensite default

service apache2 restart

# pull latest ui
pushd /var/www
git clone https://github.com/zerovm/zwift-ui
popd

# start the services
for service in proxy object container account; do

    echo "starting ${service}..."

    do_screen ${service} "/usr/bin/swift-${service}-server -v /etc/swift/${service}-server.conf"$'\n'

done

screen -S ${SESSION_NAME} -X screen -t shell

screen -DR


project: build-all.sh script.

project: build-all.sh script.

This script builds for all known targets.

Signed-off-by: Gaël PORTAY <1666f60cfa201a60b0ea694168a0b6932673170a@gmail.com>

#!/bin/sh -e

run() {
	board=$1
	shift

	case $board in
	*)
		make BOARD=$board $*
		;;
	esac >/dev/null
	echo "$board: done"
}

for board in at91-sam9260ek at91-sam9261ek at91-sam9263ek at91-sam9m10g45ek at91-sam9n12ek at91-sam9rlek at91-sam9g20ek at91-sam9g20ek_2mmc at91-sam9g15ek at91-sam9g25ek at91-sam9g35ek at91-sam9x25ek at91-sam9x35ek at91-sama5d31ek at91-sama5d33ek at91-sama5d34ek at91-sama5d35ek at91-sama5d36ek at91-sama5d3x_cmp at91-sama5d3_xplained at91-sama5d4ek at91-sama5d4_xplained; do
	run $board $*
done

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


fix issue with getting version and release from spec file

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


Pass exit codes from child to parent.

Pass exit codes from child to parent.

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


forgot build file

forgot build file

#!/bin/bash

set -e

CWD=`pwd`

do_build() {
	echo "Building Documentation..."
	mkdir -p $OUTPUT
	rsync -a app/documentation/*.pdf $OUTPUT/
}

build_mac64() {
	# MAC OS X (64 only)
	OUTPUT=$CWD/build/Mac/documentation
	do_build
}

build_windows64() {
	OUTPUT=$CWD/build/Win64/documentation
	do_build
}

build_linux64() {
	OUTPUT=$CWD/build/Linux64/documentation
	do_build
}

if [ "$1" = "L64"  ]
then
    build_linux64
elif [ "$1" = "W64"  ]
then
    build_windows64
elif [ "$1" = "M64"  ]
then
    build_mac64
else
    build_mac64
    build_windows64
    build_linux64
fi

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


Checkpoint LOM IP check

Checkpoint LOM IP check

fatal: remote error: upload-pack: not our ref 6506a2deefd90eb3b9dec6fd716af7185ba0b973
fatal: the remote end hung up unexpectedly


Create clean-tmp.sh

Create clean-tmp.sh

#!/bin/bash
#By Nicolas Simond -> http://www.nicolas-simond.com/
#The Abyss Project -> http://www.abyssproject.net/
#Compatiblity : Debian 6 + | Ubuntu 12.x + | Debian based distro
#Use at your own risk !
# in root terminal : wget -O- https://raw.githubusercontent.com/stylersnico/debian-scripts/master/clean-tmp.sh | sh
#Tested on debian 7.5 AMD64

if [ "$(id -u)" != "0" ]; then
   echo "This script must be run as root" 1>&2
   exit 1
fi
clear
echo  ":: Use at your own risk !"
echo  ":: This script use rm -ri * command !"
echo  ":: Waiting 10 seconds you can use Ctrl+c to cancel !"
sleep 10
echo  ":: Clean temp folder"
sleep 2 ; cd /tmp
rm -ri *

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


Typo.

Typo.

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


Add deb_version_base make target

Add deb_version_base make target

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


update

update

#!/bin/bash
git add .
print "Adding...."
git commit -m "update"
print "Comminting..."
git push -u origin master
print "Pushed"
done

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


add code for eventual grub2 boot from data pool

#!/bin/bash

source /tmp/cerana-bootcfg
[[ -n $CERANA_RESCUE ]] && exit 0

## The name of the zpool we're concerned with. Everything revolves around this
## being configured and present. Set name accordingly.
ZPOOL=data
FILESYSTEMS="datasets datasets/ro datasets/rw running-clones config services logs platform"

# Create the expected filesystems on the configured zpool
configure_filesystems() {

    # Do we have the zpool?
    zpool list $ZPOOL >/dev/null 2>&1
    if [[ $? -ne 0 ]]; then
        echo "ERROR: \"$ZPOOL\" pool is not present!"
        return 1
    fi

    # Create base ZFS filesystems and set their properies
    for fs in $FILESYSTEMS; do
        zfs list $ZPOOL/$fs >/dev/null 2>&1 || zfs create $ZPOOL/$fs
    done

    [[ "off" = $(zfs get compression -Ho value $ZPOOL) ]] && zfs set compression=lz4 $ZPOOL || true
}

# Gather a list of disk devices into an array
get_disklist() {

    # Get a basic list of disk devices in the format:
    # disk sda     16G VBOX HARDDISK
    # disk sdb     16G VBOX HARDDISK
    # disk sdc     45G VBOX HARDDISK
    # disk sdd     10G VBOX HARDDISK
    DISKLIST=`lsblk --ascii --noheadings \
        --output type,name,size,model --nodeps | grep ^disk`

    # Scrape the above into a list of just device nodes
    DISKDEVS=`echo "$DISKLIST" | awk '{print "/dev/"$2}'`

    readarray DISKARRAY <<<"$DISKDEVS"
}

# Prompt the user for the type of pool they desire. Offer a command shell
# to allow manual configuration using the zpool command directly.
prompt_user() {

    echo
    echo "No existing \"$ZPOOL\" pool detected."
    echo "In order to proceed, you must configure the underlying ZFS"
    echo "storage for this node. The following disks have been detected:"
    echo
    echo "$DISKLIST"
    echo
    echo "The available automatic configuration options are:"
    echo
    if [[ ${#DISKARRAY[@]} -eq 0 ]]; then
        echo "ERROR: This server has no disks!"
        exit
    elif [[ ${#DISKARRAY[@]} -eq 1 ]]; then
        echo " stripe (${#DISKARRAY[@]} disk) *"
        AUTO="stripe"
    elif [[ ${#DISKARRAY[@]} -eq 2 ]]; then
        echo " stripe (${#DISKARRAY[@]} disks) *"
        echo " mirror (${#DISKARRAY[@]} disks)"
        AUTO="mirror"
    elif [[ ${#DISKARRAY[@]} -eq 3 ]]; then
        echo " stripe (${#DISKARRAY[@]} disks) *"
        echo " raidz (${#DISKARRAY[@]} disks)"
        AUTO="raidz"
    elif [[ ${#DISKARRAY[@]} -eq 4 ]]; then
        echo " stripe (${#DISKARRAY[@]} disks) *"
        echo " raidz (${#DISKARRAY[@]} disks)"
        echo " raidz2 (${#DISKARRAY[@]} disks)"
        AUTO="raidz"
    elif [[ ${#DISKARRAY[@]} -gt 4 ]]; then
        echo " stripe (${#DISKARRAY[@]} disks) *"
        echo " raidz (${#DISKARRAY[@]} disks)"
        echo " raidz2 (${#DISKARRAY[@]} disks)"
        echo " raidz3 (${#DISKARRAY[@]} disks)"
        AUTO="raidz2"
    fi
    echo
    echo "* = not suggested for production purposes"
    echo
    echo "You may also type \"manual\" to enter a shell to perform a manual"
    echo "configuration of the \"${ZPOOL}\" pool using command-line tools."
    echo "This is preferable if an exact ZFS pool configuration is desired,"
    echo "such as one that contains hot spares, or slog/L2ARC devices."
    echo
    echo "Please reference the ZFSonLinux FAQ:"
    echo "http://zfsonlinux.org/faq.html"
    echo

    answer=${CERANA_ZFS_CONFIG}
    while [[ ! $answer ]]; do
        echo -n "Selection: "
        read answer
    done

    case $answer in
        'auto')
            answer=${AUTO}
            ;&
        'raidz') ;&
        'raidz2') ;&
        'raidz3') ;&
        'mirror') ;&
        'stripe')
            POOLTYPE="$answer"
            echo "Using all disks to create a $answer pool..."
            ;;
        'manual')
            POOLTYPE="manual"
            echo "Entering shell to perform manual pool configuration."
            echo "You must configure a pool with the name of \"$ZPOOL\"."
            ;;
        *)
            return 1
            ;;
    esac
}

# add a partition for and install GRUB2 to pool disks
install_grub() {
    [[ -n ${INSTALL_GRUB_PLEASE} ]] || return
    for d in "${DISKARRAY[@]}"; do
        echo "Adding BIOS boot partition to $d"
        echo -e "n\n2\n34\n2047\nt\n2\n4\nw\n" | fdisk $d #&>/dev/null
        echo "Installing GRUB boot block on $d"
        grub-install --modules=zfs $d #&>/dev/null
    done
}

# Minimal workable GRUB2 from ZFS (uses serial port)
create_grub_config() {
    [[ -n ${INSTALL_GRUB_PLEASE} ]] || return
    [[ -f /data/boot/grub.cfg ]] && return
    mkdir -p /data/boot
    ln -s /data/boot /boot
    cat >/data/boot/grub.cfg <<'EOF'
serial --unit=0 --speed=115200
terminal_input serial
terminal_output serial

set default 0
set timeout 10
set color_normal=white/black
set color_highlight=black/white

search --set=poolname --label data

menuentry "Boot CeranaOS from Disk" {
  linux ($poolname)/platform/@//current/bzImage loglevel=4 console=ttyS0
  initrd ($poolname)/platform/@//current/initrd
}
EOF
}

# Create the zpool using user input
configure_pool() {

    # If manual pool creation was selected, run a sub-shell and check
    # to make sure the pool was actually created after the sub-shell
    # was exited. If not, run the shell again.
    if [[ "$POOLTYPE" = "manual" ]]; then
        # Execute shell for manual zpool config; then create zfs FSs
        echo "When finished, type \"exit\" or Ctrl-D"
        echo "The option \"-o cachefile=none\" MUST be specified"
        PS1='zpool-config> ' /bin/bash
        return
    fi

    # Stripes are easy
    if [[ "$POOLTYPE" == "stripe" ]]; then
        ZPOOLARGS="${DISKARRAY[*]}"
    fi

    # Mirrors are a little tricky if we want to support more than a single
    # mirrored pair
    #
    # TODO: Works for 1 pair of disks. If we have an even number of disks,
    # 2 pairs or more, we should do the math and go through the effort to
    # make that an option.
    if [[ "$POOLTYPE" == "mirror" ]]; then
        ZPOOLARGS="mirror ${DISKARRAY[*]}"
    fi

    # RAIDZ(n)
    if [[ "$POOLTYPE" == "raidz"* ]]; then
        ZPOOLARGS="$POOLTYPE ${DISKARRAY[*]}"
    fi

    # Be sure the drives are starting fresh. Zero out any existing partition
    for d in "${DISKARRAY[@]}"; do
        echo "Clearing $d"
        sgdisk -Z $d &>/dev/null
    done

    # Block until Linux figures itself out w.r.t. paritions
    udevadm settle

    # Flag for installing GRUB onto disks
    INSTALL_GRUB_PLEASE=1

    # Now create the zpool
    zpool create -f \
        -o cachefile=none \
        $ZPOOL $ZPOOLARGS

    if [[ $? -ne 0 ]]; then
        return 1
    fi

    # Pause until the zpool is imported and mounted
    while [[ ! -d /$ZPOOL ]]; do
        sleep 2
    done

}

## Main logic

POOLTYPE=""

udevadm settle
zpool import -f $ZPOOL >/dev/null 2>&1

# We did not detect a zpool by the name of $ZPOOL, so start the process to
# create one.
if [[ $? -ne 0 ]]; then
    while [[ ! -d /$ZPOOL ]]; do
        get_disklist
        while [[ ! "$POOLTYPE" ]]; do
            prompt_user
        done
        configure_pool
    done
fi

# Check to make sure our required filesystems are on the zpool, and create
# them if any aren't.
configure_filesystems

# Add a grub config if we don't have one
create_grub_config

# Install GRUB if this is a fresh pool
install_grub

# Attempt to read in any on-disk config from a previous boot and update with info from kernel command line
if [[ -f /data/config/cerana-bootcfg ]]; then
    cp /data/config/cerana-bootcfg /data/config/cerana-previous-bootcfg
    source /data/config/cerana-bootcfg
fi

# Store current config (kernel command line arguments always override what was found on disk)
source /tmp/cerana-bootcfg
declare | grep ^CERANA >/data/config/cerana-bootcfg
rm /tmp/cerana-bootcfg
ln -s /data/config/cerana-bootcfg /tmp/cerana-bootcfg

# Link in network config directory for systemd-networkd
mkdir -p /data/config/network
ln -s /data/config/network /run/systemd/network

mkdir /etc/systemd-mutable
ln -s /data/services /etc/systemd-mutable/system

# load in unit files that already exist in the pool
systemctl daemon-reload

#!/bin/bash

source /tmp/cerana-bootcfg
[[ -n $CERANA_RESCUE ]] && exit 0

## The name of the zpool we're concerned with. Everything revolves around this
## being configured and present. Set name accordingly.
ZPOOL=data
FILESYSTEMS="datasets datasets/ro datasets/rw running-clones config services logs platform"

# Create the expected filesystems on the configured zpool
configure_filesystems() {

    # Do we have the zpool?
    zpool list $ZPOOL >/dev/null 2>&1
    if [[ $? -ne 0 ]]; then
        echo "ERROR: \"$ZPOOL\" pool is not present!"
        return 1
    fi

    # Create base ZFS filesystems and set their properies
    for fs in $FILESYSTEMS; do
        zfs list $ZPOOL/$fs >/dev/null 2>&1 || zfs create $ZPOOL/$fs
    done

    [[ "off" = $(zfs get compression -Ho value $ZPOOL) ]] && zfs set compression=lz4 $ZPOOL || true
}

# Gather a list of disk devices into an array
get_disklist() {

    # Get a basic list of disk devices in the format:
    # disk sda     16G VBOX HARDDISK
    # disk sdb     16G VBOX HARDDISK
    # disk sdc     45G VBOX HARDDISK
    # disk sdd     10G VBOX HARDDISK
    DISKLIST=`lsblk --ascii --noheadings \
        --output type,name,size,model --nodeps | grep ^disk`

    # Scrape the above into a list of just device nodes
    DISKDEVS=`echo "$DISKLIST" | awk '{print "/dev/"$2}'`

    readarray DISKARRAY <<<"$DISKDEVS"
}

# Prompt the user for the type of pool they desire. Offer a command shell
# to allow manual configuration using the zpool command directly.
prompt_user() {

    echo
    echo "No existing \"$ZPOOL\" pool detected."
    echo "In order to proceed, you must configure the underlying ZFS"
    echo "storage for this node. The following disks have been detected:"
    echo
    echo "$DISKLIST"
    echo
    echo "The available automatic configuration options are:"
    echo
    if [[ ${#DISKARRAY[@]} -eq 0 ]]; then
        echo "ERROR: This server has no disks!"
        exit
    elif [[ ${#DISKARRAY[@]} -eq 1 ]]; then
        echo " stripe (${#DISKARRAY[@]} disk) *"
        AUTO="stripe"
    elif [[ ${#DISKARRAY[@]} -eq 2 ]]; then
        echo " stripe (${#DISKARRAY[@]} disks) *"
        echo " mirror (${#DISKARRAY[@]} disks)"
        AUTO="mirror"
    elif [[ ${#DISKARRAY[@]} -eq 3 ]]; then
        echo " stripe (${#DISKARRAY[@]} disks) *"
        echo " raidz (${#DISKARRAY[@]} disks)"
        AUTO="raidz"
    elif [[ ${#DISKARRAY[@]} -eq 4 ]]; then
        echo " stripe (${#DISKARRAY[@]} disks) *"
        echo " raidz (${#DISKARRAY[@]} disks)"
        echo " raidz2 (${#DISKARRAY[@]} disks)"
        AUTO="raidz"
    elif [[ ${#DISKARRAY[@]} -gt 4 ]]; then
        echo " stripe (${#DISKARRAY[@]} disks) *"
        echo " raidz (${#DISKARRAY[@]} disks)"
        echo " raidz2 (${#DISKARRAY[@]} disks)"
        echo " raidz3 (${#DISKARRAY[@]} disks)"
        AUTO="raidz2"
    fi
    echo
    echo "* = not suggested for production purposes"
    echo
    echo "You may also type \"manual\" to enter a shell to perform a manual"
    echo "configuration of the \"${ZPOOL}\" pool using command-line tools."
    echo "This is preferable if an exact ZFS pool configuration is desired,"
    echo "such as one that contains hot spares, or slog/L2ARC devices."
    echo
    echo "Please reference the ZFSonLinux FAQ:"
    echo "http://zfsonlinux.org/faq.html"
    echo

    answer=${CERANA_ZFS_CONFIG}
    while [[ ! $answer ]]; do
        echo -n "Selection: "
        read answer
    done

    case $answer in
        'auto')
            answer=${AUTO}
            ;&
        'raidz') ;&
        'raidz2') ;&
        'raidz3') ;&
        'mirror') ;&
        'stripe')
            POOLTYPE="$answer"
            echo "Using all disks to create a $answer pool..."
            ;;
        'manual')
            POOLTYPE="manual"
            echo "Entering shell to perform manual pool configuration."
            echo "You must configure a pool with the name of \"$ZPOOL\"."
            ;;
        *)
            return 1
            ;;
    esac
}

# Create the zpool using user input
configure_pool() {

    # If manual pool creation was selected, run a sub-shell and check
    # to make sure the pool was actually created after the sub-shell
    # was exited. If not, run the shell again.
    if [[ "$POOLTYPE" = "manual" ]]; then
        # Execute shell for manual zpool config; then create zfs FSs
        echo "When finished, type \"exit\" or Ctrl-D"
        echo "The option \"-o cachefile=none\" MUST be specified"
        PS1='zpool-config> ' /bin/bash
        return
    fi

    # Stripes are easy
    if [[ "$POOLTYPE" == "stripe" ]]; then
        ZPOOLARGS="${DISKARRAY[*]}"
    fi

    # Mirrors are a little tricky if we want to support more than a single
    # mirrored pair
    #
    # TODO: Works for 1 pair of disks. If we have an even number of disks,
    # 2 pairs or more, we should do the math and go through the effort to
    # make that an option.
    if [[ "$POOLTYPE" == "mirror" ]]; then
        ZPOOLARGS="mirror ${DISKARRAY[*]}"
    fi

    # RAIDZ(n)
    if [[ "$POOLTYPE" == "raidz"* ]]; then
        ZPOOLARGS="$POOLTYPE ${DISKARRAY[*]}"
    fi

    # Be sure the drives are starting fresh. Zero out any existing partition
    for d in "${DISKARRAY[@]}"; do
        echo "Clearing $d"
        sgdisk -Z $d >/dev/null 2>&1
    done

    # Block until Linux figures itself out w.r.t. paritions
    udevadm settle

    # Now create the zpool
    zpool create -f \
        -o cachefile=none \
        $ZPOOL $ZPOOLARGS

    if [[ $? -ne 0 ]]; then
        return 1
    fi

    # Pause until the zpool is imported and mounted
    while [[ ! -d /$ZPOOL ]]; do
        sleep 2
    done

}

## Main logic

POOLTYPE=""

udevadm settle
zpool import -f $ZPOOL >/dev/null 2>&1

# We did not detect a zpool by the name of $ZPOOL, so start the process to
# create one.
if [[ $? -ne 0 ]]; then
    while [[ ! -d /$ZPOOL ]]; do
        get_disklist
        while [[ ! "$POOLTYPE" ]]; do
            prompt_user
        done
        configure_pool
    done
fi

# Check to make sure our required filesystems are on the zpool, and create
# them if any aren't.
configure_filesystems

# Attempt to read in any on-disk config from a previous boot and update with info from kernel command line
if [[ -f /data/config/cerana-bootcfg ]]; then
    cp /data/config/cerana-bootcfg /data/config/cerana-previous-bootcfg
    source /data/config/cerana-bootcfg
fi

# Store current config (kernel command line arguments always override what was found on disk)
source /tmp/cerana-bootcfg
declare | grep ^CERANA >/data/config/cerana-bootcfg
rm /tmp/cerana-bootcfg
ln -s /data/config/cerana-bootcfg /tmp/cerana-bootcfg

# Link in network config directory for systemd-networkd
mkdir -p /data/config/network
ln -s /data/config/network /run/systemd/network

mkdir /etc/systemd-mutable
ln -s /data/services /etc/systemd-mutable/system

# load in unit files that already exist in the pool
systemctl daemon-reload


Change git clone protocol from https to git+ssh [ci skip]

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


Add yajl to linux bot 1.

Add yajl to linux bot 1.

FYI:
glibc:
bot-0: ~19m
bot-1: ~14m
bot-2: ~28m

newlib:
bot-0: ~20m
bot-1: ~10m
bot-2: ~1hr 30m

BUG=none
TBR=sbc@chromium.org

Review URL: https://codereview.chromium.org/12319079

git-svn-id: 84b3587ce119b778414dcb50e18b7479aacf4f1d@709 7dad1e8b-422e-d2af-fbf5-8013b78bd812

#!/bin/bash
# Copyright (c) 2012 The Native Client Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#

# nacl-install-linux-ports-1.sh
#
# usage:  nacl-install-linux-ports-1.sh
#
# This script builds the packages for Native Client that are designated to
# the bot named linux-ports-1
#

source ../bot_common.sh

SCRIPT_DIR="$(cd $(dirname $0) && pwd)"
cd ${SCRIPT_DIR}/../../..
make clean

# pango also builds glib
# cairo also builds png, zlib, freetype, fontconfig, expat, and pixman
BuildPackage agg
BuildPackage openscenegraph
BuildPackage freeimage
BuildPackage imagemagick
BuildPackage cairo
BuildPackage pango
BuildPackage openal
BuildPackage ncurses
BuildPackage box2d
BuildPackage xml2
BuildPackage yajl

echo "@@@BUILD_STEP ${NACL_ARCH} Summary@@@"
if [[ $RESULT != 0 ]] ; then
  echo "@@@STEP_FAILURE@@@"
fi

echo -e "$MESSAGES"

exit $RESULT

#!/bin/bash
# Copyright (c) 2012 The Native Client Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#

# nacl-install-linux-ports-1.sh
#
# usage:  nacl-install-linux-ports-1.sh
#
# This script builds the packages for Native Client that are designated to
# the bot named linux-ports-1
#

source ../bot_common.sh

SCRIPT_DIR="$(cd $(dirname $0) && pwd)"
cd ${SCRIPT_DIR}/../../..
make clean

# pango also builds glib
# cairo also builds png, zlib, freetype, fontconfig, expat, and pixman
BuildPackage agg
BuildPackage openscenegraph
BuildPackage freeimage
BuildPackage imagemagick
BuildPackage cairo
BuildPackage pango
BuildPackage openal
BuildPackage ncurses
BuildPackage box2d
BuildPackage xml2

echo "@@@BUILD_STEP ${NACL_ARCH} Summary@@@"
if [[ $RESULT != 0 ]] ; then
  echo "@@@STEP_FAILURE@@@"
fi

echo -e "$MESSAGES"

exit $RESULT


contrib: ci-upload-helper.sh: import CI uploader script from setup-scripts

Signed-off-by: Koen Kooi <42e3d96910f922bdd7dd1805fe3f8aff634f391d@dominion.thruhere.net>

#!/bin/sh

HOST="$1"
nightlydir="$2"

# create directory on remote machines
ssh ${HOST} "mkdir -p ${nightlydir}"

mkdir -p deploy/glibc/images

# Compress raw images and extX files if needed
for i in $(find deploy/glibc/images/ -name "A*.ext3"; find deploy/glibc/images/ -name "A*img" ; find deploy/glibc/images/ -name "A*.ext2" ; find deploy/glibc/images/ -name "A*.ext4" ; find deploy/glibc/images/ -name "A*sdcard" ; find deploy/glibc/images/ -name "A*iso") ; do xz -f -v -z -T0 -9 -e $i ; done

# Clean up broken symlinks
find deploy/glibc/images/ -type l -exec sh -c "file -b {} | grep -q ^broken" \; -print | xargs rm || true

# Copy over images/kernels/modules/etc
rsync -l deploy/glibc/images/$machine/* ${HOST}:${nightlydir}

error: pathspec 'contrib/ci-upload-helper.sh' did not match any file(s) known to git


Reports memory allocated to running jobs.

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


Add test to execute vil

Add test to execute vil

#!/usr/bin/env bats

readonly vil="$BATS_TEST_DIRNAME/../vil"

@test "can execute" {
  run test -x "$vil"
  [[ $status = 0 ]]
}

error: pathspec 't/run.bats' did not match any file(s) known to git


Added ubuntu solarize script

Added ubuntu solarize script

gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_background" --type bool false
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_colors" --type bool false
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/palette" --type string "#070736364242:#D3D301010202:#858599990000:#B5B589890000:#26268B8BD2D2:#D3D336368282:#2A2AA1A19898:#EEEEE8E8D5D5:#00002B2B3636:#CBCB4B4B1616:#58586E6E7575:#65657B7B8383:#838394949696:#6C6C7171C4C4:#9393A1A1A1A1:#FDFDF6F6E3E3"
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/background_color" --type string "#00002B2B3636"
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/foreground_color" --type string "#65657B7B8383"

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


Add "pip install setuptools_scm" to test script, avoid fatal error

This change fixes the build failure "[SSL: CERTIFICATE_VERIFY_FAILED]"
when pip tries to download setuptools_scm to satisfy a dependency of
pytest-xdist-1.20.0, which happened consitently on various Cray internal
SLES build slaves since Aug 09 (except on chap05, where the error
never happened)

Suggested by: https://github.com/pypa/pypi-legacy/issues/322,
  search for: "I did pip install setuptools_scm and it solved the problem"

#!/usr/bin/env bash
#
# Run the python unittests for code in docs/source/examples/.
set -e

CWD=$(cd $(dirname $0) ; pwd)
source $CWD/common.bash

export CHPL_HOME=$REPO_ROOT/chapel-src
CHPL_GIT_URL=${CHPL_GIT_URL:-git://github.com/chapel-lang/chapel.git}
CHPL_GIT_BRANCH=${CHPL_GIT_BRANCH:-master}

log_info "Cloning Chapel source (branch: ${CHPL_GIT_BRANCH} repo: ${CHPL_GIT_URL}) into: ${CHPL_HOME}"
git clone --branch $CHPL_GIT_BRANCH $CHPL_GIT_URL $CHPL_HOME --depth=50

log_info "Moving to: ${CHPL_HOME}"
cd $CHPL_HOME

log_info "Building Chapel"
export CHPL_LIBMODE=shared
source util/quickstart/setchplenv.bash && \
    make -j

# Install python dependencies for running the tests (not building the docs).
log_info "Installing python test dependencies."

# 2017-08-21:   This "pip install setuptools_scm" avoids some kind of bug in pip
#     See reference: https://github.com/pypa/pypi-legacy/issues/322
#   search for text: I did pip install setuptools_scm and it solved the problem.
pip install setuptools_scm

pip install -r $TST_DIR/requirements.txt --upgrade

(
    log_info "Moving to: ${MODULE_DIR}"
    cd $MODULE_DIR

    log_info "Installing pychapel from setup.py"
    python setup.py install
)

log_info "Running pych --check"
pych --check

# Copying pyChapel libchpl dependencies
find $CHPL_HOME/lib/ -depth -type f -exec bash -c 'cp $0  $VIRTUAL_ENV/share/pych/lib/' {} \;

log_info "Moving to: ${REPO_ROOT}"
cd $REPO_ROOT

log_info "Running py.test over $TST_DIR and doc examples"
py.test --verbose --junitxml=$REPO_ROOT/python-results.xml --boxed $TST_DIR docs/source/examples/
# we run with pytest-xdist's --boxed flag so that the tests run independently
# of each other (this prevents materialization conflicts and the segfault I
# noticed with larger materializations)

log_info "Running pych --testing..."
pych --testing

#!/usr/bin/env bash
#
# Run the python unittests for code in docs/source/examples/.
set -e

CWD=$(cd $(dirname $0) ; pwd)
source $CWD/common.bash

export CHPL_HOME=$REPO_ROOT/chapel-src
CHPL_GIT_URL=${CHPL_GIT_URL:-git://github.com/chapel-lang/chapel.git}
CHPL_GIT_BRANCH=${CHPL_GIT_BRANCH:-master}

log_info "Cloning Chapel source (branch: ${CHPL_GIT_BRANCH} repo: ${CHPL_GIT_URL}) into: ${CHPL_HOME}"
git clone --branch $CHPL_GIT_BRANCH $CHPL_GIT_URL $CHPL_HOME --depth=50

log_info "Moving to: ${CHPL_HOME}"
cd $CHPL_HOME

log_info "Building Chapel"
export CHPL_LIBMODE=shared
source util/quickstart/setchplenv.bash && \
    make -j

# Install python dependencies for running the tests (not building the docs).
log_info "Installing python test dependencies."
pip install -r $TST_DIR/requirements.txt --upgrade

(
    log_info "Moving to: ${MODULE_DIR}"
    cd $MODULE_DIR

    log_info "Installing pychapel from setup.py"
    python setup.py install
)

log_info "Running pych --check"
pych --check

# Copying pyChapel libchpl dependencies
find $CHPL_HOME/lib/ -depth -type f -exec bash -c 'cp $0  $VIRTUAL_ENV/share/pych/lib/' {} \;

log_info "Moving to: ${REPO_ROOT}"
cd $REPO_ROOT

log_info "Running py.test over $TST_DIR and doc examples"
py.test --verbose --junitxml=$REPO_ROOT/python-results.xml --boxed $TST_DIR docs/source/examples/
# we run with pytest-xdist's --boxed flag so that the tests run independently
# of each other (this prevents materialization conflicts and the segfault I
# noticed with larger materializations)

log_info "Running pych --testing..."
pych --testing


Add bump-version util script.

Add bump-version util script.

#!/bin/bash
VER="$1"

if [[ "x${VER}" = "x" ]]
then
    echo "Usage: $0 <version number>"
    echo " e.g. $0 0.1.0"
    exit 1
fi

SHORT_VER=`echo "${VER}" | sed -e "s/\.[^.]*$//"`

function inplace_sed {
  # Note: we don't use sed -i -e ... because it isn't supported by FreeBSD
  # sed on OS X.
  suffix=".inplace.bak"
  sed -i"$suffix" -e "$1" "$2"
  rm "$2$suffix"
}

inplace_sed "s/\(version[ ]*=[ ]*[\"']\)\(.*\)\([\"'].*\)/\1${VER}\3/" setup.py

error: pathspec 'utils/bump-version.sh' did not match any file(s) known to git


Protoolweb 2.0

Protoolweb 2.0

New Functions:
Search for and exploit LFI crashes.
Search and Explore faults xss

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