Packer script

Packer script

#!/bin/bash
######################################################
# Utility script to download latest Hashicorp
# binaries and move into /usr/local/bin. Uses their
# releases APIs.
#
# Requires sudo password unless sudoers is configured.
#
# Can be renamed to installLatestTerraform.sh or
# installLatestPacker.sh.  If not then specify
# either terraform or packer as first argument.
######################################################

error()
{
  if [[ -n "$@" ]]
  then
    tput setaf 1
    echo "ERROR: $@" >&2
    tput sgr0
  fi

  [[ -n "$zip" ]] && [[ -f /tmp/$zip ]] && rm /tmp/$zip

  exit 1
}

# Grab software name based on either first parameters or the script name

declare -l software

if [[ -n "$1" ]]
then
  software=$1
  [[ "$software"  =~ ^(terraform|packer)$ ]] || error "Argument must be either terraform or packer"
else
  # Derive the software from the script name if it is installLatestTerraform.sh or installLatestPacker.sh
  software=$(basename $0 .sh | sed 's/^installLatest//1')
  [[ "$software"  =~ ^(terraform|packer)$ ]] || error "Usage is \"$(basename $0) terraform|packer\""
fi

# Check for zip and jq
_pkgs=""
[[ ! -x /usr/bin/zip ]] && _pkgs="$_pkgs zip"
[[ ! -x /usr/bin/jq ]]  && _pkgs="$_pkgs jq"

if [[ -n "$_pkgs"  ]]
then sudo apt-get update && sudo apt-get install --assume-yes -qq $_pkgs
fi

[[ ! -x /usr/bin/zip ]] && error "Install package \"zip\" and rerun"
[[ ! -x /usr/bin/jq ]] && error "Install package \"jq\" and rerun"

# Determine latest file using the API
latest=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/$software | jq -r -M '.current_version')
dir=https://releases.hashicorp.com/$software/$latest
zip=${software}_${latest}_linux_amd64.zip

# Download the zip file
echo "Downloading $dir/$zip ..." >&2
curl --silent --output /tmp/$zip $dir/$zip

if [[ "$(cd /tmp; sha256sum $zip)" != "$(curl -s $dir/${software}_${latest}_SHA256SUMS | grep $zip)" ]]
then
  error "Downloaded zip does not match SHA256 checksum value - removing"
else
  echo "Extracting ${software} executable ..." >&2
  unzip -oq /tmp/$zip $software -d /tmp && rm /tmp/$zip
fi

echo "Moving $software executable to /usr/local/bin with elevated privileges..." >&2

sudo bash <<EOF
mv /tmp/$software /usr/local/bin/$software
chown root:root /usr/local/bin/$software
chmod 755 /usr/local/bin/$software
EOF

# Echo out the version number for confirmation
echo -n "/usr/local/bin/$software -version: "
/usr/local/bin/$software -version

# Warn if another binary is found earlier in the path
if [[ "$(which $software)" != "/usr/local/bin/$software" ]]
then
  echo "WARNING: Additional binary found earlier in your path - $(which $software)"
else
  exit 0
fi

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


Remove installation of .deb file in the setup of the PlayDeb repository.

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/FriedMicro/Crystal-Linux.git/'


Avoid Github API limit

Avoid Github API limit

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


added link

added link

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


Sort tags in semver order

Sort tags in semver order

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/imrehorvath/tools.git/'


online status check added

online status check added

#!/bin/zsh

local offline=`dig 8.8.8.8 +short shabithishan.com A | grep -c "no servers could be reached"`
if [[ "$offline" == "0" ]]; then
  if [[ -f ~/.offline ]] rm ~/.offline
else
  touch ~/.offline
fi

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


prepare merge script

prepare merge script

- script that calls gofmt

#!/bin/bash
go fmt github.com/wafflehaus/chewcrew

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


Add configure for osx

Add configure for osx

# Dockbar on the left
defaults write com.apple.dock pinning -string start

# Automatically hide and show the Dock
defaults write com.apple.dock autohide -bool true

# Make Dock icons of hidden applications translucent
defaults write com.apple.dock showhidden -bool true

# Reset Launchpad, but keep the desktop wallpaper intact
find "${HOME}/Library/Application Support/Dock" -name "*-*.db" -maxdepth 1 -delete

# reverse scroll
defaults write ~/Library/Preferences/. GlobalPreferences com.apple.swipescrolldirection -bool false

# enable F keys
defaults write -g com.apple.keyboard.fnState -boolean true

# tap to click
# Enable tap to click (Trackpad) for this user and for the login screen
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1

# enable three finger drag
defaults -currentHost write NSGlobalDomain com.apple.trackpad.threeFingerSwipeGesture -int 1
defaults write NSGlobalDomain com.apple.trackpad.threeFingerSwipeGesture -int 1

###############################################################################
# Spotlight                                                                   #
###############################################################################

# Hide Spotlight tray-icon (and subsequent helper)
#sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search
# Disable Spotlight indexing for any volume that gets mounted and has not yet
# been indexed before.
# Use `sudo mdutil -i off "/Volumes/foo"` to stop indexing any volume.
sudo defaults write /.Spotlight-V100/VolumeConfiguration Exclusions -array "/Volumes"
# Change indexing order and disable some search results
# Yosemite-specific search results (remove them if your are using OS X 10.9 or older):
# 	MENU_DEFINITION
# 	MENU_CONVERSION
# 	MENU_EXPRESSION
# 	MENU_SPOTLIGHT_SUGGESTIONS (send search queries to Apple)
# 	MENU_WEBSEARCH             (send search queries to Apple)
# 	MENU_OTHER
defaults write com.apple.spotlight orderedItems -array \
	'{"enabled" = 1;"name" = "APPLICATIONS";}' \
	'{"enabled" = 1;"name" = "SYSTEM_PREFS";}' \
	'{"enabled" = 1;"name" = "DIRECTORIES";}' \
	'{"enabled" = 1;"name" = "PDF";}' \
	'{"enabled" = 1;"name" = "FONTS";}' \
	'{"enabled" = 0;"name" = "DOCUMENTS";}' \
	'{"enabled" = 0;"name" = "MESSAGES";}' \
	'{"enabled" = 0;"name" = "CONTACT";}' \
	'{"enabled" = 0;"name" = "EVENT_TODO";}' \
	'{"enabled" = 0;"name" = "IMAGES";}' \
	'{"enabled" = 0;"name" = "BOOKMARKS";}' \
	'{"enabled" = 0;"name" = "MUSIC";}' \
	'{"enabled" = 0;"name" = "MOVIES";}' \
	'{"enabled" = 0;"name" = "PRESENTATIONS";}' \
	'{"enabled" = 0;"name" = "SPREADSHEETS";}' \
	'{"enabled" = 0;"name" = "SOURCE";}' \
	'{"enabled" = 0;"name" = "MENU_DEFINITION";}' \
	'{"enabled" = 0;"name" = "MENU_OTHER";}' \
	'{"enabled" = 0;"name" = "MENU_CONVERSION";}' \
	'{"enabled" = 0;"name" = "MENU_EXPRESSION";}' \
	'{"enabled" = 0;"name" = "MENU_WEBSEARCH";}' \
	'{"enabled" = 0;"name" = "MENU_SPOTLIGHT_SUGGESTIONS";}'
# Load new settings before rebuilding the index
killall mds > /dev/null 2>&1
# Make sure indexing is enabled for the main volume
sudo mdutil -i on / > /dev/null
# Rebuild the index from scratch
sudo mdutil -E / > /dev/null
#osascript << EOF [paste script here] EOF
osascript << EOF
--Check if GUI Scripting is Enabled
tell application "System Events"
    if not UI elements enabled then
        set UI elements enabled to true
    end if
end tell

--Enable/Disable "Use all F1, F2, etc. keys as standard function keys" option in Keyboard & Mouse Preference pane and close System Preferences
tell application "System Events"
    tell application "System Preferences"
        reveal anchor "keyboardTab" of pane "com.apple.preference.keyboard"
    end tell
    click checkbox 1 of tab group 1 of window 1 of application process "System Preferences"
end tell
if application "System Preferences" is running then
    tell application "System Preferences" to quit
end if
EOF

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


Adds publish service crate helper.

Adds publish service crate helper.

#!/bin/sh

for D in `find . -maxdepth 1 -mindepth 1 -type d`;
do
    (cd $D ; echo "I am in `pwd`" ; cargo publish --dry-run)
done

error: pathspec 'rusoto/services/publish-services.sh' did not match any file(s) known to git


add chromium browser for linux install

add chromium browser for linux install

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


fix check functions

fix check functions


Added jenkins.bash for jenkins build jobs.

#!/bin/bash -x

export GOPATH=$WORKSPACE/build-sandbox                   # for go commands
export MOOV_HOME=$WORKSPACE/build-sandbox                # for build script
export LD_LIBRARY_PATH=$HOME/clibs/lib:$LD_LIBRARY_PATH  # for running tests

# Make my build sandbox where all code will go
[ ! -d $MOOV_HOME ] && mkdir -p $MOOV_HOME

# for compiling and linking, the clibs *need* to be in this location
# relative to the go source, otherwise compiling/linking will fail.
[ ! -d $MOOV_HOME/clibs ] && ln -s "$HOME/clibs" "$MOOV_HOME/clibs"

#hash=`git show-ref | head -n 1 | awk '{print $1}'`
python -u "$HOME/bin/build.py" tritium $GIT_BRANCH

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


Added the app debug script to admin scripts

#!/bin/bash

APP=`read -p "Application: " `
ARGS=`ps aux | grep node | grep "\-\-app $APP" | awk '{ split($0, s, / node /); print s[2] }'`

if [ "$ARGS" ]
then
    kill `ps aux | grep node | grep "\-\-app $APP" | awk '{ print $2 }'`
    `echo "node debug $ARGS"`
fi

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


Add a shell script that logs the build process for later profiling.

#!/bin/bash
# This script may be useful for developers to profile the build process itself.
#
# This shell script runs CMake and make, dumping all output into a log file.
# It also logs the CPU usage and memory information during the build.
# All log messages are timestamped to enable profiling.
#
# Dependencies:
# - ts
# sudo apt-get install -y libtime-duration-perl moreutils
# - vmstat and mpstat
# sudo apt-get install -y sysstat
#
# Usage: ./profile_build.sh
# Set the CMake and make command you want to use below.
# If CMakeLists.txt is detected, the script exits because in-source-tree build
# is not supported.
# If CMakeCache.txt is detected, the script skips cmake and runs make only.

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

set -e

CMAKE_COMMAND="cmake \
-D BUILD_SHARED_LIBS=On \
-D USE_TCMALLOC=0 \
-D CMAKE_BUILD_TYPE=Debug \
.. "
MAKE_COMMAND="make VERBOSE=1"
LOG_FILENAME=$LOG_FILENAME

# Continuously dump memory usage and cpu load info to files for later analysis
function start_stat_collectors {
  rm -f stats_*.txt
  vmstat -SM 3 | ts "%.s (%H:%M:%S)" > stats_mem.txt 3>&1 &
  PID_vmstat=$!
  mpstat 3 | ts "%.s (%H:%M:%S)" > stats_cpu.txt 2>&1  &
  PID_mpstat=$!
}

function kill_stat_collectors {
  kill $PID_vmstat
  kill $PID_mpstat
  exit
}

function check_directory {
  if [[ -f CMakeLists.txt ]]; then
    echo "Running the build in the source tree is not supported."
    exit 1
  fi
}

function log_repo_version_info {
  git log master... >> $LOG_FILENAME
  git diff master >> $LOG_FILENAME
}

function run_cmake {
  if [[ ! -f CMakeCache.txt ]]; then
    echo "$CMAKE_COMMAND" | tee -a $LOG_FILENAME
    $CMAKE_COMMAND 2>&1 | ts "%.s (%H:%M:%S)" | tee -a $LOG_FILENAME
  else
    echo "CMakeCache.txt detected. Not running CMake again."
  fi
}

function run_make {
  echo "$MAKE_COMMAND" | tee -a $LOG_FILENAME
  $MAKE_COMMAND 2>&1 | ts "%.s (%H:%M:%S)" | tee -a $LOG_FILENAME
}

