initial install script

initial install script

#!/usr/bin/env bash

# ken@solinea.com
# (c) Solinea, Inc  2014

# 0. sanity check
# 1. install elasticsearch schema (external)
# 2. install logstash configs
# 3. create package for syslog distribution to OS clients
# 4. create virtualenv
# 5. install pips
# 6. install apache
# 7. create mod_wsgi
# 8. sanity tests
# 9.

function pre_install_sanity() {
    server_os = `uname -o`
    if [[ server_os ne 'GNU/Linux' ]]; then
        bail_out("You need to be running a Linux server")
    fi
    redhat_release = `cat /etc/redhat-release`
    if [[ redhat_release ne 'CentOS release 6.5 (Final)' ]]
        bail_out("You need to be running CentOS 6.5")
    fi
}

function install_elasticsearch () {
    curl -XGET https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.1.1.noarch.rpm > elasticsearch-1.1.1.noarch.rpm
    yum install java-1.7.0-openjdk.x86_64
    yum install gcc
    yum install gcc-c++
    yum install python-devel
    yum install postgresql-server
    yum install postgresql-devel
    yum install libffi-devel
    yum install openssl-devel
    yum install httpd
    yum install mod_wsgi
    rpm -Uhv elasticsearch-1.1.1.noarch.rpm
    chkconfig --add elasticsearch
    service elasticsearch start
}

