Source the config files before doing anything else.

#!/bin/bash
# Copyright 2011, Dell
#
# 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.
#
# Author: VictorLowther
#

# This script expects to be able to run certian commands as root.
# Either run it as a user who can sudo to root, or give the user
# you are running it as the following sudo rights:
# crowbar-tester ALL = NOPASSWD: /bin/mount, /bin/umount, /usr/sbin/debootstrap, /bin/cp, /usr/sbin/chroot

# When running this script for the first time, it will automatically create a
# cache directory and try to populate it with all the build dependencies.
# After that, if you need to pull in new dependencies, you will need to
# call the script with the --update-cache parameter.  If you are going to
# develop on Crowbar, it is a good idea to put the build cache in its own git
# repository, and create a branching structure for the packages that mirrors
# the branching structure in the crowbar repository -- if you do that, then
# this build script can be smarter about what packages it should pull in
# whenever you invoke it to build an iso.

[[ $DEBUG ]] && {
    set -x
    export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): '
}

export PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin"

# Our general cleanup function.  It is called as a trap whenever the
# build script exits, and it's job is to make sure we leave the local
# system in the same state we cound it, modulo a few calories of wasted heat
# and a shiny new .iso.
cleanup() {
    # Clean up any stray mounts we may have left behind.
    # The paranoia with the grepping is to ensure that we do not
    # inadvertently umount everything.
    GREPOPTS=()
    [[ $CACHE_DIR ]] && GREPOPTS=(-e "$CACHE_DIR")
    [[ $IMAGE_DIR && $CACHE_DIR =~ $IMAGE_DIR ]] && GREPOPTS=(-e "$IMAGE_DIR")
    [[ $BUILD_DIR && $CACHE_DIR =~ $BUILD_DIR ]] && GREPOPTS=(-e "$BUILD_DIR")
    if [[ $GREPOPTS ]]; then
	while read dev fs type opts rest; do
	    sudo umount -d -l "$fs"
	done < <(tac /proc/self/mounts |grep "${GREPOPTS[@]}")
    fi
    # If the build process spawned a copy of webrick, make sure it is dead.
    [[ $webrick_pid && -d /proc/$webrick_pid ]] && kill -9 $webrick_pid
    # clean up after outselves from merging branches, if needed.
    cd "$CROWBAR_DIR"
    if [[ $THROWAWAY_BRANCH ]]; then
	# Check out the branch we started the build process, and then
	# nuke whatever throwaway branch we may have created.
	git checkout -f "${CURRENT_BRANCH##*/}" &>/dev/null
	git branch -D "$THROWAWAY_BRANCH" &>/dev/null
    fi
    # If we saved unadded changes, resurrect them.
    [[ $THROWAWAY_STASH ]] && git stash apply "$THROWAWAY_STASH" &>/dev/null
    # Do the same thing as above, but for the build cache instead.
    cd "$CACHE_DIR"
    if [[ $CACHE_THROWAWAY_BRANCH ]]; then
	git checkout -f "$CURRENT_CACHE_BRANCH" &>/dev/null
	git branch -D "$CACHE_THROWAWAY_BRANCH" &>/dev/null
    fi
    [[ $CACHE_THROWAWAY_STASH ]] && git stash apply "$CACHE_THROWAWAY_STASH"
    for d in "$IMAGE_DIR" "$BUILD_DIR"; do
	[[ -d $d ]] && rm -rf -- "$d"
    done
}

# Arrange for cleanup to be called at the most common exit points.
trap cleanup 0 INT QUIT TERM

# Source our config file if we have one
[[ -f $HOME/.build-crowbar.conf ]] && \
    . "$HOME/.build-crowbar.conf"

# Look for a local one.
[[ -f build-crowbar.conf ]] && \
    . "build-crowbar.conf"

# Next, some configuration variables that can be used to tune how the
# build process works.

# Location for caches that should not be erased between runs
[[ $CACHE_DIR ]] || CACHE_DIR="$HOME/.crowbar-build-cache"

# Location to store .iso images that we use in the build process.
# These are usually OS install DVDs that we will stage Crowbar on to.
[[ $ISO_LIBRARY ]] || ISO_LIBRARY="$CACHE_DIR/iso"

# This is the location that we will save the generated .iso to.
[[ $ISO_DEST ]] || ISO_DEST="$PWD"

# Directory that holds our Sledgehammer PXE tree.
[[ $SLEDGEHAMMER_PXE_DIR ]] || SLEDGEHAMMER_PXE_DIR="$CACHE_DIR/tftpboot"

# Location of the Crowbar checkout we are building from.
[[ $CROWBAR_DIR ]] ||CROWBAR_DIR="${0%/*}"

# Location of the Sledgehammer source tree.  Only used if we cannot
# find Sledgehammer in $SLEDGEHAMMER_PXE_DIR above.
[[ $SLEDGEHAMMER_DIR ]] || SLEDGEHAMMER_DIR="${CROWBAR_DIR}/../sledgehammer"

# Command to run to clean out the tree before starting the build.
# By default we want to be relatively pristine.
[[ $VCS_CLEAN_CMD ]] || VCS_CLEAN_CMD='git clean -f -x -d'

# Arrays holding the additional pkgs, gems, and AMI images we will populate
# Crowbar with.
PKGS=()
GEMS=()
AMIS=("http://uec-images.ubuntu.com/releases/11.04/release/ubuntu-11.04-server-uec-amd64.tar.gz")

# Some helper functions

# Print a message to stderr and exit.  cleanup will be called.
die() { echo "$(date '+%F %T %z'): $*" >&2; exit 1; }

# Print a message to stderr and keep going.
debug() { echo "$(date '+%F %T %z'): $*" >&2; }

# Clean up any cruft that we might have left behind from the last run.
clean_dirs() {
    local d=''
    for d in "$@"; do
	(   mkdir -p "$d"
	    cd "$d"
	    chmod -R u+w .
	    rm -rf * )
    done
}

# Verify that the passed name is really a branch in the git repo.
branch_exists() { git show-ref --quiet --verify --heads -- "refs/heads/$1"; }

# Run a git command in the crowbar repo.
in_repo() ( cd "$CROWBAR_DIR"; "$@")

# Run a git command in the build cache, assuming it is a git repository.
in_cache() (
    [[ $CURRENT_CACHE_BRANCH ]] || return
    cd "$CACHE_DIR"
    "$@"
)

# Get the OS we were asked to stage Crowbar on to.  Assume it is Ubuntu 10.10
# unless we specify otherwise.
OS_TO_STAGE="${1-ubuntu-10.10}"
shift

# Make sure that we actually know how to build the ISO we were asked to
# build.  If we do not, print a helpful error message.
if ! [[ $OS_TO_STAGE && -d $CROWBAR_DIR/$OS_TO_STAGE-extra && \
    -f $CROWBAR_DIR/$OS_TO_STAGE-extra/build_lib.sh ]]; then
    cat <<EOF
You must pass the name of the operating system you want to stage Crowbar
on to.  Valid choices are:
EOF
    cd "$CROWBAR_DIR"
    for d in *-extra; do
	[[ -d $d && -f $d/build_lib.sh ]] || continue
	echo "    ${d%-extra}"
    done
    exit 1
fi

# Source OS specific build knowledge.  This includes:
# Parameters that build_crowbar.sh needs to know:
# OS = the distribution we are staging on to, such as redhat or ubuntu.
# OS_VERSION = the version of the distribution we are staging on to.
#              For redhat, it would be somethibng like 5.6
# OS_TOKEN = Defaults to "$OS-$OS_VERSION"
# ISO = the name of the install ISO image we are going to stage Crowbar on to.
#
# Functions that build_crowbar needs to call:
# maybe_update_cache(): This function should check and see if the OS and Gem
#   caches in $CACHE_DIR need updating.  If they do, it shoould update them
#   in a way that is reasonably portable across Linuxes and that leaves the
#   build host alone -- the state of the hosts packaging system should not
#   be touched at all. It does not take any arguments.
# copy_pkgs(): This function should appropriatly stage any extra packages
#   that Crowbar will need to install and run. We recommend that this function
#   take care to only copy the latest version of a package if there are any
#   duplicates.  It takes 3 arguments -- the location of the package pool on
#   the OS install media, the package cache to copy packages from, and the
#   location to copy extra packages to (which should NOT be the same as the
#   package pool on the OS media).
# reindex_packages():  This function should build whatever package index
#   the package installation tools $OS needs to have to be able to use the
#   packages copy_pkgs installs as a repository for installing packages from.
#   It takes no arguments.
# final_build_fixups(): This function should take wahtever steps are needed
#   to make the default OS install process also ensure that the Crowbar bits
#   are properly staged and to completly automate the admin node install
#   process, either as an install from CD or an install via PXE.  This
#   usually entails modifying initrd files, adding kickstarts/install seeds,
#   modifying boot config files, and so on.
. "$CROWBAR_DIR/$OS_TO_STAGE-extra/build_lib.sh"