function print_stats {
  avg_mem=`grep -v r stats_mem.txt | tr -s ' ' | awk -F " " '{s+= $6; c++} END {print s/c/1024}'`
  echo -e "\n\n"
  echo "Average memory used was $avg_mem GB"  | tee -a $LOG_FILENAME

  time_taken=`expr $END_TIME - $START_TIME`
  mins=`expr $time_taken / 60`
  secs=`expr $time_taken % 60`
  echo "Time taken was ${mins}m ${secs}s" | tee -a $LOG_FILENAME
}

check_directory
echo "Starting build in " `pwd`  >> $LOG_FILENAME
start_stat_collectors
trap kill_stat_collectors SIGHUP SIGINT SIGTERM

START_TIME=`date +"%s"`
run_cmake
run_make
END_TIME=`date +"%s"`
kill_stat_collectors
print_stats

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


Adding multipage tiff to OCR script

Adding multipage tiff to OCR script

error: pathspec 'src/test/resources/tiff_ocr2pdf.sh' did not match any file(s) known to git


Add script to update the template across dirs

#!/bin/bash
# strict mode http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'

function update_template(){
  # read from opts
  local dir_to_replace_in=$1
  local dir_to_read_from=$2

  # sources
  local package_name="package.json"
  local script_name="scripts.sh"
  local source_script="$dir_to_read_from/$script_name"
  local source_package="$dir_to_read_from/$package_name"
  local source_package_scripts=$(cat $source_package | json -a scripts)

  # vars for working on files
  local work_script
  local work_dir
  local work_package
  local work_package_scripts

  # ensure dependencies are installed
  command -v json >/dev/null 2>&1 || { echo >&2 "json is required but it's not installed.  I'll just install that for you with 'npm i -g json'."; npm i -g json; }

  echo "finding script files…"
  local script_files=$(find $dir_to_replace_in -iname scripts.sh -maxdepth 2)
  echo $(echo $script_files | tr ' ' '\n' | wc -l)" directories found"

  # for each match, replace
  for work_script in $script_files
  do
    work_dir=$(dirname ${work_script})
    work_package="$work_dir/$package_name"
    work_package_scripts=$(cat $work_package | json -a scripts)

    # replace the scripts file if necessary
    if [ "$(diff $work_script $source_script)" != "" ]; then
      cp -f $source_script $work_script
      echo "UPDATED: $work_script"
    fi

    if [ "$(diff <(echo "$work_package_scripts") <(echo "$source_package_scripts"))" != "" ]; then
      node -e "var work=require('$work_package'), source=$source_package_scripts, fs = require('fs'); work.scripts = source; fs.writeFileSync('$work_package', JSON.stringify(work, null, 2) + '\n')"
      # echo $(cat $work_package) \
      #   "{\"scripts\": $source_package_scripts }" | json --deep-merge -I -f $work_package > $work_package
      echo "UPDATED $work_package"
    fi
  done

  echo "DONE"
}
update_template $@

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


adjust data

adjust data

#!/bin/bash

set -e

echo "Installing Ansible  on Ubuntu..."
apt-get install -y software-properties-common
apt-add-repository ppa:ansible/ansible
#apt-get update
apt-get install -y --force-yes ansible
cp /vagrant/ansible/ansible.cfg /etc/ansible/ansible.cf

cp /vagrant/ansible/ansible.cfg /etc/ansible/ansible.cfg

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


[enh] Add a script to check reproducible build

#!/bin/bash

# Get to the root project
if [[ "_" == "_${PROJECT_DIR}" ]]; then
  SCRIPT_DIR=$(dirname $0)
  PROJECT_DIR=$(cd ${SCRIPT_DIR}/.. && pwd)
  export PROJECT_DIR
fi;

# Preparing Android environment
. ${PROJECT_DIR}/scripts/env-android.sh
[[ $? -ne 0 ]] && exit 1

cd ${PROJECT_DIR}

# ----------------------------------
# Check templates files build
# ----------------------------------

# Generate templates JS file
echo "--------------------------------"
echo "Building templates file... [1/2]"
gulp template > /dev/null
[[ $? -ne 0 ]] && exit 1

TEMPLATES_FILE="${PROJECT_DIR}/www/dist/dist_js/app/templates.js"
PLUGIN_TEMPLATES_FILE="${PROJECT_DIR}/www/dist/dist_js/plugins/templates.js"
if [[ ! -f ${TEMPLATES_FILE} ]] || [[ ! -f ${PLUGIN_TEMPLATES_FILE} ]]; then
  echo "ERROR - Missing file ${TEMPLATES_FILE} or ${PLUGIN_TEMPLATES_FILE}"
  exit 1;
fi;

# Keep a copy
rm -f "${TEMPLATES_FILE}.tmp"
rm -f "${PLUGIN_TEMPLATES_FILE}.tmp"
mv "${TEMPLATES_FILE}" "${TEMPLATES_FILE}.tmp"
mv "${PLUGIN_TEMPLATES_FILE}" "${PLUGIN_TEMPLATES_FILE}.tmp"

# Second generation
echo "Building templates file... [2/2]"
gulp template > /dev/null
[[ $? -ne 0 ]] && exit 1
echo "Building templates file [OK]"

# Check diff
echo "Checking diff between templates files..."
diff "${TEMPLATES_FILE}" "${TEMPLATES_FILE}.tmp" > /tmp/templates.js.diff
if [[ $? -ne 0 ]]; then
  echo "ERROR: Detected some differences: build is not reproducible!"
  echo "  Diff are visible at: /tmp/templates.js.diff"
  exit 1;
fi;
diff "${PLUGIN_TEMPLATES_FILE}" "${PLUGIN_TEMPLATES_FILE}.tmp" > /tmp/plugin_templates.js.diff
if [[ $? -ne 0 ]]; then
  echo "ERROR: Detected some differences: build is not reproducible!"
  echo "  Diff are visible at: /tmp/plugin_templates.js.diff"
  exit 1;
fi;
echo "Checking diff between templates files... [OK]"

# ----------------------------------
# Check web extension build
# ----------------------------------

# Compile
echo "----------------------------"
echo "Building web extension... [1/2]"
gulp webExtBuild --release > /dev/null

WEB_EXT_DIR="${PROJECT_DIR}/dist/web/ext"
if [[ $? -ne 0 ]] || [[ ! -d "${WEB_EXT_DIR}" ]]; then
  echo "ERROR - Build failed: missing folder ${WEB_EXT_DIR}"
  exit 1;
fi;

# Keep a copy
rm -rf "${WEB_EXT_DIR}.tmp"
mv "${WEB_EXT_DIR}" "${WEB_EXT_DIR}.tmp"

# Compile web extension, second time
echo "Building web extension... [2/2]"
gulp webExtBuild --release > /dev/null
[[ $? -ne 0 ]] && exit 1

echo "Building web extension... [OK]"

echo "Checking diff between builds..."
diff -arq "${WEB_EXT_DIR}" "${WEB_EXT_DIR}.tmp" > /tmp/webExtention.diff
if [[ $? -ne 0 ]]; then
  cat /tmp/webExtention.diff
  echo "ERROR: Detected some differences: build is not reproducible!"
  exit 1;
fi;
echo "Checking diff between builds... [OK]"

echo "SUCCESS: Build are reproducible!"

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


add script for starting fault-tolerance server

git-svn-id: 9146c88ff6d39b48099bf954d15d68f687b3fa69@2050 28e8926c-6b08-0410-baaa-805c5e19b8d6

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/lpellegr/scheduling.git/'


adding install script

adding 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/cjdb/applied-modern-cpp.git/'


image-inline: add missing test file

image-inline: add missing test file

followup to 95f7f4dc

start_test "shortcut icons aren't inlined"

URL="$TEST_ROOT/shortcut_icons.html?PageSpeedFilters=debug,rewrite_images"

# We expect to see just one inline image, because of the img tag.
fetch_until -save $URL 'grep -c data:image/png' 1

OUT=$(cat $FETCH_UNTIL_OUTFILE)

# All four icon link tags should be optimized but not inlined.
check_from "$OUT" grep \
  '<link rel="icon" href="[^<]*xCuppa.png.pagespeed.ic'
check_from "$OUT" grep \
  '<link rel="apple-touch-icon" href="[^<]*xCuppa.png.pagespeed.ic'
check_from "$OUT" grep \
  '<link rel="apple-touch-icon-precomposed" href="[^<]*xCuppa.png.pagespeed.ic'
check_from "$OUT" grep \
  '<link rel="apple-touch-startup-image" href="[^<]*xCuppa.png.pagespeed.ic'

# The image tag should have been inlined instead.
check_not_from "$OUT" grep \
  '<img src="[^<]*xCuppa.png.pagespeed.ic'

function appears_exactly_four_times() {
  test $(grep -c "$@") = 4
}

check_from "$OUT" appears_exactly_four_times \
  "The image was not inlined because it is a shortcut icon."

error: pathspec 'pagespeed/automatic/system_tests/shortcut_icons.sh' did not match any file(s) known to git


Added rebuild-old.sh script

Added rebuild-old.sh script

#!/bin/bash

set -e

if [ -z "$1" ]; then
    echo 'Usage: rebuild-old.sh <image_ref>'
    exit 1
fi
set -x

image=$1

dir_name="/tmp/$(uuidgen | sed -e 's|-||g')"
mkdir -p "$dir_name"

cat "Dockerfile" | sed -e "s|selenoid/base:1.0|$image|g" > "$dir_name/Dockerfile"
pushd "$dir_name"
echo "Adding fonts and encondings to $ref..."
docker build -t "$ref" .
popd
rm -Rf "$dir_name"
exit 0

error: pathspec 'selenium/base/base_2/rebuild-old.sh' did not match any file(s) known to git


Changing header

Changing header

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/Fiware/data.Cygnus.git/'


save this somewhere

save this somewhere

#!/bin/sh

git filter-branch --env-filter '

CORRECT_NAME="max6cn"
CORRECT_EMAIL="max6cn@users.noreply.github.com"

export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
' --tag-name-filter cat -- --branches --tags

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


Add init-repo.sh for repository setup

Add init-repo.sh for repository setup

#!/bin/bash
git config user.name "katoken-0215"
git config user.email katoken@katoken-0215.sakura.ne.jp

git config credential.helper cache

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


external

external

#!/bin/bash
wget http://www.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/mcg/resources/MCG-PreTrained.tgz
wget http://www.csie.ntu.edu.tw/~cjlin/cgi-bin/liblinear.cgi?+http://www.csie.ntu.edu.tw/~cjlin/liblinear+zip -O liblinear.zip
mkdir liblinear
unzip liblinear.zip -d liblinear
cd liblinear/liblinear-1.94
make
cd ../..
tar -zxvf MCG-PreTrained.tgz
echo "You need to change the path in MCG-PreTrained/root_dir.m!"

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


kernel-post-upgrade: simplify ESP & os-release checks

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/grawity/hacks.git/'


no need for sourcing and testing installer.sh

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


Created the coolest thing ever, a unit-testing framework for bash, 'bashful-litest'.  Litest='Litest lite test', get it?

#!/bin/bash

# Bashful is copyright 2009-2015 Dejay Clayton, all rights reserved:
#     https://github.com/dejayc/bashful
# Bashful is licensed under the 2-Clause BSD License:
#     http://opensource.org/licenses/BSD-2-Clause

# Initialize the namespace presence indicator.
{
    declare BASHFUL_MODULE_LITEST='bashful-litest.inc.sh'
}

# Define global variables for test specifications.  This is much easier than
# trying to pass multiline test results back from a testSpec function.
{
    declare TEST_DESC=''
    declare TEST_CMD=''
    declare TEST_EXP_OUTPUT=''
    declare -i TEST_EXP_STATUS=0
}