function install_logstash() {
    curl -XGET https://download.elasticsearch.org/logstash/logstash/packages/centos/logstash-1.4.0-1_c82dc09.noarch.rpm > logstash-1.4.0-1_c82dc09.noarch.rpm
    rpm -Uhv logstash-1.4.0-1_c82dc09.noarch.rpm
    /opt/logstash/bin/plugin install contrib  # required for translate plugin
    cp goldstone/external/logstash/conf.d/* /etc/logstash/conf.d/
    cp goldstone/external/logstash/patterns/goldstone /opt/logstash/patterns/goldstone
    service logstash start
}

function install_pg() {
    yum install postgresql
    service postgresql initdb
    chkconfig postgresql on
    service postgresql start
    createuser goldstone -s -d
    psql -c "alter user goldstone password 'goldstone'"
}

function eth($line) {
    echo $line >> /etc/httpd/conf
}

function configure_goldstone() {
    eth("WSGIPythonPath /opt/goldstone:/opt/goldstone/lib/python2.6/site-packages")
    eth("<VirtualHost *:80>")
    eth("ServerAdmin you@example.com")
    h = `hostname`
    eth("ServerName ${h}")
    eth("WSGIScriptAlias / /opt/goldstone/goldstone/wsgi.py")
    eth("Alias /static/ /var/www/goldstone/static/")
    eth("Alias /favicon.ico /var/www/goldstone/static/images/favicon.ico")
    eth("<Location \"/static/\">")
    eth("    Options -Indexes")
    eth("</Location>")
    eth("</VirtualHost>")

    cp -r goldstone /opt/goldstone
    pip install -r requirements.txt
    mkdir -p /var/www/goldstone/static
    cd /opt/goldstone
    python manage.py collectstatic --settings=goldstone.settings.production
    service httpd restart
}


Added sym links for setup tools and buildout config files

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/paolodedios/dot-files.git/'


leaner install script

leaner install 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/rstiller/dockerfiles.git/'


Create install.sh

Create install.sh

Add apt update

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/JonthanLT/raspberrypi-hotspot-wifi.git/'


make sure to link this

make sure to link this

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 install.sh

Create install.sh

#!/bin/bash
#
# Script to install HMS program and set-up all requirements and dependencies
# Must be run as superuser with sudo
#
# IIT Kharagpur - Hall Management System
# System to manage Halls of residences, Warden grant requests, student complaints
# hall worker attendances and salary payments
#
# authors: Madhav Datt, Avikalp Srivastava
# MIT License
#

# Move kgp-hms to /etc
cd /etc
mkdir kgp-hms
mv ~/Downloads/kgp-hms/* /etc/kgp-hms
cd kgp-hms

# Grant execute permissions to shell scripts
chmod 755 setup_db.sh
./setup_db.sh
chmod 755 setup_lib.sh
./setup_lib.sh

# Add permanent aliases to run programs
cat aliases.txt >> ~/.bash_aliases
. ~/.bashrc

# Clean downloaded folders
rm -rf ~/Downloads/kgp-hms
rm ~/Downloads/kgp-hms-v1.0.zip

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


ALL TOGETHER NOW! :notes:

ALL TOGETHER NOW! :notes:

#!/bin/bash

. ./dependencies.sh
. ./software.sh
. ./place_files.sh

brew cleanup
brew doctor

echo
echo "DOTFILES: Complete."


Create half-finished installer

Create half-finished installer

#!/bin/bash
# Make sure you have wget and unzip installed!

# Fetch mod
wget https://github.com/hyperdriveguy/mtddos/archive/master.zip

# Unzip mod
unzip master.zip ~/.minetest/mods/mtddos

# Change to mod directory
cd ~/.minetest/mods/mtddos

# Make scripts executable
chmod 777 server_restart
chmod 777 server_shutdown

# Add scripts to /etc/sudoers.d
sudo printf "neohexane ALL=(ALL) NOPASSWD : \n" >> /etc/sudoers.d/mtddos


Add cron script

Add cron script

#!/bin/bash

CCVPN_PATH="$( cd "$( dirname "$0" )" && pwd )"
PATH="$HOME/.local/bin/:$PATH"

ccvpn_checkbtcorders $CCVPN_PATH/development.ini >> $CCVPN_PATH/cron_checkbtcorders.log 2>&1

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


Record which packages I install with "conda"

conda install astropy mock numpy sphinx pytz
pip install de405==1997.1 de423==2010.1
pip install -e .

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


[angular] Drop workaround for protractor waiting for angular alerts.

#!/bin/bash

set -e
source $(dirname $0)/00-init-env.sh

#-------------------------------------------------------------------------------
# Package UAA
#-------------------------------------------------------------------------------
if [[ "$JHI_APP" == *"uaa"* ]]; then
    cd "$JHI_FOLDER_UAA"
    ./mvnw -ntp verify -DskipTests -Pdev --batch-mode
    mv target/*.jar app.jar
fi

cd "$JHI_FOLDER_APP"

#-------------------------------------------------------------------------------
# Package the application
#-------------------------------------------------------------------------------
if [ "$JHI_WAR" == 1 ]; then
    if [ -f "mvnw" ]; then
        ./mvnw -ntp verify -DskipTests -P"$JHI_PROFILE",war --batch-mode
        mv target/*.war app.war
    elif [ -f "gradlew" ]; then
        ./gradlew bootWar -P"$JHI_PROFILE" -Pwar -x test
        mv build/libs/*SNAPSHOT.war app.war
    else
        echo "*** no mvnw or gradlew"
        exit 0
    fi
    if [ $? -ne 0 ]; then
        echo "*** error when packaging"
        exit 1
    fi
else
    if [ -f "mvnw" ]; then
        ./mvnw -ntp verify -DskipTests -P"$JHI_PROFILE" --batch-mode
        mv target/*.jar app.jar
    elif [ -f "gradlew" ]; then
        ./gradlew bootJar -P"$JHI_PROFILE" -x test
        mv build/libs/*SNAPSHOT.jar app.jar
    else
        echo "*** no mvnw or gradlew"
        exit 0
    fi
    if [ $? -ne 0 ]; then
        echo "*** error when packaging"
        exit 1
    fi
fi

#!/bin/bash

set -e
source $(dirname $0)/00-init-env.sh

#-------------------------------------------------------------------------------
# Package UAA
#-------------------------------------------------------------------------------
if [[ "$JHI_APP" == *"uaa"* ]]; then
    cd "$JHI_FOLDER_UAA"
    ./mvnw -ntp verify -DskipTests -Pdev --batch-mode
    mv target/*.jar app.jar
fi

#-------------------------------------------------------------------------------
# Decrease Angular timeout for Protractor tests
#-------------------------------------------------------------------------------
cd "$JHI_FOLDER_APP"
if [ "$JHI_PROTRACTOR" == 1 ] && [ -e "src/main/webapp/app/core/core.module.ts" ]; then
    sed -e 's/alertTimeout: 5000/alertTimeout: 1/1;' src/main/webapp/app/core/core.module.ts > src/main/webapp/app/core/core.module.ts.sed
    mv -f src/main/webapp/app/core/core.module.ts.sed src/main/webapp/app/core/core.module.ts
    cat src/main/webapp/app/core/core.module.ts | grep alertTimeout
fi

#-------------------------------------------------------------------------------
# Package the application
#-------------------------------------------------------------------------------
if [ "$JHI_WAR" == 1 ]; then
    if [ -f "mvnw" ]; then
        ./mvnw -ntp verify -DskipTests -P"$JHI_PROFILE",war --batch-mode
        mv target/*.war app.war
    elif [ -f "gradlew" ]; then
        ./gradlew bootWar -P"$JHI_PROFILE" -Pwar -x test
        mv build/libs/*SNAPSHOT.war app.war
    else
        echo "*** no mvnw or gradlew"
        exit 0
    fi
    if [ $? -ne 0 ]; then
        echo "*** error when packaging"
        exit 1
    fi
else
    if [ -f "mvnw" ]; then
        ./mvnw -ntp verify -DskipTests -P"$JHI_PROFILE" --batch-mode
        mv target/*.jar app.jar
    elif [ -f "gradlew" ]; then
        ./gradlew bootJar -P"$JHI_PROFILE" -x test
        mv build/libs/*SNAPSHOT.jar app.jar
    else
        echo "*** no mvnw or gradlew"
        exit 0
    fi
    if [ $? -ne 0 ]; then
        echo "*** error when packaging"
        exit 1
    fi
fi


useful enough to be included

useful enough to be included

#!/bin/bash
cmake --build build/ --config Release

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


[CI] Add python linter to check for utf8 ascii encoding

#!/usr/bin/env bash
#
# Copyright (c) 2018-2019 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Make sure we explicitly open all text files using UTF-8 (or ASCII) encoding to
# avoid potential issues on the BSDs where the locale is not always set.

export LC_ALL=C
EXIT_CODE=0
OUTPUT=$(git grep " open(" -- "*.py" ":(exclude)src/crc32c/" | grep -vE "encoding=.(ascii|utf8|utf-8)." | grep -vE "open\([^,]*, ['\"][^'\"]*b[^'\"]*['\"]")
if [[ ${OUTPUT} != "" ]]; then
    echo "Python's open(...) seems to be used to open text files without explicitly"
    echo "specifying encoding=\"utf8\":"
    echo
    echo "${OUTPUT}"
    EXIT_CODE=1
fi
OUTPUT=$(git grep "check_output(" -- "*.py" ":(exclude)src/crc32c/"| grep "universal_newlines=True" | grep -vE "encoding=.(ascii|utf8|utf-8).")
if [[ ${OUTPUT} != "" ]]; then
    echo "Python's check_output(...) seems to be used to get program outputs without explicitly"
    echo "specifying encoding=\"utf8\":"
    echo
    echo "${OUTPUT}"
    EXIT_CODE=1
fi
exit ${EXIT_CODE}

error: pathspec 'test/lint/lint-python-utf8-encoding.sh' did not match any file(s) known to git


unit tests for err

unit tests for err

#!./tester
#
include err
include assert

testcase_begin "$@"
test_err_str() {
	assertOutput "No error" err_str 0
	assertOutput "Operation not permitted" err_str 1
}
test_err_str_returns_err_INVAL_if_unknown_error_code_is_passed() {
	err_str 256
	assertEquals "$err_INVAL" $?
}
test_err_str_returns_err_INVAL_if_negative_error_code_is_passed() {
	err_str -1
	assertEquals "$err_INVAL" $?
}
test_err_str_returns_err_INVAL_if_non_integral_is_passed() {
	err_str a
	assertEquals "$err_INVAL" $?
}
testcase_end "$@"

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


Changed Service Principal Creation sequence to comply with newer CLI reqs

#!/usr/bin/env bash
set -e

meta_name=
azure_client_id=       # Derived from application after creation
azure_client_name=     # Application name
azure_client_secret=   # Application password
azure_group_name=
azure_storage_name=
azure_subscription_id= # Derived from the account after login
azure_tenant_id=       # Derived from the account after login
location=
azure_object_id=
azureversion=

showhelp() {
	echo "azure-setup"
	echo ""
	echo "  azure-setup helps you generate packer credentials for Azure"
	echo ""
	echo "  The script creates a resource group, storage account, application"
	echo "  (client), service principal, and permissions and displays a snippet"
	echo "  for use in your packer templates."
	echo ""
	echo "  For simplicity we make a lot of assumptions and choose reasonable"
	echo "  defaults. If you want more control over what happens, please use"
	echo "  the azure-cli directly."
	echo ""
	echo "  Note that you must already have an Azure account, username,"
	echo "  password, and subscription. You can create those here:"
	echo ""
	echo "  - https://account.windowsazure.com/"
	echo ""
	echo "REQUIREMENTS"
	echo ""
	echo "  - azure-cli"
	echo "  - jq"
	echo ""
	echo "  Use the requirements command (below) for more info."
	echo ""
	echo "USAGE"
	echo ""
	echo "  ./azure-setup.sh requirements"
	echo "  ./azure-setup.sh setup"
	echo ""
}

requirements() {
	found=0

	azureversion=$(azure -v)
	if [ $? -eq 0 ]; then
		found=$((found + 1))
		echo "Found azure-cli version: $azureversion"
	else
		echo "azure-cli is missing. Please install azure-cli from"
		echo "https://azure.microsoft.com/en-us/documentation/articles/xplat-cli-install/"
	fi

	jqversion=$(jq --version)
	if [ $? -eq 0 ]; then
		found=$((found + 1))
		echo "Found jq version: $jqversion"
	else
		echo "jq is missing. Please install jq from"
		echo "https://stedolan.github.io/jq/"
	fi

	if [ $found -lt 2 ]; then
		exit 1
	fi
}

askSubscription() {
	azure account list
	echo ""
	echo "Please enter the Id of the account you wish to use. If you do not see"
	echo "a valid account in the list press Ctrl+C to abort and create one."
	echo "If you leave this blank we will use the Current account."
	echo -n "> "
	read azure_subscription_id
	if [ "$azure_subscription_id" != "" ]; then
		azure account set $azure_subscription_id
	else
		azure_subscription_id=$(azure account show --json | jq -r .[].id)
	fi
	azure_tenant_id=$(azure account show --json | jq -r .[].tenantId)
	echo "Using subscription_id: $azure_subscription_id"
	echo "Using tenant_id: $azure_tenant_id"
}

askName() {
	echo ""
	echo "Choose a name for your resource group, storage account and client"
	echo "client. This is arbitrary, but it must not already be in use by"
	echo "any of those resources. ALPHANUMERIC ONLY. Ex: mypackerbuild"
	echo -n "> "
	read meta_name
}

askSecret() {
	echo ""
	echo "Enter a secret for your application. We recommend generating one with"
	echo "openssl rand -base64 24. If you leave this blank we will attempt to"
	echo "generate one for you using openssl. THIS WILL BE SHOWN IN PLAINTEXT."
	echo "Ex: mypackersecret8734"
	echo -n "> "
	read azure_client_secret
	if [ "$azure_client_secret" = "" ]; then
		azure_client_secret=$(openssl rand -base64 24)
		if [ $? -ne 0 ]; then
			echo "Error generating secret"
			exit 1
		fi
		echo "Generated client_secret: $azure_client_secret"
	fi
}

askLocation() {
	azure location list
	echo ""
	echo "Choose which region your resource group and storage account will be created."
	echo -n "> "
	read location
}

createResourceGroup() {
	echo "==> Creating resource group"
	azure group create -n $meta_name -l $location
	if [ $? -eq 0 ]; then
		azure_group_name=$meta_name
	else
		echo "Error creating resource group: $meta_name"
		exit 1
	fi
}

createStorageAccount() {
	echo "==> Creating storage account"
	azure storage account create -g $meta_name -l $location --sku-name LRS --kind Storage $meta_name
	if [ $? -eq 0 ]; then
		azure_storage_name=$meta_name
	else
		echo "Error creating storage account: $meta_name"
		exit 1
	fi
}

createApplication() {
	echo "==> Creating application"
	azure_client_id=$(azure ad app create -n $meta_name -i http://$meta_name --home-page http://$meta_name -p $azure_client_secret --json | jq -r .appId)
	if [ $? -ne 0 ]; then
		echo "Error creating application: $meta_name @ http://$meta_name"
		exit 1
	fi
}

createServicePrincipal() {
	echo "==> Creating service principal"
	# Azure CLI 0.10.2 introduced a breaking change, where appId must be supplied with the -a switch
	# prior version accepted appId as the only parameter without a switch
	newer_syntax=false
	IFS='.' read -ra azureversionsemver <<< "$azureversion"
	if [ ${azureversionsemver[0]} -ge 0 ] && [ ${azureversionsemver[1]} -ge 10 ] && [ ${azureversionsemver[2]} -ge 2 ]; then
		newer_syntax=true
	fi

	if [ "${newer_syntax}" = true ]; then
		azure_object_id=$(azure ad sp create -a $azure_client_id | jq -r .objectId)
	else
		azure_object_id=$(azure ad sp create $azure_client_id | jq -r .objectId)
	fi

	if [ $? -ne 0 ]; then
		echo "Error creating service principal: $azure_client_id"
		exit 1
	fi
}

createPermissions() {
	echo "==> Creating permissions"
	azure role assignment create --objectId $azure_object_id -o "Owner" -c /subscriptions/$azure_subscription_id
	# We want to use this more conservative scope but it does not work with the
	# current implementation which uses temporary resource groups
	# azure role assignment create --spn http://$meta_name -g $azure_group_name -o "API Management Service Contributor"
	if [ $? -ne 0 ]; then
		echo "Error creating permissions for: http://$meta_name"
		exit 1
	fi
}

showConfigs() {
	echo ""
	echo "Use the following configuration for your packer template:"
	echo ""
	echo "{"
	echo "      \"client_id\": \"$azure_client_id\","
	echo "      \"client_secret\": \"$azure_client_secret\","
	echo "      \"object_id\": \"$azure_object_id\","
	echo "      \"subscription_id\": \"$azure_subscription_id\","
	echo "      \"tenant_id\": \"$azure_tenant_id\","
	echo "      \"resource_group_name\": \"$azure_group_name\","
	echo "      \"storage_account\": \"$azure_storage_name\","
	echo "}"
	echo ""
}

setup() {
	requirements

	azure config mode arm
	azure login

	askSubscription
	askName
	askSecret
	askLocation

	# Some of the resources take a while to converge in the API. To make the
	# script more reliable we'll add a sleep after we create each resource.

	createResourceGroup
	sleep 5
	createStorageAccount
	sleep 5
	createApplication
	sleep 5
	createServicePrincipal
	sleep 5
	createPermissions

	showConfigs
}

case "$1" in
	requirements)
		requirements
		;;
	setup)
		setup
		;;
	*)
		showhelp
		;;
esac

#!/usr/bin/env bash
set -e

meta_name=
azure_client_id=       # Derived from application after creation
azure_client_name=     # Application name
azure_client_secret=   # Application password
azure_group_name=
azure_storage_name=
azure_subscription_id= # Derived from the account after login
azure_tenant_id=       # Derived from the account after login
location=
azure_object_id=
azureversion=

showhelp() {
	echo "azure-setup"
	echo ""
	echo "  azure-setup helps you generate packer credentials for Azure"
	echo ""
	echo "  The script creates a resource group, storage account, application"
	echo "  (client), service principal, and permissions and displays a snippet"
	echo "  for use in your packer templates."
	echo ""
	echo "  For simplicity we make a lot of assumptions and choose reasonable"
	echo "  defaults. If you want more control over what happens, please use"
	echo "  the azure-cli directly."
	echo ""
	echo "  Note that you must already have an Azure account, username,"
	echo "  password, and subscription. You can create those here:"
	echo ""
	echo "  - https://account.windowsazure.com/"
	echo ""
	echo "REQUIREMENTS"
	echo ""
	echo "  - azure-cli"
	echo "  - jq"
	echo ""
	echo "  Use the requirements command (below) for more info."
	echo ""
	echo "USAGE"
	echo ""
	echo "  ./azure-setup.sh requirements"
	echo "  ./azure-setup.sh setup"
	echo ""
}

requirements() {
	found=0

	azureversion=$(azure -v)
	if [ $? -eq 0 ]; then
		found=$((found + 1))
		echo "Found azure-cli version: $azureversion"
	else
		echo "azure-cli is missing. Please install azure-cli from"
		echo "https://azure.microsoft.com/en-us/documentation/articles/xplat-cli-install/"
	fi

	jqversion=$(jq --version)
	if [ $? -eq 0 ]; then
		found=$((found + 1))
		echo "Found jq version: $jqversion"
	else
		echo "jq is missing. Please install jq from"
		echo "https://stedolan.github.io/jq/"
	fi

	if [ $found -lt 2 ]; then
		exit 1
	fi
}

askSubscription() {
	azure account list
	echo ""
	echo "Please enter the Id of the account you wish to use. If you do not see"
	echo "a valid account in the list press Ctrl+C to abort and create one."
	echo "If you leave this blank we will use the Current account."
	echo -n "> "
	read azure_subscription_id
	if [ "$azure_subscription_id" != "" ]; then
		azure account set $azure_subscription_id
	else
		azure_subscription_id=$(azure account show --json | jq -r .[].id)
	fi
	azure_tenant_id=$(azure account show --json | jq -r .[].tenantId)
	echo "Using subscription_id: $azure_subscription_id"
	echo "Using tenant_id: $azure_tenant_id"
}

askName() {
	echo ""
	echo "Choose a name for your resource group, storage account and client"
	echo "client. This is arbitrary, but it must not already be in use by"
	echo "any of those resources. ALPHANUMERIC ONLY. Ex: mypackerbuild"
	echo -n "> "
	read meta_name
}

askSecret() {
	echo ""
	echo "Enter a secret for your application. We recommend generating one with"
	echo "openssl rand -base64 24. If you leave this blank we will attempt to"
	echo "generate one for you using openssl. THIS WILL BE SHOWN IN PLAINTEXT."
	echo "Ex: mypackersecret8734"
	echo -n "> "
	read azure_client_secret
	if [ "$azure_client_secret" = "" ]; then
		azure_client_secret=$(openssl rand -base64 24)
		if [ $? -ne 0 ]; then
			echo "Error generating secret"
			exit 1
		fi
		echo "Generated client_secret: $azure_client_secret"
	fi
}

askLocation() {
	azure location list
	echo ""
	echo "Choose which region your resource group and storage account will be created."
	echo -n "> "
	read location
}

createResourceGroup() {
	echo "==> Creating resource group"
	azure group create -n $meta_name -l $location
	if [ $? -eq 0 ]; then
		azure_group_name=$meta_name
	else
		echo "Error creating resource group: $meta_name"
		exit 1
	fi
}

createStorageAccount() {
	echo "==> Creating storage account"
	azure storage account create -g $meta_name -l $location --sku-name LRS --kind Storage $meta_name
	if [ $? -eq 0 ]; then
		azure_storage_name=$meta_name
	else
		echo "Error creating storage account: $meta_name"
		exit 1
	fi
}

createApplication() {
	echo "==> Creating application"
	azure_client_id=$(azure ad app create -n $meta_name -i http://$meta_name --home-page http://$meta_name -p $azure_client_secret --json | jq -r .appId)
	if [ $? -ne 0 ]; then
		echo "Error creating application: $meta_name @ http://$meta_name"
		exit 1
	fi
}

createServicePrincipal() {
	echo "==> Creating service principal"
	# Azure CLI 0.10.2 introduced a breaking change, where appId must be supplied with the -a switch
	# prior version accepted appId as the only parameter without a switch
	newer_syntax=false
	IFS='.' read -ra azureversionsemver <<< "$azureversion"
	if [ ${azureversionsemver[0]} -ge 0 ] && [ ${azureversionsemver[1]} -ge 10 ] && [ ${azureversionsemver[2]} -ge 2 ]; then
		newer_syntax=true
	fi

	if [ "${newer_syntax}" = true ]; then
		azure ad sp create -a $azure_client_id
	else
		azure ad sp create $azure_client_id
	fi

	if [ $? -ne 0 ]; then
		echo "Error creating service principal: $azure_client_id"
		exit 1
	fi
}

createPermissions() {
	echo "==> Creating permissions"
	azure role assignment create --objectId $azure_object_id -o "Owner" -c /subscriptions/$azure_subscription_id
	# We want to use this more conservative scope but it does not work with the
	# current implementation which uses temporary resource groups
	# azure role assignment create --spn http://$meta_name -g $azure_group_name -o "API Management Service Contributor"
	if [ $? -ne 0 ]; then
		echo "Error creating permissions for: http://$meta_name"
		exit 1
	fi
}

showConfigs() {
	echo ""
	echo "Use the following configuration for your packer template:"
	echo ""
	echo "{"
	echo "      \"client_id\": \"$azure_client_id\","
	echo "      \"client_secret\": \"$azure_client_secret\","
	echo "      \"object_id\": \"$azure_object_id\","
	echo "      \"subscription_id\": \"$azure_subscription_id\","
	echo "      \"tenant_id\": \"$azure_tenant_id\","
	echo "      \"resource_group_name\": \"$azure_group_name\","
	echo "      \"storage_account\": \"$azure_storage_name\","
	echo "}"
	echo ""
}

setup() {
	requirements

	azure config mode arm
	azure login

	askSubscription
	askName
	askSecret
	askLocation

	# Some of the resources take a while to converge in the API. To make the
	# script more reliable we'll add a sleep after we create each resource.

	createResourceGroup
	sleep 5
	createStorageAccount
	sleep 5
	createApplication
	sleep 5
	createServicePrincipal
	sleep 5
	createPermissions

	showConfigs
}

case "$1" in
	requirements)
		requirements
		;;
	setup)
		setup
		;;
	*)
		showhelp
		;;
esac


removed mp4box

removed mp4box

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


lowercase comments

lowercase comments


Automating mysql database creation for builds

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/ciandt-dev/docker-jenkins-aws.git/'


Missed the actual file...

Missed the actual file...

#!/bin/sh
# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
if [true != "$INIT_D_SCRIPT_SOURCED" ] ; then
    set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
fi
### BEGIN INIT INFO
# Provides:             baby-connect-sqs-listener
# Required-Start:       $remote_fs $syslog
# Required-Stop:        $remote_fs $syslog
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    Baby Connect SQS message queue listener
# Description:          A Node.js listener that reads messages from an AWS SQS
#                       message queue and uses them to load data into the Baby
#                       Connect service.
### END INIT INFO

# Author: Adam Platt <adam@plattsoft.net>

do_start () {
    # Start Xvfb
    Xvfb -ac -screen scrn 1280x1024x24 :9.0 &

    # Start listener
    node /usr/local/baby-connect-sqs-listener/index &

    # Record listener PID
    echo $! > /tmp/.baby-connect-sqs-listener
}

do_stop () {
    # Stop listener
    if [ -f /tmp/.baby-connect-sqs-listener ] ; then
        kill -9 `cat /tmp/.baby-connect-sqs-listener`
        rm /tmp/.baby-connect-sqs-listener
    fi

    # Stop xvfb
    if [ -f /tmp/.X9-lock ] ; then
        kill -9 `cat /tmp/.X9-lock`
        rm /tmp/.X9-lock
    fi
}

do_status () {
    # Check xvfb and listener
    if [ (-f /tmp/.baby-connect-sqs-listener) -a (-f /tmp/.X9-lock) ] ; then
        return 4
    else
        return 0
    fi
}

case "$1" in
    start|"")
        do_start
        ;;
    restart)
        do_stop
        do_start
        ;;
    stop)
        do_stop
        ;;
    status)
        do_status
        exit $?
        ;;
    *)
        echo "Usage: baby-connect-sqs-listener [start|stop|restart|status]" >&2
        exit 3
        ;;
esac

error: pathspec 'daemon/baby-connect-sqs-listener.sh' did not match any file(s) known to git


build: add build and run bash script

build: add build and run bash script

# Start database service
sudo service postgresql start

# Build client app
npm run build:prod-sw --prefix front

# Build server app
npm run build:prod --prefix back

if [ $? -eq 0 ]; then
  echo "=== Build process has been completed successfully ===\nbundle-size: $(du -sh builds/word-kombat-lin)"
  # Run the app
  ./builds/word-kombat-lin
else
  echo "=== Build failed ==="
fi

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


moving all the variables together

moving all the variables together

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


Add initial local envirnoment bash script

#!/bin/bash
clear

echo "Setting up local environment for ClaremontReview\n"

echo "Installing all needed gems"
bundle install

echo "Starting up elasticsearch service"
sudo service elasticsearch restart

echo "Setting up local database"
rake db:reset
rake db:migrate
rake task:importjson
rake task:slug
rake searchkick:reindex CLASS=Course

echo "Running local server on localhost"
rails s -b 0.0.0.0

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


Add high-level tests for build command

Add high-level tests for build command

#!/usr/bin/env bats

load '/usr/local/lib/bats/load.bash'
load '../lib/shared'
load '../lib/run'

@test "Run a build without a repository" {
  export BUILDKITE_JOB_ID=1111
  export BUILDKITE_PLUGIN_DOCKER_COMPOSE_BUILD=myservice
  export BUILDKITE_PIPELINE_SLUG=test
  export BUILDKITE_BUILD_NUMBER=1

  export DOCKER_COMPOSE_STUB_DEBUG=/dev/stdout

  stub docker-compose \
    "-f docker-compose.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml build myservice : echo built myservice"

  run $PWD/hooks/command

  unstub docker-compose
  assert_success
  assert_output --partial "built myservice"
}

@test "Run a build with a repository" {
  export BUILDKITE_JOB_ID=1111
  export BUILDKITE_PLUGIN_DOCKER_COMPOSE_BUILD=myservice
  export BUILDKITE_PLUGIN_DOCKER_COMPOSE_IMAGE_REPOSITORY=my.repository/llamas
  export BUILDKITE_PIPELINE_SLUG=test
  export BUILDKITE_BUILD_NUMBER=1

  stub docker-compose \
    "-f docker-compose.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml build myservice : echo built myservice" \
    "-f docker-compose.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml push myservice : echo pushed myservice" \

  stub buildkite-agent \
    "meta-data set docker-compose-plugin-built-image-tag-myservice my.repository/llamas:test-myservice-build-1 : echo set metadata"

  run $PWD/hooks/command

  unstub docker-compose
  unstub buildkite-agent
  assert_success
  assert_output --partial "built myservice"
  assert_output --partial "pushed myservice"
  assert_output --partial "set metadata"
}

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


Fix test for libudev1

Fix test for libudev1

The test for libudev1/libudev0 fails when an sdk has installed
a dependency on libudev1, which will go away on recompile, on
a system with only libudev0.  The dependency created an empty
virtual package that passes the "show" test, but cannot be installed.

BUG=243398
TEST=local

Review URL: https://chromiumcodereview.appspot.com/15911004

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@202021 0039d316-1c4b-4281-b951-d872f2087c98

#!/bin/bash -e

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

# Script to install everything needed to build chromium (well, ideally, anyway)
# See http://code.google.com/p/chromium/wiki/LinuxBuildInstructions
# and http://code.google.com/p/chromium/wiki/LinuxBuild64Bit

usage() {
  echo "Usage: $0 [--options]"
  echo "Options:"
  echo "--[no-]syms: enable or disable installation of debugging symbols"
  echo "--[no-]lib32: enable or disable installation of 32 bit libraries"
  echo "--[no-]arm: enable or disable installation of arm cross toolchain"
  echo "--[no-]chromeos-fonts: enable or disable installation of Chrome OS"\
       "fonts"
  echo "--no-prompt: silently select standard options/defaults"
  echo "Script will prompt interactively if options not given."
  exit 1
}

while test "$1" != ""
do
  case "$1" in
  --syms)                   do_inst_syms=1;;
  --no-syms)                do_inst_syms=0;;
  --lib32)                  do_inst_lib32=1;;
  --no-lib32)               do_inst_lib32=0;;
  --arm)                    do_inst_arm=1;;
  --no-arm)                 do_inst_arm=0;;
  --chromeos-fonts)         do_inst_chromeos_fonts=1;;
  --no-chromeos-fonts)      do_inst_chromeos_fonts=0;;
  --no-prompt)              do_default=1
                            do_quietly="-qq --assume-yes"
    ;;
  --unsupported)            do_unsupported=1;;
  *) usage;;
  esac
  shift
done

ubuntu_versions="10\.04|10\.10|11\.04|11\.10|12\.04|12\.10|13\.04"
ubuntu_codenames="lucid|maverick|natty|oneiric|precise|quantal|raring"
ubuntu_issue="Ubuntu ($ubuntu_versions|$ubuntu_codenames)"
# GCEL is an Ubuntu-derived VM image used on Google Compute Engine; /etc/issue
# doesn't contain a version number so just trust that the user knows what
# they're doing.
gcel_issue="^GCEL"

if [ 0 -eq "${do_unsupported-0}" ] ; then
  if ! egrep -q "($ubuntu_issue|$gcel_issue)" /etc/issue; then
    echo "ERROR: Only Ubuntu 10.04 (lucid) through 13.04 (raring) are"\
        "currently supported" >&2
    exit 1
  fi

  if ! uname -m | egrep -q "i686|x86_64"; then
    echo "Only x86 architectures are currently supported" >&2
    exit
  fi
fi

if [ "x$(id -u)" != x0 ]; then
  echo "Running as non-root user."
  echo "You might have to enter your password one or more times for 'sudo'."
  echo
fi

# Packages needed for chromeos only
chromeos_dev_list="libbluetooth-dev"

# Packages need for development
dev_list="apache2.2-bin bison curl elfutils fakeroot flex g++ gperf
          language-pack-fr libapache2-mod-php5 libasound2-dev libbz2-dev
          libcairo2-dev libcups2-dev libcurl4-gnutls-dev libelf-dev
          libgconf2-dev libgl1-mesa-dev libglib2.0-dev libglu1-mesa-dev
          libgnome-keyring-dev libgtk2.0-dev libkrb5-dev libnspr4-dev
          libnss3-dev libpam0g-dev libpci-dev libpulse-dev libsctp-dev
          libspeechd-dev libsqlite3-dev libssl-dev libudev-dev libwww-perl
          libxslt1-dev libxss-dev libxt-dev libxtst-dev mesa-common-dev
          metacity patch perl php5-cgi pkg-config python python-cherrypy3
          python-dev python-psutil rpm ruby subversion ttf-dejavu-core
          ttf-indic-fonts ttf-kochi-gothic ttf-kochi-mincho ttf-thai-tlwg
          wdiff git-core
          $chromeos_dev_list"

# 64-bit systems need a minimum set of 32-bit compat packages for the pre-built
# NaCl binaries. These are always needed, regardless of whether or not we want
# the full 32-bit "cross-compile" support (--lib32).
if [ "$(uname -m)" = "x86_64" ]; then
  dev_list="${dev_list} libc6-i386 lib32gcc1 lib32stdc++6"
fi

# Run-time libraries required by chromeos only
chromeos_lib_list="libpulse0 libbz2-1.0 libcurl4-gnutls-dev"

# Full list of required run-time libraries
lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libcups2 libexpat1
          libfontconfig1 libfreetype6 libglib2.0-0 libgnome-keyring0
          libgtk2.0-0 libpam0g libpango1.0-0 libpci3 libpcre3 libpixman-1-0
          libpng12-0 libspeechd2 libstdc++6 libsqlite3-0 libx11-6
          libxau6 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6
          libxext6 libxfixes3 libxi6 libxinerama1 libxrandr2 libxrender1
          libxtst6 zlib1g $chromeos_lib_list"

# Debugging symbols for all of the run-time libraries
dbg_list="libatk1.0-dbg libc6-dbg libcairo2-dbg libfontconfig1-dbg
          libglib2.0-0-dbg libgtk2.0-0-dbg libpango1.0-0-dbg libpcre3-dbg
          libpixman-1-0-dbg libsqlite3-0-dbg libx11-6-dbg libxau6-dbg
          libxcb1-dbg libxcomposite1-dbg libxcursor1-dbg libxdamage1-dbg
          libxdmcp6-dbg libxext6-dbg libxfixes3-dbg libxi6-dbg libxinerama1-dbg
          libxrandr2-dbg libxrender1-dbg libxtst6-dbg zlib1g-dbg"

# arm cross toolchain packages needed to build chrome on arm
arm_list="libc6-armel-cross libc6-dev-armel-cross libgcc1-armel-cross
          libgomp1-armel-cross linux-libc-dev-armel-cross
          libgcc1-dbg-armel-cross libgomp1-dbg-armel-cross
          binutils-arm-linux-gnueabi cpp-arm-linux-gnueabi
          gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
          libmudflap0-dbg-armel-cross"

# Some package names have changed over time
if apt-cache show ttf-mscorefonts-installer >/dev/null 2>&1; then
  dev_list="${dev_list} ttf-mscorefonts-installer"
else
  dev_list="${dev_list} msttcorefonts"
fi
if apt-cache show libnspr4-dbg >/dev/null 2>&1; then
  dbg_list="${dbg_list} libnspr4-dbg libnss3-dbg"
  lib_list="${lib_list} libnspr4 libnss3"
else
  dbg_list="${dbg_list} libnspr4-0d-dbg libnss3-1d-dbg"
  lib_list="${lib_list} libnspr4-0d libnss3-1d"
fi
if apt-cache show libjpeg-dev >/dev/null 2>&1; then
  dev_list="${dev_list} libjpeg-dev"
else
  dev_list="${dev_list} libjpeg62-dev"
fi
if [ "$(apt-cache pkgnames libudev1 2>&1)" == "libudev1" ] ; then
  dev_list="${dev_list} libudev1"
else
  dev_list="${dev_list} libudev0"
fi

# Some packages are only needed, if the distribution actually supports
# installing them.
if apt-cache show appmenu-gtk >/dev/null 2>&1; then
  lib_list="$lib_list appmenu-gtk"
fi

# Waits for the user to press 'Y' or 'N'. Either uppercase of lowercase is
# accepted. Returns 0 for 'Y' and 1 for 'N'. If an optional parameter has
# been provided to yes_no(), the function also accepts RETURN as a user input.
# The parameter specifies the exit code that should be returned in that case.
# The function will echo the user's selection followed by a newline character.
# Users can abort the function by pressing CTRL-C. This will call "exit 1".
yes_no() {
  if [ 0 -ne "${do_default-0}" ] ; then
    return $1
  fi
  local c
  while :; do
    c="$(trap 'stty echo -iuclc icanon 2>/dev/null' EXIT INT TERM QUIT
         stty -echo iuclc -icanon 2>/dev/null
         dd count=1 bs=1 2>/dev/null | od -An -tx1)"
    case "$c" in
      " 0a") if [ -n "$1" ]; then
               [ $1 -eq 0 ] && echo "Y" || echo "N"
               return $1
             fi
             ;;
      " 79") echo "Y"
             return 0
             ;;
      " 6e") echo "N"
             return 1
             ;;
      "")    echo "Aborted" >&2
             exit 1
             ;;
      *)     # The user pressed an unrecognized key. As we are not echoing
             # any incorrect user input, alert the user by ringing the bell.
             (tput bel) 2>/dev/null
             ;;
    esac
  done
}

if test "$do_inst_syms" = ""
then
  echo "This script installs all tools and libraries needed to build Chromium."
  echo ""
  echo "For most of the libraries, it can also install debugging symbols, which"
  echo "will allow you to debug code in the system libraries. Most developers"
  echo "won't need these symbols."
  echo -n "Do you want me to install them for you (y/N) "
  if yes_no 1; then
    do_inst_syms=1
  fi
fi
if test "$do_inst_syms" = "1"; then
  echo "Installing debugging symbols."
else
  echo "Skipping installation of debugging symbols."
  dbg_list=
fi

# Install the Chrome OS default fonts.
if test "$do_inst_chromeos_fonts" != "0"; then
  echo
  echo "Installing Chrome OS fonts."
  dir=`echo $0 | sed -r -e 's/\/[^/]+$//'`
  if ! sudo $dir/linux/install-chromeos-fonts.py; then
    echo "ERROR: The installation of the Chrome OS default fonts failed."
    if [ `stat -f -c %T $dir` == "nfs" ]; then
      echo "The reason is that your repo is installed on a remote file system."
    else
      echo "This is expected if your repo is installed on a remote file system."
    fi
    echo "It is recommended to install your repo on a local file system."
    echo "You can skip the installation of the Chrome OS default founts with"
    echo "the command line option: --no-chromeos-fonts."
    exit 1
  fi
else
  echo "Skipping installation of Chrome OS fonts."
fi

# When cross building for arm on 64-bit systems the host binaries
# that are part of v8 need to be compiled with -m32 which means
# that basic multilib support is needed.
if [ "$(uname -m)" = "x86_64" ]; then
  arm_list="$arm_list g++-multilib"
fi

if test "$do_inst_arm" = "1"; then
  . /etc/lsb-release
  if test "$DISTRIB_CODENAME" != "precise"; then
    echo "ERROR: Installing the ARM cross toolchain is only available on" \
         "Ubuntu precise." >&2
    exit 1
  fi
  echo "Installing ARM cross toolchain."
else
  echo "Skipping installation of ARM cross toolchain."
  arm_list=
fi

sudo apt-get update

# We initially run "apt-get" with the --reinstall option and parse its output.
# This way, we can find all the packages that need to be newly installed
# without accidentally promoting any packages from "auto" to "manual".
# We then re-run "apt-get" with just the list of missing packages.
echo "Finding missing packages..."
packages="${dev_list} ${lib_list} ${dbg_list} ${arm_list}"
# Intentionally leaving $packages unquoted so it's more readable.
echo "Packages required: " $packages
echo
new_list_cmd="sudo apt-get install --reinstall $(echo $packages)"
if new_list="$(yes n | LANGUAGE=en LANG=C $new_list_cmd)"; then
  # We probably never hit this following line.
  echo "No missing packages, and the packages are up-to-date."
elif [ $? -eq 1 ]; then
  # We expect apt-get to have exit status of 1.
  # This indicates that we cancelled the install with "yes n|".
  new_list=$(echo "$new_list" |
    sed -e '1,/The following NEW packages will be installed:/d;s/^  //;t;d')
  new_list=$(echo "$new_list" | sed 's/ *$//')
  if [ -z "$new_list" ] ; then
    echo "No missing packages, and the packages are up-to-date."
  else
    echo "Installing missing packages: $new_list."
    sudo apt-get install ${do_quietly-} ${new_list}
  fi
  echo
else
  # An apt-get exit status of 100 indicates that a real error has occurred.

  # I am intentionally leaving out the '"'s around new_list_cmd,
  # as this makes it easier to cut and paste the output
  echo "The following command failed: " ${new_list_cmd}
  echo
  echo "It produces the following output:"
  yes n | $new_list_cmd || true
  echo
  echo "You will have to install the above packages yourself."
  echo
  exit 100
fi

# Install 32bit backwards compatibility support for 64bit systems
if [ "$(uname -m)" = "x86_64" ]; then
  if test "$do_inst_lib32" != "1"
  then
    echo "NOTE: If you were expecting the option to install 32bit libs,"
    echo "please run with the --lib32 flag."
    echo
    echo "Installation complete."
    exit 0
  else
    # This conditional statement has been added to deprecate and eventually
    # remove support for 32bit libraries on 64bit systems. But for the time
    # being, we still have to support a few legacy systems (e.g. bots), where
    # this feature is needed.
    # We only even give the user the option to install these libraries, if
    # they explicitly requested doing so by setting the --lib32 command line
    # flag.
    # And even then, we interactively ask them one more time whether they are
    # absolutely sure.
    # In order for that to work, we must reset the ${do_inst_lib32} variable.
    # There are other ways to achieve the same goal. But resetting the
    # variable is the best way to document the intended behavior -- and to
    # allow us to gradually deprecate and then remove the obsolete code.
    do_inst_lib32=
  fi

  echo "WARNING"
  echo
  echo "We no longer recommend that you use this script to install"
  echo "32bit libraries on a 64bit system. Instead, consider using the"
  echo "install-chroot.sh script to help you set up a 32bit environment"
  echo "for building and testing 32bit versions of Chrome."
  echo
  echo "The code for installing 32bit libraries on a 64bit system is"
  echo "unmaintained and might not work with modern versions of Ubuntu"
  echo "or Debian."
  echo
  echo -n "Are you sure you want to proceed (y/N) "
  if yes_no 1; then
    do_inst_lib32=1
  fi
  if test "$do_inst_lib32" != "1"
  then
    exit 0
  fi

  # Standard 32bit compatibility libraries
  echo "First, installing the limited existing 32-bit support..."
  cmp_list="ia32-libs lib32asound2-dev lib32stdc++6 lib32z1
            lib32z1-dev libc6-dev-i386 libc6-i386 g++-multilib"
  if [ -n "`apt-cache search lib32readline-gplv2-dev 2>/dev/null`" ]; then
    cmp_list="${cmp_list} lib32readline-gplv2-dev"
  else
    cmp_list="${cmp_list} lib32readline5-dev"
  fi
  sudo apt-get install ${do_quietly-} $cmp_list

  tmp=/tmp/install-32bit.$$
  trap 'rm -rf "${tmp}"' EXIT INT TERM QUIT
  mkdir -p "${tmp}/apt/lists/partial" "${tmp}/cache" "${tmp}/partial"
  touch "${tmp}/status"

  [ -r /etc/apt/apt.conf ] && cp /etc/apt/apt.conf "${tmp}/apt/"
  cat >>"${tmp}/apt/apt.conf" <<EOF
        Apt::Architecture "i386";
        Dir::Cache "${tmp}/cache";
        Dir::Cache::Archives "${tmp}/";
        Dir::State::Lists "${tmp}/apt/lists/";
        Dir::State::status "${tmp}/status";
EOF

  # Download 32bit packages
  echo "Computing list of available 32bit packages..."
  sudo apt-get -c="${tmp}/apt/apt.conf" update

  echo "Downloading available 32bit packages..."
  sudo apt-get -c="${tmp}/apt/apt.conf" \
          --yes --download-only --force-yes --reinstall install \
          ${lib_list} ${dbg_list}

  # Open packages, remove everything that is not a library, move the
  # library to a lib32 directory and package everything as a *.deb file.
  echo "Repackaging and installing 32bit packages for use on 64bit systems..."
  for i in ${lib_list} ${dbg_list}; do
    orig="$(echo "${tmp}/${i}"_*_i386.deb)"
    compat="$(echo "${orig}" |
              sed -e 's,\(_[^_/]*_\)i386\(.deb\),-ia32\1amd64\2,')"
    rm -rf "${tmp}/staging"
    msg="$(fakeroot -u sh -exc '
      # Unpack 32bit Debian archive
      umask 022
      mkdir -p "'"${tmp}"'/staging/dpkg/DEBIAN"
      cd "'"${tmp}"'/staging"
      ar x "'${orig}'"
      tar Cfx dpkg data.tar*
      tar zCfx dpkg/DEBIAN control.tar.gz

      # Create a posix extended regular expression fragment that will
      # recognize the includes which have changed. Should be rare,
      # will almost always be empty.
      includes=`sed -n -e "s/^[0-9a-z]*  //g" \
                       -e "\,usr/include/,p" dpkg/DEBIAN/md5sums |
                  xargs -n 1 -I FILE /bin/sh -c \
                    "cmp -s dpkg/FILE /FILE || echo FILE" |
                  tr "\n" "|" |
                  sed -e "s,|$,,"`

      # If empty, set it to not match anything.
      test -z "$includes" && includes="^//"

      # Turn the conflicts into an extended RE for removal from the
      # Provides line.
      conflicts=`sed -n -e "/Conflicts/s/Conflicts: *//;T;s/, */|/g;p" \
                   dpkg/DEBIAN/control`

      # Rename package, change architecture, remove conflicts and dependencies
      sed -r -i                              \
          -e "/Package/s/$/-ia32/"           \
          -e "/Architecture/s/:.*$/: amd64/" \
          -e "/Depends/s/:.*/: ia32-libs/"   \
          -e "/Provides/s/($conflicts)(, *)?//g;T1;s/, *$//;:1"   \
          -e "/Recommends/d"                 \
          -e "/Conflicts/d"                  \
        dpkg/DEBIAN/control

      # Only keep files that live in "lib" directories or the includes
      # that have changed.
      sed -r -i                                                               \
          -e "/\/lib64\//d" -e "/\/.?bin\//d"                                 \
          -e "\,$includes,s,[ /]include/,&32/,g;s,include/32/,include32/,g"   \
          -e "s, lib/, lib32/,g"                                              \
          -e "s,/lib/,/lib32/,g"                                              \
          -e "t;d"                                                            \
          -e "\,^/usr/lib32/debug\(.*/lib32\),s,^/usr/lib32/debug,/usr/lib/debug," \
        dpkg/DEBIAN/md5sums

      # Re-run ldconfig after installation/removal
      { echo "#!/bin/sh"; echo "[ \"x\$1\" = xconfigure ]&&ldconfig||:"; } \
        >dpkg/DEBIAN/postinst
      { echo "#!/bin/sh"; echo "[ \"x\$1\" = xremove ]&&ldconfig||:"; } \
        >dpkg/DEBIAN/postrm
      chmod 755 dpkg/DEBIAN/postinst dpkg/DEBIAN/postrm

      # Remove any other control files
      find dpkg/DEBIAN -mindepth 1 "(" -name control -o -name md5sums -o \
                       -name postinst -o -name postrm ")" -o -print |
        xargs -r rm -rf

      # Remove any files/dirs that live outside of "lib" directories,
      # or are not in our list of changed includes.
      find dpkg -mindepth 1 -regextype posix-extended \
          "(" -name DEBIAN -o -name lib -o -regex "dpkg/($includes)" ")" \
          -prune -o -print | tac |
        xargs -r -n 1 sh -c "rm \$0 2>/dev/null || rmdir \$0 2>/dev/null || : "
      find dpkg -name lib64 -o -name bin -o -name "?bin" |
        tac | xargs -r rm -rf

      # Remove any symbolic links that were broken by the above steps.
      find -L dpkg -type l -print | tac | xargs -r rm -rf

      # Rename lib to lib32, but keep debug symbols in /usr/lib/debug/usr/lib32
      # That is where gdb looks for them.
      find dpkg -type d -o -path "*/lib/*" -print |
        xargs -r -n 1 sh -c "
          i=\$(echo \"\${0}\" |
               sed -e s,/lib/,/lib32/,g \
               -e s,/usr/lib32/debug\\\\\(.*/lib32\\\\\),/usr/lib/debug\\\\1,);
          mkdir -p \"\${i%/*}\";
          mv \"\${0}\" \"\${i}\""

      # Rename include to include32.
      [ -d "dpkg/usr/include" ] && mv "dpkg/usr/include" "dpkg/usr/include32"

      # Prune any empty directories
      find dpkg -type d | tac | xargs -r -n 1 rmdir 2>/dev/null || :

      # Create our own Debian package
      cd ..
      dpkg --build staging/dpkg .' 2>&1)"
    compat="$(eval echo $(echo "${compat}" |
                          sed -e 's,_[^_/]*_amd64.deb,_*_amd64.deb,'))"
    [ -r "${compat}" ] || {
      echo "${msg}" >&2
      echo "Failed to build new Debian archive!" >&2
      exit 1
    }

    msg="$(sudo dpkg -i "${compat}" 2>&1)" && {
        echo "Installed ${compat##*/}"
      } || {
        # echo "${msg}" >&2
        echo "Skipped ${compat##*/}"
      }
  done

  # Add symbolic links for developing 32bit code
  echo "Adding missing symbolic links, enabling 32bit code development..."
  for i in $(find /lib32 /usr/lib32 -maxdepth 1 -name \*.so.\* |
             sed -e 's/[.]so[.][0-9].*/.so/' |
             sort -u); do
    [ "x${i##*/}" = "xld-linux.so" ] && continue
    [ -r "$i" ] && continue
    j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' |
         sort -n | tail -n 1)"
    [ -r "$i.$j" ] || continue
    sudo ln -s "${i##*/}.$j" "$i"
  done