{
    # Make sure only one instance of the ISO build runs at a time.
    # Otherwise you can easily end up with a corrupted image.
    flock 65
    # Figure out what our current branch is, in case we need to merge
    # other branches in to the iso to create our build.
    CURRENT_BRANCH="$(in_repo git symbolic-ref HEAD)" || \
	die "Not on a branch we can build from!"
    CURRENT_BRANCH=${CURRENT_BRANCH##*/}
    [[ $CURRENT_BRANCH ]] || die "Not on a branch we can merge from!"

    # Check and see if our local build repository is a git repo. If it is,
    # we may need to do the same sort of merging in it that we might do in the
    # Crowbar repository.
    if [[ -d $CACHE_DIR/.git ]]; then
	for br in "$CURRENT_BRANCH" master ''; do
	    [[ $br ]] || die "Cannot find $CURRENT_BRANCH or master in $CACHE_DIR"
	    (cd "$CACHE_DIR"; branch_exists "$br") || continue
	    CURRENT_CACHE_BRANCH="$br"
	    break
	done
	# If there are packages that have not been comitted, save them
	# in a stash before continuing.  We do this on the assumption that
	# these packages were added manually for testing purposes, or were
	# added in an earlier update-cache operation, but that the user has
	# not gotten around to comitting yet.
	if [[ ! $(in_cache git status) =~ working\ directory\ clean ]]; then
	    CACHE_THROWAWAY_STASH=$(in_cache git stash create)
	    in_cache git checkout -f .
	fi
    fi

    # Parse our options.
    while [[ $1 ]]; do
	case $1 in
	    # Merge a list of branches into a throwaway branch with the
	    # current branch as a baseline before starting the rest of the
	    # build process.  This makes it easier to spin up iso images
	    # with local changes without having to manually merge those
	    # changes in with any other branches of interest first.
	    # This code takes heavy advantage of the lightweight nature of
	    # git branches and takes care to leave uncomitted changes in place.
	    -m|--merge)
		shift
		# Loop through the rest of the arguments, as long as they
		# do not start with a -.
		while [[ $1 && ! ( $1 = -* ) ]]; do
		    # Check to make sure that this argument refers to a branch
		    # in the crowbar git tree.  Die if it does not.
		    in_repo branch_exists "$1" || die "$1 is not a git branch!"
		    # If we have not already created a throwaway branch to
		    # merge these branches into, do so now. If we have
		    # uncomitted changes that need to be stashed, do so here.
		    if [[ ! $THROWAWAY_BRANCH ]]; then
			THROWAWAY_BRANCH="build-throwaway-$$-$RANDOM"
			REPO_PWD="$PWD"
			if [[ ! $(in_repo git status) =~ working\ directory\ clean ]]; then
			    THROWAWAY_STASH=$(in_repo git stash create)
			    in_repo git checkout -f .
			fi
			in_repo git checkout -b "$THROWAWAY_BRANCH"
		    fi
		    # Merge the requested branch into the throwaway branch.
		    # Die if the merge failed -- there must have been a
		    # conflict, and the user needs to fix it up.
		    in_repo git merge "$1" || \
			die "Merge of $1 failed, fix things up and continue"
		    # If there is n identically named branch in the build cache,
		    # merge it into a throwaway branch of the build cache
		    # along with the current branch in the build cache.
		    # This makes it easier to include and manage packages that
		    # are branch-specific, but that do not need to be included
		    # in every build.
		    if in_cache branch_exists "$1"; then
			if [[ ! $CACHE_THROWAWAY_BRANCH ]]; then
			    CACHE_THROWAWAY_BRANCH=${THROWAWAY_BRANCH/build/cache}
			    in_cache git checkout -b "$CACHE_THROWAWAY_BRANCH"
			fi
			in_cache git merge "$1" || \
			    die "Could not merge build cache branch $1"
		    fi
		    shift
		done
		;;
	    update-cache|--update-cache) shift; need_update=true;;
	    *) 	die "Unknown command line parameter $1";;
	esac
    done
    # If we stached changes to the crowbar repo, apply them now.
    [[ $THROWAWAY_STASH ]] && in_repo git stash apply "$THROWAWAY_STASH"
    # Ditto for the build cache.
    [[ $CACHE_THROWAWAY_STASH ]] && \
	in_cache git stash apply "$CACHE_THROWAWAY_STASH"

    # Finalize where we expect to find our caches and out chroot.
    # If they were set in one of the conf files, don't touch them.

    # The directory we perform a minimal install into if we need
    # to refresh our gem or pkg caches
    [[ $CHROOT ]] || CHROOT="$CACHE_DIR/$OS_TOKEN/chroot"

    # Make sure that the $OS_TOKEN directory exist.
    mkdir -p "$CACHE_DIR/$OS_TOKEN"

    # The directory we will stage the build into.
    [[ $BUILD_DIR ]] || \
	BUILD_DIR="$(mktemp -d "$CACHE_DIR/$OS_TOKEN/build-XXXXX")"
    # The directory that we will mount the OS .ISO on .
    [[ $IMAGE_DIR ]] || \
	IMAGE_DIR="$CACHE_DIR/$OS_TOKEN/image-${BUILD_DIR##*-}"

    # Directories where we cache our pkgs, gems, and ami files
    [[ $PKG_CACHE ]] || PKG_CACHE="$CACHE_DIR/$OS_TOKEN/pkgs"
    [[ $GEM_CACHE ]] || GEM_CACHE="$CACHE_DIR/gems"
    [[ $AMI_CACHE ]] || AMI_CACHE="$CACHE_DIR/amis"

    # Directory where we will look for our package lists
    [[ $PACKAGE_LISTS ]] || PACKAGE_LISTS="$BUILD_DIR/extra/packages"

    # Proxy Variables
    [[ $USE_PROXY ]] || USE_PROXY=0
    [[ $PROXY_HOST ]] || PROXY_HOST=""
    [[ $PROXY_PORT ]] || PROXY_PORT=""
    [[ $PROXY_USER ]] || PROXY_USER=""
    [[ $PROXY_ESC_USER ]] || PROXY_ESC_USER=""
    [[ $PROXY_PASSWORD ]] || PROXY_PASSWORD=""

    # Version for ISO
    [[ $VERSION ]] || VERSION="$(cd "$CROWBAR_DIR"; git describe --long)-dev"

    # Name of the openstack iso we will build
    [[ $OPENSTACK_ISO ]] || OPENSTACK_ISO="openstack-${VERSION}.iso"

    # Make any directories we don't already have
    for d in "$PKG_CACHE" "$GEM_CACHE" "$ISO_LIBRARY" "$ISO_DEST" \
	"$IMAGE_DIR" "$BUILD_DIR" "$AMI_CACHE" \
	"$SLEDGEHAMMER_PXE_DIR" "$CHROOT"; do
	mkdir -p "$d"
    done

    # Make sure Sledgehammer has already been built and pre-staged.
    if ! [[ -f $SLEDGEHAMMER_DIR/bin/sledgehammer-tftpboot.tar.gz || \
	-f $SLEDGEHAMMER_PXE_DIR/initrd0.img ]]; then
	echo "Slegehammer TFTP image missing!"
	echo "Please build Sledgehammer from $SLEDGEHAMMER_DIR before building Crowbar."
	exit 1
    fi

    # make sure we have the AMIs we want
    for ami in "${AMIS[@]}"; do
	[[ -f $AMI_CACHE/${ami##*/} ]] && continue
	echo "$(date '+%F %T %z'): Downloading and caching $ami"
	curl -o "$AMI_CACHE/${ami##*/}" "$ami" || \
	    die "Could not download $ami"
    done

    # Fetch the OS ISO if we need to.
    [[ -f $ISO_LIBRARY/$ISO ]] || fetch_os_iso

    # Start with a clean slate.
    clean_dirs "$IMAGE_DIR" "$BUILD_DIR"

    # Clean up any cruft that the editor may have left behind.
    (cd "$CROWBAR_DIR"; $VCS_CLEAN_CMD)

    # Mount our ISO for the build process.
    debug "Mounting $ISO"
    sudo mount -t iso9660 -o loop "$ISO_LIBRARY/$ISO" "$IMAGE_DIR" || \
	die "Could not mount $ISO"

    # Make additional directories we will need.
    for d in discovery extra ami updates ; do
	mkdir -p "$BUILD_DIR/$d"
    done

    # Copy over the Crowbar bits and their prerequisites
    debug "Staging extra Crowbar bits"
    cp -r "$CROWBAR_DIR/$OS_TOKEN-extra"/* "$BUILD_DIR/extra"
    cp -r "$CROWBAR_DIR/change-image"/* "$BUILD_DIR"

    # If we need to or were asked to update our cache, do it.
    maybe_update_cache

    # Copy our extra pkgs, gems, and amis into the appropriate staging
    # directory.
    debug "Copying pkgs, gems, and amis"
    copy_pkgs "$IMAGE_DIR" "$PKG_CACHE" "$BUILD_DIR/extra/pkgs"
    cp -r "$GEM_CACHE" "$BUILD_DIR/extra"
    cp -r "$AMI_CACHE/." "$BUILD_DIR/ami/."

    # Make sure the OS package tools know how to install packages.
    reindex_packages

    # Store off the version
    echo "$VERSION" >> "$BUILD_DIR/dell/Version"

    final_build_fixups

    # Copy over the bits that Sledgehammer will look for.
    debug "Copying over Sledgehammer bits"
    for d in "$CROWBAR_DIR/"updates*; do
	[[ -d $d ]] || continue
	cp -r "$d"/* "$BUILD_DIR/updates"
    done
    # If we need to copy over a new Sledgehammer image, do so.
    if [[ $SLEDGEHAMMER_DIR/bin/sledgehammer-tftpboot.tar.gz -nt \
	$SLEDGEHAMMER_PXE_DIR/initrd0.img ]]; then
	(   cd $SLEDGEHAMMER_PXE_DIR
	    debug "Extracting new Sledgehammer TFTP boot image"
	    rm -rf .
	    cd ..
	    tar xzf "$SLEDGEHAMMER_DIR/bin/sledgehammer-tftpboot.tar.gz"
	    rm -f "$SLEDGEHAMMER_DIR/bin/sledgehammer-tftpboot.tar.gz"
	)
    fi
    cp -a "$SLEDGEHAMMER_PXE_DIR"/* "$BUILD_DIR/discovery"

    # Make our image
    debug "Creating new ISO"
    # Find files and directories that mkisofs will complain about.
    # Do just top-level overlapping directories for now.
    for d in $(cat <(cd "$BUILD_DIR"; find -maxdepth 1 -type d ) \
	           <(cd "$IMAGE_DIR"; find -maxdepth 1 -type d) | \
	           sort |uniq -d); do
	[[ $d = . ]] && continue
	d=${d#./}
	# Copy contents of the found directories into $BUILD_DIR, taking care
	# to not clobber existing files.
	mkdir -p "$BUILD_DIR/$d"
	# We could also use cp -n, but rhel5 and centos5 do not understand it.
	rsync -a --ignore-existing "$IMAGE_DIR/$d/." "$BUILD_DIR/$d/."
	chmod -R u+wr "$BUILD_DIR/$d"
	# Bind mount an empty directory on the $IMAGE_DIR instance.
	sudo mount -t tmpfs -o size=1K tmpfs "$IMAGE_DIR/$d"
    done
    (   cd "$BUILD_DIR"
	rm -f isolinux/boot.cat
	find -name '.svn' -type d -exec rm -rf '{}' ';' 2>/dev/null >/dev/null
	mkdir -p $ISO_DEST
	mkisofs -r -V "${VERSION:0:30}" -cache-inodes -J -l -quiet \
	    -b isolinux/isolinux.bin -c isolinux/boot.cat \
	    -no-emul-boot --boot-load-size 4 -boot-info-table \
	    -o "$ISO_DEST/$OPENSTACK_ISO" "$IMAGE_DIR" "$BUILD_DIR" ) || \
	    die "There was a problem building our ISO."

    echo "$(date '+%F %T %z'): Finshed. Image at $ISO_DEST/$OPENSTACK_ISO"
} 65> /tmp/.build_crowbar.lock

#!/bin/bash
# Copyright 2011, Dell
#
# 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.
#
# Author: VictorLowther
#

# This script expects to be able to run certian commands as root.
# Either run it as a user who can sudo to root, or give the user
# you are running it as the following sudo rights:
# crowbar-tester ALL = NOPASSWD: /bin/mount, /bin/umount, /usr/sbin/debootstrap, /bin/cp, /usr/sbin/chroot

# When running this script for the first time, it will automatically create a
# cache directory and try to populate it with all the build dependencies.
# After that, if you need to pull in new dependencies, you will need to
# call the script with the --update-cache parameter.  If you are going to
# develop on Crowbar, it is a good idea to put the build cache in its own git
# repository, and create a branching structure for the packages that mirrors
# the branching structure in the crowbar repository -- if you do that, then
# this build script can be smarter about what packages it should pull in
# whenever you invoke it to build an iso.

[[ $DEBUG ]] && {
    set -x
    export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): '
}

export PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin"

# Our general cleanup function.  It is called as a trap whenever the
# build script exits, and it's job is to make sure we leave the local
# system in the same state we cound it, modulo a few calories of wasted heat
# and a shiny new .iso.
cleanup() {
    # Clean up any stray mounts we may have left behind.
    # The paranoia with the grepping is to ensure that we do not
    # inadvertently umount everything.
    GREPOPTS=()
    [[ $CACHE_DIR ]] && GREPOPTS=(-e "$CACHE_DIR")
    [[ $IMAGE_DIR && $CACHE_DIR =~ $IMAGE_DIR ]] && GREPOPTS=(-e "$IMAGE_DIR")
    [[ $BUILD_DIR && $CACHE_DIR =~ $BUILD_DIR ]] && GREPOPTS=(-e "$BUILD_DIR")
    if [[ $GREPOPTS ]]; then
	while read dev fs type opts rest; do
	    sudo umount -d -l "$fs"
	done < <(tac /proc/self/mounts |grep "${GREPOPTS[@]}")
    fi
    # If the build process spawned a copy of webrick, make sure it is dead.
    [[ $webrick_pid && -d /proc/$webrick_pid ]] && kill -9 $webrick_pid
    # clean up after outselves from merging branches, if needed.
    cd "$CROWBAR_DIR"
    if [[ $THROWAWAY_BRANCH ]]; then
	# Check out the branch we started the build process, and then
	# nuke whatever throwaway branch we may have created.
	git checkout -f "${CURRENT_BRANCH##*/}" &>/dev/null
	git branch -D "$THROWAWAY_BRANCH" &>/dev/null
    fi
    # If we saved unadded changes, resurrect them.
    [[ $THROWAWAY_STASH ]] && git stash apply "$THROWAWAY_STASH" &>/dev/null
    # Do the same thing as above, but for the build cache instead.
    cd "$CACHE_DIR"
    if [[ $CACHE_THROWAWAY_BRANCH ]]; then
	git checkout -f "$CURRENT_CACHE_BRANCH" &>/dev/null
	git branch -D "$CACHE_THROWAWAY_BRANCH" &>/dev/null
    fi
    [[ $CACHE_THROWAWAY_STASH ]] && git stash apply "$CACHE_THROWAWAY_STASH"
    for d in "$IMAGE_DIR" "$BUILD_DIR"; do
	[[ -d $d ]] && rm -rf -- "$d"
    done
}

# Arrange for cleanup to be called at the most common exit points.
trap cleanup 0 INT QUIT TERM

# Next, some configuration variables that can be used to tune how the
# build process works.

# Location for caches that should not be erased between runs
[[ $CACHE_DIR ]] || CACHE_DIR="$HOME/.crowbar-build-cache"

# Location to store .iso images that we use in the build process.
# These are usually OS install DVDs that we will stage Crowbar on to.
[[ $ISO_LIBRARY ]] || ISO_LIBRARY="$CACHE_DIR/iso"

# This is the location that we will save the generated .iso to.
[[ $ISO_DEST ]] || ISO_DEST="$PWD"

# Directory that holds our Sledgehammer PXE tree.
[[ $SLEDGEHAMMER_PXE_DIR ]] || SLEDGEHAMMER_PXE_DIR="$CACHE_DIR/tftpboot"

# Location of the Crowbar checkout we are building from.
[[ $CROWBAR_DIR ]] ||CROWBAR_DIR="${0%/*}"

# Location of the Sledgehammer source tree.  Only used if we cannot
# find Sledgehammer in $SLEDGEHAMMER_PXE_DIR above.
[[ $SLEDGEHAMMER_DIR ]] || SLEDGEHAMMER_DIR="${CROWBAR_DIR}/../sledgehammer"

# Command to run to clean out the tree before starting the build.
# By default we want to be relatively pristine.
[[ $VCS_CLEAN_CMD ]] || VCS_CLEAN_CMD='git clean -f -x -d'

# Arrays holding the additional pkgs, gems, and AMI images we will populate
# Crowbar with.
PKGS=()
GEMS=()
AMIS=("http://uec-images.ubuntu.com/releases/11.04/release/ubuntu-11.04-server-uec-amd64.tar.gz")

# Some helper functions

# Print a message to stderr and exit.  cleanup will be called.
die() { echo "$(date '+%F %T %z'): $*" >&2; exit 1; }

# Print a message to stderr and keep going.
debug() { echo "$(date '+%F %T %z'): $*" >&2; }

# Clean up any cruft that we might have left behind from the last run.
clean_dirs() {
    local d=''
    for d in "$@"; do
	(   mkdir -p "$d"
	    cd "$d"
	    chmod -R u+w .
	    rm -rf * )
    done
}

# Verify that the passed name is really a branch in the git repo.
branch_exists() { git show-ref --quiet --verify --heads -- "refs/heads/$1"; }

# Run a git command in the crowbar repo.
in_repo() ( cd "$CROWBAR_DIR"; "$@")

# Run a git command in the build cache, assuming it is a git repository.
in_cache() (
    [[ $CURRENT_CACHE_BRANCH ]] || return
    cd "$CACHE_DIR"
    "$@"
)

# Get the OS we were asked to stage Crowbar on to.  Assume it is Ubuntu 10.10
# unless we specify otherwise.
OS_TO_STAGE="${1-ubuntu-10.10}"
shift

# Make sure that we actually know how to build the ISO we were asked to
# build.  If we do not, print a helpful error message.
if ! [[ $OS_TO_STAGE && -d $CROWBAR_DIR/$OS_TO_STAGE-extra && \
    -f $CROWBAR_DIR/$OS_TO_STAGE-extra/build_lib.sh ]]; then
    cat <<EOF
You must pass the name of the operating system you want to stage Crowbar
on to.  Valid choices are:
EOF
    cd "$CROWBAR_DIR"
    for d in *-extra; do
	[[ -d $d && -f $d/build_lib.sh ]] || continue
	echo "    ${d%-extra}"
    done
    exit 1
fi

# Source OS specific build knowledge.  This includes:
# Parameters that build_crowbar.sh needs to know:
# OS = the distribution we are staging on to, such as redhat or ubuntu.
# OS_VERSION = the version of the distribution we are staging on to.
#              For redhat, it would be somethibng like 5.6
# OS_TOKEN = Defaults to "$OS-$OS_VERSION"
# ISO = the name of the install ISO image we are going to stage Crowbar on to.
#
# Functions that build_crowbar needs to call:
# maybe_update_cache(): This function should check and see if the OS and Gem
#   caches in $CACHE_DIR need updating.  If they do, it shoould update them
#   in a way that is reasonably portable across Linuxes and that leaves the
#   build host alone -- the state of the hosts packaging system should not
#   be touched at all. It does not take any arguments.
# copy_pkgs(): This function should appropriatly stage any extra packages
#   that Crowbar will need to install and run. We recommend that this function
#   take care to only copy the latest version of a package if there are any
#   duplicates.  It takes 3 arguments -- the location of the package pool on
#   the OS install media, the package cache to copy packages from, and the
#   location to copy extra packages to (which should NOT be the same as the
#   package pool on the OS media).
# reindex_packages():  This function should build whatever package index
#   the package installation tools $OS needs to have to be able to use the
#   packages copy_pkgs installs as a repository for installing packages from.
#   It takes no arguments.
# final_build_fixups(): This function should take wahtever steps are needed
#   to make the default OS install process also ensure that the Crowbar bits
#   are properly staged and to completly automate the admin node install
#   process, either as an install from CD or an install via PXE.  This
#   usually entails modifying initrd files, adding kickstarts/install seeds,
#   modifying boot config files, and so on.
. "$CROWBAR_DIR/$OS_TO_STAGE-extra/build_lib.sh"

{
    # Make sure only one instance of the ISO build runs at a time.
    # Otherwise you can easily end up with a corrupted image.
    flock 65
    # Figure out what our current branch is, in case we need to merge
    # other branches in to the iso to create our build.
    CURRENT_BRANCH="$(in_repo git symbolic-ref HEAD)" || \
	die "Not on a branch we can build from!"
    CURRENT_BRANCH=${CURRENT_BRANCH##*/}
    [[ $CURRENT_BRANCH ]] || die "Not on a branch we can merge from!"

    # Check and see if our local build repository is a git repo. If it is,
    # we may need to do the same sort of merging in it that we might do in the
    # Crowbar repository.
    if [[ -d $CACHE_DIR/.git ]]; then
	for br in "$CURRENT_BRANCH" master ''; do
	    [[ $br ]] || die "Cannot find $CURRENT_BRANCH or master in $CACHE_DIR"
	    (cd "$CACHE_DIR"; branch_exists "$br") || continue
	    CURRENT_CACHE_BRANCH="$br"
	    break
	done
	# If there are packages that have not been comitted, save them
	# in a stash before continuing.  We do this on the assumption that
	# these packages were added manually for testing purposes, or were
	# added in an earlier update-cache operation, but that the user has
	# not gotten around to comitting yet.
	if [[ ! $(in_cache git status) =~ working\ directory\ clean ]]; then
	    CACHE_THROWAWAY_STASH=$(in_cache git stash create)
	    in_cache git checkout -f .
	fi
    fi

    # Parse our options.
    while [[ $1 ]]; do
	case $1 in
	    # Merge a list of branches into a throwaway branch with the
	    # current branch as a baseline before starting the rest of the
	    # build process.  This makes it easier to spin up iso images
	    # with local changes without having to manually merge those
	    # changes in with any other branches of interest first.
	    # This code takes heavy advantage of the lightweight nature of
	    # git branches and takes care to leave uncomitted changes in place.
	    -m|--merge)
		shift
		# Loop through the rest of the arguments, as long as they
		# do not start with a -.
		while [[ $1 && ! ( $1 = -* ) ]]; do
		    # Check to make sure that this argument refers to a branch
		    # in the crowbar git tree.  Die if it does not.
		    in_repo branch_exists "$1" || die "$1 is not a git branch!"
		    # If we have not already created a throwaway branch to
		    # merge these branches into, do so now. If we have
		    # uncomitted changes that need to be stashed, do so here.
		    if [[ ! $THROWAWAY_BRANCH ]]; then
			THROWAWAY_BRANCH="build-throwaway-$$-$RANDOM"
			REPO_PWD="$PWD"
			if [[ ! $(in_repo git status) =~ working\ directory\ clean ]]; then
			    THROWAWAY_STASH=$(in_repo git stash create)
			    in_repo git checkout -f .
			fi
			in_repo git checkout -b "$THROWAWAY_BRANCH"
		    fi
		    # Merge the requested branch into the throwaway branch.
		    # Die if the merge failed -- there must have been a
		    # conflict, and the user needs to fix it up.
		    in_repo git merge "$1" || \
			die "Merge of $1 failed, fix things up and continue"
		    # If there is n identically named branch in the build cache,
		    # merge it into a throwaway branch of the build cache
		    # along with the current branch in the build cache.
		    # This makes it easier to include and manage packages that
		    # are branch-specific, but that do not need to be included
		    # in every build.
		    if in_cache branch_exists "$1"; then
			if [[ ! $CACHE_THROWAWAY_BRANCH ]]; then
			    CACHE_THROWAWAY_BRANCH=${THROWAWAY_BRANCH/build/cache}
			    in_cache git checkout -b "$CACHE_THROWAWAY_BRANCH"
			fi
			in_cache git merge "$1" || \
			    die "Could not merge build cache branch $1"
		    fi
		    shift
		done
		;;
	    update-cache|--update-cache) shift; need_update=true;;
	    *) 	die "Unknown command line parameter $1";;
	esac
    done
    # If we stached changes to the crowbar repo, apply them now.
    [[ $THROWAWAY_STASH ]] && in_repo git stash apply "$THROWAWAY_STASH"
    # Ditto for the build cache.
    [[ $CACHE_THROWAWAY_STASH ]] && \
	in_cache git stash apply "$CACHE_THROWAWAY_STASH"

    # Source our config file if we have one
    [[ -f $HOME/.build-crowbar.conf ]] && \
	. "$HOME/.build-crowbar.conf"

    # Look for a local one.
    [[ -f build-crowbar.conf ]] && \
	. "build-crowbar.conf"

    # Finalize where we expect to find our caches and out chroot.
    # If they were set in one of the conf files, don't touch them.

    # The directory we perform a minimal install into if we need
    # to refresh our gem or pkg caches
    [[ $CHROOT ]] || CHROOT="$CACHE_DIR/$OS_TOKEN/chroot"

    # Make sure that the $OS_TOKEN directory exist.
    mkdir -p "$CACHE_DIR/$OS_TOKEN"

    # The directory we will stage the build into.
    [[ $BUILD_DIR ]] || \
	BUILD_DIR="$(mktemp -d "$CACHE_DIR/$OS_TOKEN/build-XXXXX")"
    # The directory that we will mount the OS .ISO on .
    [[ $IMAGE_DIR ]] || \
	IMAGE_DIR="$CACHE_DIR/$OS_TOKEN/image-${BUILD_DIR##*-}"

    # Directories where we cache our pkgs, gems, and ami files
    [[ $PKG_CACHE ]] || PKG_CACHE="$CACHE_DIR/$OS_TOKEN/pkgs"
    [[ $GEM_CACHE ]] || GEM_CACHE="$CACHE_DIR/gems"
    [[ $AMI_CACHE ]] || AMI_CACHE="$CACHE_DIR/amis"

    # Directory where we will look for our package lists
    [[ $PACKAGE_LISTS ]] || PACKAGE_LISTS="$BUILD_DIR/extra/packages"

    # Proxy Variables
    [[ $USE_PROXY ]] || USE_PROXY=0
    [[ $PROXY_HOST ]] || PROXY_HOST=""
    [[ $PROXY_PORT ]] || PROXY_PORT=""
    [[ $PROXY_USER ]] || PROXY_USER=""
    [[ $PROXY_ESC_USER ]] || PROXY_ESC_USER=""
    [[ $PROXY_PASSWORD ]] || PROXY_PASSWORD=""

    # Version for ISO
    [[ $VERSION ]] || VERSION="$(cd "$CROWBAR_DIR"; git describe --long)-dev"

    # Name of the openstack iso we will build
    [[ $OPENSTACK_ISO ]] || OPENSTACK_ISO="openstack-${VERSION}.iso"

    # Make any directories we don't already have
    for d in "$PKG_CACHE" "$GEM_CACHE" "$ISO_LIBRARY" "$ISO_DEST" \
	"$IMAGE_DIR" "$BUILD_DIR" "$AMI_CACHE" \
	"$SLEDGEHAMMER_PXE_DIR" "$CHROOT"; do
	mkdir -p "$d"
    done

    # Make sure Sledgehammer has already been built and pre-staged.
    if ! [[ -f $SLEDGEHAMMER_DIR/bin/sledgehammer-tftpboot.tar.gz || \
	-f $SLEDGEHAMMER_PXE_DIR/initrd0.img ]]; then
	echo "Slegehammer TFTP image missing!"
	echo "Please build Sledgehammer from $SLEDGEHAMMER_DIR before building Crowbar."
	exit 1
    fi

    # make sure we have the AMIs we want
    for ami in "${AMIS[@]}"; do
	[[ -f $AMI_CACHE/${ami##*/} ]] && continue
	echo "$(date '+%F %T %z'): Downloading and caching $ami"
	curl -o "$AMI_CACHE/${ami##*/}" "$ami" || \
	    die "Could not download $ami"
    done

    # Fetch the OS ISO if we need to.
    [[ -f $ISO_LIBRARY/$ISO ]] || fetch_os_iso

    # Start with a clean slate.
    clean_dirs "$IMAGE_DIR" "$BUILD_DIR"

    # Clean up any cruft that the editor may have left behind.
    (cd "$CROWBAR_DIR"; $VCS_CLEAN_CMD)

    # Mount our ISO for the build process.
    debug "Mounting $ISO"
    sudo mount -t iso9660 -o loop "$ISO_LIBRARY/$ISO" "$IMAGE_DIR" || \
	die "Could not mount $ISO"

    # Make additional directories we will need.
    for d in discovery extra ami updates ; do
	mkdir -p "$BUILD_DIR/$d"
    done

    # Copy over the Crowbar bits and their prerequisites
    debug "Staging extra Crowbar bits"
    cp -r "$CROWBAR_DIR/$OS_TOKEN-extra"/* "$BUILD_DIR/extra"
    cp -r "$CROWBAR_DIR/change-image"/* "$BUILD_DIR"

    # If we need to or were asked to update our cache, do it.
    maybe_update_cache

    # Copy our extra pkgs, gems, and amis into the appropriate staging
    # directory.
    debug "Copying pkgs, gems, and amis"
    copy_pkgs "$IMAGE_DIR" "$PKG_CACHE" "$BUILD_DIR/extra/pkgs"
    cp -r "$GEM_CACHE" "$BUILD_DIR/extra"
    cp -r "$AMI_CACHE/." "$BUILD_DIR/ami/."

    # Make sure the OS package tools know how to install packages.
    reindex_packages

    # Store off the version
    echo "$VERSION" >> "$BUILD_DIR/dell/Version"

    final_build_fixups

    # Copy over the bits that Sledgehammer will look for.
    debug "Copying over Sledgehammer bits"
    for d in "$CROWBAR_DIR/"updates*; do
	[[ -d $d ]] || continue
	cp -r "$d"/* "$BUILD_DIR/updates"
    done
    # If we need to copy over a new Sledgehammer image, do so.
    if [[ $SLEDGEHAMMER_DIR/bin/sledgehammer-tftpboot.tar.gz -nt \
	$SLEDGEHAMMER_PXE_DIR/initrd0.img ]]; then
	(   cd $SLEDGEHAMMER_PXE_DIR
	    debug "Extracting new Sledgehammer TFTP boot image"
	    rm -rf .
	    cd ..
	    tar xzf "$SLEDGEHAMMER_DIR/bin/sledgehammer-tftpboot.tar.gz"
	    rm -f "$SLEDGEHAMMER_DIR/bin/sledgehammer-tftpboot.tar.gz"
	)
    fi
    cp -a "$SLEDGEHAMMER_PXE_DIR"/* "$BUILD_DIR/discovery"

    # Make our image
    debug "Creating new ISO"
    # Find files and directories that mkisofs will complain about.
    # Do just top-level overlapping directories for now.
    for d in $(cat <(cd "$BUILD_DIR"; find -maxdepth 1 -type d ) \
	           <(cd "$IMAGE_DIR"; find -maxdepth 1 -type d) | \
	           sort |uniq -d); do
	[[ $d = . ]] && continue
	d=${d#./}
	# Copy contents of the found directories into $BUILD_DIR, taking care
	# to not clobber existing files.
	mkdir -p "$BUILD_DIR/$d"
	# We could also use cp -n, but rhel5 and centos5 do not understand it.
	rsync -a --ignore-existing "$IMAGE_DIR/$d/." "$BUILD_DIR/$d/."
	chmod -R u+wr "$BUILD_DIR/$d"
	# Bind mount an empty directory on the $IMAGE_DIR instance.
	sudo mount -t tmpfs -o size=1K tmpfs "$IMAGE_DIR/$d"
    done
    (   cd "$BUILD_DIR"
	rm -f isolinux/boot.cat
	find -name '.svn' -type d -exec rm -rf '{}' ';' 2>/dev/null >/dev/null
	mkdir -p $ISO_DEST
	mkisofs -r -V "${VERSION:0:30}" -cache-inodes -J -l -quiet \
	    -b isolinux/isolinux.bin -c isolinux/boot.cat \
	    -no-emul-boot --boot-load-size 4 -boot-info-table \
	    -o "$ISO_DEST/$OPENSTACK_ISO" "$IMAGE_DIR" "$BUILD_DIR" ) || \
	    die "There was a problem building our ISO."

    echo "$(date '+%F %T %z'): Finshed. Image at $ISO_DEST/$OPENSTACK_ISO"
} 65> /tmp/.build_crowbar.lock


Added reminder build_package.sh

Added reminder build_package.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/physion/ovation-R.git/'


Adds a user to a mongodb database.

Adds a user to a mongodb database.

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/madewithlove/vaprobash-scripts.git/'


auto-restart Alexa

auto-restart Alexa

Check if Alexa is already running.  If not, restart in 'silent' mode

#!/bin/sh

if pgrep python -a | grep main.py > /dev/null; then
        echo "Alexa is already running."
else
        python /root/AlexaPi/main.py -s &
fi

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


re-committing monitorAlexa.sh

re-committing monitorAlexa.sh

Hoping this will set the executable bit.


Add ACL fuzzer.  It's not used by the regression tests right now, but I'd prefert to have it here, so it won't get lost.

#!/bin/sh
#
# Copyright (c) 2008, 2009 Edward Tomasz Napierała <trasz@FreeBSD.org>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD$
#

# This is an NFSv4 ACL fuzzer.  It expects to be run by non-root in a scratch
# directory on a filesystem with NFSv4 ACLs support.  Output it generates
# is expected to be fed to /usr/src/tools/regression/acltools/run script.

NUMBER_OF_COMMANDS=300

run_command()
{
	echo "\$ $1"
	eval $1 2>&1 | sed 's/^/> /'
}

rnd_from_0_to()
{
	max=`expr $1 + 1`
	rnd=`jot -r 1`
	rnd=`expr $rnd % $max`

	echo $rnd
}

rnd_path()
{
	rnd=`rnd_from_0_to 3`
	case $rnd in
		0) echo "$TMP/aaa" ;;
		1) echo "$TMP/bbb" ;;
		2) echo "$TMP/aaa/ccc" ;;
		3) echo "$TMP/bbb/ddd" ;;
	esac
}

f_prepend_random_acl_on()
{
	rnd=`rnd_from_0_to 4`
	case $rnd in
		0) u="owner@" ;;
		1) u="group@" ;;
		2) u="everyone@" ;;
		3) u="u:1138" ;;
		4) u="g:1138" ;;
	esac

	p=""
	while :; do
		rnd=`rnd_from_0_to 30`
		if [ -n "$p" -a $rnd -ge 14 ]; then
			break;
		fi

		case $rnd in
			0) p="${p}r" ;;
			1) p="${p}w" ;;
			2) p="${p}x" ;;
			3) p="${p}p" ;;
			4) p="${p}d" ;;
			5) p="${p}D" ;;
			6) p="${p}a" ;;
			7) p="${p}A" ;;
			8) p="${p}R" ;;
			9) p="${p}W" ;;
			10) p="${p}R" ;;
			11) p="${p}c" ;;
			12) p="${p}C" ;;
			13) p="${p}o" ;;
			14) p="${p}s" ;;
		esac
	done

	f=""
	while :; do
		rnd=`rnd_from_0_to 10`
		if [ $rnd -ge 6 ]; then
			break;
		fi

		case $rnd in
			0) f="${f}f" ;;
			1) f="${f}d" ;;
			2) f="${f}n" ;;
			3) f="${f}i" ;;
		esac
	done

	rnd=`rnd_from_0_to 1`
	case $rnd in
		0) x="allow" ;;
		1) x="deny" ;;
	esac

	acl="$u:$p:$f:$x"

	file=`rnd_path`
	run_command "setfacl -a0 $acl $file"
}

f_getfacl()
{
	file=`rnd_path`
	run_command "getfacl -qn $file"
}

f_ls_mode()
{
	file=`rnd_path`
	run_command "ls -al $file | sed -n '2p' | cut -d' ' -f1"
}

f_chmod()
{
	b1=`rnd_from_0_to 7`
	b2=`rnd_from_0_to 7`
	b3=`rnd_from_0_to 7`
	b4=`rnd_from_0_to 7`
	file=`rnd_path`

	run_command "chmod $b1$b2$b3$b4 $file $2"
}

f_touch()
{
	file=`rnd_path`
	run_command "touch $file"
}

f_rm()
{
	file=`rnd_path`
	run_command "rm -f $file"
}

f_mkdir()
{
	file=`rnd_path`
	run_command "mkdir $file"
}

f_rmdir()
{
	file=`rnd_path`
	run_command "rmdir $file"
}

f_mv()
{
	from=`rnd_path`
	to=`rnd_path`
	run_command "mv -f $from $to"
}

# XXX: To be implemented: chown(8), setting times with touch(1).

switch_to_random_user()
{
	# XXX: To be implemented.
}

execute_random_command()
{
	rnd=`rnd_from_0_to 20`

	case $rnd in
		0|10|11|12|13|15) cmd=f_prepend_random_acl_on ;;
		1) cmd=f_getfacl ;;
		2) cmd=f_ls_mode ;;
		3) cmd=f_chmod ;;
		4|18|19) cmd=f_touch ;;
		5) cmd=f_rm ;;
		6|16|17) cmd=f_mkdir ;;
		7) cmd=f_rmdir ;;
		8) cmd=f_mv ;;
	esac

	$cmd "XXX"
}

echo "# Fuzzing; will stop after $NUMBER_OF_COMMANDS commands."
TMP="aclfuzzer_`dd if=/dev/random bs=1k count=1 2>/dev/null | openssl md5`"

run_command "whoami"
umask 022
run_command "umask 022"
run_command "mkdir $TMP"

i=0;
while [ "$i" -lt "$NUMBER_OF_COMMANDS" ]; do
	switch_to_random_user
	execute_random_command
	i=`expr $i + 1`
done

run_command "find $TMP -exec setfacl -a0 everyone@:rxd:allow {} \;"
run_command "rm -rfv $TMP"

echo "# Fuzzed, thank you."

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


add fd alias for cding into dirs

add fd alias for cding into dirs

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/partounian/dotfiles.git/'


newclientOVPN.sh

newclientOVPN.sh

New client script, puts everything into a single .ovpn file (including the CA client CERT TA Server details)

#!/bin/bash

# Default Variables
KEYENC=".3des.key"
OPENVPN_DIR=/etc/openvpn/easy-rsa
OPENVPN_KEY_DIR=$OPENVPN_DIR/keys
EXPORT=/home/theHTTPdoNOTtouch/openvpnOVPN
CN=$1
DEFAULT="/etc/openvpn/easy-rsa/default.txt" # the files default.txt should contain the client config.
FILEEXT=".ovpn"
CA="ca.crt"
TA="ta.key"
OU="Redstonevapour.co.uk VPN"

# New Client
if [ -z "$1" ]
	then echo -n "[OK] Enter new Client name: "
	read -e CN
else
	CN=$1
fi

# Ensure CN isn't blank
if [ -z "$CN" ]
	then echo "[ERROR] You must provide a name."
	exit
fi

if [ -f $OPENVPN_KEY_DIR/$CN.crt ]
  then echo "[ERROR] cerificate already exsists with the name $CN already exsists! Exiting now."
    echo " $OPENVPN_KEY_DIR/$CN.crt"
  exit
fi

cd $OPENVPN_DIR

if [ x$CN = x ]; then
    echo "[ERROR] Usage: $0 clientname"
    exit 1
fi

if [ ! -e keys/$CN.key ]; then
    echo "[OK] Generating keys... "
    . vars
    KEY_CN=$CN KEY_OU=$OU ./pkitool $CN
    echo "[OK] ...keys generated. "
fi

# Encrypting keys as per variables variables.

cd $OPENVPN_KEY_DIR

if [ -f $OPENVPN_KEY_DIR/$CN$KEYENC ]
  then echo "[ERROR] Key keys/$CN$KEYENC already exsist! Exiting now. "
fi

echo "[OK] Changing encryption now... "

# EDIT ME IF YOU CHANGE ENCRYTION!
openssl rsa -in $CN.key -des3 -out $CN$KEYENC

if [ ! -f $OPENVPN_KEY_DIR/$CN$KEYENC ]
  then echo "[ERROR] keys/$CN$KEYENC file not found. Exiting now. "
fi

echo "[OK] Key sucessfully encrytped. "

# Generate the OVPN file

if [ ! -f $OPENVPN_KEY_DIR/$CA ]
 then echo "[ERROR] CA Public Key not found: $CA"
 exit
fi

if [ ! -f $OPENVPN_KEY_DIR/$TA ]
 then echo "[ERROR] tls-auth Key not found: $TA"
 exit
fi

echo "[OK] Generating OVPN file now. "

cd $OPENVPN_KEY_DIR

cat $DEFAULT > $CN$FILEEXT

echo "<ca>" >> $CN$FILEEXT
cat $CA >> $CN$FILEEXT
echo "</ca>" >> $CN$FILEEXT

echo "<cert>" >> $CN$FILEEXT
cat $CN.crt | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' >> $CN$FILEEXT
echo "</cert>" >> $CN$FILEEXT

echo "<key>" >> $CN$FILEEXT
cat $CN$KEYENC >> $CN$FILEEXT
echo "</key>" >> $CN$FILEEXT

echo "<tls-auth>" >> $CN$FILEEXT
cat $TA >> $CN$FILEEXT
echo "</tls-auth>" >> $CN$FILEEXT

echo "[OK] Done creating $CN$FILEEXT! "

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


add node path

add node path

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


add this script to package gcs connector into a Cloudera parcel can be used to distribute the connector to whole cluster

#!/bin/bash
# Copyright 2018 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This script creates a Cloudera Parcel which contains Google Cloud Storage connector which
# enables connections between CDH cluster and Cloud Storage. Using the parcel, CDH can distribute
# the connector to all the nodes to save time and efforts of distributing and installing the
# connector.

# User must run the script in a separate folder where only the files to be packaged are present
# -f: name of the parcel in a single string format without any spaces or special characters.
# -v: version of the parcel in the format x.x.x (ex: 1.0.0)
# -o: name of the operating system distribution
# -d: flag is to be used if you want to deploy the parcel to the cloudera manager parcel repo
# folder, this flag is optional and if not provided then the parcel file will be created in the
# same directory where script run.

while getopts f:v:o:d: option
do
case "${option}"
in
f) filen=${OPTARG};;
v) version=${OPTARG};;
o) OSTYPE=${OPTARG};;
d) placefile='true';;
esac
done

#capture logs
>/var/log/build_parcel.log
exec 1>/var/log/build_parcel.log 2>&1

if [[ "$OSTYPE" == "el5" ]];
	then OS=el5 ; yum install wget -y
elif [[ "$OSTYPE" == "el6" ]];
	then OS=el6 ; yum install wget -y
elif [[ "$OSTYPE" == "el7" ]];
	then OS=el7 ; yum install wget -y
elif [[ "$OSTYPE" == "sles11" ]];
	then OS=sles11 ; zypper install wget -y
elif [[ "$OSTYPE" == "sles12" ]];
	then OS=sles12 ; zypper install wget -y
elif [[ "$OSTYPE" == "lucid" ]];
	then OS=lucid ; apt-get install wget -y
elif [[ "$OSTYPE" == "precise" ]];
	then OS=precise ; apt-get install wget -y
elif [[ "$OSTYPE" == "trusty" ]];
	then OS=trusty ; apt-get install wget -y
elif [[ "$OSTYPE" == "squeeze" ]];
	then OS=squeeze ; apt-get install wget -y
elif [[ "$OSTYPE" == "wheezy" ]];
	then OS=wheezy ; apt-get install wget -y
else
     echo "OS not in list, please provide valid OS name"
fi

## Display variable information input by user
#echo "Downloaded file:$link"
echo "Version number:$version"
echo "OS type:$OS"
echo "Filename:$filen"
mkdir -p ${filen^^}-$version/lib/hadoop/lib && mkdir -p ${filen^^}-$version/meta
touch ${filen^^}-$version/meta/parcel.json

###Download gcs connector jar and copy all folder content to parcel location

wget https://storage.googleapis.com/hadoop-lib/gcs/gcs-connector-hadoop2-latest.jar

cp * ${filen^^}-$version/lib/hadoop/lib/

## Create parcel.json file required for parcel packaging

cat >>${filen^^}-$version/meta/parcel.json<< EOL
{
  "schema_version":     1,
  "name":               "${filen^^}",
  "version":            "$version",
  "extraVersionInfo": {
    "fullVersion":        "$version-0-$OS",
    "baseVersion":        "${filen^^}$version",
    "patchCount":         ""
  },

  "conflicts":          "",

  "setActiveSymlink":   true,

  "scripts": {
        "defines": "${filen^^}.sh"
  },

  "packages": [ ],
  "components": [ ],

  "provides": [
    "cdh-plugin"
  ],

  "users": { },

  "groups": [ ]
}

EOL

##export HADOOP_CLASSPATH
cat >>${filen^^}-$version/meta/$filen.sh<< EOL
#!/bin/bash
export HADOOP_CLASSPATH=\$HADOOP_CLASSPATH:/opt/cloudera/parcels/$filen-$version/lib/hadoop/lib/gcs-connector-latest-hadoop2.jar
EOL

## Create parcel file, checksum file and shift parcel files to cloudera parcel directory and change ownership to cloudera-scm user

sudo tar zcvf ${filen^^}-$version-$OS.parcel ${filen^^}-$version/ --owner=root --group=root
sudo sha1sum ${filen^^}-$version-$OS.parcel | awk '{ print $1 }' > ${filen^^}-$version-$OS.parcel.sha

if [[ "$placefile" == "true" ]];
	then
	sudo cp ${filen^^}-$version-$OS.parcel* /opt/cloudera/parcel-repo/ ; sudo chown cloudera-scm:cloudera-scm /opt/cloudera/parcel-repo/*
else
     echo "Creating parcel on local host"
fi

error: pathspec 'examples/cloudera-parcel-gcsconnector/create_parcel.sh' did not match any file(s) known to git


Reworked the conf_dotfiles to add more stuff

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/charlestracker/install-scripts.git/'


To avoid the risk of things like zlib (and OpenSSL, if we turn its use on)
colliding with symbols in nginx, do a processing run on libpagespeed_automatic.a
renaming most of non-C++ symbols.

(Part of this snuck into r3636 --- the change in net/instaweb/automatic/Makefile
 due to an oversight on my part)

#!/bin/sh
#
# Copyright 2013 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Author: morlovich@google.com (Maksim Orlovich)
#
# Script that takes an .a file and renames all internal C functions in it
# to have a new prefix in order to avoid symbol clashes.
#
# Usage:  ./rename_c_symbols.sh input_library.a output_library.a

set -e  # exit script if any command returns an error
set -u  # exit the script if any variable is uninitialized

IN=$(readlink -f $1)
OUT=$(readlink -f $2)

# Get a list of defined non-C++ symbols that are global and not weak.
# We also exclude AtomicOps_Internalx86CPUFeatures since it's used by some
# Chromium headers.
# _Z is used at start of C++-mangled symbol names.
# Lower-cased letters indicate symbols local to the object file.
# V and W denote weak symbols.
SYMBOLS=$(mktemp)
nm -o -P --defined-only $IN | grep -v " _Z" | egrep -v " [[:lower:]] " \
  | grep -v " V " | grep -v " W " | grep -v AtomicOps_Internalx86CPUFeatures \
  | cut -d ' ' -f 2 > $SYMBOLS

# Generate a renaming map
RENAME_MAP=$(mktemp)
while read S; do
  echo $S pagespeed_ol_$S >> $RENAME_MAP
done < $SYMBOLS

rm $SYMBOLS

# Extract and patch up the object files
IN_OBJ_DIR=$(mktemp -d)
OUT_OBJ_DIR=$(mktemp -d)
cd $IN_OBJ_DIR
ar xvf $IN
for FILE in $(ls *.o); do
  objcopy -v --redefine-syms $RENAME_MAP $FILE $OUT_OBJ_DIR/$FILE
done

rm $RENAME_MAP
rm -rf $IN_OBJ_DIR

# Create the new .a
rm -f $OUT
cd $OUT_OBJ_DIR
ar -q -S $OUT *.o
echo ranlib $OUT
ranlib $OUT

error: pathspec 'src/net/instaweb/automatic/rename_c_symbols.sh' did not match any file(s) known to git


Add shellscript to create virtaul display and start x11vnc

#!/bin/bash

## PARAMS
## 1 - VIRTUAL display to be used. Sample VIRTUAL1 or VIRTUAL2
## 2 - Device resolution using [width]x[height], without bracets
## 3 - Position left or right

### Uncomment what you are using, hardcoded
## Laptop
fisical="LVDS1"
## VGA
#fisical="VGA1"
## HDMI
#fisical="HDM1"

## ADB path. hardcoded
adb_bin=~/android-sdk-linux/platform-tools/adb

## Log and Run commands
function run () {
	echo "$1"
	$1
}

## Find Possible IPs
echo "Possible IPs, use 'ifconfig' to check it out, if you want"
ifconfig | grep 'inet addr' | cut -d':' -f 2 | cut -d' ' -f 1
echo ""

## Find Android device Resolution, some devices works
if [ -z "$2" ] ; then
	device=$($adb_bin shell dumpsys window displays | grep init | cut -d'=' -f 2 | cut -d' ' -f 1)
else
	device=$2
fi
if [ -z "$device" ] ; then
	echo "Can't read device resolution using adb"
	exit 0
else
	## Device width and height
	d_width=$(echo $device | cut -d'x' -f 1)
	d_height=$(echo $device | cut -d'x' -f 2)
fi

echo "device  = $device"
echo "width   = $d_width"
echo "height  = $d_height"
echo ""

## Check param position, this position is where the user want the new screen
if [ -z "$3" ] ; then
	position="left"
else
	position=$3
fi
#echo "position= $position"
if [ "$position" = "left" ] ; then
	xinerama="xinerama0"
else
	xinerama="xinerama1"
fi

## Find Host Resolution
host=$(xdpyinfo  | grep 'dimensions:' | cut -d' ' -f 7)
h_width=$(echo $host | cut -d'x' -f 1)
h_height=$(echo $host | cut -d'x' -f 2)

echo "host    = $host"
echo "width   = $h_width"
echo "height  = $h_height"
echo ""

## Proportion, bash don't handle float, only integers so we use bc to do that operation
##proportion=$(($d_height / $h_height))
proportion=$(bc <<< "scale=2; $d_height / $h_height")
v_width=$(bc <<< "scale=0; $d_width / $proportion")
v_height=$h_height
echo "virtual proportion = $proportion"
echo "width   = $v_width"
echo "height  = $v_height"
echo ""

## Use VIRTUAL1 if none was passed
if [ -z "$1" ] ; then
	virtual="VIRTUAL1"
else
	virtual=$1
fi
echo "Display = $virtual"

## Build the modeline, the display configurations
modeline=$(cvt $v_width $v_height 20.00 | grep "Modeline" | cut -d' ' -f 2-17)
## Find the mode
mode=$(echo "$modeline" | cut -d' ' -f 1)
## remove quotes, don't need to remove quotes
#mode=${mode//\"}
res=$(echo $mode | cut -d'_' -f 1)
echo "device  = $res"

## Evaluates the start width position, to clip vnc
#s_width=$(echo $host | cut -d'x' -f 1)
#s_width=$((s_width + 1))
#echo "s_width = $s_width"

#echo $modeline
#echo $mode
echo ""

## Create Virtual Display
run "xrandr --newmode $modeline"
run "xrandr --addmode $virtual $mode"
run "xrandr --output $virtual --mode $mode --${position}-of ${fisical}"

## Start VNC
run "x11vnc -clip ${xinerama} -xrandr -ncache 1 -nosel -viewonly -fixscreen \"V=2\" -noprimary -nosetclipboard -noclipboard -cursor arrow -nopw -nowf -nonap -noxdamage -sb 0 -display :0"

## Turn VirtualDisplay off
run "xrandr --output $virtual --off"
run "xrandr --delmode $virtual $mode"
run "xrandr --rmmode $mode"
run "xrandr -s 0"

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


remove faulty package

remove faulty package

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/sivakumar-kailasam/dotfiles.git/'


Current version of the script, built around the i3 window manager.

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/Ofenhed/virt-start.git/'


More aliases for npm

More aliases for npm

alias npis='npm install --save'
alias npisd='npm install --save-dev'
alias npig='npm install -g'
alias npit='npm init'
alias npi='npm install'

alias npis='npm install --save'
alias npig='npm install -g'
alias npit='npm init'
alias npi='npm install'


Create nginx-and-php-fpm-auto-install.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/nginx-and-php-fpm-auto-install.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
sleep 5 ; echo "update sources list"
sleep 5
echo "deb http://ftp.de.debian.org/debian/ wheezy main contrib non-free
deb-src http://ftp.de.debian.org/debian/ wheezy main contrib non-free

deb http://security.debian.org/ wheezy/updates main contrib non-free
deb-src http://security.debian.org/ wheezy/updates main contrib non-free

# wheezy-updates, previously known as 'volatile'
deb http://ftp.de.debian.org/debian/ wheezy-updates main contrib non-free
deb-src http://ftp.de.debian.org/debian/ wheezy-updates main contrib non-free
#NGINX
deb http://nginx.org/packages/debian/ wheezy nginx
deb-src http://nginx.org/packages/debian/ wheezy nginx" >> /etc/apt/sources.list
sleep 3
clear
echo  ":: Install ginx, PHP-FPM, fcgiwrap et php mods"
sleep 3 ; apt-get update && apt-get upgrade -y && apt-get install -y nginx php5-fpm php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-memcached php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl fcgiwrap memcached
sleep 3
clear
echo  ":: Done, now restart service and clear the terminal"
sleep 2 ; service nginx restart && service php5-fpm restart
sleep 3
clear

error: pathspec 'nginx-and-php-fpm-auto-install.sh' did not match any file(s) known to git


xbps-src: fix xbps-create(1) --tags option.

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/Bubble-be/void-packages.git/'


Only email if addresses are given

Only email if addresses are given

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/enckse/core-scripts.git/'


Create toggle__run_lid_closed.sh

Create toggle__run_lid_closed.sh

#!/bin/bash

## --

# check if already toggled on or off
_check_and_toggle(){
  ret_val=`gsettings get org.gnome.settings-daemon.plugins.power active`
  if [ "$ret_val" == "true" ]
  then
    gsettings set org.gnome.settings-daemon.plugins.power active false
    notify-send "stag_lid:: laptop run with lid closed: ON"
  elif [ "$ret_val" == "false" ]
  then
    gsettings set org.gnome.settings-daemon.plugins.power active true
    notify-send "stag_lid:: laptop run with lid closed: OFF"
  fi
}

## --
_check_and_toggle # run the fcn that toggles the "run when lid closed" fcnality
## --

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


Create getPcap.sh

Create getPcap.sh

More options need to be added for pulling out more specific traffic.

#!/bin/bash
# input:  date source.IP destination.IP
# date is in format of: YYYY-MM-DD

display_usage() {
        echo -e "\n\nUSAGE: getPcap source.ip destination.ip\n\n"
                echo -e "This script can take a long time to run against all PCap files."
}

# if less than two arguments supplied, display usage
if [ $# -le 1 ]; then
        display_usage
        exit 1
fi

# check whether user had supplied -h or --help . If yes display usage
if [[ ($# == "--help") || ($# == "-h") ]]; then
        display_usage
        exit 0
fi

# if output directory doesn't exist then create it
if [ ! -d "./pcap" ]; then
        mkdir ./pcap
fi

# Displays a list of directories in packet capture directory and prompt for which
# file to edit

# Set the prompt for the select command
PS3="Choose interface or 'q' to quit: "
echo -e "\n\n"

# Create a list of files to display
dirList=$(find /nsm/sensor_data/ -maxdepth 1 -mindepth 1 -type d | sort)

# Show a menu and ask for input. If the user entered a valid choice,
# then invoke the editor on that file
select dir in $dirList; do
    if [ -n "$dir" ]; then
        int=$dir
    else
                exit
    fi
    break
done

# Displays a list of directories in packet capture directory and prompt for which
# file to edit

# Set the prompt for the select command
PS3="Choose date or 'q' to quit: "
echo -e "\n\n"

# Create a list of files to display
dirList=$(find $int/dailylogs -maxdepth 1 -mindepth 1 -type d | sort)

# Show a menu and ask for input. If the user entered a valid choice,
# then invoke the editor on that file
select dir in $dirList; do
    if [ -n "$dir" ]; then
        pdate=$dir
    else
                exit
    fi
    break
done

rm ./pcap/*.pcap

x=1
# iterate through all pcap files and extract searched for packets
for i in `find $pdate -type f`;
  do
    echo $i
    tshark -r $i -R "(ip.src == $1 and ip.dst == $2) or (ip.dst == $1 and ip.src == $2)" -w ./pcap/$x.pcap
    x=$((x+1))
  done
# merge all pcaps created in /home/so/pcap into one file
rm ./pcap/pcap.out
mergecap ./pcap/* -w ./pcap/pcap.out
# remove all pcaps but leave pcap.out alone
rm ./pcap/*.pcap
# rename pcap.out to out.pcap so we can open it with Wireshark
mv ./pcap/pcap.out ./pcap/out.pcap

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


Added script to fetch the example payloads from the wiki

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/hamstah/quack.git/'


get page headers test via telnet

get page headers test via telnet

#!/bin/bash

echo "open $1 $2"
sleep 2
echo "$3 HTTP/1.1"
#echo "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4"
echo "Host: $1"
echo
echo
sleep 2

: '
Usage:
./getpage.sh www.google.com 80 "GET /" | telnet
./getpage.sh www.google.com 80 "OPTIONS /" | telnet
./getpage.sh www.google.com 80 "HEAD /" | telnet
./getpage.sh www.google.com 80 "POST /" | telnet

./getpage.sh www.bing.com 80 "HEAD /search?q=python" | telnet

HEAD
GET
PUT
DELETE
------ idempotent
POST
TRACE
OPTIONS
CONNECT
'

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


Fixed logging into the API if the APACHE Gaia Port is changed.

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/seiruss/policy-debug.git/'


新增修改项目初始化的脚本

新增修改项目初始化的脚本

#! /bin/bash

PORJECT_NAME='MyProject'
AUTHOR_NAME='Kennylee'
AUTHOR_EMAIL='kennylee26@gmail.com'
DESCRIPTION=''
PACKAGE_FILE=package.json
BUILD_FILE=gulpfile.js

sed -i "" "s/\"name\"\: \"BaseJsProject\"/\"name\"\: \"$PORJECT_NAME\"/" $PACKAGE_FILE
sed -i "" "s/\"name\"\: \"KennyLee\"/\"name\"\: \"$AUTHOR_NAME\"/" $PACKAGE_FILE
sed -i "" "s/\"email\"\: \"kennylee26\@gmail\.com\"/\"email\"\: \"$AUTHOR_EMAIL\"/" $PACKAGE_FILE
sed -i "" "s/\"description\"\: \".*\"/\"description\"\: \"$DESCRIPTION\"/" $PACKAGE_FILE
sed -i "" "s/projectName = \'.*\'/projectName = \'$PORJECT_NAME\'/" $BUILD_FILE

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


Update DB installation script

Update DB installation 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/krouma/Ctyriadvacitka.git/'


Improve EAT corpus messages

Improve EAT corpus messages

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/cybeliak/mispronounceableness.git/'


add daemonize_adb.sh

add daemonize_adb.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/rseek/appium-autoregister.git/'


Add script for jekyll -> gatsby post.

Add script for jekyll -> gatsby post.

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/DylanVann/dylanvann-com.git/'


#876 netlify build

#876 netlify build

#!/usr/bin/env bash

# create a locally installed version of the current repo
mkdir -p $HOME/.doctoolchain/docToolchain-dev
cp -r * $HOME/.doctoolchain/docToolchain-dev/.
# set 'dev' as version in dtcw
sed -i 's/VERSION=[-0-9.a-z]*/VERSION=dev/' dtcw
# ensure that dtcw is installed
./dtcw tasks
# export information about contributors for those little avatars on top of each file
./dtcw exportContributors
# for the excel demo to work, we need to export the excel file
./dtcw exportExcel
# the docs for exportMarkdown are written in markdown, so let's export them
./dtcw exportMarkdown
# and now we are ready to generate the site
./dtcw generateSite

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


feat:supervisor init

feat:supervisor init

#!/bin/bash
sudo easy_install supervisor
sudo echo_supervisord_conf > /etc/supervisord.conf
sudo sed -i -- 's/minfds=1024/minfds=65535/g' /etc/supervisord.conf
sudo echo "[include]" >> /etc/supervisord.conf
sudo echo "files = supervisord.d/*.ini" >> /etc/supervisord.conf
sudo tee /usr/lib/systemd/system/supervisord.service <<-'EOF'
[Unit]
Description=Process Monitoring and Control Daemon
After=rc-local.service

[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf
SysVStartPriority=99

[Install]
WantedBy=multi-user.target
EOF

systemctl enable supervisord.service
systemctl start supervisord.service

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


Use a temporary working directory, just like before.

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/AmeBel/opencog.git/'


Adding a doc building script.

Adding a doc building script.

#!/bin/bash

# This script builds *every* release of the project documentation. This is used
# to rebuild all of our previous Express project docs. Should probably not be
# ran unless we update our Sphinx templates, and want to re-generate things all
# at once.

for tag in `git tag -l`; do
    git checkout $tag;
    cd docs;
    make html && cp -r _build/html ~/Desktop/$tag;
    cd ..;
done

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


Added heimdall to build-test.sh

Added heimdall to build-test.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/slamdata/slamengine.git/'


add lint

add lint

#!/bin/bash

# Prerequisite: pip install nblint
for f in build/chapter*/*.ipynb; do
	echo '===' $f
	nblint --linter pyflakes $f
done

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