# function executeLitest:
#
# Refer to function _showUsage for a description of how Litest works.
function executeLitest()
{
    declare -i IGNORE_FAIL=0
    declare -i ITERATIONS=0
    declare -i VERBOSITY=1

    # Parse function options.
    declare -i OPTIND
    local OPT=''

    while getopts ":chist:v" OPT
    do
        case "${OPT}" in
        'c')
            clear
            ;;
        'h')
            _showUsage
            return
            ;;
        'i')
            let IGNORE_FAIL=1
            ;;
        's')
            let VERBOSITY=0
            ;;
        't')
            let ITERATIONS=${OPTARG}
            ;;
        'v')
            let VERBOSITY=2
            ;;
        *)
            echo "ERROR: Unknown flag '${OPTARG}'" >&2
            return 2
        esac
    done
    shift $(( OPTIND - 1 ))
    # Done parsing function options.

    local TEST_NAME="${1}"
    shift

    case "${TEST_NAME}" in
    '')
        _listAllTestNames
        ;;
    'all')
        _executeAllTests \
            "${*}" ${IGNORE_FAIL} ${VERBOSITY} ${ITERATIONS}
        ;;
    'list')
        _listAllTestNames "${*}"
        ;;
    *)
        _executeTestCasesForTest \
            "${TEST_NAME}" "${*}" ${IGNORE_FAIL} ${VERBOSITY} ${ITERATIONS}
        ;;
    esac
}

# Sample testSpec function to demonstrate usage.
function testSpec__litest()
{
    TEST_CASE="${1}"

    local DESC=''
    local CMD=''
    local OUT=''
    declare -i STAT=0

    # Automatically-incremented integers are used to designate the test cases,
    # just for simplicity of maintenance.  Textual test names could be used
    # here instead, if desired.
    declare -i I=1

    case "${TEST_CASE}" in
    $(( I++ )) )
        DESC="Test basic 'echo' functionality"
        CMD="echo -n 'hello'"
        OUT='hello'
        let STAT=0
        ;;
    $(( I++ )) )
        DESC='This test fails to match output'
        CMD="echo -n 'gotcha'"
        OUT='hello'
        let STAT=0
        ;;
    $(( I++ )) )
        DESC='This test fails to match status'
        CMD="echo -n 'hello'"
        OUT='hello'
        let STAT=1
        ;;
    all)
        _iterateTo ${I}
        ;;
    *)
        return 1
        ;;
    esac

    TEST_DESC="${DESC}"
    TEST_CMD="${CMD}"
    TEST_EXP_OUTPUT="${OUT}"
    let TEST_EXP_STATUS=${STAT}
    return 0
}

function testSpecs_all()
{
    declare -i SUPPRESS_HIDDEN="${1}"

    local FN_DECL_LIST="$( declare -f -F )"
    local TEST_NAME_LIST=''

    while read -r TEST_SPEC
    do
        local TEST_NAME="${TEST_SPEC#declare -f testSpec_}"

    declare -i OMIT_HIDDEN="${1}"

        [[ "${TEST_NAME}" == "${TEST_SPEC}" ]] && continue
        [[ "${TEST_NAME:0:1}" != '_' ||
           "${SUPPRESS_HIDDEN}" -eq 0 ]] && {

            TEST_NAME_LIST="${TEST_NAME_LIST} ${TEST_NAME}"
        }
    done <<< "${FN_DECL_LIST}"

    echo "${TEST_NAME_LIST# }"
}

function _describeAllTestCases()
{
    local TEST_NAMES_LIST
    TEST_NAMES_LIST=" $( _getAllTestNames 1 ) " || return

    declare -a TEST_NAMES=()
    read -r -a TEST_NAMES <<< "${TEST_NAMES_LIST}"
    declare -i TEST_NAMES_LEN=${#TEST_NAMES[@]}
    declare -i I=0

    while [ ${I} -lt ${TEST_NAMES_LEN} ]
    do
        local TEST_NAME="${TEST_NAMES[I]}"
        let I++

        _describeAllTestCasesForTest "${TEST_NAME}"
        echo
    done
}

function _describeAllTestCasesForTest()
{
    local TEST_NAME="${1}"

    echo "The following test cases are available for test '${TEST_NAME}':"

    TEST_CASES_LIST="$( _getAllTestCasesForTest "${TEST_NAME}" )" || return

    declare -a TEST_CASES
    read -r -a TEST_CASES <<< "${TEST_CASES_LIST}"
    declare -i TEST_CASES_LEN=${#TEST_CASES[@]}
    declare -i I=0

    while [ ${I} -lt ${TEST_CASES_LEN} ]
    do
        local TEST_CASE="${TEST_CASES[I]}"
        let I++

        _executeTestSpecForTestCase "${TEST_NAME}" "${TEST_CASE}" || return

        echo "${TEST_CASE}: ${TEST_DESC}"
    done
}

function _executeAllTests()
{
    local TEST_NAMES_LIST="${1}"
    declare -i IGNORE_FAIL="${2}"
    declare -i VERBOSITY="${3}"
    declare -i ITERATIONS="${4}"

    [[ -n "${TEST_NAMES_LIST}" ]] || {

        TEST_NAMES_LIST=" $( _getAllTestNames 1 ) " || return
    }

    _verifyTestNames "${TEST_NAMES_LIST}" || return

    declare -a TEST_NAMES
    read -r -a TEST_NAMES <<< "${TEST_NAMES_LIST}"
    declare -i TEST_NAMES_LEN=${#TEST_NAMES[@]}
    declare -i I=0

    while [ ${I} -lt ${TEST_NAMES_LEN} ]
    do
        _executeTestCasesForTest \
            "${TEST_NAMES[I]}" all \
            ${IGNORE_FAIL} ${VERBOSITY} ${ITERATIONS} || return

        let I++
    done
}

function _executeTestCase()
{
    local TEST_NAME="${1}"
    local TEST_CASE="${2}"
    local TEST_DESC="${3}"
    local TEST_CMD="${4}"
    local EXPECTED_OUTPUT="${5}"
    declare -i EXPECTED_STATUS="${6}"
    declare -i VERBOSITY="${7}"

    if [ -n "${TEST_DESC}" ]
    then
        [[ -n "${TEST_CMD}" && "${TEST_CMD}" != "${TEST_DESC}" ]] && {

            printf -v TEST_DESC '%b\n  %b' "${TEST_DESC}" "${TEST_CMD}"
        }
    else
        TEST_DESC="${TEST_CMD}"
    fi

    local HEADER="EXECUTING test '${TEST_NAME}' case '${TEST_CASE}'"

    if [ ${VERBOSITY} -eq 2 ]
    then
        echo "${HEADER}"
        echo
        echo "  ${TEST_DESC}"
        echo
    else
        printf '%s: ' "${HEADER}"
    fi

    declare -i STATUS=0
    local OUTPUT
    OUTPUT="$( eval "${TEST_CMD}" )" || let STATUS=${?}

    [[ ${STATUS} -eq ${EXPECTED_STATUS} && \
       "${OUTPUT}" == "${EXPECTED_OUTPUT}" ]] && {

        echo 'PASS'
        [[ ${VERBOSITY} -eq 2 ]] && echo
        return 0
    }

    echo 'FAIL'

    [[ ${VERBOSITY} -ne 0 ]] && {

        echo "${TEST_DESC}"
        echo
    }

    [[ ${VERBOSITY} -gt 0 ]] && {

        if [ ${STATUS} -ne ${EXPECTED_STATUS} ]
        then
            echo \
"Status ${STATUS} did not match expected status ${EXPECTED_STATUS}"
            echo
        else
            cat \
<<ERROR_MSG
The following output:

  ${OUTPUT}

did not match the expected output:

  ${EXPECTED_OUTPUT}

ERROR_MSG
        fi
    }

    return 1
}

function _executeTestCasesForTest()
{
    local TEST_NAME="${1}"
    local TEST_CASES_LIST="${2}"
    declare -i IGNORE_FAIL="${3}"
    declare -i VERBOSITY="${4}"
    declare -i ITERATIONS="${5}"

    case "${TEST_CASES_LIST}" in
    '')
        _listTestCasesForTest "${TEST_NAME}"
        return
        ;;
    'all')
        TEST_CASES_LIST="$( _getAllTestCasesForTest "${TEST_NAME}" )" \
            || return
        ;;
    'list')
        _describeAllTestCasesForTest "${TEST_NAME}"
        return
        ;;
    *)
        _verifyTestCases "${TEST_NAME}" "${TEST_CASES_LIST}" || return
        ;;
    esac

    declare -a TEST_CASES
    read -r -a TEST_CASES <<< "${TEST_CASES_LIST}"
    declare -i TEST_CASES_LEN=${#TEST_CASES[@]}
    declare -i I=0

    while [ ${I} -lt ${TEST_CASES_LEN} ]
    do
        local TEST_CASE="${TEST_CASES[I]}"
        let I++

        _executeTestSpecForTestCase "${TEST_NAME}" "${TEST_CASE}" || return

        if [ ${ITERATIONS} -gt 0 ]
        then
            _executeTestLoop \
                "${TEST_NAME}" "${TEST_CASE}" "${TEST_DESC}" "${TEST_CMD}" \
                ${ITERATIONS} ${VERBOSITY} ${IGNORE_FAIL}
        else
            declare -i STATUS=0

            _executeTestCase \
                "${TEST_NAME}" "${TEST_CASE}" "${TEST_DESC}" "${TEST_CMD}" \
                "${TEST_EXP_OUTPUT}" ${TEST_EXP_STATUS} ${VERBOSITY}

            let STATUS=${?}

            [[ ${STATUS} -eq 0 || ${IGNORE_FAIL} -ne 0 ]] || return ${STATUS}
        fi
    done
}

function _executeTestLoop()
{
    local TEST_NAME="${1}"
    local TEST_CASE="${2}"
    local TEST_DESC="${3}"
    local TEST_CMD="${4}"
    declare -i ITERATIONS="${5}"
    declare -i VERBOSITY="${6}"
    declare -i IGNORE_FAIL="${7}"

    declare -i STATUS=0
    declare -i I=0

    if [ ${IGNORE_FAIL} -ne 0 ]
    then
        IFS='' read -r -d '' EVAL \
<<EVAL
        while [ \${I} -lt \${ITERATIONS} ]
        do
            ${TEST_CMD} >/dev/null
            STATUS=\${?}
            let I++
        done
EVAL
    else
        IFS='' read -r -d '' EVAL \
<<EVAL
        while [ \${I} -lt \${ITERATIONS} ]
        do
            ${TEST_CMD} >/dev/null || {

                STATUS=\${?}
                break
            }
            let I++
        done
EVAL
    fi

    echo "EXECUTING test '${TEST_NAME}' case '${TEST_CASE}' @ ${ITERATIONS}x"
    echo

    [[ -n "${TEST_DESC}" ]] && echo "  ${TEST_DESC}"

    echo "  ${TEST_CMD}"

    time (
        eval "${EVAL}"
        echo
        echo "${I} out of ${ITERATIONS} completed; final status was ${STATUS}"
    )
    echo
}

function _executeTestSpecForTestCase()
{
    local TEST_NAME="${1}"
    local TEST_CASE="${2}"

    local SPEC_FN
    SPEC_FN="$( _getTestSpecFn "${TEST_NAME}" )" || return

    eval "${SPEC_FN}" "${TEST_CASE}" || {

        declare -i STATUS=${?}

        echo \
"ERROR: '${SPEC_FN} ${TEST_CASE}' returned an error status code" >&2

        return ${STATUS}
    }
}

function _getAllTestCasesForTest()
{
    local TEST_NAME="${1}"

    local SPEC_FN
    SPEC_FN="$( _getTestSpecFn "${TEST_NAME}" )" || return

    local TEST_CASES_LIST
    TEST_CASES_LIST="$( eval "${SPEC_FN}" all )" || {

        declare -i STATUS=${?}
        echo "ERROR: '${SPEC_FN} all' returned an error status code" >&2
        return ${STATUS}
    }

    echo -n "${TEST_CASES_LIST}"
}

function _getAllTestNames()
{
    declare -i SUPPRESS_HIDDEN="${1}"

    local TEST_NAMES_LIST
    TEST_NAMES_LIST="$( testSpecs_all ${SUPPRESS_HIDDEN} )" || {

        declare -i STATUS=${?}
        echo "ERROR: '${SPEC_FN}' returned an error status code" >&2
        return ${STATUS}
    }

    echo -n "${TEST_NAMES_LIST}"
}

function _getTestSpecFn()
{
    local TEST_NAME="${1}"

    [[ -n "${TEST_NAME}" ]] || {

        echo "INTERNAL ERROR: Missing test name" >&2
        return 1
    }

    local SPEC_FN="testSpec_${TEST_NAME}"

    declare -f -F "${SPEC_FN}" &> /dev/null || {

        SPEC_FN="testSpec__${TEST_NAME}"

        declare -f -F "${SPEC_FN}" &> /dev/null || {

            echo "ERROR: Unknown test '${TEST_NAME}'" >&2
            return 1
        }
    }

    echo -n "${SPEC_FN}"
}