fi

#!/bin/bash -e

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

# Script to install everything needed to build chromium (well, ideally, anyway)
# See http://code.google.com/p/chromium/wiki/LinuxBuildInstructions
# and http://code.google.com/p/chromium/wiki/LinuxBuild64Bit

usage() {
  echo "Usage: $0 [--options]"
  echo "Options:"
  echo "--[no-]syms: enable or disable installation of debugging symbols"
  echo "--[no-]lib32: enable or disable installation of 32 bit libraries"
  echo "--[no-]arm: enable or disable installation of arm cross toolchain"
  echo "--[no-]chromeos-fonts: enable or disable installation of Chrome OS"\
       "fonts"
  echo "--no-prompt: silently select standard options/defaults"
  echo "Script will prompt interactively if options not given."
  exit 1
}

while test "$1" != ""
do
  case "$1" in
  --syms)                   do_inst_syms=1;;
  --no-syms)                do_inst_syms=0;;
  --lib32)                  do_inst_lib32=1;;
  --no-lib32)               do_inst_lib32=0;;
  --arm)                    do_inst_arm=1;;
  --no-arm)                 do_inst_arm=0;;
  --chromeos-fonts)         do_inst_chromeos_fonts=1;;
  --no-chromeos-fonts)      do_inst_chromeos_fonts=0;;
  --no-prompt)              do_default=1
                            do_quietly="-qq --assume-yes"
    ;;
  --unsupported)            do_unsupported=1;;
  *) usage;;
  esac
  shift
done

ubuntu_versions="10\.04|10\.10|11\.04|11\.10|12\.04|12\.10|13\.04"
ubuntu_codenames="lucid|maverick|natty|oneiric|precise|quantal|raring"
ubuntu_issue="Ubuntu ($ubuntu_versions|$ubuntu_codenames)"
# GCEL is an Ubuntu-derived VM image used on Google Compute Engine; /etc/issue
# doesn't contain a version number so just trust that the user knows what
# they're doing.
gcel_issue="^GCEL"

if [ 0 -eq "${do_unsupported-0}" ] ; then
  if ! egrep -q "($ubuntu_issue|$gcel_issue)" /etc/issue; then
    echo "ERROR: Only Ubuntu 10.04 (lucid) through 13.04 (raring) are"\
        "currently supported" >&2
    exit 1
  fi

  if ! uname -m | egrep -q "i686|x86_64"; then
    echo "Only x86 architectures are currently supported" >&2
    exit
  fi
fi

if [ "x$(id -u)" != x0 ]; then
  echo "Running as non-root user."
  echo "You might have to enter your password one or more times for 'sudo'."
  echo
fi

# Packages needed for chromeos only
chromeos_dev_list="libbluetooth-dev"

# Packages need for development
dev_list="apache2.2-bin bison curl elfutils fakeroot flex g++ gperf
          language-pack-fr libapache2-mod-php5 libasound2-dev libbz2-dev
          libcairo2-dev libcups2-dev libcurl4-gnutls-dev libelf-dev
          libgconf2-dev libgl1-mesa-dev libglib2.0-dev libglu1-mesa-dev
          libgnome-keyring-dev libgtk2.0-dev libkrb5-dev libnspr4-dev
          libnss3-dev libpam0g-dev libpci-dev libpulse-dev libsctp-dev
          libspeechd-dev libsqlite3-dev libssl-dev libudev-dev libwww-perl
          libxslt1-dev libxss-dev libxt-dev libxtst-dev mesa-common-dev
          metacity patch perl php5-cgi pkg-config python python-cherrypy3
          python-dev python-psutil rpm ruby subversion ttf-dejavu-core
          ttf-indic-fonts ttf-kochi-gothic ttf-kochi-mincho ttf-thai-tlwg
          wdiff git-core
          $chromeos_dev_list"