function _iterateTo()
{
    declare -i I="${1}"
    declare -i L=$(( I - 1 ))
    declare -i J=1
    while [ ${J} -lt ${L} ]
    do
        echo -n "${J} "
        let J++
    done

    [[ ${J} -eq ${L} ]] && echo "${J}"
    return
}

function _listAllTestNames()
{
    local TEST_NAMES_LIST="${1}"

    declare -a TEST_NAMES
    read -r -a TEST_NAMES <<< "${TEST_NAMES_LIST}"
    declare -i TEST_NAMES_LEN=${#TEST_NAMES[@]}

    if [ ${TEST_NAMES_LEN} -gt 0 ]
    then
        [[ ${TEST_NAMES_LEN} -ne 0 && "${TEST_NAMES[0]}" == 'all' ]] && {

            _describeAllTestCases
            return
        }

        declare -i I=0

        while [ ${I} -lt ${TEST_NAMES_LEN} ]
        do
            _describeAllTestCasesForTest "${TEST_NAMES[I]}"
            let I++

            [[ ${I} -lt TEST_NAMES_LEN ]] && echo
        done
    else
        local TEST_NAMES_LIST
        TEST_NAMES_LIST="$( _getAllTestNames 1 )" || return

        echo 'The following tests are available:'
        echo "${TEST_NAMES_LIST}"
    fi
}

function _listTestCasesForTest()
{
    local TEST_NAME="${1}"

    local TEST_CASES_LIST
    TEST_CASES_LIST="$( _getAllTestCasesForTest "${TEST_NAME}" )" || return

    echo "The following test cases are available for test '${TEST_NAME}':"
    echo "${TEST_CASES_LIST}"
    echo
    echo "Specify '${TEST_NAME} list' to list all test case descriptions."
}

function _showUsage()
{
    local CMD="${0##*/}"
    local USAGE_TEXT
    local USAGE_SYNOPSIS

    IFS='' read -r -d '' USAGE_SYNOPSIS <<USAGE_SYNOPSIS
Usage: ${CMD}
       ${CMD} -h
       ${CMD} [-c] [-i] [-s] [-t count] 'all' [group ...]
       ${CMD} [-c] [-i] [-s] [-t count] [group 'all']
       ${CMD} [-c] [-i] [-s] [-t count] [group [case ...]]
       ${CMD} 'list' ['all']
       ${CMD} 'list' [group ...]
       ${CMD} [group] 'list'
USAGE_SYNOPSIS

    IFS='' read -r -d '' USAGE_TEXT <<'USAGE_TEXT'
  Executes the specified test cases within the specified test group,
  optionally timing the duration required to execute the specified number of
  test iterations.

  If no test groups are specified, or 'list' is specified without test cases,
  the list of available test groups will be listed.

  If 'list' 'all' is specified, all test cases for all test groups will be
  listed with descriptions.

  If 'list' is specified with one or more test groups, all test cases for the
  specified test groups will be listed with descriptions.

  If a test group is specified without test cases, the list of available test
  cases for the specified test group will be listed.

  If 'all' is specified without test cases, all test cases within all test
  groups will be executed.

  If 'all' is specified with one or more test groups, all test cases within
  the specified test groups will be executed.

  If a test group is specified with one or more test cases, the specified test
  cases will be executed.

  If a test group is specified with 'all' as the next argument, all test cases
  for the specified test group will be executed.

  If a test group is specified with 'list' as the next argument, all test cases
  for the specified test group will be listed with descriptions.

  Litest may be called with the following optional flags:

  -c causes the screen to be cleared prior to test execution.

  -h shows usage information.

  -i allows remaining test cases to be executed even if some test cases fail.
     By default, Litest aborts the execution of remaining test cases if one
     fails.

  -s reports the results of each test case in a summarized format, supressing
     the test description, executed test command, and superfluous whitespace.
     By default, only passing tests are summarized, and failing tests are
     reported in verbose mode.

  -t allows an iteration count to be specified, which causes test executions
     to be timed as they are executed the specified number of iterations.

  -v reports the results of each test case in verbose format, in which the
     description and executed command for each test case is reported.  By
     default, only failing tests are reported in verbose mode.

  Each test group must correlate with a function created by the test author.
  The name of the function must consist of the format 'testSpec_GROUP', where
  GROUP must be replaced with the actual name of the test group.  For example,
  if the test author created a test group named 'text', a function must exist
  named 'testSpec_text'.

  'testSpec' functions may be designated as 'hidden' by naming the prefix of
  the function as 'testSpec__' (with two underscores) instead of 'testSpec_'.
  Doing so will cause the test to be omitted from all lists of tests available
  to be run, and will also cause the test to be skipped when 'all' tests are
  run.

  The purpose of the 'testSpec' functions are to accept a single parameter as
  input, which designates the test case to execute, and in response, set the
  following global variables to define the behavior of the test case:

     TEST_DESC: A brief, human-readable description of the test case goals.
        E.g. "Test basic 'echo' functionality"

     TEST_CMD: The shell command that comprises the test case to execute.
        E.g. "echo 'hello'"

     TEST_EXP_OUTPUT: The output expected to be received as a result of
        executing TEST_CMD.  The test will be considered a failure if the
        actual command output doesn't match the expected output.  E.g. 'hello'

     TEST_EXP_STATUS: The status value expected to be returned upon execution
        of TEST_CMD.  The test will be considered a failure if the actual
        command status doesn't match the expected status.  E.g. 0

  The testSpec function must also be capable of echoing the entire list of
  supported test cases for the test group, if 'all' is received as the first
  parameter.  For example, 'testSpec_text all' might echo 'echo sort unique'
  in response.

  'testSpec' functions that return a status code other than 0 will cause
  Litest to abort.

  For simplicity, the test author may choose to use ascending integers instead
  of textual test case names.  For reference on how to easily implement this,
  refer to the reference function 'testSpec__litest'.
USAGE_TEXT

    echo "${USAGE_SYNOPSIS}"
    echo "${USAGE_TEXT}"
}

function _verifyTestCases()
{
    local TEST_NAME="${1}"
    local TEST_CASES_LIST="${2}"

    local ALL_TEST_NAMES
    ALL_TEST_NAMES=" $( _getAllTestCasesForTest "${TEST_NAME}" ) " || return

    declare -a TEST_CASES=()
    read -r -a TEST_CASES <<< "${TEST_CASES_LIST}"
    declare -i TEST_CASES_LEN=${#TEST_CASES[@]}
    declare -i I=0

    while [ ${I} -lt ${TEST_CASES_LEN} ]
    do
        local TEST_CASE="${TEST_CASES[I]}"
        let I++

        [[ "${ALL_TEST_NAMES}" =~ " ${TEST_CASE} " ]] || {

            echo \
"ERROR: Unknown test case '${TEST_CASE}' for test '${TEST_NAME}'" >&2

            return 1
        }
    done
}

function _verifyTestNames()
{
    local TEST_NAMES_LIST="${1}"

    local ALL_TEST_NAMES
    ALL_TEST_NAMES=" $( _getAllTestNames ) " || return

    declare -a TEST_NAMES=()
    read -r -a TEST_NAMES <<< "${TEST_NAMES_LIST}"
    declare -i TEST_NAMES_LEN=${#TEST_NAMES[@]}
    declare -i I=0

    while [ ${I} -lt ${TEST_NAMES_LEN} ]
    do
        local TEST_NAME="${TEST_NAMES[I]}"
        let I++

        [[ "${ALL_TEST_NAMES}" =~ " ${TEST_NAME} " ]] || {

            echo "ERROR: Unknown test '${TEST_NAME}'" >&2
            return 1
        }
    done
}

error: pathspec 'bashful-litest.inc.sh' did not match any file(s) known to git


sysroot: add SDK_VERSION to artik_sysroot_release

This patch adds routine that adds SDK_VERSION to artik_sysroot_release.
Because libartik-sdk libraries are installed in official image,
we don't need to seperate building sysroot and installing sdk libraries.
So we can know sdk version and add it in this step.

Change-Id: Ibb5c986bd6b26447484dc0501cc36d1793026343
Signed-off-by: Sowon Na <7ed402a04f2fdc9693a203092231aea9e041664b@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/'


AppVeyor: don't fail if the dynrun rebuild fails.

#!/bin/bash
################################################################################
#  OASIS: architecture for building OCaml libraries and applications           #
#                                                                              #
#  Copyright (C) 2011-2013, Sylvain Le Gall                                    #
#  Copyright (C) 2008-2011, OCamlCore SARL                                     #
#                                                                              #
#  This library is free software; you can redistribute it and/or modify it     #
#  under the terms of the GNU Lesser General Public License as published by    #
#  the Free Software Foundation; either version 2.1 of the License, or (at     #
#  your option) any later version, with the OCaml static compilation           #
#  exception.                                                                  #
#                                                                              #
#  This library is distributed in the hope that it will be useful, but         #
#  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY  #
#  or FITNESS FOR A PARTICULAR PURPOSE. See the file COPYING for more          #
#  details.                                                                    #
#                                                                              #
#  You should have received a copy of the GNU Lesser General Public License    #
#  along with this library; if not, write to the Free Software Foundation,     #
#  Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA               #
################################################################################

function run {
    NAME=$1
    shift
    echo -n "$NAME ... "
    $@
    CODE=$?
    if [ $CODE -ne 0 ]; then
        echo "... $NAME failed!"
        exit $CODE
    else
        echo "... $NAME OK"
    fi
}

cd "$APPVEYOR_BUILD_FOLDER"

export OCAMLRUNPARAM=b

run "OPAM initialization" opam init -y -a
run "Install packages" opam install -y ocamlfind ocamlmod ocamlify ounit \
  fileutils ounit
eval $(opam config env)
export OCAML_TOPLEVEL_PATH=$(opam config var toplevel)

run "OASIS Configure step" ocaml setup.ml -configure
run "OASIS Build step" ocaml setup.ml -build

run "Install" ocaml setup.ml -install

echo "------------------------------------------------------------"
echo "Rebuild with dynamic mode"
run "Setup" ./Main.native setup -setup-update dynamic
run "Configure" ocaml setup.ml -info -configure
# TODO: temporary fix, remove
run "Build" ocaml setup.ml -build || true

#!/bin/bash
################################################################################
#  OASIS: architecture for building OCaml libraries and applications           #
#                                                                              #
#  Copyright (C) 2011-2013, Sylvain Le Gall                                    #
#  Copyright (C) 2008-2011, OCamlCore SARL                                     #
#                                                                              #
#  This library is free software; you can redistribute it and/or modify it     #
#  under the terms of the GNU Lesser General Public License as published by    #
#  the Free Software Foundation; either version 2.1 of the License, or (at     #
#  your option) any later version, with the OCaml static compilation           #
#  exception.                                                                  #
#                                                                              #
#  This library is distributed in the hope that it will be useful, but         #
#  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY  #
#  or FITNESS FOR A PARTICULAR PURPOSE. See the file COPYING for more          #
#  details.                                                                    #
#                                                                              #
#  You should have received a copy of the GNU Lesser General Public License    #
#  along with this library; if not, write to the Free Software Foundation,     #
#  Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA               #
################################################################################

function run {
    NAME=$1
    shift
    echo -n "$NAME ... "
    $@
    CODE=$?
    if [ $CODE -ne 0 ]; then
        echo "... $NAME failed!"
        exit $CODE
    else
        echo "... $NAME OK"
    fi
}

cd "$APPVEYOR_BUILD_FOLDER"

run "OPAM initialization" opam init -y -a
run "Install packages" opam install -y ocamlfind ocamlmod ocamlify ounit \
  fileutils ounit
eval $(opam config env)
export OCAML_TOPLEVEL_PATH=$(opam config var toplevel)

run "OASIS Configure step" ocaml setup.ml -configure
run "OASIS Build step" ocaml setup.ml -build

run "Install" ocaml setup.ml -install

echo "------------------------------------------------------------"
echo "Rebuild with dynamic mode"
run "Setup" ./Main.native setup -setup-update dynamic
run "Configure" ocaml setup.ml -info -configure
run "Build" ocaml setup.ml -build


add alias for rspec to zeus plugin

add alias for rspec to zeus plugin

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/yukimemi/oh-my-zsh.git/'


Turn querying E-Mails off after dbRestore on Test

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/michalroxorpl/settings.git/'


Changed back to afterany but foolproof

Changed back to afterany but foolproof

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


add execute perm

add execute perm

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/stanxii/indexRiver.git/'


[openthread] enable coaps feature (#1851)

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

./bootstrap

./configure                             \
    --enable-fuzz-targets               \
    --enable-application-coap           \
    --enable-application-coap-secure    \
    --enable-border-agent               \
    --enable-border-router              \
    --enable-cert-log                   \
    --enable-channel-manager            \
    --enable-channel-monitor            \
    --enable-child-supervision          \
    --enable-commissioner               \
    --enable-dhcp6-client               \
    --enable-dhcp6-server               \
    --enable-dns-client                 \
    --enable-diag                       \
    --enable-dns-client                 \
    --enable-ftd                        \
    --enable-jam-detection              \
    --enable-joiner                     \
    --enable-legacy                     \
    --enable-mac-filter                 \
    --enable-mtd-network-diagnostic     \
    --enable-raw-link-api               \
    --enable-service                    \
    --enable-udp-proxy                  \
    --disable-docs

make -j$(nproc)

find . -name '*-fuzzer' -exec cp -v '{}' $OUT ';'
find . -name '*-fuzzer.dict' -exec cp -v '{}' $OUT ';'
find . -name '*-fuzzer.options' -exec cp -v '{}' $OUT ';'

fuzzers=$(find tests/fuzz -name "*-fuzzer")
for f in $fuzzers; do
    fuzzer=$(basename $f -fuzzer)

    if [ -d "tests/fuzz/corpora/${fuzzer}" ]; then
	zip -j $OUT/$(basename $f)_seed_corpus.zip tests/fuzz/corpora/${fuzzer}/*
    fi
done

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

./bootstrap

./configure                             \
    --enable-fuzz-targets               \
    --enable-application-coap           \
    --enable-border-agent               \
    --enable-border-router              \
    --enable-cert-log                   \
    --enable-channel-manager            \
    --enable-channel-monitor            \
    --enable-child-supervision          \
    --enable-commissioner               \
    --enable-dhcp6-client               \
    --enable-dhcp6-server               \
    --enable-dns-client                 \
    --enable-diag                       \
    --enable-dns-client                 \
    --enable-ftd                        \
    --enable-jam-detection              \
    --enable-joiner                     \
    --enable-legacy                     \
    --enable-mac-filter                 \
    --enable-mtd-network-diagnostic     \
    --enable-raw-link-api               \
    --enable-service                    \
    --enable-udp-proxy                  \
    --disable-docs

make -j$(nproc)

find . -name '*-fuzzer' -exec cp -v '{}' $OUT ';'
find . -name '*-fuzzer.dict' -exec cp -v '{}' $OUT ';'
find . -name '*-fuzzer.options' -exec cp -v '{}' $OUT ';'

fuzzers=$(find tests/fuzz -name "*-fuzzer")
for f in $fuzzers; do
    fuzzer=$(basename $f -fuzzer)

    if [ -d "tests/fuzz/corpora/${fuzzer}" ]; then
	zip -j $OUT/$(basename $f)_seed_corpus.zip tests/fuzz/corpora/${fuzzer}/*
    fi
done


go bindata helper script

go bindata helper script

#!/bin/bash
# We pack the configuration templates using go-bindata.
# go get -u go-bindata.  This is included in our binary as bindata.go.  For now we include this file in the source checkout also.
rm bindata.go ||true
go-bindata templates/ k8s_certs/*.sh config/

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


Add "OS/2" to the op_sys field.

Add "OS/2" to the op_sys field.

#!/bin/sh
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.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.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are Copyright (C) 1998
# Netscape Communications Corporation. All Rights Reserved.
#
# Contributor(s): Terry Weissman <terry@mozilla.org>

mysql > /dev/null 2>/dev/null << OK_ALL_DONE

use bugs;

drop table bugs;
OK_ALL_DONE

mysql << OK_ALL_DONE
use bugs;
create table bugs (
bug_id mediumint not null auto_increment primary key,
assigned_to mediumint not null, # This is a comment.
bug_file_loc text,
bug_severity enum("critical", "major", "normal", "minor", "trivial", "enhancement") not null,
bug_status enum("NEW", "ASSIGNED", "REOPENED", "RESOLVED", "VERIFIED", "CLOSED") not null,
creation_ts datetime,
delta_ts timestamp,
short_desc mediumtext,
long_desc mediumtext,
op_sys enum("All", "Windows 3.1", "Windows 95", "Windows 98", "Windows NT", "Mac System 7", "Mac System 7.5", "Mac System 7.1.6", "Mac System 8.0", "AIX", "BSDI", "HP-UX", "IRIX", "Linux", "OSF/1", "Solaris", "SunOS", "OS/2", "other") not null,
priority enum("P1", "P2", "P3", "P4", "P5") not null,
product varchar(16) not null,
rep_platform enum("All", "DEC", "HP", "Macintosh", "PC", "SGI", "Sun", "Other"),
reporter mediumint not null,
version varchar(16) not null,
area enum("BUILD", "CODE", "CONTENT", "DOC", "PERFORMANCE", "TEST", "UI", "i18n", "l10n") not null,
component varchar(50) not null,
resolution enum("", "FIXED", "INVALID", "WONTFIX", "LATER", "REMIND", "DUPLICATE", "WORKSFORME") not null,

index (assigned_to),
index (delta_ts),
index (bug_severity),
index (bug_status),
index (priority),
index (product),
index (reporter),
index (version),
index (area),
index (component),
index (resolution)

);

show columns from bugs;
show index from bugs;

OK_ALL_DONE

#!/bin/sh
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.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.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are Copyright (C) 1998
# Netscape Communications Corporation. All Rights Reserved.
#
# Contributor(s): Terry Weissman <terry@mozilla.org>

mysql > /dev/null 2>/dev/null << OK_ALL_DONE

use bugs;

drop table bugs;
OK_ALL_DONE

mysql << OK_ALL_DONE
use bugs;
create table bugs (
bug_id mediumint not null auto_increment primary key,
assigned_to mediumint not null, # This is a comment.
bug_file_loc text,
bug_severity enum("critical", "major", "normal", "minor", "trivial", "enhancement") not null,
bug_status enum("NEW", "ASSIGNED", "REOPENED", "RESOLVED", "VERIFIED", "CLOSED") not null,
creation_ts datetime,
delta_ts timestamp,
short_desc mediumtext,
long_desc mediumtext,
op_sys enum("All", "Windows 3.1", "Windows 95", "Windows 98", "Windows NT", "Mac System 7", "Mac System 7.5", "Mac System 7.1.6", "Mac System 8.0", "AIX", "BSDI", "HP-UX", "IRIX", "Linux", "OSF/1", "Solaris", "SunOS", "other") not null,
priority enum("P1", "P2", "P3", "P4", "P5") not null,
product varchar(16) not null,
rep_platform enum("All", "DEC", "HP", "Macintosh", "PC", "SGI", "Sun", "Other"),
reporter mediumint not null,
version varchar(16) not null,
area enum("BUILD", "CODE", "CONTENT", "DOC", "PERFORMANCE", "TEST", "UI", "i18n", "l10n") not null,
component varchar(50) not null,
resolution enum("", "FIXED", "INVALID", "WONTFIX", "LATER", "REMIND", "DUPLICATE", "WORKSFORME") not null,

index (assigned_to),
index (delta_ts),
index (bug_severity),
index (bug_status),
index (priority),
index (product),
index (reporter),
index (version),
index (area),
index (component),
index (resolution)

);

show columns from bugs;
show index from bugs;

OK_ALL_DONE


More minor fixes

More minor fixes

git-svn-id: 50f83ef66c13f323b544ac924010c921a9f4a0f7@3533 00569f92-eb28-0410-84fd-f71c24880f43

#!/bin/sh
#
# This script generates a .run file that will install DMDirc
#
# DMDirc - Open Source IRC Client
# Copyright (c) 2006-2008 Chris Smith, Shane Mc Cormack, Gregory Holmes
#
# 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.

# Final Name of the installer (without file extention)
INSTALLERNAME=DMDirc-Setup
# Location of .run stub start
STARTLINE=`grep -n "^###START INCLUDE###$" $0`
STARTLINE=$((${STARTLINE%%:*} + 1))
# full name of the file to output to
RUNNAME="${PWD}/${INSTALLERNAME}.run"

# Compress stuff!
compress() {
	tar cvfh - $@ | gzip - 2>/dev/null >>${RUNNAME} || {
		echo "Compression failed."
		kill -15 $$;
	};
}

# Go!
echo "-----------"
if [ -e "${RUNNAME}" ]; then
	echo "Removing existing .run file"
	rm -Rf ./*.run
fi

showHelp() {
	echo "This will generate a DMDirc installer for a unix based system."
	echo "The following command line arguments are known:"
	echo "---------------------"
	echo "-h, --help                Help information"
	echo "-r, --release <version>   Generate a file based on an svn tag (or branch with -b aswell)"
	echo "-b, --branch              Release in -r is a branch "
	echo "-p, --plugins <plugins>   What plugins to add to the jar file"
	echo "-c, --compile             Recompile the .jar file"
	echo "    --jre                 Include the JRE in this installer"
	echo "    --jre64               Include the 64-Bit JRE in this installer"
	echo "    --jar <file>          use <file> as DMDirc.jar"
	echo "    --current             Use the current folder as the base for the build"
	echo "-t, --tag <tag>           Tag to add to final exe name to distinguish this build from a standard build"
	echo "-k, --keep                Keep the existing source tree when compiling"
	echo "                          (don't svn update beforehand)"
	echo "---------------------"
	exit 0;
}

# Check for some CLI params
compileJar="false"
updateSVN="true"
isRelease=""
finalTag=""
BRANCH="0"
plugins=""
location="../../../"
jarfile=""
current=""
jre=""
jrename="jre" # Filename for JRE without the .bin
while test -n "$1"; do
	case "$1" in
		--plugins|-p)
			shift
			plugins=${1}
			;;
		--jar)
			shift
			jarfile=${1}
			;;
		--jre)
			jre="http://www.dmdirc.com/getjava/linux/i686"
			;;
		--jre64)
			jre="http://www.dmdirc.com/getjava/linux/x86_64"
			jrename="jre64"
			;;
		--current)
			location="../../"
			current="1"
			;;
		--compile|-c)
			compileJar="true"
			;;
		--release|-r)
			shift
			isRelease=${1}
			;;
		--tag|-t)
			shift
			finalTag=${1}
			RUNNAME="${PWD}/${INSTALLERNAME}-${1}.run"
			;;
		--keep|-k)
			updateSVN="false"
			;;
		--help|-h)
			showHelp;
			;;
		--branch|-b)
			BRANCH="1"
			;;
	esac
	shift
done
if [ "" = "${current}" ]; then
	jarPath="${location}trunk"
else
	jarPath="${location}"
fi
if [ "${isRelease}" != "" ]; then
	if [ "${BRANCH}" != "0" ]; then
		if [ -e "${location}/${isRelease}" ]; then
			jarPath="${location}/${isRelease}"
		else
			echo "Branch "${isRelease}" not found."
			exit 1;
		fi
	else
		if [ -e "${location}/${isRelease}" ]; then
			jarPath="${location}/${isRelease}"
		else
			echo "Tag "${isRelease}" not found."
			exit 1;
		fi
	fi
fi

if [ "" = "${jarfile}" ]; then
	jarfile=${jarPath}"/dist/DMDirc.jar"
	if [ ! -e ${jarPath}"/dist/DMDirc.jar" -o "${compileJar}" = "true" ]; then
		echo "Creating jar.."
		OLDPWD=${PWD}
		cd ${jarPath}
		if [ "${updateSVN}" = "true" ]; then
			svn update
		fi
		rm -Rf build dist
		ant jar
		if [ ! -e "dist/DMDirc.jar" ]; then
			echo "There was an error creating the .jar file. Aborting."
			exit 1;
		fi;
		cd ${OLDPWD}
	fi;
elif [ ! -e "${jarfile}" ]; then
	echo "Requested Jar file (${jarfile}) does not exist."
	exit 1;
fi;

if [ "" = "${plugins}" ]; then
	echo "Linking jar (${jarfile}).."
	ln -sf ${jarfile} "./DMDirc.jar"
else
	echo "Copying jar (${jarfile}).."
	cp ${jarfile} "./DMDirc.jar"

	echo "Adding plugins to jar"
	ln -sf ${jarPath}"/plugins"
	pluginList=""
	for plugin in ${plugins}; do
		pluginList=${pluginList}" plugins/${plugin}"
	done
	jar -uvf "DMDirc.jar" ${pluginList}
	rm -Rf plugins;
fi

echo "Creating .run file"
echo "Adding stub.."
tail -n +${STARTLINE} $0 > ${RUNNAME}

# Add release info.
awk '{gsub(/###ADDITIONAL_STUFF###/,"isRelease=\"'${isRelease}'\"");print}' ${RUNNAME} > ${RUNNAME}.tmp
mv ${RUNNAME}.tmp ${RUNNAME}

FILES="DMDirc.jar";
echo "Compressing files.."
for FILE in "getjre.sh" "installjre.sh" "progressbar.sh"; do
	if [ -e "${FILE}" ]; then
		FILES="${FILES} ${FILE}"
	fi
done;

if [ "" != "${jre}" ]; then
	if [ ! -e "../common/${jrename}.bin" ]; then
		echo "Downloading JRE to include in installer"
		wget ${jre} -O ../common/${jrename}.bin
	fi
	ln -sf ../common/${jrename}.bin jre.bin
	FILES="${FILES} jre.bin"
fi;

if [ -e "setup.sh" ]; then
	FILES="${FILES} setup.sh"
else
	echo "[WARNING] Creating setup-less archive. This will just extract and immediately delete the .jar file unless the -e flag is used"
fi

if [ -e "../common/installer.jar" ]; then
	ln -sf ../common/installer.jar ./installer.jar
	FILES="${FILES} installer.jar"
else
	echo "[WARNING] Creating installer-less archive - relying on setup.sh"
fi

if [ -e ${jarPath}"/src/com/dmdirc/res/source/logo.svg" ]; then
	ln -sf ${jarPath}"/src/com/dmdirc/res/source/logo.svg" ./icon.svg
	FILES="${FILES} icon.svg"
fi

if [ "${isRelease}" != "" ]; then
	DOCSDIR=${jarPath}
else
	DOCSDIR="../common"
fi

if [ -e "${DOCSDIR}/README.TXT" ]; then
	ln -sf "${DOCSDIR}/README.TXT" .
	FILES="${FILES} README.TXT"
fi

if [ -e "${DOCSDIR}/CHANGES.TXT" ]; then
	ln -sf "${DOCSDIR}/CHANGES.TXT" .
	FILES="${FILES} CHANGES.TXT"
elif [ -e "${DOCSDIR}/CHANGELOG.TXT" ]; then
	ln -sf "${DOCSDIR}/CHANGELOG.TXT" .
	FILES="${FILES} CHANGELOG.TXT"
fi

if [ -e "${jarPath}/launcher/linux" ]; then
	ln -sf ${jarPath}/launcher/linux/DMDirc.sh .
	FILES="${FILES} DMDirc.sh"
fi

compress $FILES

MD5BIN=`which md5sum`
AWK=`which awk`
getMD5() {
	echo "test" | ${MD5BIN}
	if [ $? -eq 0 ]; then
		getMD5Linux $@
	else
		getMD5OSX $@
	fi;
}

getMD5Linux() {
	# Everything below the MD5SUM Line
	MD5LINE=`grep -na "^MD5=\".*\"$" ${1}`
	MD5LINE=$((${MD5LINE%%:*} + 1))

	MD5SUM=`tail -n +${MD5LINE} "${1}" | ${MD5BIN} - | ${AWK} '{print $1}'`
	return;
}

getMD5OSX() {
	# Everything below the MD5SUM Line
	MD5LINE=`grep -na "^MD5=\".*\"$" ${1}`
	MD5LINE=$((${MD5LINE%%:*} + 1))

	MD5SUM=`tail -n +${MD5LINE} "${1}" | ${MD5BIN} | ${AWK} '{print $1}'`
	return;
}

if [ "${MD5BIN}" != "" -a "${AWK}" != "" ]; then
	echo "Adding MD5.."

	MD5SUM=""
	getMD5 ${RUNNAME} ${MD5SUM}

	echo "SUM obtained is: ${MD5SUM}"

	LINENUM=`grep -na "^MD5=\"\"$" ${RUNNAME}`
	LINENUM=${LINENUM%%:*}

	head -n $((${LINENUM} -1)) ${RUNNAME} > ${RUNNAME}.tmp
	echo 'MD5="'${MD5SUM}'"' >> ${RUNNAME}.tmp
	tail -n +$((${LINENUM} +1)) ${RUNNAME} >> ${RUNNAME}.tmp
	mv ${RUNNAME}.tmp ${RUNNAME}
else
	echo "Not Adding MD5.."
fi;

echo "Chmodding"
chmod a+x ${RUNNAME}

if [ "${isRelease}" != "" ]; then
	if [ "${BRANCH}" = "1" ]; then
		isRelease=branch-${isRelease}
	fi;
	if [ "" != "${finalTag}" ]; then
		finalTag="-${finalTag}"
	fi;
	finalname=DMDirc-${isRelease}-Setup${finalTag}.run
else
	finalname=${RUNNAME##*/}
fi;

if [ "" != "${jre}" ]; then
	finalname=`echo ${finalname} | sed "s/.run$/.${jrename}.run/"`
fi;

mv ${RUNNAME} ../output/${finalname}
mv setup.sh setup.sh.tmp
mv getjre.sh getjre.sh.tmp
mv installjre.sh installjre.sh.tmp
mv progressbar.sh progressbar.sh.tmp
rm -f ${FILES}
mv setup.sh.tmp setup.sh
mv getjre.sh.tmp getjre.sh
mv installjre.sh.tmp installjre.sh
mv progressbar.sh.tmp progressbar.sh

echo "-----------"
echo "Done."
echo "-----------"

# and Done \o
exit 0;
### Everything below here is part of the .run stub.
###START INCLUDE###
#!/bin/sh
#
# This script installs dmdirc
#
# DMDirc - Open Source IRC Client
# Copyright (c) 2006-2008 Chris Smith, Shane Mc Cormack, Gregory Holmes
#
# 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.

MD5=""

# Check the which command exists
WHICH=`which`
if [ "" != "${WHICH}" ]; then
	echo "which command not found. Aborting.";
	exit 0;
fi

###ADDITIONAL_STUFF###

errordialog() {
	# Send message to console.
	echo ""
	echo "-----------------------------------------------------------------------"
	echo "Error: ${1}"
	echo "-----------------------------------------------------------------------"
	echo "${2}"
	echo "-----------------------------------------------------------------------"

	# Now try to use the GUI Dialogs.
	ISKDE=`pidof -x -s kdeinit`
	KDIALOG=`which kdialog`
	ISGNOME=`pidof -x -s gnome-panel`
	ZENITY=`which zenity`
	if [ "" != "${ISKDE}" -a "" != "${KDIALOG}" -a "" != "${DISPLAY}" ]; then
		echo "Dialog on Display: ${DISPLAY}"
		${KDIALOG} --title "DMDirc: ${1}" --error "${1}\n\n${2}"
	elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
		echo "Dialog on Display: ${DISPLAY}"
		${ZENITY} --error --title "DMDirc: ${1}" --text "${1}\n\n${2}"
	fi
}

# Location of .run stub end
ENDLINE=`grep -na "^###END INCLUDE###$" $0`
ENDLINE=$((${ENDLINE%%:*} + 1))

if [ "" = "${ENDLINE}" ]; then
	errordialog "DMDirc Setup" "End of stub not found. Aborting.";
	exit 0;
fi

# Attempt to get a name for a random dir in /tmp
random() {
	# First off, lets try mktemp.
	MKTEMP=`which mktemp`
	if [ "" != "${MKTEMP}" ]; then
		# mktemp exists \o
		DIR=`${MKTEMP} -d /tmp/DMDirc.XXXXXX`
		eval "$1=${DIR}"
		return;
	fi

	TMPDIR=${TMPDIR:=/tmp}
	BASEDIR=${TMPDIR}dmdirc_`whoami`_
	DIR=${PWD}
	while [ -d "${DIR}" ]; do
		if [ "" != "${RANDOM}" ]; then
			# Bash has a psuedo random number generator that can be accessed
			# using ${RANDOM}
			RND=${RANDOM}${RANDOM}${RANDOM}
		else
			# Dash (the ubuntu default sh) however does not.
			# od and awk however usually exist, and we can get a random number
			# from /dev/urandom or /dev/random
			OD=`which od`
			AWK=`which awk`
			RND=""
			if [ "" != "$OD" -a "" != "$AWK" ]; then
				# Try /dev/urandom first
				RAND=/dev/urandom
				# If it doesn't exist try /dev/random
				if [ ! -e "${RAND}" ]; then
					RAND=/dev/urandom;
				fi
				# This makes sure we only try to read if one exists
				if [ ! -e "${RAND}" ]; then
					RND=$(head -1 ${RAND} | od -N 3 -t u | awk '{ print $2 }')
				fi;
			fi;

			# No random number was generated, getting to here means that
			# ${RANDOM} doesn't exist, /dev/random doesn't exist, /dev/urandom doesn't exist
			# or that od/awk don't exist. Annoying.
			# Try using this processes PID instead!
			if [ "${RND}" = "" ]; then
				RND=$$
				DIR=${BASEDIR}${RND}
				if [ -e "${DIR}" ]; then
					# Lets hope this never happens.
					errordialog "DMDirc Setup" "Unable to create random directory";
					exit 0;
				fi;
			fi;
		fi;
		DIR=${BASEDIR}${RND}
	done
	mkdir ${DIR}
	eval "$1=${DIR}"
}

uncompress() {
	tail -n +${ENDLINE} "${OLDPWD}/$0" | gzip -cd | tar -xvf - 2>/dev/null || {
		echo "Decompression failed."
		kill -15 $$;
	};
}

showHelp() {
	echo "This will install DMDirc on a unix based system."
	echo "The following command line arguments are known:"
	echo "---------------------"
	echo "-h, --help        Help information"
	echo "-e, --extract     Extract .run file only, do not run setup.sh"
	echo "-s, --script      Don't use installer.jar (not implemented yet)"
	echo "---------------------"
	exit 0;
}

# Defaults
extractOnly="false"
setupParams=""
skipMD5="false"

# Begin
echo "---------------------"
echo "DMDirc Unix Setup"
if [ "${isRelease}" != "" ]; then
	echo "Version: "${isRelease};
	setupParams="${setupParams} --release "${isRelease}
fi;
echo "---------------------"
# Check for cmdline args
while test -n "$1"; do
	case "$1" in
		--help|-h)
			showHelp
			;;
		--extract|-e)
			extractOnly="true"
			;;
		--script|-s)
			setupParams="${setupParams} --script"
			;;
		--nomd5)
			skipMD5="true"
			;;
	esac
	shift