# 64-bit systems need a minimum set of 32-bit compat packages for the pre-built
# NaCl binaries. These are always needed, regardless of whether or not we want
# the full 32-bit "cross-compile" support (--lib32).
if [ "$(uname -m)" = "x86_64" ]; then
  dev_list="${dev_list} libc6-i386 lib32gcc1 lib32stdc++6"
fi

# Run-time libraries required by chromeos only
chromeos_lib_list="libpulse0 libbz2-1.0 libcurl4-gnutls-dev"

# Full list of required run-time libraries
lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libcups2 libexpat1
          libfontconfig1 libfreetype6 libglib2.0-0 libgnome-keyring0
          libgtk2.0-0 libpam0g libpango1.0-0 libpci3 libpcre3 libpixman-1-0
          libpng12-0 libspeechd2 libstdc++6 libsqlite3-0 libx11-6
          libxau6 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6
          libxext6 libxfixes3 libxi6 libxinerama1 libxrandr2 libxrender1
          libxtst6 zlib1g $chromeos_lib_list"

# Debugging symbols for all of the run-time libraries
dbg_list="libatk1.0-dbg libc6-dbg libcairo2-dbg libfontconfig1-dbg
          libglib2.0-0-dbg libgtk2.0-0-dbg libpango1.0-0-dbg libpcre3-dbg
          libpixman-1-0-dbg libsqlite3-0-dbg libx11-6-dbg libxau6-dbg
          libxcb1-dbg libxcomposite1-dbg libxcursor1-dbg libxdamage1-dbg
          libxdmcp6-dbg libxext6-dbg libxfixes3-dbg libxi6-dbg libxinerama1-dbg
          libxrandr2-dbg libxrender1-dbg libxtst6-dbg zlib1g-dbg"

# arm cross toolchain packages needed to build chrome on arm
arm_list="libc6-armel-cross libc6-dev-armel-cross libgcc1-armel-cross
          libgomp1-armel-cross linux-libc-dev-armel-cross
          libgcc1-dbg-armel-cross libgomp1-dbg-armel-cross
          binutils-arm-linux-gnueabi cpp-arm-linux-gnueabi
          gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
          libmudflap0-dbg-armel-cross"

# Some package names have changed over time
if apt-cache show ttf-mscorefonts-installer >/dev/null 2>&1; then
  dev_list="${dev_list} ttf-mscorefonts-installer"
else
  dev_list="${dev_list} msttcorefonts"
fi
if apt-cache show libnspr4-dbg >/dev/null 2>&1; then
  dbg_list="${dbg_list} libnspr4-dbg libnss3-dbg"
  lib_list="${lib_list} libnspr4 libnss3"
else
  dbg_list="${dbg_list} libnspr4-0d-dbg libnss3-1d-dbg"
  lib_list="${lib_list} libnspr4-0d libnss3-1d"
fi
if apt-cache show libjpeg-dev >/dev/null 2>&1; then
  dev_list="${dev_list} libjpeg-dev"
else
  dev_list="${dev_list} libjpeg62-dev"
fi
if apt-cache show libudev1 >/dev/null 2>&1; then
  dev_list="${dev_list} libudev1"
else
  dev_list="${dev_list} libudev0"
fi

# Some packages are only needed, if the distribution actually supports
# installing them.
if apt-cache show appmenu-gtk >/dev/null 2>&1; then
  lib_list="$lib_list appmenu-gtk"
fi

# Waits for the user to press 'Y' or 'N'. Either uppercase of lowercase is
# accepted. Returns 0 for 'Y' and 1 for 'N'. If an optional parameter has
# been provided to yes_no(), the function also accepts RETURN as a user input.
# The parameter specifies the exit code that should be returned in that case.
# The function will echo the user's selection followed by a newline character.
# Users can abort the function by pressing CTRL-C. This will call "exit 1".
yes_no() {
  if [ 0 -ne "${do_default-0}" ] ; then
    return $1
  fi
  local c
  while :; do
    c="$(trap 'stty echo -iuclc icanon 2>/dev/null' EXIT INT TERM QUIT
         stty -echo iuclc -icanon 2>/dev/null
         dd count=1 bs=1 2>/dev/null | od -An -tx1)"
    case "$c" in
      " 0a") if [ -n "$1" ]; then
               [ $1 -eq 0 ] && echo "Y" || echo "N"
               return $1
             fi
             ;;
      " 79") echo "Y"
             return 0
             ;;
      " 6e") echo "N"
             return 1
             ;;
      "")    echo "Aborted" >&2
             exit 1
             ;;
      *)     # The user pressed an unrecognized key. As we are not echoing
             # any incorrect user input, alert the user by ringing the bell.
             (tput bel) 2>/dev/null
             ;;
    esac
  done
}

if test "$do_inst_syms" = ""
then
  echo "This script installs all tools and libraries needed to build Chromium."
  echo ""
  echo "For most of the libraries, it can also install debugging symbols, which"
  echo "will allow you to debug code in the system libraries. Most developers"
  echo "won't need these symbols."
  echo -n "Do you want me to install them for you (y/N) "
  if yes_no 1; then
    do_inst_syms=1
  fi
fi
if test "$do_inst_syms" = "1"; then
  echo "Installing debugging symbols."
else
  echo "Skipping installation of debugging symbols."
  dbg_list=
fi

# Install the Chrome OS default fonts.
if test "$do_inst_chromeos_fonts" != "0"; then
  echo
  echo "Installing Chrome OS fonts."
  dir=`echo $0 | sed -r -e 's/\/[^/]+$//'`
  if ! sudo $dir/linux/install-chromeos-fonts.py; then
    echo "ERROR: The installation of the Chrome OS default fonts failed."
    if [ `stat -f -c %T $dir` == "nfs" ]; then
      echo "The reason is that your repo is installed on a remote file system."
    else
      echo "This is expected if your repo is installed on a remote file system."
    fi
    echo "It is recommended to install your repo on a local file system."
    echo "You can skip the installation of the Chrome OS default founts with"
    echo "the command line option: --no-chromeos-fonts."
    exit 1
  fi
else
  echo "Skipping installation of Chrome OS fonts."
fi

# When cross building for arm on 64-bit systems the host binaries
# that are part of v8 need to be compiled with -m32 which means
# that basic multilib support is needed.
if [ "$(uname -m)" = "x86_64" ]; then
  arm_list="$arm_list g++-multilib"
fi

if test "$do_inst_arm" = "1"; then
  . /etc/lsb-release
  if test "$DISTRIB_CODENAME" != "precise"; then
    echo "ERROR: Installing the ARM cross toolchain is only available on" \
         "Ubuntu precise." >&2
    exit 1
  fi
  echo "Installing ARM cross toolchain."
else
  echo "Skipping installation of ARM cross toolchain."
  arm_list=
fi

sudo apt-get update

# We initially run "apt-get" with the --reinstall option and parse its output.
# This way, we can find all the packages that need to be newly installed
# without accidentally promoting any packages from "auto" to "manual".
# We then re-run "apt-get" with just the list of missing packages.
echo "Finding missing packages..."
packages="${dev_list} ${lib_list} ${dbg_list} ${arm_list}"
# Intentionally leaving $packages unquoted so it's more readable.
echo "Packages required: " $packages
echo
new_list_cmd="sudo apt-get install --reinstall $(echo $packages)"
if new_list="$(yes n | LANGUAGE=en LANG=C $new_list_cmd)"; then
  # We probably never hit this following line.
  echo "No missing packages, and the packages are up-to-date."
elif [ $? -eq 1 ]; then
  # We expect apt-get to have exit status of 1.
  # This indicates that we cancelled the install with "yes n|".
  new_list=$(echo "$new_list" |
    sed -e '1,/The following NEW packages will be installed:/d;s/^  //;t;d')
  new_list=$(echo "$new_list" | sed 's/ *$//')
  if [ -z "$new_list" ] ; then
    echo "No missing packages, and the packages are up-to-date."
  else
    echo "Installing missing packages: $new_list."
    sudo apt-get install ${do_quietly-} ${new_list}
  fi
  echo
else
  # An apt-get exit status of 100 indicates that a real error has occurred.

  # I am intentionally leaving out the '"'s around new_list_cmd,
  # as this makes it easier to cut and paste the output
  echo "The following command failed: " ${new_list_cmd}
  echo
  echo "It produces the following output:"
  yes n | $new_list_cmd || true
  echo
  echo "You will have to install the above packages yourself."
  echo
  exit 100
fi