done

MD5BIN=`which md5sum`
AWK=`which awk`
getMD5() {
	# Everything below the MD5SUM Line
	MD5LINE=`grep -na "^MD5=\".*\"$" ${1}`
	MD5LINE=$((${MD5LINE%%:*} + 1))

	MD5SUM=`tail -n +${MD5LINE} "${1}" | ${MD5BIN} - | ${AWK} '{print $1}'`
	return;
}

if [ "${MD5BIN}" != "" ]; then
	if [ ${skipMD5} != "true" ]; then
		#if [ -e "${0}.md5"  ]; then
		#	echo "Checking MD5 using ${0}.md5.."
		#	${MD5BIN} --check --status ${0}.md5
		#	if [ $? = 0 ]; then
		#		echo "MD5 Check Passed!"
		#	else
		#		ERROR="This copy of the DMDirc installer appears to be damaged and will now exit.";
		#		ERROR=${ERROR}"\nYou may choose to skip this check and run it anyway by passing the --nomd5 parameter";
		#		errordialog "DMDirc Setup: MD5 Check Failed!" "${ERROR}";
		#		exit 1;
		#	fi
		#elif [ "${MD5}" != ""  ]; then
		if [ "${MD5}" != ""  ]; then
			echo "Checking MD5 using built in hash.."
			if [ "${AWK}" != "" ]; then
				MD5SUM=""
				getMD5 ${0} ${MD5SUM}

				echo "SUM obtained is: ${MD5SUM}"
				echo "SUM expected is: ${MD5}"
				if [ "${MD5SUM}" = "${MD5}" ]; then
					echo "MD5 Check Passed!"
				else
					ERROR="This copy of the DMDirc installer appears to be damaged and will now exit.";
					ERROR=${ERROR}"\nYou may choose to skip this check and run it anyway by passing the --nomd5 parameter";
					errordialog "DMDirc Setup: MD5 Check Failed!" "${ERROR}";
					exit 1;
				fi;
			else
				echo "MD5 Check skipped (awk not found).."
			fi;
		else
			#if [ "${MD5BIN}" = "" ]; then
			#	echo "MD5 Check skipped (md5sum not found).."
			#else
				echo "MD5 Check skipped (No MD5 hash found to compare against).."
			#fi
		fi;
	else
		echo "MD5 Check skipped (Requested).."
	fi