# Install 32bit backwards compatibility support for 64bit systems
if [ "$(uname -m)" = "x86_64" ]; then
  if test "$do_inst_lib32" != "1"
  then
    echo "NOTE: If you were expecting the option to install 32bit libs,"
    echo "please run with the --lib32 flag."
    echo
    echo "Installation complete."
    exit 0
  else
    # This conditional statement has been added to deprecate and eventually
    # remove support for 32bit libraries on 64bit systems. But for the time
    # being, we still have to support a few legacy systems (e.g. bots), where
    # this feature is needed.
    # We only even give the user the option to install these libraries, if
    # they explicitly requested doing so by setting the --lib32 command line
    # flag.
    # And even then, we interactively ask them one more time whether they are
    # absolutely sure.
    # In order for that to work, we must reset the ${do_inst_lib32} variable.
    # There are other ways to achieve the same goal. But resetting the
    # variable is the best way to document the intended behavior -- and to
    # allow us to gradually deprecate and then remove the obsolete code.
    do_inst_lib32=
  fi

  echo "WARNING"
  echo
  echo "We no longer recommend that you use this script to install"
  echo "32bit libraries on a 64bit system. Instead, consider using the"
  echo "install-chroot.sh script to help you set up a 32bit environment"
  echo "for building and testing 32bit versions of Chrome."
  echo
  echo "The code for installing 32bit libraries on a 64bit system is"
  echo "unmaintained and might not work with modern versions of Ubuntu"
  echo "or Debian."
  echo
  echo -n "Are you sure you want to proceed (y/N) "
  if yes_no 1; then
    do_inst_lib32=1
  fi
  if test "$do_inst_lib32" != "1"
  then
    exit 0
  fi

  # Standard 32bit compatibility libraries
  echo "First, installing the limited existing 32-bit support..."
  cmp_list="ia32-libs lib32asound2-dev lib32stdc++6 lib32z1
            lib32z1-dev libc6-dev-i386 libc6-i386 g++-multilib"
  if [ -n "`apt-cache search lib32readline-gplv2-dev 2>/dev/null`" ]; then
    cmp_list="${cmp_list} lib32readline-gplv2-dev"
  else
    cmp_list="${cmp_list} lib32readline5-dev"
  fi
  sudo apt-get install ${do_quietly-} $cmp_list

  tmp=/tmp/install-32bit.$$
  trap 'rm -rf "${tmp}"' EXIT INT TERM QUIT
  mkdir -p "${tmp}/apt/lists/partial" "${tmp}/cache" "${tmp}/partial"
  touch "${tmp}/status"

  [ -r /etc/apt/apt.conf ] && cp /etc/apt/apt.conf "${tmp}/apt/"
  cat >>"${tmp}/apt/apt.conf" <<EOF
        Apt::Architecture "i386";
        Dir::Cache "${tmp}/cache";
        Dir::Cache::Archives "${tmp}/";
        Dir::State::Lists "${tmp}/apt/lists/";
        Dir::State::status "${tmp}/status";
EOF

  # Download 32bit packages
  echo "Computing list of available 32bit packages..."
  sudo apt-get -c="${tmp}/apt/apt.conf" update

  echo "Downloading available 32bit packages..."
  sudo apt-get -c="${tmp}/apt/apt.conf" \
          --yes --download-only --force-yes --reinstall install \
          ${lib_list} ${dbg_list}

  # Open packages, remove everything that is not a library, move the
  # library to a lib32 directory and package everything as a *.deb file.
  echo "Repackaging and installing 32bit packages for use on 64bit systems..."
  for i in ${lib_list} ${dbg_list}; do
    orig="$(echo "${tmp}/${i}"_*_i386.deb)"
    compat="$(echo "${orig}" |
              sed -e 's,\(_[^_/]*_\)i386\(.deb\),-ia32\1amd64\2,')"
    rm -rf "${tmp}/staging"
    msg="$(fakeroot -u sh -exc '
      # Unpack 32bit Debian archive
      umask 022
      mkdir -p "'"${tmp}"'/staging/dpkg/DEBIAN"
      cd "'"${tmp}"'/staging"
      ar x "'${orig}'"
      tar Cfx dpkg data.tar*
      tar zCfx dpkg/DEBIAN control.tar.gz

      # Create a posix extended regular expression fragment that will
      # recognize the includes which have changed. Should be rare,
      # will almost always be empty.
      includes=`sed -n -e "s/^[0-9a-z]*  //g" \
                       -e "\,usr/include/,p" dpkg/DEBIAN/md5sums |
                  xargs -n 1 -I FILE /bin/sh -c \
                    "cmp -s dpkg/FILE /FILE || echo FILE" |
                  tr "\n" "|" |
                  sed -e "s,|$,,"`

      # If empty, set it to not match anything.
      test -z "$includes" && includes="^//"

      # Turn the conflicts into an extended RE for removal from the
      # Provides line.
      conflicts=`sed -n -e "/Conflicts/s/Conflicts: *//;T;s/, */|/g;p" \
                   dpkg/DEBIAN/control`

      # Rename package, change architecture, remove conflicts and dependencies
      sed -r -i                              \
          -e "/Package/s/$/-ia32/"           \
          -e "/Architecture/s/:.*$/: amd64/" \
          -e "/Depends/s/:.*/: ia32-libs/"   \
          -e "/Provides/s/($conflicts)(, *)?//g;T1;s/, *$//;:1"   \
          -e "/Recommends/d"                 \
          -e "/Conflicts/d"                  \
        dpkg/DEBIAN/control

      # Only keep files that live in "lib" directories or the includes
      # that have changed.
      sed -r -i                                                               \
          -e "/\/lib64\//d" -e "/\/.?bin\//d"                                 \
          -e "\,$includes,s,[ /]include/,&32/,g;s,include/32/,include32/,g"   \
          -e "s, lib/, lib32/,g"                                              \
          -e "s,/lib/,/lib32/,g"                                              \
          -e "t;d"                                                            \
          -e "\,^/usr/lib32/debug\(.*/lib32\),s,^/usr/lib32/debug,/usr/lib/debug," \
        dpkg/DEBIAN/md5sums

      # Re-run ldconfig after installation/removal
      { echo "#!/bin/sh"; echo "[ \"x\$1\" = xconfigure ]&&ldconfig||:"; } \
        >dpkg/DEBIAN/postinst
      { echo "#!/bin/sh"; echo "[ \"x\$1\" = xremove ]&&ldconfig||:"; } \
        >dpkg/DEBIAN/postrm
      chmod 755 dpkg/DEBIAN/postinst dpkg/DEBIAN/postrm

      # Remove any other control files
      find dpkg/DEBIAN -mindepth 1 "(" -name control -o -name md5sums -o \
                       -name postinst -o -name postrm ")" -o -print |
        xargs -r rm -rf

      # Remove any files/dirs that live outside of "lib" directories,
      # or are not in our list of changed includes.
      find dpkg -mindepth 1 -regextype posix-extended \
          "(" -name DEBIAN -o -name lib -o -regex "dpkg/($includes)" ")" \
          -prune -o -print | tac |
        xargs -r -n 1 sh -c "rm \$0 2>/dev/null || rmdir \$0 2>/dev/null || : "
      find dpkg -name lib64 -o -name bin -o -name "?bin" |
        tac | xargs -r rm -rf

      # Remove any symbolic links that were broken by the above steps.
      find -L dpkg -type l -print | tac | xargs -r rm -rf

      # Rename lib to lib32, but keep debug symbols in /usr/lib/debug/usr/lib32
      # That is where gdb looks for them.
      find dpkg -type d -o -path "*/lib/*" -print |
        xargs -r -n 1 sh -c "
          i=\$(echo \"\${0}\" |
               sed -e s,/lib/,/lib32/,g \
               -e s,/usr/lib32/debug\\\\\(.*/lib32\\\\\),/usr/lib/debug\\\\1,);
          mkdir -p \"\${i%/*}\";
          mv \"\${0}\" \"\${i}\""

      # Rename include to include32.
      [ -d "dpkg/usr/include" ] && mv "dpkg/usr/include" "dpkg/usr/include32"

      # Prune any empty directories
      find dpkg -type d | tac | xargs -r -n 1 rmdir 2>/dev/null || :

      # Create our own Debian package
      cd ..
      dpkg --build staging/dpkg .' 2>&1)"
    compat="$(eval echo $(echo "${compat}" |
                          sed -e 's,_[^_/]*_amd64.deb,_*_amd64.deb,'))"
    [ -r "${compat}" ] || {
      echo "${msg}" >&2
      echo "Failed to build new Debian archive!" >&2
      exit 1
    }

    msg="$(sudo dpkg -i "${compat}" 2>&1)" && {
        echo "Installed ${compat##*/}"
      } || {
        # echo "${msg}" >&2
        echo "Skipped ${compat##*/}"
      }
  done

  # Add symbolic links for developing 32bit code
  echo "Adding missing symbolic links, enabling 32bit code development..."
  for i in $(find /lib32 /usr/lib32 -maxdepth 1 -name \*.so.\* |
             sed -e 's/[.]so[.][0-9].*/.so/' |
             sort -u); do
    [ "x${i##*/}" = "xld-linux.so" ] && continue
    [ -r "$i" ] && continue
    j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' |
         sort -n | tail -n 1)"
    [ -r "$i.$j" ] || continue
    sudo ln -s "${i##*/}.$j" "$i"
  done
fi


Thermal Script

Thermal Script

#!/bin/bash
cpuTemp0=$(cat /sys/class/thermal/thermal_zone0/temp)
cpuTemp1=$(($cpuTemp0/1000))
cpuTemp2=$(($cpuTemp0/100))
cpuTempM=$(($cpuTemp2 % $cpuTemp1))
# TODO: Add the degree symbol once we get tmux and fbterm stuff set up
# TODO: Get rid of the apostrophe in the GPU temperature readout
# TODO: what about the quad core stuff of Raspberry Pi 2?
# TODO: Color code therma temperatures. Green, yellow, orange, red. Red is bad!
cputemp=$(echo "$cpuTemp1.$cpuTempM C")
gputemp=$(/opt/vc/bin/vcgencmd measure_temp | sed -n "s/'/ /;p" | sed -n 's/temp=//p')

# echo "CPU temp=$cpuTemp1.$cpuTempM C"
# echo  GPU $gputemp
echo "CPU $cputemp GPU $gputemp"

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


Added run dir to mongrel2 chroot

Added run dir to mongrel2 chroot

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/daltonmatos/wsgid.git/'


Add keypair rotation test scenario

Add keypair rotation test scenario

#!/usr/bin/env bash

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

REPO_ROOT=$(git rev-parse --show-toplevel);
source "${REPO_ROOT}"/tests/e2e/scenarios/lib/common.sh

kops-acquire-latest

kops-up

REPORT_DIR="${ARTIFACTS:-$(pwd)/_artifacts}/keypair-rotation/"

kops create keypair all
kops update cluster --yes
kops rolling-update cluster --yes --validate-count=10

KUBECFG_CREATE=$(mktemp -t kubeconfig.XXXXXXXXX)
kops export kubecfg --admin --kubeconfig="${KUBECFG_CREATE}"
kubectl --kubeconfig="${KUBECFG_CREATE}" config view > "${REPORT_DIR}/create.kubeconfig"

# Confirm the first kubeconfig still works
kops validate cluster --wait=10m --count=3

export KUBECONFIG="${KUBECFG_CREATE}"
kops promote keypair all
kops update cluster --yes
kops rolling-update cluster --yes --validate-count=10

KUBECFG_PROMOTE=$(mktemp -t kubeconfig.XXXXXXXXX)
kops export kubecfg --admin --kubeconfig="${KUBECFG_PROMOTE}"
kubectl --kubeconfig="${KUBECFG_PROMOTE}" config view > "${REPORT_DIR}/promote.kubeconfig"

CA=$(kubectl --kubeconfig="${KUBECFG_PROMOTE}" config view --raw -o jsonpath="{.clusters[0].cluster.certificate-authority-data}" | base64 -D)
if [ "$(echo "${CA}" | grep -c "BEGIN CERTIFICATE")" != "1" ]; then
  >&2 echo unexpected number of CA certificates in kubeconfig
  exit 1
fi

export KUBECONFIG="${KUBECFG_PROMOTE}"
kops distrust keypair all
kops update cluster --yes
kops rolling-update cluster --yes --validate-count=10

KUBECFG_DISTRUST=$(mktemp -t kubeconfig.XXXXXXXXX)
kops export kubecfg --admin --kubeconfig="${KUBECFG_DISTRUST}"
kubectl --kubeconfig="${KUBECFG_DISTRUST}" config view > "${REPORT_DIR}/distrust.kubeconfig"

export KUBECONFIG="${KUBECFG_DISTRUST}"
kops validate cluster --wait=10m --count=3

error: pathspec 'tests/e2e/scenarios/keypair-rotation/run-test.sh' did not match any file(s) known to git


update monitor-hotplug script

update monitor-hotplug 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/lbischof/ansible-playbooks.git/'


add install.sh

add install.sh

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


Utopic install instructions

Utopic install instructions

#!/bin/sh

set -e

wget -O - http://ubuntu.hyperdex.org/hyperdex.gpg.key | apt-key add -
cat >> /etc/apt/sources.list.d/hyperdex.list << EOF
deb [arch=amd64] http://ubuntu.hyperdex.org utopic main
EOF
apt-get update
apt-get install -y hyperdex

error: pathspec 'doc/install/ubuntu14.10-packages.sh' did not match any file(s) known to git


bangxi added random delay before describe-auto-scaling-groups

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/KCFTech/aws-codedeploy-samples.git/'


release: add SE_FW version for artik5 device

This patch adds SE_FW version for artik5 device.

Change-Id: I5d13fe19afd4af23ca01d755b4f311635faa628b
Signed-off-by: Chanho Park <8ec285a53e21b773fd914e03c50e1b6431bc9aa8@samsung.com>

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/SamsungARTIK/build-artik.git/'


Re-add release script

Re-add release script

#!/bin/bash

# ---------------------------
# Data
LEIN="$(which lein) "
LEIN_EACH="$LEIN monolith each"
LEIN_BUMP="change version leiningen.release/bump-version"
LEVEL="$1"

set -eu
# ---------------------------
# Assertions
if [ ! -z "$(git status --porcelain)" ]; then
    echo "There are uncommitted changes or untracked files in the current repository." 1>&2
    exit 1
fi

if [ ! "master" = "$(git rev-parse --abbrev-ref HEAD)" ]; then
    echo "Can only release from master branch." 1>&2;
    exit 1;
fi

COMMITS_SINCE_LAST_RELEASE=$(git rev-list $(git rev-list --tags --no-walk --max-count=1 2> /dev/null)..HEAD --count 2> /dev/null)
if [[ "$COMMITS_SINCE_LAST_RELEASE" == "1" ]]; then
    echo "It seems there was only one commit since the last tag, indicating that no" 1>&2;
    echo "changes would be released." 1>&2;
    exit 1;
fi

# ---------------------------
# Helpers
function adjust_ancient_clj_version() {
    local CURRENT_VERSION=$(head -n 1 "project.clj" | cut -c33- | sed 's/"//g')
    sed -i'.bak' "s/ancient-clj \".*\"/ancient-clj \"$CURRENT_VERSION\"/" "lein-ancient/project.clj"
    rm lein-ancient/project.clj.bak
}

function bump_version() {
    $LEIN $LEIN_BUMP "$@"
}

function commit_release() {
    $LEIN do vcs commit, vcs tag "v"
}

function commit_snapshot() {
    $LEIN do vcs commit
}

function deploy_artifacts() {
    cd ancient-clj
    $LEIN deploy clojars
    cd ../lein-ancient
    $LEIN deploy clojars
    cd ..
}

function run_tests() {
    cd ancient-clj
    $LEIN test
    $LEIN install > /dev/null
    cd ../lein-ancient
    $LEIN test
    cd ..
}

# ---------------------------
# Release Flow
bump_version $LEVEL release
adjust_ancient_clj_version
run_tests
exit 0
commit_release
deploy_artifacts
bump_version
commit_snapshot
git push origin master --tags

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


Adds release.sh script

Adds release.sh script

#!/bin/bash

git clean -xfdi
git submodule foreach --recursive git clean -xfdi

VERSION=`git describe --tags`
DIR_NAME="modsecurity-apache-$VERSION"
TAR_NAME="modsecurity-apache-$VERSION.tar.gz"

MY_DIR=${PWD##*/}

cd ..
tar --transform "s/^$MY_DIR/$DIR_NAME/" -cvzf $TAR_NAME --exclude .git $MY_DIR

sha256sum $TAR_NAME > $TAR_NAME.sha256
gpg --detach-sign -a $TAR_NAME

cd -
echo $TAR_NAME ": done."


Add release script

Add release script

#!/usr/bin/env bash

set -e

export GITHUB_USER=akolov
export GITHUB_REPO=YouTubePlayer
export GITHUB_TOKEN=$(cat ~/.github_token)

PRODUCT_NAME=YouTubePlayer
TAG=$1

carthage build --no-skip-current
carthage archive --project-directory .

git tag -a -m "$TAG release" $TAG
git push --tags

PRODUCT_FILE=$PRODUCT_NAME.framework.zip
github-release release --tag $TAG
github-release upload --tag $TAG --file $PRODUCT_FILE --name $PRODUCT_FILE

rm -f $PRODUCT_FILE


Added release script

Added release script

#!/bin/bash
# This script (for macOS) will release the plugin to the Jenkins update site.

export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
export PATH=JAVA_HOME/bin:$PATH

mvn clean
mvn release:prepare release:perform -X


Adding release script

Adding release script

#!/bin/bash
# This script (for macOS) will release the plugin to the Jenkins update site.

export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
export PATH=JAVA_HOME/bin:$PATH

mvn clean
mvn release:prepare release:perform -X


PROTON-47 - Added script to generate C and Java tarballs.

git-svn-id: 33ed6c3feaacb64944efc691d1ae8e09b17f2bf9@1400252 13f79535-47bb-0310-9956-ffa450edef68

#!/bin/bash
#
# release.sh - Creates release tarballs from the upstream source
# repository.
#

ME=$(basename ${0})
CURRDIR=$PWD
die()
{
    printf "ERROR: %s\n", "$*"
    exit 1
}

URL="http://svn.apache.org/repos/asf/qpid/proton"
BRANCH="trunk"
VERSION=""

usage()
{
    echo "Usage: ${ME} -v VERSION [-u URL] [-b BRANCH] [-c]"
    echo "-v VERSION  Specifies the release version; i.e., 0.18"
    echo "-u URL      The base URL for the repository (def. ${URL})"
    echo "-b BRANCH   The branch to check out (def. ${BRANCH})"
    echo ""
    exit 0
}

while getopts "hu:b:v:" OPTION; do
    case $OPTION in
        h) usage;;

        v) VERSION=$OPTARG;;

        u) URL=$OPTARG;;

        b) BRANCH=$OPTARG;;

        \?) usage;;
    esac
done

if [[ -z "${VERSION}" ]]; then
    die "You need to specify a version."
fi

##
## Create the C Tarball
##
rootname="qpid-proton-c-${VERSION}"
WORKDIR=$(mktemp -d)
mkdir -p "${WORKDIR}"
(
    cd ${WORKDIR}
    svn export ${URL}/${BRANCH} ${WORKDIR}/${rootname} >/dev/null

    ##
    ## Remove content not for the C tarball
    ##
    rm -f  ${rootname}/.gitignore
    rm -f  ${rootname}/config.sh
    rm -rf ${rootname}/bin
    rm -rf ${rootname}/examples/broker
    rm -rf ${rootname}/examples/mailbox
    rm -rf ${rootname}/proton-j
    rm -rf ${rootname}/design

    echo "Generating Archive: ${CURRDIR}/${rootname}.tar.gz"
    tar zcf ${CURRDIR}/${rootname}.tar.gz ${rootname}
)

##
## Create the Java Tarball
##
rootname="qpid-proton-java-${VERSION}"
WORKDIR=$(mktemp -d)
mkdir -p "${WORKDIR}"
(
    cd ${WORKDIR}
    svn export ${URL}/${BRANCH} ${WORKDIR}/${rootname} >/dev/null

    ##
    ## Remove content not for the Java tarball
    ##
    rm -f  ${rootname}/.gitignore
    rm -f  ${rootname}/config.sh
    rm -rf ${rootname}/bin
    rm -rf ${rootname}/examples
    rm -rf ${rootname}/proton-c
    rm -rf ${rootname}/design

    echo "Generating Archive: ${CURRDIR}/${rootname}.tar.gz"
    tar zcf ${CURRDIR}/${rootname}.tar.gz ${rootname}
)


new release script

new release script

#!/bin/bash
set -e
# npm install --global np
np $1

PACKAGE_VERSION=$(node -e 'console.log(require("./package").version)')

docker build --no-cache -t sitespeedio/coach:$PACKAGE_VERSION -t sitespeedio/coach:latest .

docker login

docker push sitespeedio/coach:$PACKAGE_VERSION
docker push sitespeedio/coach:latest


release script for react-sdk

release script for react-sdk

#!/bin/sh
#
# Script to perform a release of matrix-react-sdk.
#
# Requires githib-changelog-generator; to install, do
#   pip install git+https://github.com/matrix-org/github-changelog-generator.git

set -e

cd `dirname $0`

exec ./node_modules/matrix-js-sdk/release.sh -z -c CHANGES.rst "$@"


Create parsedata.sh

Create parsedata.sh

This file parses the data and only keeps Latitude and Longitude from the received GPS data from the Android device.

#!/bin/bash

while :
do
  sed -e 's:{:\n:g' /home/file2 | sed -e 's:}: :g' | tr -d "u'longitude':" | tr -s " " | awk '{print $11,$7;}' | cut -d "," -f 1-2 | tail -1 > /home/file
  sleep 10
done

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


Add debug information

Add debug information

[skip ci]

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/tfahub/dropwizard-bom.git/'


Fixed a typo

Fixed a typo

#!/bin/bash

set -e

export MAVENW_BIN
MAVENW_BIN="${MAVENW_BIN:-./mvnw}"

# It takes ages on Docker to run the app without this
if [[ ${BUILD_OPTIONS} != *"java.security.egd"* ]]; then
	if [[ ! -z ${BUILD_OPTIONS} && ${BUILD_OPTIONS} != "null" ]]; then
		export BUILD_OPTIONS="${BUILD_OPTIONS} -Djava.security.egd=file:///dev/urandom"
	else
		export BUILD_OPTIONS="-Djava.security.egd=file:///dev/urandom"
	fi
fi

function build() {
	local pipelineVersion="${PASSED_PIPELINE_VERSION:-${PIPELINE_VERSION:-}}"
	# Required by settings.xml
	BUILD_OPTIONS="${BUILD_OPTIONS} -DM2_SETTINGS_REPO_ID=${M2_SETTINGS_REPO_ID} -DM2_SETTINGS_REPO_USERNAME=${M2_SETTINGS_REPO_USERNAME} -DM2_SETTINGS_REPO_PASSWORD=${M2_SETTINGS_REPO_PASSWORD}"
	# shellcheck disable=SC2086
	"${MAVENW_BIN}" org.codehaus.mojo:versions-maven-plugin:2.3:set -DnewVersion="${pipelineVersion}" ${BUILD_OPTIONS} || (echo "Build failed!!!" && return 1)
	if [[ "${CI}" == "CONCOURSE" ]]; then
		# shellcheck disable=SC2086
		"${MAVENW_BIN}" clean verify deploy -Ddistribution.management.release.id="${M2_SETTINGS_REPO_ID}" -Ddistribution.management.release.url="${REPO_WITH_BINARIES_FOR_UPLOAD}" -Drepo.with.binaries="${REPO_WITH_BINARIES}" ${BUILD_OPTIONS} || (printTestResults && return 1)
	else
		# shellcheck disable=SC2086
		"${MAVENW_BIN}" clean verify deploy -Ddistribution.management.release.id="${M2_SETTINGS_REPO_ID}" -Ddistribution.management.release.url="${REPO_WITH_BINARIES_FOR_UPLOAD}" -Drepo.with.binaries="${REPO_WITH_BINARIES}" ${BUILD_OPTIONS}
	fi
}