fi;

OLDPWD=${PWD}
echo "Getting Temp Dir"
random TEMPDIR
echo "Got Temp Dir: ${TEMPDIR}"
cd ${TEMPDIR}
echo "Uncompressing to temp dir.."
uncompress
echo "Done."
# Check if extract only was wanted.
if [ "${extractOnly}" = "true" ]; then
	echo "Extracted. (Files can be found in: ${TEMPDIR})"
	exit 0;
fi

if [ -e "${TEMPDIR}/setup.sh" ]; then
	echo "Running setup.."
	chmod a+x ${TEMPDIR}/setup.sh
	${TEMPDIR}/setup.sh ${setupParams}
	echo ""
	if [ $? -eq 0 ]; then
		echo "Setup completed."
	else
		echo "Setup failed."
	fi
else
	echo "No setup.sh found. This was pointless?"
fi
echo "Removing temp dir"
cd ${OLDPWD}
rm -Rf ${TEMPDIR}
echo "Installation Completed."
# Job Done!
exit 0;
###END INCLUDE###

#!/bin/sh
#
# This script generates a .run file that will install DMDirc
#
# DMDirc - Open Source IRC Client
# Copyright (c) 2006-2008 Chris Smith, Shane Mc Cormack, Gregory Holmes
#
# 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.

# Final Name of the installer (without file extention)
INSTALLERNAME=DMDirc-Setup
# Location of .run stub start
STARTLINE=`grep -n "^###START INCLUDE###$" $0`
STARTLINE=$((${STARTLINE%%:*} + 1))
# full name of the file to output to
RUNNAME="${PWD}/${INSTALLERNAME}.run"

# Compress stuff!
compress() {
	tar cvfh - $@ | gzip - 2>/dev/null >>${RUNNAME} || {
		echo "Compression failed."
		kill -15 $$;
	};
}

# Go!
echo "-----------"
if [ -e "${RUNNAME}" ]; then
	echo "Removing existing .run file"
	rm -Rf ./*.run
fi

showHelp() {
	echo "This will generate a DMDirc installer for a unix based system."
	echo "The following command line arguments are known:"
	echo "---------------------"
	echo "-h, --help                Help information"
	echo "-r, --release <version>   Generate a file based on an svn tag (or branch with -b aswell)"
	echo "-b, --branch              Release in -r is a branch "
	echo "-p, --plugins <plugins>   What plugins to add to the jar file"
	echo "-c, --compile             Recompile the .jar file"
	echo "    --jre                 Include the JRE in this installer"
	echo "    --jre64               Include the 64-Bit JRE in this installer"
	echo "    --jar <file>          use <file> as DMDirc.jar"
	echo "    --current             Use the current folder as the base for the build"
	echo "-t, --tag <tag>           Tag to add to final exe name to distinguish this build from a standard build"
	echo "-k, --keep                Keep the existing source tree when compiling"
	echo "                          (don't svn update beforehand)"
	echo "---------------------"
	exit 0;
}

# Check for some CLI params
compileJar="false"
updateSVN="true"
isRelease=""
finalTag=""
BRANCH="0"
plugins=""
location="../../../"
jarfile=""
current=""
jre=""
jrename="jre" # Filename for JRE without the .bin
while test -n "$1"; do
	case "$1" in
		--plugins|-p)
			shift
			plugins=${1}
			;;
		--jar)
			shift
			jarfile=${1}
			;;
		--jre)
			jre="http://www.dmdirc.com/getjava/linux/i686"
			;;
		--jre64)
			jre="http://www.dmdirc.com/getjava/linux/x86_64"
			jrename="jre64"
			;;
		--current)
			location="../../"
			current="1"
			;;
		--compile|-c)
			compileJar="true"
			;;
		--release|-r)
			shift
			isRelease=${1}
			;;
		--tag|-t)
			shift
			finalTag=${1}
			RUNNAME="${PWD}/${INSTALLERNAME}-${1}.run"
			;;
		--keep|-k)
			updateSVN="false"
			;;
		--help|-h)
			showHelp;
			;;
		--branch|-b)
			BRANCH="1"
			;;
	esac
	shift
done
if [ "" = "${current}" ]; then
	jarPath="${location}trunk"
else
	jarPath="${location}"
fi
if [ "${isRelease}" != "" ]; then
	if [ "${BRANCH}" != "0" ]; then
		if [ -e "${location}/${isRelease}" ]; then
			jarPath="${location}/${isRelease}"
		else
			echo "Branch "${isRelease}" not found."
			exit 1;
		fi
	else
		if [ -e "${location}/${isRelease}" ]; then
			jarPath="${location}/${isRelease}"
		else
			echo "Tag "${isRelease}" not found."
			exit 1;
		fi
	fi
fi

if [ "" = "${jarfile}" ]; then
	jarfile=${jarPath}"/dist/DMDirc.jar"
	if [ ! -e ${jarPath}"/dist/DMDirc.jar" -o "${compileJar}" = "true" ]; then
		echo "Creating jar.."
		OLDPWD=${PWD}
		cd ${jarPath}
		if [ "${updateSVN}" = "true" ]; then
			svn update
		fi
		rm -Rf build dist
		ant jar
		if [ ! -e "dist/DMDirc.jar" ]; then
			echo "There was an error creating the .jar file. Aborting."
			exit 1;
		fi;
		cd ${OLDPWD}
	fi;
elif [ ! -e "${jarfile}" ]; then
	echo "Requested Jar file (${jarfile}) does not exist."
	exit 1;
fi;

if [ "" = "${plugins}" ]; then
	echo "Linking jar (${jarfile}).."
	ln -sf ${jarfile} "./DMDirc.jar"
else
	echo "Copying jar (${jarfile}).."
	cp ${jarfile} "./DMDirc.jar"

	echo "Adding plugins to jar"
	ln -sf ${jarPath}"/plugins"
	pluginList=""
	for plugin in ${plugins}; do
		pluginList=${pluginList}" plugins/${plugin}"
	done
	jar -uvf "DMDirc.jar" ${pluginList}
	rm -Rf plugins;
fi

echo "Creating .run file"
echo "Adding stub.."
tail -n +${STARTLINE} $0 > ${RUNNAME}

# Add release info.
awk '{gsub(/###ADDITIONAL_STUFF###/,"isRelease=\"'${isRelease}'\"");print}' ${RUNNAME} > ${RUNNAME}.tmp
mv ${RUNNAME}.tmp ${RUNNAME}

FILES="DMDirc.jar";
echo "Compressing files.."
for FILE in "getjre.sh" "installjre.sh" "progressbar.sh"; do
	if [ -e "${FILE}" ]; then
		FILES="${FILES} ${FILE}"
	fi
done;

if [ "" != "${jre}" ]; then
	if [ ! -e "../common/${jrename}.bin" ]; then
		echo "Downloading JRE to include in installer"
		wget ${jre} -O ../common/${jrename}.bin
	fi
	ln -sf ../common/${jrename}.bin jre.bin
	FILES="${FILES} jre.bin"
fi;

if [ -e "setup.sh" ]; then
	FILES="${FILES} setup.sh"
else
	echo "[WARNING] Creating setup-less archive. This will just extract and immediately delete the .jar file unless the -e flag is used"
fi

if [ -e "../common/installer.jar" ]; then
	ln -sf ../common/installer.jar ./installer.jar
	FILES="${FILES} installer.jar"
else
	echo "[WARNING] Creating installer-less archive - relying on setup.sh"
fi

if [ -e ${jarPath}"/src/com/dmdirc/res/source/logo.svg" ]; then
	ln -sf ${jarPath}"/src/com/dmdirc/res/source/logo.svg" ./icon.svg
	FILES="${FILES} icon.svg"
fi

if [ "${isRelease}" != "" ]; then
	DOCSDIR=${jarPath}
else
	DOCSDIR="../common"
fi

if [ -e "${DOCSDIR}/README.TXT" ]; then
	ln -sf "${DOCSDIR}/README.TXT" .
	FILES="${FILES} README.TXT"
fi

if [ -e "${DOCSDIR}/CHANGES.TXT" ]; then
	ln -sf "${DOCSDIR}/CHANGES.TXT" .
	FILES="${FILES} CHANGES.TXT"
elif [ -e "${DOCSDIR}/CHANGELOG.TXT" ]; then
	ln -sf "${DOCSDIR}/CHANGELOG.TXT" .
	FILES="${FILES} CHANGELOG.TXT"
fi

if [ -e "${jarPath}/launcher/linux" ]; then
	ln -sf ${jarPath}/launcher/linux/DMDirc.sh .
	FILES="${FILES} DMDirc.sh"
fi

compress $FILES

MD5BIN=`which md5sum`
AWK=`which awk`
getMD5() {
	# Everything below the MD5SUM Line
	MD5LINE=`grep -na "^MD5=\".*\"$" ${1}`
	MD5LINE=$((${MD5LINE%%:*} + 1))

	MD5SUM=`tail -n +${MD5LINE} "${1}" | ${MD5BIN} - | ${AWK} '{print $1}'`
	return;
}

if [ "${MD5BIN}" != "" -a "${AWK}" != "" ]; then
	echo "Adding MD5.."

	MD5SUM=""
	getMD5 ${RUNNAME} ${MD5SUM}

	echo "SUM obtained is: ${MD5SUM}"

	LINENUM=`grep -na "^MD5=\"\"$" ${RUNNAME}`
	LINENUM=${LINENUM%%:*}

	head -n $((${LINENUM} -1)) ${RUNNAME} > ${RUNNAME}.tmp
	echo 'MD5="'${MD5SUM}'"' >> ${RUNNAME}.tmp
	tail -n +$((${LINENUM} +1)) ${RUNNAME} >> ${RUNNAME}.tmp
	mv ${RUNNAME}.tmp ${RUNNAME}
else
	echo "Not Adding MD5.."
fi;

echo "Chmodding"
chmod a+x ${RUNNAME}

if [ "${isRelease}" != "" ]; then
	if [ "${BRANCH}" = "1" ]; then
		isRelease=branch-${isRelease}
	fi;
	if [ "" != "${finalTag}" ]; then
		finalTag="-${finalTag}"
	fi;
	finalname=DMDirc-${isRelease}-Setup${finalTag}.run
else
	finalname=${RUNNAME##*/}
fi;

if [ "" != "${jre}" ]; then
	finalname=`echo ${finalname} | sed "s/.run$/.${jrename}.run/"`
fi;

mv ${RUNNAME} ../output/${finalname}
mv setup.sh setup.sh.tmp
mv getjre.sh getjre.sh.tmp
mv installjre.sh installjre.sh.tmp
mv progressbar.sh progressbar.sh.tmp
rm -f ${FILES}
mv setup.sh.tmp setup.sh
mv getjre.sh.tmp getjre.sh
mv installjre.sh.tmp installjre.sh
mv progressbar.sh.tmp progressbar.sh

echo "-----------"
echo "Done."
echo "-----------"