function apiCompatibilityCheck() {
	local prodTag="${PASSED_LATEST_PROD_TAG:-${LATEST_PROD_TAG:-}}"
	[[ -z "${prodTag}" ]] && prodTag="$(findLatestProdTag)"
	echo "Last prod tag equals [${prodTag}]"
	if [[ -z "${prodTag}" ]]; then
		echo "No prod release took place - skipping this step"
	else
		# Putting env vars to output properties file for parameter passing
		export PASSED_LATEST_PROD_TAG="${prodTag}"
		local fileLocation="${OUTPUT_FOLDER}/test.properties"
		echo "PASSED_LATEST_PROD_TAG=${prodTag}" >>"${fileLocation}"
		# Downloading latest jar
		LATEST_PROD_VERSION=${prodTag#prod/}
		echo "Last prod version equals [${LATEST_PROD_VERSION}]"
		if [[ "${CI}" == "CONCOURSE" ]]; then
			# shellcheck disable=SC2086
			"${MAVENW_BIN}" clean verify -Papicompatibility -Dlatest.production.version="${LATEST_PROD_VERSION}" -Drepo.with.binaries="${REPO_WITH_BINARIES}" ${BUILD_OPTIONS} || (printTestResults && return 1)
		else
			# shellcheck disable=SC2086
			"${MAVENW_BIN}" clean verify -Papicompatibility -Dlatest.production.version="${LATEST_PROD_VERSION}" -Drepo.with.binaries="${REPO_WITH_BINARIES}" ${BUILD_OPTIONS}
		fi
	fi
}

# The function uses Maven Wrapper - if you're using Maven you have to have it on your classpath
# and change this function
function extractMavenProperty() {
	local prop="${1}"
	MAVEN_PROPERTY=$("${MAVENW_BIN}" -q  \
 -Dexec.executable="echo"  \
 -Dexec.args="\${${prop}}"  \
 --non-recursive  \
 org.codehaus.mojo:exec-maven-plugin:1.3.1:exec)
	# In some spring cloud projects there is info about deactivating some stuff
	MAVEN_PROPERTY=$(echo "${MAVEN_PROPERTY}" | tail -1)
	# In Maven if there is no property it prints out ${propname}
	if [[ "${MAVEN_PROPERTY}" == "\${${prop}}" ]]; then
		echo ""
	else
		echo "${MAVEN_PROPERTY}"
	fi
}

function retrieveGroupId() {
	{
		ruby -r rexml/document  \
 -e 'puts REXML::Document.new(File.new(ARGV.shift)).elements["/project/groupId"].text' pom.xml  \
 || "${MAVENW_BIN}" org.apache.maven.plugins:maven-help-plugin:2.2:evaluate  \
 -Dexpression=project.groupId | grep -Ev '(^\[|Download\w+:)'
	} | tail -1
}

function retrieveAppName() {
	{
		ruby -r rexml/document  \
 -e 'puts REXML::Document.new(File.new(ARGV.shift)).elements["/project/artifactId"].text' pom.xml  \
 || "${MAVENW_BIN}" org.apache.maven.plugins:maven-help-plugin:2.2:evaluate  \
 -Dexpression=project.artifactId | grep -Ev '(^\[|Download\w+:)'
	} | tail -1
}

function printTestResults() {
	# shellcheck disable=SC1117
	echo -e "\n\nBuild failed!!! - will print all test results to the console (it's the easiest way to debug anything later)\n\n" && tail -n +1 "$(testResultsAntPattern)"
}

function retrieveStubRunnerIds() {
	extractMavenProperty 'stubrunner.ids'
}

function runSmokeTests() {
	local applicationUrl="${APPLICATION_URL}"
	local stubrunnerUrl="${STUBRUNNER_URL}"
	echo "Running smoke tests. Application url [${applicationUrl}], Stubrunner Url [${stubrunnerUrl}]"

	if [[ "${CI}" == "CONCOURSE" ]]; then
		# shellcheck disable=SC2086
		"${MAVENW_BIN}" clean install -Psmoke -Dapplication.url="${applicationUrl}" -Dstubrunner.url="${stubrunnerUrl}" ${BUILD_OPTIONS} || (printTestResults && return 1)
	else
		# shellcheck disable=SC2086
		"${MAVENW_BIN}" clean install -Psmoke -Dapplication.url="${applicationUrl}" -Dstubrunner.url="${stubrunnerUrl}" ${BUILD_OPTIONS}
	fi
}

function runE2eTests() {
	local applicationUrl="${APPLICATION_URL}"
	echo "Running e2e tests for application with url [${applicationUrl}]"

	if [[ "${CI}" == "CONCOURSE" ]]; then
		# shellcheck disable=SC2086
		"${MAVENW_BIN}" clean install -Pe2e -Dapplication.url="${applicationUrl}" ${BUILD_OPTIONS} || (printTestResults && return 1)
	else
		# shellcheck disable=SC2086
		"${MAVENW_BIN}" clean install -Pe2e -Dapplication.url="${applicationUrl}" ${BUILD_OPTIONS}
	fi
}

function outputFolder() {
	echo "target"
}

function testResultsAntPattern() {
	echo "**/surefire-reports/*"
}

export -f build
export -f apiCompatibilityCheck
export -f runSmokeTests
export -f runE2eTests
export -f outputFolder
export -f testResultsAntPattern

#!/bin/bash

set -e

export MAVENW_BIN
MAVENW_BIN="${MAVENW_BIN:-./mvnw}"

# It takes ages on Docker to run the app without this
if [[ ${BUILD_OPTIONS} != *"java.security.egd"* ]]; then
	if [[ ! -z ${BUILD_OPTIONS} && ${BUILD_OPTIONS} != "null" ]]; then
		export BUILD_OPTIONS="${BUILD_OPTIONS} -Djava.security.egd=file:///dev/urandom"
	else
		export BUILD_OPTIONS="-Djava.security.egd=file:///dev/urandom"
	fi
fi

function build() {
	local pipelineVersion="${PASSED_PIPELINE_VERSION:-${PIPELINE_VERSION:-}}"
	# Required by settings.xml
	BUILD_OPTIONS="${BUILD_OPTIONS} -DM2_SETTINGS_REPO_ID=${M2_SETTINGS_REPO_ID} -DM2_SETTINGS_REPO_USERNAME=${M2_SETTINGS_REPO_USERNAME} -DM2_SETTINGS_REPO_PASSWORD=${M2_SETTINGS_REPO_PASSWORD}"
	# shellcheck disable=SC2086
	"${MAVENW_BIN}" org.codehaus.mojo:versions-maven-plugin:2.3:set -DnewVersion="${pipelineVersion}" ${BUILD_OPTIONS} || (echo "Build failed!!!" && return 1)
	if [[ "${CI}" == "CONCOURSE" ]]; then
		# shellcheck disable=SC2086
		"${MAVENW_BIN}" clean verify deploy -Ddistribution.management.release.id="${M2_SETTINGS_REPO_ID}" -Ddistribution.management.release.url="${REPO_WITH_BINARIES_FOR_UPLOAD}" -Drepo.with.binaries="${REPO_WITH_BINARIES}" ${BUILD_OPTIONS} || (printTestResults && return 1)
	else
		# shellcheck disable=SC2086
		"${MAVENW_BIN}" clean verify deploy -Ddistribution.management.release.id="${M2_SETTINGS_REPO_ID}" -Ddistribution.management.release.url="${REPO_WITH_BINARIES_FOR_UPLOAD}" -Drepo.with.binaries="${REPO_WITH_BINARIES}" ${BUILD_OPTIONS}
	fi
}

function apiCompatibilityCheck() {
	local prodTag="${PASSED_LATEST_PROD_TAG:-${LATEST_PROD_TAG:-}}"
	[[ -z "${prodTag}" ]] && prodTag="$(findLatestProdTag)"
	echo "Last prod tag equals [${prodTag}]"
	if [[ -z "${prodTag}" ]]; then
		echo "No prod release took place - skipping this step"
	else
		# Putting env vars to output properties file for parameter passing
		export PASSED_LATEST_PROD_TAG="${prodTag}"
		local fileLocation="${OUTPUT_FOLDER}/test.properties}"
		echo "PASSED_LATEST_PROD_TAG=${prodTag}" >>"${fileLocation}"
		# Downloading latest jar
		LATEST_PROD_VERSION=${prodTag#prod/}
		echo "Last prod version equals [${LATEST_PROD_VERSION}]"
		if [[ "${CI}" == "CONCOURSE" ]]; then
			# shellcheck disable=SC2086
			"${MAVENW_BIN}" clean verify -Papicompatibility -Dlatest.production.version="${LATEST_PROD_VERSION}" -Drepo.with.binaries="${REPO_WITH_BINARIES}" ${BUILD_OPTIONS} || (printTestResults && return 1)
		else
			# shellcheck disable=SC2086
			"${MAVENW_BIN}" clean verify -Papicompatibility -Dlatest.production.version="${LATEST_PROD_VERSION}" -Drepo.with.binaries="${REPO_WITH_BINARIES}" ${BUILD_OPTIONS}
		fi
	fi
}

# The function uses Maven Wrapper - if you're using Maven you have to have it on your classpath
# and change this function
function extractMavenProperty() {
	local prop="${1}"
	MAVEN_PROPERTY=$("${MAVENW_BIN}" -q  \
 -Dexec.executable="echo"  \
 -Dexec.args="\${${prop}}"  \
 --non-recursive  \
 org.codehaus.mojo:exec-maven-plugin:1.3.1:exec)
	# In some spring cloud projects there is info about deactivating some stuff
	MAVEN_PROPERTY=$(echo "${MAVEN_PROPERTY}" | tail -1)
	# In Maven if there is no property it prints out ${propname}
	if [[ "${MAVEN_PROPERTY}" == "\${${prop}}" ]]; then
		echo ""
	else
		echo "${MAVEN_PROPERTY}"
	fi
}

function retrieveGroupId() {
	{
		ruby -r rexml/document  \
 -e 'puts REXML::Document.new(File.new(ARGV.shift)).elements["/project/groupId"].text' pom.xml  \
 || "${MAVENW_BIN}" org.apache.maven.plugins:maven-help-plugin:2.2:evaluate  \
 -Dexpression=project.groupId | grep -Ev '(^\[|Download\w+:)'
	} | tail -1
}

function retrieveAppName() {
	{
		ruby -r rexml/document  \
 -e 'puts REXML::Document.new(File.new(ARGV.shift)).elements["/project/artifactId"].text' pom.xml  \
 || "${MAVENW_BIN}" org.apache.maven.plugins:maven-help-plugin:2.2:evaluate  \
 -Dexpression=project.artifactId | grep -Ev '(^\[|Download\w+:)'
	} | tail -1
}

function printTestResults() {
	# shellcheck disable=SC1117
	echo -e "\n\nBuild failed!!! - will print all test results to the console (it's the easiest way to debug anything later)\n\n" && tail -n +1 "$(testResultsAntPattern)"
}

function retrieveStubRunnerIds() {
	extractMavenProperty 'stubrunner.ids'
}

function runSmokeTests() {
	local applicationUrl="${APPLICATION_URL}"
	local stubrunnerUrl="${STUBRUNNER_URL}"
	echo "Running smoke tests. Application url [${applicationUrl}], Stubrunner Url [${stubrunnerUrl}]"

	if [[ "${CI}" == "CONCOURSE" ]]; then
		# shellcheck disable=SC2086
		"${MAVENW_BIN}" clean install -Psmoke -Dapplication.url="${applicationUrl}" -Dstubrunner.url="${stubrunnerUrl}" ${BUILD_OPTIONS} || (printTestResults && return 1)
	else
		# shellcheck disable=SC2086
		"${MAVENW_BIN}" clean install -Psmoke -Dapplication.url="${applicationUrl}" -Dstubrunner.url="${stubrunnerUrl}" ${BUILD_OPTIONS}
	fi
}

function runE2eTests() {
	local applicationUrl="${APPLICATION_URL}"
	echo "Running e2e tests for application with url [${applicationUrl}]"

	if [[ "${CI}" == "CONCOURSE" ]]; then
		# shellcheck disable=SC2086
		"${MAVENW_BIN}" clean install -Pe2e -Dapplication.url="${applicationUrl}" ${BUILD_OPTIONS} || (printTestResults && return 1)
	else
		# shellcheck disable=SC2086
		"${MAVENW_BIN}" clean install -Pe2e -Dapplication.url="${applicationUrl}" ${BUILD_OPTIONS}
	fi
}

function outputFolder() {
	echo "target"
}

function testResultsAntPattern() {
	echo "**/surefire-reports/*"
}

export -f build
export -f apiCompatibilityCheck
export -f runSmokeTests
export -f runE2eTests
export -f outputFolder
export -f testResultsAntPattern


Add iOS simulator alias

Add iOS simulator alias

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


always get the default branch

always get the default branch

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/Mausy5043/raspboot.git/'


Add the 'iptables-medium.sh' script.

Add the 'iptables-medium.sh' script.

#!/bin/bash

# Copyright (c) 2007,2015 Jérémie DECOCK <jd.jdhp@gmail.com> (www.jdhp.org)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# For more information, see https://github.com/jeremiedecock/iptables-scripts
#
# To display the curent Netfilter rules, type the following commands in a Linux
# console (from the administrator account):
#
#   iptables -L -n -v
#   ip6tables -L -n -v

#IP4TABLES="/sbin/iptables -v"
#IP6TABLES="/sbin/ip6tables -v"

IP4TABLES="/sbin/iptables"
IP6TABLES="/sbin/ip6tables"

# Kernel params ###############################################################

modprobe ip_conntrack_ftp

# IPv6 ########################################################################

# Flush rules
$IP6TABLES -F
$IP6TABLES -X

# Default rule: reject every packet (incoming, outgoing and forwarded)
$IP6TABLES -P INPUT   DROP
$IP6TABLES -P OUTPUT  DROP
$IP6TABLES -P FORWARD DROP

# Accept everything on the loopback interface
$IP6TABLES -A INPUT -i lo -j ACCEPT
$IP6TABLES -A OUTPUT -o lo -j ACCEPT

# IPv4 ########################################################################

# Flush rules
$IP4TABLES -F
$IP4TABLES -X

# Default rule: only accept outgoing packets
$IP4TABLES -P INPUT   DROP
$IP4TABLES -P OUTPUT  ACCEPT
$IP4TABLES -P FORWARD DROP

# Accept incoming packets on the loopback interface
$IP4TABLES -A INPUT -i lo -j ACCEPT

# Reject invalid incoming packets
$IP4TABLES -A INPUT -m state --state INVALID -j DROP

# Reject invalid incoming TCP packets (i.e. with flags not equals to "ALL" or "SYN")
$IP4TABLES -A INPUT -m state --state NEW,RELATED -p tcp ! --tcp-flags ALL SYN -j DROP

# Accept incoming TCP packets related to an already established connexion
$IP4TABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# Reject (and notify) incoming connexions on port 113/TCP ("authentication tap ident")
$IP4TABLES -A INPUT -p tcp --destination-port auth -j REJECT --reject-with tcp-reset

# ALLOWED_LOCAL_TCP_SERVICES ##########

# TRUSTED_IP contains the list of trusted IPs (IPs allowed to connect to this
# computer). For instance:
#
#    TRUSTED_IP=(192.168.0.1 192.168.0.2)
#   or:
#    TRUSTED_IP=(192.168.0.1)
#   or:
#    TRUSTED_IP=()
#
# ALLOWED_LOCAL_TCP_SERVICES contains the list of services made available for
# trusted IPs. For instance:
#
#    ALLOWED_LOCAL_TCP_SERVICES=(80 443)
#   or:
#    ALLOWED_LOCAL_TCP_SERVICES=(80)
#   or:
#    ALLOWED_LOCAL_TCP_SERVICES=()

TRUSTED_IP=()
ALLOWED_LOCAL_TCP_SERVICES=()

for IP in ${TRUSTED_IP[@]}; do
    for SERVICE in ${ALLOWED_LOCAL_TCP_SERVICES[@]}; do
        $IP4TABLES -A INPUT -p tcp -s $IP --dport $SERVICE -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
    done
done

# USERS RULES #########################

#$IP4TABLES -A OUTPUT -p tcp -m tcp --dport 80 -m owner --uid-owner john -j DROP
#$IP4TABLES -A OUTPUT -p tcp -m tcp --dport 80 -m owner --uid-owner alice -j DROP

# DEFAUT ##############################

#$IP4TABLES -A INPUT -m limit --limit 4/s -j LOG --log-prefix "IPTABLES : "

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