# and Done \o
exit 0;
### Everything below here is part of the .run stub.
###START INCLUDE###
#!/bin/sh
#
# This script installs dmdirc
#
# DMDirc - Open Source IRC Client
# Copyright (c) 2006-2008 Chris Smith, Shane Mc Cormack, Gregory Holmes
#
# 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.

MD5=""

# Check the which command exists
WHICH=`which`
if [ "" != "${WHICH}" ]; then
	echo "which command not found. Aborting.";
	exit 0;
fi

###ADDITIONAL_STUFF###

errordialog() {
	# Send message to console.
	echo ""
	echo "-----------------------------------------------------------------------"
	echo "Error: ${1}"
	echo "-----------------------------------------------------------------------"
	echo "${2}"
	echo "-----------------------------------------------------------------------"

	# Now try to use the GUI Dialogs.
	ISKDE=`pidof -x -s kdeinit`
	KDIALOG=`which kdialog`
	ISGNOME=`pidof -x -s gnome-panel`
	ZENITY=`which zenity`
	if [ "" != "${ISKDE}" -a "" != "${KDIALOG}" -a "" != "${DISPLAY}" ]; then
		echo "Dialog on Display: ${DISPLAY}"
		${KDIALOG} --title "DMDirc: ${1}" --error "${1}\n\n${2}"
	elif [ "" != "${ISGNOME}" -a "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
		echo "Dialog on Display: ${DISPLAY}"
		${ZENITY} --error --title "DMDirc: ${1}" --text "${1}\n\n${2}"
	fi
}

# Location of .run stub end
ENDLINE=`grep -na "^###END INCLUDE###$" $0`
ENDLINE=$((${ENDLINE%%:*} + 1))

if [ "" = "${ENDLINE}" ]; then
	errordialog "DMDirc Setup" "End of stub not found. Aborting.";
	exit 0;
fi

# Attempt to get a name for a random dir in /tmp
random() {
	# First off, lets try mktemp.
	MKTEMP=`which mktemp`
	if [ "" != "${MKTEMP}" ]; then
		# mktemp exists \o
		DIR=`${MKTEMP} -d /tmp/DMDirc.XXXXXX`
		eval "$1=${DIR}"
		return;
	fi

	TMPDIR=${TMPDIR:=/tmp}
	BASEDIR=${TMPDIR}dmdirc_`whoami`_
	DIR=${PWD}
	while [ -d "${DIR}" ]; do
		if [ "" != "${RANDOM}" ]; then
			# Bash has a psuedo random number generator that can be accessed
			# using ${RANDOM}
			RND=${RANDOM}${RANDOM}${RANDOM}
		else
			# Dash (the ubuntu default sh) however does not.
			# od and awk however usually exist, and we can get a random number
			# from /dev/urandom or /dev/random
			OD=`which od`
			AWK=`which awk`
			RND=""
			if [ "" != "$OD" -a "" != "$AWK" ]; then
				# Try /dev/urandom first
				RAND=/dev/urandom
				# If it doesn't exist try /dev/random
				if [ ! -e "${RAND}" ]; then
					RAND=/dev/urandom;
				fi
				# This makes sure we only try to read if one exists
				if [ ! -e "${RAND}" ]; then
					RND=$(head -1 ${RAND} | od -N 3 -t u | awk '{ print $2 }')
				fi;
			fi;

			# No random number was generated, getting to here means that
			# ${RANDOM} doesn't exist, /dev/random doesn't exist, /dev/urandom doesn't exist
			# or that od/awk don't exist. Annoying.
			# Try using this processes PID instead!
			if [ "${RND}" = "" ]; then
				RND=$$
				DIR=${BASEDIR}${RND}
				if [ -e "${DIR}" ]; then
					# Lets hope this never happens.
					errordialog "DMDirc Setup" "Unable to create random directory";
					exit 0;
				fi;
			fi;
		fi;
		DIR=${BASEDIR}${RND}
	done
	mkdir ${DIR}
	eval "$1=${DIR}"
}

uncompress() {
	tail -n +${ENDLINE} "${OLDPWD}/$0" | gzip -cd | tar -xvf - 2>/dev/null || {
		echo "Decompression failed."
		kill -15 $$;
	};
}

showHelp() {
	echo "This will install DMDirc on a unix based system."
	echo "The following command line arguments are known:"
	echo "---------------------"
	echo "-h, --help        Help information"
	echo "-e, --extract     Extract .run file only, do not run setup.sh"
	echo "-s, --script      Don't use installer.jar (not implemented yet)"
	echo "---------------------"
	exit 0;
}

# Defaults
extractOnly="false"
setupParams=""
skipMD5="false"

# Begin
echo "---------------------"
echo "DMDirc Unix Setup"
if [ "${isRelease}" != "" ]; then
	echo "Version: "${isRelease};
	setupParams="${setupParams} --release "${isRelease}
fi;
echo "---------------------"
# Check for cmdline args
while test -n "$1"; do
	case "$1" in
		--help|-h)
			showHelp
			;;
		--extract|-e)
			extractOnly="true"
			;;
		--script|-s)
			setupParams="${setupParams} --script"
			;;
		--nomd5)
			skipMD5="true"
			;;
	esac
	shift
done

MD5BIN=`which md5sum`
AWK=`which awk`
getMD5() {
	# Everything below the MD5SUM Line
	MD5LINE=`grep -na "^MD5=\".*\"$" ${1}`
	MD5LINE=$((${MD5LINE%%:*} + 1))

	MD5SUM=`tail -n +${MD5LINE} "${1}" | ${MD5BIN} - | ${AWK} '{print $1}'`
	return;
}

if [ "${MD5BIN}" != "" ]; then
	if [ ${skipMD5} != "true" ]; then
		#if [ -e "${0}.md5"  ]; then
		#	echo "Checking MD5 using ${0}.md5.."
		#	${MD5BIN} --check --status ${0}.md5
		#	if [ $? = 0 ]; then
		#		echo "MD5 Check Passed!"
		#	else
		#		ERROR="This copy of the DMDirc installer appears to be damaged and will now exit.";
		#		ERROR=${ERROR}"\nYou may choose to skip this check and run it anyway by passing the --nomd5 parameter";
		#		errordialog "DMDirc Setup: MD5 Check Failed!" "${ERROR}";
		#		exit 1;
		#	fi
		#elif [ "${MD5}" != ""  ]; then
		if [ "${MD5}" != ""  ]; then
			echo "Checking MD5 using built in hash.."
			if [ "${AWK}" != "" ]; then
				MD5SUM=""
				getMD5 ${0} ${MD5SUM}

				echo "SUM obtained is: ${MD5SUM}"
				echo "SUM expected is: ${MD5}"
				if [ "${MD5SUM}" = "${MD5}" ]; then
					echo "MD5 Check Passed!"
				else
					ERROR="This copy of the DMDirc installer appears to be damaged and will now exit.";
					ERROR=${ERROR}"\nYou may choose to skip this check and run it anyway by passing the --nomd5 parameter";
					errordialog "DMDirc Setup: MD5 Check Failed!" "${ERROR}";
					exit 1;
				fi;
			else
				echo "MD5 Check skipped (awk not found).."
			fi;
		else
			#if [ "${MD5BIN}" = "" ]; then
			#	echo "MD5 Check skipped (md5sum not found).."
			#else
				echo "MD5 Check skipped (No MD5 hash found to compare against).."
			#fi
		fi;
	else
		echo "MD5 Check skipped (Requested).."
	fi
fi;

OLDPWD=${PWD}
echo "Getting Temp Dir"
random TEMPDIR
echo "Got Temp Dir: ${TEMPDIR}"
cd ${TEMPDIR}
echo "Uncompressing to temp dir.."
uncompress
echo "Done."
# Check if extract only was wanted.
if [ "${extractOnly}" = "true" ]; then
	echo "Extracted. (Files can be found in: ${TEMPDIR})"
	exit 0;
fi

if [ -e "${TEMPDIR}/setup.sh" ]; then
	echo "Running setup.."
	chmod a+x ${TEMPDIR}/setup.sh
	${TEMPDIR}/setup.sh ${setupParams}
	echo ""
	if [ $? -eq 0 ]; then
		echo "Setup completed."
	else
		echo "Setup failed."
	fi
else
	echo "No setup.sh found. This was pointless?"
fi
echo "Removing temp dir"
cd ${OLDPWD}
rm -Rf ${TEMPDIR}
echo "Installation Completed."
# Job Done!
exit 0;
###END INCLUDE###


chmod

chmod

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/amonks/rpi-setup.git/'


Add merge master script.

Add merge master script.

Former-commit-id: 77f6fc53f7610b4e5d7d63ab1a9877302bfbeb4b [formerly d1d4a2d2284132d888326436ba1f648fc705513c]
Former-commit-id: 0aa229f8fd07bf1a27664b111232ceba2ffe439d

#!/bin/bash

for branch in mapi2 pourbaix
do
    git checkout $branch
    git merge master -m "auto merge"
done
git checkout master
git push

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


Adding simple GNU parallel md5deep sbatch script

#!/bin/bash
#SBATCH -p devel
#SBATCH -N 1
#SBATCH -t 00:00:30
#SBATCH -J pmd5deep
#SBATCH -A <project_id>

function usage {
    echo "Usage: $0 files_to_checksum"
}

# ignore directory errors redirecting to null
find | parallel md5deep {} 2> /dev/null

#usage

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


Adding mozua.sh to the repo

Adding mozua.sh to the repo

#!/bin/sh
# Script to add a UA override to B2G
# Based on Dave Hyland's script https://gist.github.com/2656232
# Based on Lawrence Mandel's script https://gist.github.com/lmandel/4291503
# Put at https://github.com/karlcow/webcompat/moz/mozua.sh
# Options:
#   remove - removes the override
# Usage:
#   ./mozua.sh add example.com
#   ./mozua.sh remove example.com
#   ./mozua.sh list example

LOCAL_USER_JS=/tmp/user.js
PROFILE_DIR=/system/b2g/defaults/pref
REMOTE_USER_JS=${PROFILE_DIR}/user.js

# explaining the command
if [ $# != 2 ]; then
    echo ""
    echo "Usage: mozua.sh"
    echo ""
    echo "This program:-"
    echo "    mozua.sh add    example.com"
    echo "    mozua.sh remove example.com"
    echo "    mozua.sh list   example"
    echo "    mozua.sh list   all"
    echo "==============================="
    echo "Improve it!"
    echo "https://github.com/karlcow/webcompat/moz/mozua.sh"
    exit 1
fi

# remove any previous files
rm -f ${LOCAL_USER_JS}
# pull from the device to a local tmp directory
adb pull ${REMOTE_USER_JS} ${LOCAL_USER_JS}

# remove a ua from the list
if [ ${1} == "remove" ]
then
    echo "Removing UA override for ${2}"
    ua=""
# add a ua to the list
elif [ ${1} == "add" ]
then
    echo "Adding fennec UA override for ${2}"
    ua=fennec
# list domains in the list
elif [ ${1} == "list" ]
then
    # if all list everything and quit. no need to reboot
    if [ ${2} == "all" ]
    then
        echo "Listing every domains"
        grep general.useragent.override ${LOCAL_USER_JS} | sed -e 's/^pref.*override\.\(.*\)", .* bug \(.*\)/\2 \1/'
        exit 1
    # if pattern foo list everything matching foo and quit.
    else
        echo "Listing domain matching ${2}"
        grep general.useragent.override ${LOCAL_USER_JS} | grep -i ${2} | sed -e 's/^pref.*override\.\(.*\)", .* bug \(.*\)/\2 \1/'
        exit 1
    fi
# avoiding surprises
else
    echo "Unknown command: ${1}"
    exit 1
fi
grep -v ${2} ${LOCAL_USER_JS} > ${LOCAL_USER_JS}.tmp
if [ "${ua}" != "" ]
then
    echo 'pref("general.useragent.override.'${2}'", "\Mobile#(Android; Mobile");' >> ${LOCAL_USER_JS}.tmp
fi

set -x
adb shell mount -o rw,remount /system
adb push ${LOCAL_USER_JS}.tmp ${REMOTE_USER_JS}
adb shell mount -o ro,remount /system
adb shell stop b2g && adb shell start b2g
#adb reboot

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