{"doc_id": "00386ea2eb643cd536db98de6e023972", "text": "#!/bin/sh\n\n# build ports with poudriere\n#\n# Usage: build [-U] [-W]\n# -U: do not update the ports tree before building\n# -W: if tmux is running locally (and local is not the build host), then do\n# not create a new tmux window\n#\n# globals expected in ${HOME}/.ports.conf with sample values\n# bhost='storage2.mathstat.dal.ca' # build host\n# bjail='12amd64' # build jail\n# listf='.pl' # list file of ports to build\n# if no path is supplied in listf, then ${HOME}/ is assumed\n\n. \"$HOME/.ports.conf\"\n\nusage () {\n [ -n \"$*\" ] && printf \"%s\\\\n\" \"$*\" 1>&2\n cat <&2\nUsage: ${0##*/} [-U][-W]\nEOF\n}\n\ncreate_listf() {\n cat \"$listf\".* > \"$listf\"\n sort -u \"$listf\" -o \"$listf\"\n}\n\nbuild () {\n if [ \"$(hostname)\" != \"$bhost\" ]; then\n if pgrep -q tmux && [ \"$newtw\" != 'no' ]; then\n tmux neww \\; send \"ssh $bhost\" KPEnter \"build $nu\" KPEnter\n else\n ssh -t \"$bhost\" \"build $nu\"\n fi\n else\n if ! command -v tmux >/dev/null 2>&1; then\n printf \"tmux is required on the build host.\\\\n\"\n exit 1\n fi\n if ! [ -f \"$listf\" ]; then\n printf \"The file, %s, does not exist.\\\\n\" \"$listf\"\n exit 1\n elif ! [ -r \"$listf\" ]; then\n printf \"The file, %s, is not readable.\\\\n\" \"$listf\"\n exit 1\n elif ! [ -s \"$listf\" ]; then\n printf \"Nothing new to build. The file, %s, is empty.\\\\n\" \"$listf\"\n return 0\n else\n# if tmux ls 2>&1 | grep -q '^build:'; then\n# tmux neww -t '=build'\n# else\n# tmux new -d -s 'build'\n# fi\n# [ -z \"$nu\" ] && tmux send -t '=build:$' pull KPENTER\n# tmux send -t '=build:$' \"sudo poudriere options -j $bjail -f $listf \\\n# && sudo poudriere bulk -j $bjail -f $listf\" KPEnter\n# tmux att -d -t '=build' > /dev/null 2>&1\n pull && \\\n #sudo poudriere options -j \"$bjail\" -f \"$listf\" && \\\n sudo poudriere bulk -j \"$bjail\" -f \"$listf\"\n fi\n fi\n}\n\n############################################ main\n\nOPTIND=1\nwhile getopts \":UW\" opt; do\n case $opt in\n U) nu='-U' ;;\n W) newtw=no ;;\n *) usage \"Invalid option: -$OPTARG.\"\n exit 1\n ;;\n esac\ndone\nshift $((OPTIND-1))\n\nif ! command -v tmux >/dev/null 2>&1 && [ \"$newtw\" != 'no' ]; then\n printf \"tmux is required locally unless -W is specified.\\\\n\"\n exit 1\nfi\n\n[ $# != 0 ] && { usage; exit 1; }\n\n[ -n \"${listf##/*}\" ] && listf=\"${HOME}/$listf\"\n\ncreate_listf\nbuild\n"} {"doc_id": "0038b33f018f0de73901a2acc7ba60ec", "text": "#!/sbin/sh\n\n# Start and stop LOCKSS daemon(s) on Solaris\n# XXX copyright\n#\n\ndo_command () {\nif [ -f ${LOCKSS_HOME}/etc/lockss/config.$2.dat ]\nthen\n CFG_FILE=${LOCKSS_HOME}/etc/lockss/config.$2.dat\nfi\ncase \"$1\" in\n start)\n if [ ! -r ${CFG_FILE} ]; then\n echo \"Can't start ${2}: ${CFG_FILE} missing or not readable\"\n exit 1\n fi\n if [ ! -d ${LOG_DIR} ]; then\n mkdir -p ${LOG_DIR}\n chown $2 ${LOG_DIR}\n chmod 755 ${LOG_DIR}\n fi\n if [ ! -f ${PID_FILE} ]; then\n touch ${PID_FILE}\n fi\n chown $2 ${PID_FILE}\n chmod 644 ${PID_FILE}\n echo \"Starting LOCKSS for user $2 at `date`\" >> ${LOG_FILE}\n chown $2 ${LOG_FILE}\n if [ -x /usr/bin/bash ]; then\n /usr/bin/bash ${LOCKSS_HOME}/etc/lockss/startdaemon $2\n else\n echo \"Needs /usr/bin/bash\"\n exit 1\n fi\n ;;\n stop)\n rm -f \"${KEEP_GOING}\"\n /usr/bin/pkill -U $2\n rm -f ${PID_FILE} ${RUN_DIR}/${2}-ssl.pid\n ;;\n *)\n echo \"Usage: $0 {start|stop}\"\n exit 1\n ;;\nesac\n}\n\nLOCKSS_HOME=/opt/lockss\nexport LOCKSS_HOME\nFUNCTIONS=${LOCKSS_HOME}/etc/lockss/functions\nif [ ! -x ${FUNCTIONS} ] ; then\n echo \"Can't find ${FUNCTIONS}\"\n exit 1\nfi\n. ${FUNCTIONS}\nset_lockss_user\nfor A in ${LOCKSS_USER}\ndo\n set_variables ${A}\n do_command $1 $A\n unset_variables\ndone\n"} {"doc_id": "003c42692112a5a8c7a9897f4e1e666d", "text": "#!/bin/bash\n\n# This is a helper library for the setup scripts of each package\n# in this repository.\n\nsource ../versions.txt\nPACKAGING_DIR=/var/packaging\nLOG_DIR=${PACKAGING_DIR}/build_logs\nBUILD_ARCH=x86_64\n\nfunction display_help()\n{\n\tcat <<-EOL \n\t$SCRIPT_NAME\n\n\tThis script is intended to create Clear Containers 3.X packages for the OBS \n\t(Open Build Service) platform.\n\n Usage:\n $SCRIPT_NAME [options]\n\n\tOptions:\n\n -l --local-build Build the runtime locally\n -w\t --workdir Repository directory\n -c --commit-id Build with a given commit ID\n -b --branch Build with a given branch name\n -p --push Push changes to OBS\n -a --api-url Especify an OBS API (e.g. custom private OBS)\n -r --obs-repository An OBS repository to push the changes.\n -w --workdir Directory of a working copy of the OBS runtime repo\n -v --verbose Set the -x flag for verbosity\n -C --clean Clean the repository\n -V --verify Verify the environment\n -h --help Display this help message\n\n Usage examples:\n\n $SCRIPT_NAME --local-build --branch staging\n $SCRIPT_NAME --commit-id a76f45c --push --api-url http://127.0.0.1\n $SCRIPT_NAME --commit-id a76f45c --push --obs-repository home:userx/repository\n $SCRIPT_NAME --commit-id a76f45c --push\n\n\tEOL\n\texit 1\n}\n\ndie()\n{\n\tmsg=\"$*\"\n\techo >&2 \"ERROR: $msg\"\n\texit 1\n}\n\nfunction verify()\n{\n # This function perform some checks in order to make sure\n # the script will run flawlessly.\n\n # Make sure this script is called from ./\n [ \"$SCRIPT_DIR\" != \".\" ] && die \"The script must be called from its base dir.\" || true\n \n # Verify if osc is installed, exit otherwise.\n [ ! -x \"$(command -v osc)\" ] && die \"osc is not installed.\" || true\n}\n\nfunction clean()\n{\n # This function clean generated files\n for file in \"$@\"\n do\n [ -e $file ] && rm -v $file || true\n done\n [ -e ./debian.changelog ] && git checkout ./debian.changelog || true\n [ -e ./release ] && git checkout ./release || true\n echo \"Clean done.\"\n}\n\nfunction get_git_info()\n{\n AUTHOR=${AUTHOR:-$(git config user.name)}\n AUTHOR_EMAIL=${AUTHOR_EMAIL:-$(git config user.email)}\n}\n\nfunction set_versions()\n{\n local commit_hash=\"$1\"\n\n if [ -n \"$OBS_REVISION\" ]\n then\n\t# Validate input is alphanumeric, commit ID\n\t# If a commit ID is provided, override versions.txt one\n\tif [ -n \"$COMMIT\" ] && [[ \"$OBS_REVISION\" =~ ^[a-zA-Z0-9][-a-zA-Z0-9]{0,40}[a-zA-Z0-9]$ ]]; then\n hash_tag=$OBS_REVISION\n\telif [ -n \"$BRANCH\" ]\n\tthen\n hash_tag=$commit_hash\n\tfi\n else\n hash_tag=$commit_hash\n fi\n short_hashtag=\"${hash_tag:0:7}\"\t\n}\n\nfunction changelog_update {\n d=$(date -R)\n git checkout debian.changelog\n cp debian.changelog debian.changelog-bk\n cat <<< \"$PKG_NAME ($VERSION) stable; urgency=medium\n\n * Update $PKG_NAME $VERSION ${hash_tag:0:7}\n\n -- $AUTHOR <$AUTHOR_EMAIL> $d\n\" > debian.changelog\n cat debian.changelog-bk >> debian.changelog\n rm debian.changelog-bk\n\n\t# Append, so it can be copied to the OBS repository\n\tSTATIC_FILES+=('debian.changelog')\n}\n\nfunction local_build()\n{\n [ ! -e $PACKAGING_DIR ] && mkdir $PACKAGING_DIR || true\n [ ! -e $LOG_DIR ] && mkdir $LOG_DIR || true\n\n pushd $OBS_WORKDIR\n\n BUILD_ARGS=('--local-package' '--no-verify' '--noservice' '--trust-all-projects' '--keep-pkgs=/var/packaging/results')\n [ \"$OFFLINE\" == \"true\" ] && BUILD_ARGS+=('--offline') || true\n\n osc service run\n for distro in ${BUILD_DISTROS[@]}\n do\n # If more distros are supported, add here the relevant validations.\n if [[ \"$distro\" =~ ^Fedora.* ]]\n then\n\t echo \"Perform a local build for ${distro}\"\n\t osc build ${BUILD_ARGS[@]} \\\n ${distro} $BUILD_ARCH *.spec | tee ${LOG_DIR}/${distro}_${PKG_NAME}_build.log\n\n elif [[ \"$distro\" =~ ^xUbuntu.* ]]\n then\n\t echo \"Perform a local build for ${distro}\"\n\t osc build ${BUILD_ARGS[@]} \\\n\t\t${distro} $BUILD_ARCH *.dsc | tee ${LOG_DIR}/${distro}_${PKG_NAME}_build.log\n fi\n done\n}\n\nfunction checkout_repo()\n{\n local REPO=\"$1\"\n if [ -z \"$OBS_WORKDIR\" ]\n then\n # If no workdir is provided, use a temporary directory.\n temp=$(basename $0)\n OBS_WORKDIR=$(mktemp -d -u -t ${temp}.XXXXXXXXXXX) || exit 1\n osc $APIURL co $REPO -o $OBS_WORKDIR\n fi\n\n mv ${GENERATED_FILES[@]} $OBS_WORKDIR\n cp ${STATIC_FILES[@]} $OBS_WORKDIR\n cp ../scripts/apport_hook.py $OBS_WORKDIR/$APPORT_HOOK\n}\n\n\n# generate_kernel_config function takes 2 arguments: a kernel version\n# and a filename of the kernel configfile. This one will be created and commited back when\n# doing a kernel update.\nfunction generate_kernel_config() {\n local kernel_version=$1\n [[ ! \"$kernel_version\" =~ ^[0-9]\\.[0-9]{1,3}\\.[0-9]{1,3}$ ]] && die \"Wrong kernel version supplied\"\n\n local config_file=$2\n [ -z \"$config_file\" ] && die \"No kernel config filename supplied\"\n [ -e \"$config_file\" ] && echo \"INFO: ${config_file} exists, it will be overwritten!\"\n\n # Temporary directory to decompress the kernel\n local tmpdir=$(mktemp -d)\n\n local kernel_tarball_suffix=\".tar.xz\"\n local kernel_url=https://www.kernel.org/pub/linux/kernel/v\"${KR_SERIES}\"/linux-\"${kernel_version}${kernel_tarball_suffix}\"\n local kernel_tree_dir=\"${tmpdir}/linux-${kernel_version}\"\n\n # Download the kernel source tree tarball and decompress it in ${tmpdir}\n [ ! -e \"${kernel_tree_dir}${kernel_tarball_suffix}\" ] &&\n curl -o \"${kernel_tree_dir}${kernel_tarball_suffix}\" -L $kernel_url || true\n tar -C $tmpdir -xf \"${kernel_tree_dir}${kernel_tarball_suffix}\"\n\n # Generate a new kernel config file based on the one in this repo\n cp \"${config_file}\" \"${kernel_tree_dir}/.config\"\n pushd \"${kernel_tree_dir}\"\n make -s ARCH=x86_64 oldconfig\n popd\n\n # Remove old config and replace it with the new one\n rm -f \"${config_file}\"\n cp \"${kernel_tree_dir}/.config\" $config_file\n\n # If Kernel config file has changed, create a commit adding the new config.\n for file in $(git status -s | awk '/^\\ M/ {print $2}'); do\n if [ \"$file\" == \"$config_file\" ]; then\n git add \"$config_file\"\n git commit -s -m \"$(echo -e \"kernel: automatic config update\\\\n\\\\nApplied 'make oldconfig' changes.\")\" \"$kernel_filename\"\n\tfi\n done\n\n # remove the kernel tree\n rm -rf \"${kernel_tree_dir}\"\n}\n\nfunction obs_push()\n{\n pushd $OBS_WORKDIR\n osc $APIURL addremove\n osc $APIURL commit -m \"Update ${PKG_NAME} $VERSION: ${hash_tag:0:7}\"\n popd\n}\n\nfunction cli()\n{\n\tOPTS=$(getopt -o abclprwvCVh: --long api-url,branch,commit-id,local-build,push,obs-repository,workdir,verbose,clean,verify,help -- \"$@\")\n\twhile true; do\n\t\tcase \"${1}\" in\n\t\t\t-a | --api-url ) APIURL=\"$2\"; shift 2;;\n\t\t\t-b | --branch ) BRANCH=\"true\"; OBS_REVISION=\"$2\"; shift 2;;\n\t\t\t-c | --commit-id ) COMMIT=\"true\"; OBS_REVISION=\"$2\"; shift 2;;\n\t\t\t-l | --local-build ) LOCAL_BUILD=\"true\"; shift;;\n\t\t\t-p | --push ) OBS_PUSH=\"true\"; shift;;\n\t\t\t-r | --obs-repository ) PROJECT_REPO=\"$2\"; shift 2;;\n\t\t\t-w | --workdir ) OBS_WORKDIR=\"$2\"; shift 2;;\n\t\t\t-v | --verbose ) VERBOSE=\"true\"; shift;;\n\t\t\t-o | --offline ) OFFLINE=\"true\"; shift;;\n\t\t\t-C | --clean ) clean ${GENERATED_FILES[@]}; exit $?;;\n\t\t\t-V | --verify ) verify; exit $?;;\n\t\t\t-h | --help ) display_help; exit $?;;\n\t\t\t-- ) shift; break ;;\n\t\t\t* ) break ;;\n\t\tesac\n\tdone\n\n}\n"} {"doc_id": "003c7eff09f026d2f362cb5cbc26da98", "text": "#!/bin/bash\n\n# Get current working directory\ncd \"$(dirname $0)\" > /dev/null || return\nreadonly CWD=$(pwd)\ncd - > /dev/null || return\n\n# Script configuration\nreadonly CONTAINER_NAME=\"postgres\"\nreadonly POSTGRES_DATA_DIR=\"${CWD}/tmp/postgres\"\nreadonly POSTGRES_PORT=5432\nreadonly POSTGRES_USER=\"kyma\"\nreadonly POSTGRES_PASSWORD=\"kyma\"\nreadonly POSTGRES_DB=\"kyma\"\nreadonly POSTGRES_START_DELAY=3\nreadonly MIGRATE_PATH=\"${CWD}/../configs/db/postgres\"\n\n# Get Postgres container ID\nfunction containerId() {\n docker ps --filter \"name=$CONTAINER_NAME\" --format \"{{.ID}}\"\n}\n\n# Print to STDERR and exit\nfunction error() {\n local msg=\"$1\"\n local exitCode=\"$2\"\n\n >&2 echo \"$msg\"\n\n if [ -z \"$exitCode\" ]; then\n exitCode=\"1\"\n fi\n exit $exitCode\n}\n\n# Start Postgres container\nfunction start() { \n local waitForPg=$1\n local id\n local exitCode\n\n if [ -n \"$(containerId)\" ]; then\n echo \"Postgres container already running\"\n exit 0\n fi\n\n mkdir -p \"$POSTGRES_DATA_DIR\"\n\n cleanup #prune any old Postgres container\n\n id=$(docker run \\\n -d \\\n -p $POSTGRES_PORT:$POSTGRES_PORT \\\n --name \"$CONTAINER_NAME\" \\\n -l \"name=$CONTAINER_NAME\" \\\n -v \"$POSTGRES_DATA_DIR\":/var/lib/postgresql/data \\\n -e POSTGRES_PASSWORD=$POSTGRES_PASSWORD \\\n -e POSTGRES_USER=$POSTGRES_USER \\\n -e POSTGRES_DB=$POSTGRES_DB \\\n postgres)$\n exitCode=$?\n\n if [ $exitCode -eq 0 ]; then\n echo \"Postgres container started (listening on port $POSTGRES_PORT)\"\n echo \"Waiting for Postgres to be ready\"\n if [ -z \"$waitForPg\" ]; then\n sleep $POSTGRES_START_DELAY\n else\n sleep \"$waitForPg\"\n fi\n \n migrate\n else\n error \"Failed to start Postgres container (code: $exitCode)\" $exitCode\n fi\n}\n\n# Migrate database schema\nfunction migrate() {\n local postgresDSN=\"postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:$POSTGRES_PORT/$POSTGRES_DB?sslmode=disable\"\n migrateCmd=$(which migrate)\n if [ $? -eq 0 ]; then\n echo -n \"Migrating database: \"\n $migrateCmd -database \"$postgresDSN\" -path \"$MIGRATE_PATH\" up\n else\n error \"DB migration requires the 'migrate' tool, please install it and try again.\n\nSee https://github.com/golang-migrate/migrate/tree/master/cmd/migrate\n\"\n fi\n}\n\n# Purge any old Posgres container\nfunction cleanup() {\n docker container prune --force --filter \"label=name=$CONTAINER_NAME\" > /dev/null\n}\n\n# Stop Postgres container\nfunction stop() {\n local id\n local exitCode\n local contId\n\n contId=$(containerId)\n if [ -z \"$contId\" ]; then\n echo \"Postgres container not running\"\n return\n fi\n\n id=$(docker container kill \"$contId\")\n exitCode=$? \n\n if [ $exitCode -eq 0 ]; then\n cleanup\n echo \"Postgres container stopped\"\n else\n error \"Failed to stop Postgres container (code: $exitCode, containerId: $id)\"\n fi\n}\n\n# Delete Postgres data directory\nfunction reset() {\n stop\n echo \"Cleaning the database\"\n rm -rf \"$POSTGRES_DATA_DIR\"\n mkdir -p \"$POSTGRES_DATA_DIR\"\n echo \"Database clean up finished\"\n start 30 #start with a waitFor period of 30 sec (DB-creation on FS can take longer for the first time)\n}\n\n# Check whether Postgres container is running\nfunction status() {\n if [ -n \"$(containerId)\" ]; then\n echo \"Postgres is running\"\n exit 0\n else\n echo \"Postgres not running\"\n exit 2\n fi\n}\n\n# Dispatch input command\ncase \"$1\" in\n start)\n start\n ;;\n stop)\n stop\n ;;\n reset)\n reset\n ;;\n status)\n status\n ;;\n cleanup)\n cleanup\n ;;\n migrate)\n migrate\n ;;\n *)\n echo \"\nCommand '$1' not supported. Please use:\n\n $> $(basename $0) start|stop|reset|status|cleanup|migrate\n\n * start = Start Postgres\n * stop = Stop Postgres\n * reset = Erase data and restart Postgres\n * status = Check if Postgres is running\n * cleanup = Prune remaining postgres container\n * migrate = Migrate DB to latest schema\n\"\nesac\n\n"} {"doc_id": "0041136bb0e556f17a03cc7d8e78fdb7", "text": "#!/bin/sh\n\n# Script to create/update include/generated/autoksyms.h and dependency files\n#\n# Copyright:\t(C) 2016 Linaro Limited\n# Created by:\tNicolas Pitre, January 2016\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License version 2 as\n# published by the Free Software Foundation.\n\n# Create/update the include/generated/autoksyms.h file from the list\n# of all module's needed symbols as recorded on the third line of\n# .tmp_versions/*.mod files.\n#\n# For each symbol being added or removed, the corresponding dependency\n# file's timestamp is updated to force a rebuild of the affected source\n# file. All arguments passed to this script are assumed to be a command\n# to be exec'd to trigger a rebuild of those files.\n\nset -e\n\ncur_ksyms_file=\"include/generated/autoksyms.h\"\nnew_ksyms_file=\"include/generated/autoksyms.h.tmpnew\"\n\ninfo() {\n\tif [ \"$quiet\" != \"silent_\" ]; then\n\t\tprintf \" %-7s %s\\n\" \"$1\" \"$2\"\n\tfi\n}\n\ninfo \"CHK\" \"$cur_ksyms_file\"\n\n# Use \"make V=1\" to debug this script.\ncase \"$KBUILD_VERBOSE\" in\n*1*)\n\tset -x\n\t;;\nesac\n\n# We need access to CONFIG_ symbols\ncase \"${KCONFIG_CONFIG}\" in\n*/*)\n\t. \"${KCONFIG_CONFIG}\"\n\t;;\n*)\n\t# Force using a file from the current directory\n\t. \"./${KCONFIG_CONFIG}\"\nesac\n\n# In case it doesn't exist yet...\nif [ -e \"$cur_ksyms_file\" ]; then touch \"$cur_ksyms_file\"; fi\n\n# Generate a new ksym list file with symbols needed by the current\n# set of modules.\ncat > \"$new_ksyms_file\" << EOT\n/*\n * Automatically generated file; DO NOT EDIT.\n */\n\nEOT\n[ \"$(ls -A \"$MODVERDIR\")\" ] &&\nsed -ns -e '3{s/ /\\n/g;/^$/!p;}' \"$MODVERDIR\"/*.mod | sort -u |\nwhile read sym; do\n\tif [ -n \"$CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX\" ]; then\n\t\tsym=\"${sym#_}\"\n\tfi\n\techo \"#define __KSYM_${sym} 1\"\ndone >> \"$new_ksyms_file\"\n\n# Special case for modversions (see modpost.c)\nif [ -n \"$CONFIG_MODVERSIONS\" ]; then\n\techo \"#define __KSYM_module_layout 1\" >> \"$new_ksyms_file\"\nfi\n\n# Extract changes between old and new list and touch corresponding\n# dependency files.\nchanged=$(\ncount=0\nsort \"$cur_ksyms_file\" \"$new_ksyms_file\" | uniq -u |\nsed -n 's/^#define __KSYM_\\(.*\\) 1/\\1/p' | tr \"A-Z_\" \"a-z/\" |\nwhile read sympath; do\n\tif [ -z \"$sympath\" ]; then continue; fi\n\tdepfile=\"include/config/ksym/${sympath}.h\"\n\tmkdir -p \"$(dirname \"$depfile\")\"\n\ttouch \"$depfile\"\n\techo $((count += 1))\ndone | tail -1 )\nchanged=${changed:-0}\n\nif [ $changed -gt 0 ]; then\n\t# Replace the old list with tne new one\n\told=$(grep -c \"^#define __KSYM_\" \"$cur_ksyms_file\" || true)\n\tnew=$(grep -c \"^#define __KSYM_\" \"$new_ksyms_file\" || true)\n\tinfo \"KSYMS\" \"symbols: before=$old, after=$new, changed=$changed\"\n\tinfo \"UPD\" \"$cur_ksyms_file\"\n\tmv -f \"$new_ksyms_file\" \"$cur_ksyms_file\"\n\t# Then trigger a rebuild of affected source files\n\texec $@\nelse\n\trm -f \"$new_ksyms_file\"\nfi\n"} {"doc_id": "004f6cccd58c857c30ad3b3e325d56a8", "text": "#!/usr/bin/env bash\n\nset -e\n\nfunction __get_system_timezone ()\n{\n\tlocal -r default_value=\"${1:-UTC}\"\n\n\tlocal value=\"${SYSTEM_TIMEZONE}\"\n\n\tif ! __is_valid_system_timezone \"${value}\"\n\tthen\n\t\tvalue=\"${default_value}\"\n\tfi\n\n\tprintf -- '%s' \"${value}\"\n}\n\nfunction __have_mysql_access ()\n{\n\tlocal -r database=\"${3:-mysql}\"\n\tlocal -r password=\"${2:-}\"\n\tlocal -r user=\"${1:-root}\"\n\n\tif [[ ${user} == root ]]\n\tthen\n\t\tif mysql \\\n\t\t\t--protocol=socket \\\n\t\t\t--user=\"${user}\" \\\n\t\t\t-e \"use ${database}\" \\\n\t\t\t2> /dev/null\n\t\tthen\n\t\t\treturn 0\n\t\tfi\n\telse\n\t\tif mysql \\\n\t\t\t--protocol=socket \\\n\t\t\t--user=\"${user}\" \\\n\t\t\t--password=\"${password}\" \\\n\t\t\t-e \"use ${database}\" \\\n\t\t\t2> /dev/null\n\t\tthen\n\t\t\treturn 0\n\t\tfi\n\tfi\n\n\treturn 1\n}\n\n# interval must be between 1 and 60 seconds\nfunction __is_throttled_interval ()\n{\n\tlocal -i interval=\"${1:-10}\"\n\n\tif (( $(date +%-S)%${interval} == 0 ))\n\tthen\n\t\treturn 0\n\telse\n\t\treturn 1\n\tfi\n}\n\nfunction __is_mysql_data_directory_populated ()\n{\n\tlocal datadir=\"$(\n\t\t__mysql_get_option \\\n\t\t\tmysqld \\\n\t\t\tdatadir \\\n\t\t\t\"/var/lib/mysql\"\n\t)\"\n\n\tif [[ -f ${datadir}/ibdata1 ]]\n\tthen\n\t\treturn 0\n\tfi\n\n\treturn 1\n}\n\nfunction __is_valid_system_timezone ()\n{\n\t__is_valid_zone \"${@}\"\n}\n\nfunction __is_valid_zone ()\n{\n\tlocal zone=\"${1}\"\n\n\tif [[ -n ${zone} ]] \\\n\t\t&& [[ -f /usr/share/zoneinfo/${zone} ]]\n\tthen\n\t\treturn 0\n\tfi\n\n\treturn 1\n}\n\nfunction __last_check_passed ()\n{\n\tlocal -i status=0\n\n\tif [[ ! -f ${status_path} ]]\n\tthen\n\t\treturn ${status}\n\telse\n\t\tread \\\n\t\t\t-n 1 \\\n\t\t\tstatus \\\n\t\t\t< \"${status_path}\"\n\n\t\tif [[ ${status} =~ ^[01]$ ]]\n\t\tthen\n\t\t\treturn ${status}\n\t\telse\n\t\t\treturn 1\n\t\tfi\n\tfi\n}\n\nfunction __mysql_get_option ()\n{\n\tlocal value=\"$(\n\t\t/usr/bin/my_print_defaults \"${1}\" \\\n\t\t| sed -n \"s/^--${2}=//p\" \\\n\t\t| tail -n 1\n\t)\"\n\n\tprintf -- \\\n\t\t'%s' \\\n\t\t\"${value:-$3}\"\n}\n\nfunction __record_exit_status ()\n{\n\tlocal -r status_directory=\"${status_path%/*}\"\n\n\tlocal -i status=${1:-${?}}\n\n\tif [[ ! -d ${status_directory} ]]\n\tthen\n\t\tinstall \\\n\t\t\t-d \\\n\t\t\t-m 0660 \\\n\t\t\t-o root \\\n\t\t\t-g root \\\n\t\t\t\"${status_directory}\"\n\tfi\n\n\tif [[ ! -f ${status_path} ]]\n\tthen\n\t\tinstall \\\n\t\t\t-m 0660 \\\n\t\t\t-o root \\\n\t\t\t-g root \\\n\t\t\t/dev/null \\\n\t\t\t\"${status_path}\"\n\tfi\n\n\tprintf -- \\\n\t\t'%d' \\\n\t\t\"${status}\" \\\n\t\t> \"${status_path}\"\n\n\ttrap - \\\n\t\tEXIT\n\n\texit ${status}\n}\n\nfunction __usage ()\n{\n\tcat <<-USAGE\n\t\n\tUsage: ${0##*/} [OPTIONS]\n\t ${0##*/} [-h|--help]\n\t\n\tOptions:\n\t -i, --interval= After the first successful check the \n\t check interval can be throttled to \n\t repeat at an interval of seconds between\n\t 1-60. An interval of 1 results in a \n\t check occurring every second whereas an\n\t interval of 60 limits checks to once per\n\t minute. Default: 10\n\t -q, --quiet Do not print message output.\n\t\n\tUSAGE\n\n\texit 1\n}\n\nfunction main ()\n{\n\tlocal -r mysqld=\"/usr/sbin/mysqld\"\n\tlocal -r pattern_seconds_in_minute='^([1-9]|[1-5][0-9]|60)$'\n\tlocal -r redacted_value=\"********\"\n\tlocal -r status_path=\"/var/lib/healthcheck/status\"\n\tlocal -r system_timezone=\"$(\n\t\t__get_system_timezone\n\t)\"\n\tlocal -r zone=\"$(\n\t\tsystem-timezone -qq\n\t)\"\n\n\tlocal quiet=\"false\"\n\tlocal -i interval=10\n\n\t# Trap and record the exit status\n\ttrap \"__record_exit_status \\${?}\" \\\n\t\tEXIT\n\n\twhile [[ \"${#}\" -gt 0 ]]\n\tdo\n\t\tcase \"${1}\" in\n\t\t\t-h|--help)\n\t\t\t\t__usage\n\t\t\t\tbreak\n\t\t\t\t;;\n\t\t\t--interval=*)\n\t\t\t\tinterval=\"${1#*=}\"\n\t\t\t\tshift 1\n\t\t\t\t;;\n\t\t\t-i|--interval)\n\t\t\t\tinterval=\"${2}\"\n\t\t\t\tshift 2 || break\n\t\t\t\t;;\n\t\t\t-q|--quiet)\n\t\t\t\tquiet=\"true\"\n\t\t\t\tshift 1\n\t\t\t\t;;\n\t\t\t*)\n\t\t\t\t__usage\n\t\t\t\t;;\n\t\tesac\n\tdone\n\n\tif [[ ! ${interval} =~ ${pattern_seconds_in_minute} ]]\n\tthen\n\t\t>&2 printf -- \\\n\t\t\t'ERROR: %s invalid interval' \\\n\t\t\t\"${0##*/}\"\n\t\texit 1\n\tfi\n\n\tif ! ps axo command \\\n\t\t| grep -qE '^/usr/bin/python /usr/bin/supervisord'\n\tthen\n\t\t>&2 printf -- \\\n\t\t\t\"supervisord not running\"\n\t\texit 1\n\tfi\n\n\tif [[ ${system_timezone} != \"${zone}\" ]]\n\tthen\n\t\t>&2 printf -- \\\n\t\t\t\"system-timezone zone mismatch\"\n\t\texit 1\n\tfi\n\n\tif [[ ${ENABLE_MYSQLD_BOOTSTRAP} == true ]]\n\tthen\n\t\tif [[ -f /var/lock/subsys/mysqld-bootstrap ]] \\\n\t\t\t|| ! __is_mysql_data_directory_populated\n\t\tthen\n\t\t\t>&2 printf -- \\\n\t\t\t\t\"bootstrap failed to complete\"\n\t\t\texit 1\n\t\tfi\n\tfi\n\n\tif [[ ${ENABLE_MYSQLD_WRAPPER} == true ]]\n\tthen\n\t\tif ! ps axo command \\\n\t\t\t| grep -qE \"^${mysqld} \"\n\t\tthen\n\t\t\t>&2 printf -- \\\n\t\t\t\t\"service process not running\"\n\t\t\texit 1\n\t\tfi\n\n\t\t# Skip connection tests if password is stored hashed\n\t\tif [[ ${MYSQL_ROOT_PASSWORD_HASHED} == true ]]\n\t\tthen\n\t\t\texit 0\n\t\tfi\n\n\t\t# Throttle connection checks if last check passed.\n\t\tif __last_check_passed \\\n\t\t\t&& ! __is_throttled_interval \\\n\t\t\t\t\"${interval}\"\n\t\tthen\n\t\t\texit 0\n\t\tfi\n\n\t\tif ! __have_mysql_access\n\t\tthen\n\t\t\t>&2 printf -- \\\n\t\t\t\t\"root@localhost access failed\"\n\t\t\texit 1\n\t\tfi\n\tfi\n\n\texit 0\n}\n\nmain \"${@}\"\n"} {"doc_id": "00a071f45d4c91e7cf804d8747fff061", "text": "#!/bin/sh\n#\n# This script will create all database schemas and fill them with all the initial data.\n#\n# Before using this script you need to set or change the following variables below:\n#\n# * SPOTFIRE_DB_HOST\n# * SPOTFIRE_DB_ADMIN_PASSWORD\n# * SPOTFIRE_DB_USER\n# * SPOTFIRE_DB_PASSWORD\n#\n# it is assumed that the psql binary is in the PATH\n\n. /etc/profile.d/spotfire.env\n\n# Set this variable to the hostname of the PostgreSQL instance\nSPOTFIRE_DB_HOST=${SPOTFIRE_DB_HOST:-localhost}\n\n# Set these variables to the username and password of a database user\n# with permissions to create users and databases\nSPOTFIRE_DB_ADMIN_USER=${SPOTFIRE_DB_ADMIN_USER:-dbadmin}\nSPOTFIRE_DB_ADMIN_PASSWORD=${SPOTFIRE_DB_ADMIN_PASSWORD:-dbpass123!}\n\n# Set these variables to the name of the database to be created for the TIBCO Spotfire\n# Server, and the user to be created for TIBCO Spotfire Server to access the database.\n# Note that the password is entered here in plain text, you might want to delete\n# any sensitive information once the script has been run.\nSPOTFIRE_DB_NAME=${SPOTFIRE_DB_NAME:-spotfire_server}\nSPOTFIRE_DB_USER=$SPOTFIRE_DB_ADMIN_USER\nSPOTFIRE_DB_PASSWORD=$SPOTFIRE_DB_ADMIN_PASSWORD\n\n# Common error checking function\ncheck_error() {\n # Function.\n # Parameter 1 is the return code to check\n # Parameter 2 is the name of the SQL script run\n if [ \"${1}\" -ne \"0\" ]; then\n echo \"Error while running SQL script '${2}'\"\n echo \"For more information consult the log (log.txt) file\"\n cat log.txt\n exit 1\n fi\n}\n\ncheck_table_exists() {\n DB_TABLE=\"persistent_sessions\"\n # poor's man check for some created table\n table_exists_out=$(psql -h ${SPOTFIRE_DB_HOST} -U ${SPOTFIRE_DB_USER} -d ${SPOTFIRE_DB_NAME} -c \"SELECT * FROM pg_catalog.pg_tables;\")\n rc=$?\n if [[ $rc != 0 ]];then\n echo \"ERROR($rc): Could not read tables in database \\\"$SPOTFIRE_DB_HOST\\\". Continue database schema creation.\"\n return 1\n else\n table_exists=$(echo $table_exists_out | grep -i $DB_TABLE)\n rc=$?\n if [[ $rc != 0 ]];then\n echo \"ERROR($rc): Could not find table \\\"$DB_TABLE\\\" in database \\\"$SPOTFIRE_DB_HOST\\\". Continue database schema creation.\"\n return 2\n else\n echo \"Found table \\\"$DB_TABLE\\\" in database \\\"$SPOTFIRE_DB_HOST\\\". Continue checking if required database schema creation.\"\n fi\n fi\n}\n\nsn_version_file=\"sn_version_file\"\nsn_version_db=\"sn_version_db\"\ncheck_sn_version_file() {\n sn_version_file_out=$(grep SN_VERSION populate_server_db.sql)\n rc=$?\n if [[ $rc != 0 ]];then\n echo \"ERROR($rc): Could not identify SN_VERSION in file: $sn_version_file_out. Skipping database schema creation.\"\n exit 11\n else\n sn_version_file=$(echo $sn_version_file_out | cut -d\"'\" -f 2,4 --output-delimiter=\"|\" | tr -d '[:space:]')\n fi\n}\ncheck_sn_version_db() {\n sn_version_db_out=$(psql -h ${SPOTFIRE_DB_HOST} -U ${SPOTFIRE_DB_USER} -d ${SPOTFIRE_DB_NAME} -c \"SELECT spotfire_version,schema_version FROM SN_VERSION;\" -t)\n rc=$?\n if [[ $rc != 0 ]];then\n echo \"ERROR($rc): Could not identify SN_VERSION in database: $sn_version_db_out. Skipping database schema creation.\"\n exit 12\n else\n sn_version_db=$(echo $sn_version_db_out | tr -d '[:space:]')\n fi\n}\n\n# export database admin password\nexport PGPASSWORD=${SPOTFIRE_DB_ADMIN_PASSWORD}\n\nif check_table_exists;then\n check_sn_version_file\n check_sn_version_db\n\n #if ! check_sn_version_file; then\n # echo \"ERROR: Could not identify SN_VERSION in file: $check_sn_version_file. Skipping database creation.\"\n # exit 11\n #fi\n #if ! check_sn_version_db; then\n # echo \"ERROR: Could not identify SN_VERSION in database: $check_sn_version_db. Skipping database creation.\"\n # exit 12\n #fi\n if [[ \"$sn_version_file\" == \"$sn_version_db\" ]]; then\n echo \"Database exists and SN_VERSION in file ($sn_version_file) and ($sn_version_db) are the same. Skipping database schema creation.\"\n exit 0\n else\n echo \"WARN: Database exists and SN_VERSION in file ($sn_version_file) and ($sn_version_db) differ. Skipping database schema creation.\"\n exit 13\n fi\nelse\n echo \"Not found table. Will create Skipping database schema creation.\"\nfi\n\n# Create the table spaces and user\n#echo \"Creating Spotfire Server database and user\"\n#psql -h ${SPOTFIRE_DB_HOST} -U ${SPOTFIRE_DB_ADMIN_USER} -f create_server_env.sql -v db_name=${SPOTFIRE_DB_NAME} -v db_user=${SPOTFIRE_DB_USER} -v db_pass=${SPOTFIRE_DB_PASSWORD} > log.txt 2>&1\n\n# Azure: skip spotfiredb creation\n#psql -h ${SPOTFIRE_DB_HOST} -U ${SPOTFIRE_DB_ADMIN_USER} -f create_server_env_azure.sql -d postgres -v db_name=${SPOTFIRE_DB_NAME} > log.txt 2>&1\n#check_error $? create_server_env_azure.sql\n\n# Create the tables and fill them with initial data\necho \"Creating TIBCO Spotfire Server tables\"\nexport PGPASSWORD=${SPOTFIRE_DB_PASSWORD}\npsql -h ${SPOTFIRE_DB_HOST} -U ${SPOTFIRE_DB_USER} -d ${SPOTFIRE_DB_NAME} -f create_server_db.sql >> log.txt 2>&1\ncheck_error $? create_server_db.sql\n\necho \"Populating TIBCO Spotfire Server tables\"\npsql -h ${SPOTFIRE_DB_HOST} -U ${SPOTFIRE_DB_USER} -d ${SPOTFIRE_DB_NAME} -f populate_server_db.sql >> log.txt 2>&1\ncheck_error $? populate_server_db.sql\n\n\necho \"-----------------------------------------------------------------\"\necho \"Please review the log file (log.txt) for any errors or warnings!\"\nexit 0\n"} {"doc_id": "00a7b98ad9d2adec5188aa69175e885e", "text": "#!/bin/bash\nSEARCHTEXT=\"TODO\"\nROOT=$(git rev-parse --show-toplevel)\nOUTFILE=\"todo.md\"\nEXCLUDE=''\n\nwhile getopts \"ohlf:t:e:i:\" option; do\n case $option in\n 'o' )\n STDOUT=true\n ;;\n 'h' )\n echo \"$(basename $0) - generate a todo file based on your code\"\n echo \"---\"\n echo \" -h - display this help\"\n echo -n \" -l - LIVE MODE this will add the generated file to your \"\n echo \"staged changes.\"\n echo -n \" Use this in the git hook. Off by default \"\n echo \"for playing around in the terminal\"\n echo \" -o - print output to STDOUT\"\n echo -n \" -f - write to this file (defaults to todo.md and path \"\n echo \"starts at the repo's root)\"\n echo \" -t - text to search for (defaults to TODO)\"\n echo \" -e - exclude pattern\"\n echo \" -i - include patter\"\n exit\n ;;\n 'l' )\n LIVEMODE=true\n ;;\n 'f' )\n OUTFILE=$OPTARG\n ;;\n 't' )\n SEARCHTEXT=$OPTARG\n ;;\n 'e' )\n EXCLUDE=\"$EXCLUDE$OPTARG|\"\n ;;\n 'i' )\n if [[ -z $INCLUDE ]]; then\n INCLUDE=$OPTARG\n else\n INCLUDE=\"$INCLUDE|$OPTARG\"\n fi\n ;;\n esac\ndone\n\nif [[ $INCLUDE ]] && [[ $EXCLUDE ]]; then\n echo \"-i and -e can't be used together!\"\n exit 1\nfi\n\nEXCLUDE=$EXCLUDE$OUTFILE\n\nif [ $STDOUT ] && [ $LIVEMODE ]; then\n echo \"-o and -l can't be used together! Ignoring -l\" >&2\n unset LIVEMODE\nfi\n\nOUTFILE=\"$ROOT/$OUTFILE\"\nif [ -z $STDOUT ]; then\n exec 1>$OUTFILE\nfi\n\necho \"## To Do\"\n\ncurrent_file=''\nif [[ -z $INCLUDE ]]; then\n IFS=$'\\r\\n' tasks=($(git grep -In --full-name $SEARCHTEXT $ROOT | egrep -v \"($EXCLUDE)\"))\nelse\n IFS=$'\\r\\n' tasks=($(git grep -In --full-name $SEARCHTEXT $ROOT | egrep \"($INCLUDE)\"))\nfi\n# -I - skip binaries\n# -n - include line numbers\n# --full-name - the full path (starting from the repo root)\n\nfor task in ${tasks[@]}; do\n file=$(echo $task | cut -f1 -d':')\n line=$(echo $task | cut -f2 -d':')\n item=$(echo $task | cut -f3- -d':' | sed \"s/.*$SEARCHTEXT *//g\")\n\n if [[ $file != $current_file ]]; then\n if [ $current_file ]; then\n echo\n fi\n current_file=$file\n echo \"### \\`\\`$current_file\\`\\`\"\n fi\n echo \"(line $line) $item\"\n echo\ndone\n\necho \"######Generated using [todo.md](https://github.com/charlesthomas/todo.md)\"\n\nif [ -z $LIVEMODE ]; then\n exit\nfi\n\n$(git add $OUTFILE)\n"} {"doc_id": "00aa9bd4b6ef9c57c92ae459cfc17297", "text": "#!/usr/bin/env bash\n#\n# Builds Docker images and uploads them to the docker hub\n#\n# Copyright (c) 2017, Groupon, Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n# Redistributions of source code must retain the above copyright notice,\n# this list of conditions and the following disclaimer.\n#\n# Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and/or other materials provided with the distribution.\n#\n# Neither the name of GROUPON nor the names of its contributors may be\n# used to endorse or promote products derived from this software without\n# specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS\n# IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\n# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\n# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\n# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n# shellcheck disable=SC1091\nsource silo/exit_codes.sh\n\n# Default Dockerfile to process. Can be overwritten via -i\ndockerfile=\"Dockerfile\"\n\n# Default image name to build. Can be overwritten via -i\nimage_name=\"ansible-silo\"\n\n# Fallback image version. It will be tried to detect the current version to\n# rebuild it unless -v war provided\nimage_version=\"0.0.0\"\n\n# If set to 1, the built image will be uploaded to the docker hub\npush=0\n\nwhile getopts \"v:i:p\" opt; do\n case \"${opt}\" in\n v)\n image_version=\"${OPTARG}\"\n ;;\n i)\n dockerfile=\"${OPTARG}.Dockerfile\"\n image_name=\"ansible-silo-${OPTARG}\"\n ;;\n p)\n push=1\n ;;\n \\?)\n exit \"${EX_USAGE}\"\n ;;\n esac\ndone\n\nif [[ ! -f \"${dockerfile}\" ]]; then\n echo \"There is no file ${dockerfile}\" >&2\n exit \"${EX_NOINPUT}\"\nfi\n\nimage_path=\"grpn/${image_name}\"\n\n# If -v was not passed as option, we use the latest available version\n# Though we disable the push, as this might not have been intended.\nif [[ \"${image_version}\" == \"0.0.0\" ]]; then\n if [[ \"${push}\" -eq 1 ]]; then\n echo \"DISABLING PUSH - NO VERSION GIVEN\"\n push=0\n fi\n # Detect latest version\n last_version=$(docker inspect \"${image_path}\" 2> /dev/null \\\n | grep \"${image_path}:\" \\\n | grep -v \"${image_path}:latest\" \\\n | sed \"s/\\\"//g;s/,//g\" \\\n | cut -d':' -f2)\n if [[ ! -z \"${last_version}\" ]]; then\n image_version=\"${last_version}\"\n fi\nfi\n\n# Validate version\nif [[ ! \"${image_version}\" =~ ^[0-9]+(\\.[0-9]+)+(-[0-9]){0,2}$ ]]; then\n echo \"Version must be in format X.Y.Z, e.g. 1.2.3. Given: ${image_version}\" \\\n >&2\n exit \"${EX_VERSION}\"\nfi\n\necho \"Building new ${image_name} image ${image_version}\"\n\n# Build as \"latest\"\ndocker build --build-arg \"v=${image_version}\" --file \"${dockerfile}\" \\\n --tag \"${image_path}:latest\" . || exit\ndocker tag \"$(docker images --quiet \"${image_path}:latest\")\" \\\n \"${image_path}:${image_version}\" || exit\n\nif [[ \"${push}\" -eq 1 ]]; then\n docker push \"${image_path}:${image_version}\" || exit\n docker push \"${image_path}:latest\" || exit\nfi\n"} {"doc_id": "00c6c07428e9d888c0632afffdeae258", "text": "#!/bin/bash\n\nset -o errexit -o nounset -o pipefail\nset -o xtrace\n\n# Calls CMake to generate build files and then run the build.\n# Usage:\n# generate_and_build [ ...]\ngenerate_and_build() {\n local folder_name=$1\n shift\n\n mkdir \"${folder_name}\"\n (cd \"${folder_name}\"; cmake \"$@\" ..)\n cmake --build \"${folder_name}\"\n}\n\n# Choose what to do based on OS and compiler.\ncase \"${TRAVIS_OS_NAME}_${TRAVIS_COMPILER}\" in\n linux_clang)\n sudo apt install \"linux-headers-$(uname -r)\"\n\n generate_and_build build\n ;;\n\n osx_clang)\n generate_and_build build\n ;;\n\n windows_*)\n generate_and_build build-x64 -A x64\n generate_and_build build-win32 -A Win32\n ;;\n\n linux_gcc)\n # Need this `apt update` for the install to succeed. Without it, the\n # Travis worker only has lists for the ${distro}-security repository.\n sudo apt update\n sudo apt install \\\n \"linux-headers-$(uname -r)\" \\\n g++-i686-linux-gnu \\\n g++-aarch64-linux-gnu \\\n g++-powerpc64le-linux-gnu\n\n generate_and_build build-x86_64\n\n generate_and_build build-i686 \\\n -DCMAKE_TOOLCHAIN_FILE=ci/toolchains/i686-linux-gnu.cmake\n\n generate_and_build build-aarch64 \\\n -DCMAKE_TOOLCHAIN_FILE=ci/toolchains/aarch64-linux-gnu.cmake\n\n generate_and_build build-powerpc64le \\\n -DCMAKE_TOOLCHAIN_FILE=ci/toolchains/powerpc64le-linux-gnu.cmake\n ;;\nesac\n"} {"doc_id": "00c8cb2a7d0eff275e713f65238b0c25", "text": "#!/bin/bash\n#\n# Purpose: Custom Xray Commands Master Script\n# Requirements: jq | curl | Xray credentials\n# Author: Loren Y\n#\n\nSCRIPT_DIR=`dirname $0`;\nPARENT_SCRIPT_DIR=\"$(dirname \"$SCRIPT_DIR\")\"\nPARENT2_SCRIPT_DIR=\"$(dirname \"$PARENT_SCRIPT_DIR\")\"\n\nif [ ! -f $PARENT_SCRIPT_DIR/json/xrayValues.json ]; then\n SCRIPT_VERSION=$(jq -r .script_version $PARENT_SCRIPT_DIR/metadata.json)\n echo \"Welcome to Loren's Custom Xray commands master script. You're on version $SCRIPT_VERSION. Creating $PARENT_SCRIPT_DIR/json/...\"\n $PARENT_SCRIPT_DIR/common/installPrerequisites.sh\n echo \"Could not find xrayValues.json, generating:\"\n while true; do\n echo \"Enter your Xray URL (e.g. http://localhost:8000):\"\n read xray_url\n if [ \"$(curl -s $xray_url/api/v1/system/ping | jq -r .status)\" != \"pong\" ]; then\n echo \"Xray doesn't look to be either running or reachable from here.\"\n else\n break\n fi \n done\n\n echo \"Enter your $xray_url username:\"\n read username\n echo \"Enter your $xray_url password:\"\n read -s password\n\n while true; do\n echo \"Enter your \\$XRAY_HOME location (e.g. /Users/loreny/.jfrog/xray):\"\n read xray_home\n if [ \"$xray_home\" != \"/\" ]; then\n xray_home=$(echo $xray_home | sed 's:/*$::')\n fi\n if [ ! -d \"$xray_home\" ]; then\n echo \"$xray_home doesnt exist.\"\n else\n break\n fi \n done\n while true; do\n echo \"Enter your Xray Directory location (e.g. /Users/loreny/xray):\"\n read xray_dir\n if [ \"$xray_dir\" != \"/\" ]; then\n xray_dir=$(echo $xray_dir | sed 's:/*$::')\n fi\n if [ ! -d \"$xray_dir\" ]; then\n echo \"$xray_dir doesnt exist.\"\n else\n break\n fi \n done\n echo \"Select your Xray installation type:\"\n select install_type in \"docker\" \"centos\" \"debian\" \"redhat\" \"ubuntu\"; do\n case $install_type in\n docker ) break;;\n centos ) break;;\n debian ) break;;\n redhat ) break;;\n ubuntu ) break;;\n esac\n done\n echo \"Creating $PARENT_SCRIPT_DIR/json/xrayValues.json\"\n echo -e \"{\\\"username\\\":\\\"\"$username\"\\\", \\\"password\\\":\\\"\"$password\"\\\", \\\"xray_home\\\":\\\"\"$xray_home\"\\\", \\\"xray_url\\\":\\\"\"$xray_url\"\\\", \\\"xray_dir\\\":\\\"\"$xray_dir\"\\\", \\\"install_type\\\":\\\"\"$install_type\"\\\"}\" > $PARENT_SCRIPT_DIR/json/xrayValues.json\nfi\nXRAY_HOME=$(jq -r '.xray_home' $PARENT_SCRIPT_DIR/json/xrayValues.json)\nXRAY_URL=$(jq -r '.xray_url' $PARENT_SCRIPT_DIR/json/xrayValues.json)\nXRAY_CREDS=$(jq -r '\"\\(.username):\\(.password)\"' $PARENT_SCRIPT_DIR/json/xrayValues.json)\nXRAY_DIR=$(jq -r '.xray_dir' $PARENT_SCRIPT_DIR/json/xrayValues.json)\n\ncase \"$1\" in\n check)\n $PARENT_SCRIPT_DIR/common/upgradeScriptToLatest.sh;;\n upgrade)\n $SCRIPT_DIR/upgradeXrayToLatest.sh;;\n restart)\n $XRAY_DIR/xray restart;;\n status)\n curl -u $XRAY_CREDS $XRAY_URL/api/v1/system/ping;\n echo \"\";;\n baseUrl)\n $SCRIPT_DIR/setBaseUrl.sh;; \n start)\n $XRAY_DIR/xray start;;\n stop)\n $XRAY_DIR/xray stop;;\n ps)\n $XRAY_DIR/xray ps;;\n default)\n $XRAY_DIR/xray $2;;\n disableRestart)\n $SCRIPT_DIR/disableRestart.sh;; \n *)\n echo $\"Usage: xray (commands ... )\";\n echo \"commands:\";\n echo \" check = Check for latest script version and optionally upgrade\";\n echo \" upgrade = Upgrade Xray to latest, or a specified version\";\n echo \" restart = Restart Xray\";\n echo \" start = Start Xray\";\n echo \" status = Xray Status\";\n echo \" stop = Stop Xray\";\n echo \" ps = Xray microservices' status\"\n echo \" baseUrl = Change Xray Base URL to current internal IP\";\n echo \" disableRestart = Disable Xray Docker restart\";\n echo \" default = Normal Xray command script + [options]\";;\nesac"} {"doc_id": "00cdd8a98de520d71670e305aefe54a6", "text": "#!/usr/bin/env bash\n# pw - a mnml password manager\n\ncommand -v gpg >/dev/null 2>&1 && gpg=gpg\ncommand -v gpg2 >/dev/null 2>&1 && gpg=gpg2\n\n# check if xclip or pbcopy exist\n# command -v xclip >/dev/null 2>&1 && copy=\"xclip -rmlastnl -selection clipboard\"\n# command -v pbcopy >/dev/null 2>&1 && copy=\"pbcopy | tr -d '\\n'\"\n\n# export PW_DIR to your own path\n[[ -z \"$PW_DIR\" ]] && PW_DIR=\"$HOME/.pw\"\n\ninit() {\n if [[ ! -e \"$PW_DIR\" ]]; then\n mkdir -p \"$PW_DIR\"\n printf \"pw: password directory initialized at %s\\n\" \"$PW_DIR\"\n else\n printf \"PW_DIR is %s\\n\" \"$PW_DIR\"\n die \"$PW_DIR exists\"\n fi\n}\n\nadd() {\n # $1: path to file\n # $2 [optional]: password text\n [[ -z \"$PW_KEY\" ]] && die \"\\$PW_KEY not set\"\n\n if [[ \"$#\" -eq 2 ]]; then\n pass=\"$2\"\n else\n # uses default length of 25 chars, unless PW_LEN is set\n pass=\"$(pwgen \"${PW_LEN:-25}\" 1 -s)\"\n printf \"pw: generated password for %s\\n\" \"$1\"\n fi\n if [[ ! -f \"$PW_DIR/$1.gpg\" ]]; then\n printf \"%s\" \"$pass\" | \"$gpg \"-er \"$PW_KEY\" -o \"$PW_DIR/$1.gpg\"\n printf \"pw: %s/%s.gpg created\\n\" \"$PW_DIR\" \"$1\"\n else\n die \"the file %s/%s.gpg exists\" \"$PW_DIR\" \"$1\"\n fi\n}\n\nlist() {\n for f in \"$PW_DIR\"/*.gpg; do\n printf '%s\\n' \"$(basename \"${f%.gpg}\")\"\n done\n}\n\ndel() {\n checkf \"$PW_DIR/$1.gpg\"\n read -rn 1 -p \"pw: are you sure you want to delete $1? [y/n]: \"\n printf \"\\n\"\n [[ \"$REPLY\" == [yY] ]] && {\n rm -f \"$PW_DIR/$1.gpg\"\n printf \"pw: deleted %s\" \"$1\"\n }\n}\n\nshow() {\n checkf \"$PW_DIR/$1.gpg\"\n \"$gpg\" --decrypt --quiet --use-agent \"$PW_DIR/$1.gpg\"\n}\n\n# TODO: rework having to checkf twice\n\ncopy() {\n checkf \"$PW_DIR/$1.gpg\"\n if [[ \"$OSTYPE\" =~ darwin* ]]; then\n show \"$1\" | head -1 | pbcopy | tr -d '\\n'\n else\n show \"$1\" | head -1 | xclip -rmlastnl -selection clipboard\n fi\n printf \"pw: copied %s to clipboard\\n\" \"$1\"\n}\n\nusage() {\n usage=\"\npw - mnml password manager\n\nusage: pw [options] [NAME]\nAll options except -i and -h require a NAME argument.\n\noptions:\n -i Initializes password directory at \\$HOME/.pw or at \\$PW_DIR, if it exists.\n -a Add a password.\n -g Generate a password.\n -s Print password to STDOUT.\n -l List out all passwords.\n -c Copy existing password to clipboard.\n -d Delete password.\n -h Display this help message and exit.\n\nRequires PW_KEY to be set. Optionally, set PW_DIR for custom directory location.\nSet PW_LEN to an integer of your choice, to override the default password length of 25.\n\"\n\n printf \"%s\" \"$usage\"\n exit 1\n}\n\ncheckf() {\n [[ ! -f \"$1\" ]] &&\n die \"$1 does not exist\"\n}\n\ndie() {\n printf \"error: %s\\n\" \"$1\" >&2\n exit 1\n}\n\n\nmain() {\n [[ -z \"$1\" ]] && {\n usage\n }\n\n while getopts \"ila:g:s:c:d:h\" options\n do\n # shellcheck disable=SC2221,SC2222\n case \"$options\" in\n i) init ;;\n l) list ;;\n g) add \"$OPTARG\" ;;\n a)\n read -rsp \"enter password: \" pass\n printf \"\\n\"\n add \"$OPTARG\" \"$pass\"\n ;;\n s) show \"$OPTARG\" ;;\n c) copy \"$OPTARG\" ;;\n d) del \"$OPTARG\" ;;\n *|h) usage ;;\n esac\n done\n\n shift $(( OPTIND -1 ))\n}\n\nmain \"$@\"\n"} {"doc_id": "00ec55ac6d3098fbdba169312670417a", "text": "#!/bin/bash\n\n# This script compiles from scratch a Node.js executable and copy it with its\n# needed libraries on the ROOT filesystem\n\nGRN=\"\\e[32m\"\nCLR=\"\\e[0m\"\n\n\nif [[ -z \"$name\" ]]; then name=layer2; fi\n\ncase $PLATFORM in\n docker)\n ROOT=$(pwd)/ROOT\n\n rm -rf $ROOT &&\n mkdir -p $ROOT || exit 10\n ;;\n qemu)\n ROOT=/tmp/ROOT\n ;;\nesac\n\n\nNODE_VERSION=v`curl -s https://semver.io/node/stable`\nNODE_URL=http://nodejs.org/dist/latest/node-$NODE_VERSION.tar.gz\n\n\n# explicicly clone node because submodules SUCK\nif [[ ! -d deps/node ]]; then\n mkdir -p deps/node &&\n curl $NODE_URL | tar xzf - -C deps/node --strip-components=1 &&\n ( cd deps/node && ./configure && make --jobs=16 ) || exit 21\nfi\n\nmkdir -p $ROOT/usr/bin &&\ncp deps/node/node $ROOT/usr/bin/node || exit 22\n\n\n# Important shared libraries\nif [ $(uname -m) == 'x86_64' ]; then\n platform=x86_64-linux-gnu\nelse\n platform=i386-linux-gnu\nfi\n\nrm -rf $ROOT/lib &&\nrm -rf $ROOT/lib64 && \nrm -rf $ROOT/usr/lib || exit 23\n\nmkdir -p $ROOT/lib/$platform &&\n\ncp -f /lib/$platform/libdl.so.2 $ROOT/lib/$platform/ &&\ncp -f /lib/$platform/librt.so.1 $ROOT/lib/$platform/ &&\ncp -f /lib/$platform/libm.so.6 $ROOT/lib/$platform/ &&\ncp -f /lib/$platform/libgcc_s.so.1 $ROOT/lib/$platform/ &&\ncp -f /lib/$platform/libpthread.so.0 $ROOT/lib/$platform/ &&\ncp -f /lib/$platform/libc.so.6 $ROOT/lib/$platform/ &&\n\ncp -f /lib/$platform/ld-2.19.so $ROOT/lib/$platform/ &&\nln -s $platform/ld-2.19.so $ROOT/lib/ld-linux.so.2 &&\n\nmkdir -p $ROOT/usr/lib/$platform &&\ncp -f /usr/lib/$platform/libstdc++.so.6 $ROOT/usr/lib/$platform/ || exit 24\n\nif [ $(uname -m) == 'x86_64' ]; then\n mkdir -p $ROOT/lib64 &&\n cp -f /lib/$platform/ld-linux.so.2 $ROOT/lib/$platform/ &&\n ln -s /lib/$platform/ld-linux.so.2 $ROOT/lib64/ld-linux-x86-64.so.2 || exit 25\nfi\n\n\ncase $PLATFORM in\n docker)\n sudo docker build -t $name . || exit 26\n ;;\nesac\n\necho -e \"${GRN}Successfully built Layer-2 image '$name'${CLR}\"\n"} {"doc_id": "00f877c322bb3ee91ed33f9806ec9f41", "text": "#!/bin/bash\n\ndeclare -a FUNCS_CHECK\n\nfunction _register_check_function() {\n FUNCS_CHECK+=(\"${1}\")\n _log 'trace' \"${1}() registered\"\n}\n\nfunction _check() {\n _log 'info' 'Checking configuration'\n for FUNC in \"${FUNCS_CHECK[@]}\"; do\n ${FUNC}\n done\n}\n\nfunction _check_improper_restart() {\n _log 'debug' 'Checking for improper restart'\n\n if [[ -f /CONTAINER_START ]]; then\n _log 'warn' 'This container was (likely) improperly restarted which can result in undefined behavior'\n _log 'warn' 'Please destroy the container properly and then start DMS again'\n fi\n}\n\nfunction _check_hostname() {\n _log 'debug' 'Checking that hostname/domainname is provided or overridden'\n\n _log 'debug' \"Domain has been set to ${DOMAINNAME}\"\n _log 'debug' \"Hostname has been set to ${HOSTNAME}\"\n\n # HOSTNAME should be an FQDN (eg: hostname.domain)\n if ! grep -q -E '^(\\S+[.]\\S+)$' <<< \"${HOSTNAME}\"; then\n _dms_panic__general 'Setting hostname/domainname is required'\n fi\n}\n\nfunction _check_log_level() {\n if [[ ${LOG_LEVEL} == 'trace' ]] \\\n || [[ ${LOG_LEVEL} == 'debug' ]] \\\n || [[ ${LOG_LEVEL} == 'info' ]] \\\n || [[ ${LOG_LEVEL} == 'warn' ]] \\\n || [[ ${LOG_LEVEL} == 'error' ]]\n then\n return 0\n else\n local DEFAULT_LOG_LEVEL='info'\n _log 'warn' \"Log level '${LOG_LEVEL}' is invalid (falling back to default '${DEFAULT_LOG_LEVEL}')\"\n\n # shellcheck disable=SC2034\n VARS[LOG_LEVEL]=\"${DEFAULT_LOG_LEVEL}\"\n LOG_LEVEL=\"${DEFAULT_LOG_LEVEL}\"\n fi\n}\n"} {"doc_id": "01327a99ffd344394cdd14b5a91cd5a1", "text": "#!/bin/sh\n\nNAMEFROM=module.name\nSTATICFROM=static.parts\nCC=i686-pc-ray-g++\nLD=i686-pc-ray-ld\nINCLUDEDIR=../ray/include\nKSTAT_DIR=../ray/raylib\nOUTFILE=Makefile\nDEBUG=1\n\nif [ -r $NAMEFROM ]\nthen\n\tMODFILE=`cat $NAMEFROM`\nelse\n\techo -e \"File '$NAMEFROM' needed to read module name from not found. Aborting.\"\n\texit 1\nfi\n\nif [ -r $STATICFROM ]\nthen\n\tSTATFILES=`cat $STATICFROM`\nelse\n\techo -e \"File '$STATICFROM' needed to read parts that will be staticly compiled into the module $MODFILE.\"\n\texit 1\nfi\n\t\n\n\n\nSTATFILES=\"$STATFILES\nstandard\"\n\nfor STATICFILE in $STATFILES\ndo\n\tSTATICS=\"$STATICS $KSTAT_DIR/$STATICFILE.o\"\ndone\n\n\nif [ $DEBUG == 1 ]\nthen\n\tDEFS=\"-g3\"\n\tOPT=0\nelse\n\tDEFS=\"\"\n\tOPT=2\nfi\n\nC_ARGS=\"$DEFS -I$INCLUDEDIR -O$OPT -c -Wall -Wswitch-enum -Werror\"\n\n#echo -e \" ========== GENERATING MAKEFILE ============\"\n#echo -e \" include dir: $INCLUDEDIR\"\n#echo -e \" CC args: $C_ARGS\"\n#echo -e \" ===========================================\"\n\t\n\n\necho -e \"# NURNware Ray kernel module $MODFILE\">$OUTFILE\necho -e \"# (For use with Cold iGnition operating system)\">>$OUTFILE\necho -e \"# Copyright (C) 2007 - NURNware Technologies\">>$OUTFILE\necho -e \"\\n\">>$OUTFILE\n\n# Variables\necho -e \"CC=$CC\">>$OUTFILE\necho -e \"C_ARGS=$C_ARGS\">>$OUTFILE\necho -e \"LD=$LD\">>$OUTFILE\necho -e \"\\n\">>$OUTFILE\n\necho -e \"all: $MODFILE\">>$OUTFILE\necho -e \"\\n\">>$OUTFILE\n\necho -e \"clean:\">>$OUTFILE\necho -e \"\\t@echo -e \\\"Deleting all object files...\\\"\">>$OUTFILE\necho -e \"\\t@-rm \\`find . -iname '*.o'\\`>/dev/null\">>$OUTFILE\necho -e \"\\n\">>$OUTFILE\n\necho -e \"rebuild: clean $MODFILE\">>$OUTFILE\necho -e \"\\n\">>$OUTFILE\n\n\nCFILES=0\nISERR=0\n for CURFILE in *.cpp\n do\n\tif [ $ISERR == \"0\" ]\n\tthen\n\t\tif [[ \"$CURFILE\" = *.cpp ]]\n\t\tthen\n\t\t\tOBJFILE=${CURFILE%.cpp}.o\n\t\telse\n\t\t\tOBJFILE=\"\"\n\t\tfi\n\t\techo -e \"\\t Getting headers for $CURFILE...\"\n\t\tHEADERS=`$CC $C_ARGS $CURFILE -M -MT $OBJFILE`\n \t\tif [ $? != \"0\" ]\n\t\tthen\n\t\t ISERR=1\n\t\tfi\n\n\t\techo -e \"$HEADERS\">>$OUTFILE\n\t\techo -e \"\\t@echo -e \\\"\\t SUBPART OF MODULE [$CURFILE]\\\"\">>$OUTFILE\n\t\techo -e \"\\t@\\$(CC) \\$(C_ARGS) $CURFILE -o $OBJFILE\">>$OUTFILE\n\t\techo -e \"\\n\">>$OUTFILE\n\n\t\tALLFILES=\"$ALLFILES $CURFILE\"\n\t\tOBJECTS=\"$OBJECTS $OBJFILE\"\n\n\telse\n\t echo -e \"Aborting $CURFILE due to errors.\"\n\tfi\n\n\tCFILES=`expr $CFILES + 1`\n done\n\necho -e \"Makefile $MODFILE\"\necho -e \"$MODFILE: $OBJECTS\">>$OUTFILE\necho -e \"\\t@echo -e \\\"Building module $MODFILE\\\"\">>$OUTFILE\necho -e \"\\t@\\$(CC) -o $MODFILE $OBJECTS $STATICS\">>$OUTFILE\n\nif [ $ISERR == \"0\" ]\nthen\n\techo -e \"Makefile built successfully.\"\nelse\n\techo -e \"There were errors generating the Makefile!\"\nfi\n"} {"doc_id": "0140d3b6319d13e52e1b5093beab61e0", "text": "#!/bin/bash\nset -e\n\nIS_CORE=\"\"\n\nif [ \"$1\" == \"--core\" ]; then\n shift\n IS_CORE=yes\nelif [ \"$1\" == \"--no-core\" ]; then\n shift\nelif echo $PWD | grep -q \"trezor-core\"; then\n IS_CORE=yes\nfi\n\nif [ -n \"$1\" ]; then\n OUTDIR=`readlink -f \"$1\"`\nfi\n\ncd \"$(dirname \"$0\")\"\n\n# set up paths\nINDEX=\"__init__.py\"\nGENPATH=\"${OUTDIR:-../trezorlib/messages}\"\nPROTO_PATH=\"../vendor/trezor-common/protob\"\nPROTO_FILES=\"types messages\"\n\n# set up temporary directory & cleanup\nTMPDIR=$(mktemp -d)\nfunction cleanup {\n rm -r $TMPDIR\n}\ntrap cleanup EXIT\n\n# set up pb2 outdir\nPB2_OUT=\"$TMPDIR/pb2\"\nmkdir -p \"$PB2_OUT\"\n\n# compile .proto files to python2 modules using google protobuf library\nfor file in $PROTO_FILES; do\n protoc --python_out=\"$PB2_OUT\" -I/usr/include -I/usr/local/include -I\"$PROTO_PATH\" \"$PROTO_PATH/$file.proto\"\ndone\n\n\nif [ -n \"$IS_CORE\" ]; then\n # generate for micropython\n PB2PY_OPTS=\"-m\"\nelse\n # create index (__init__.py)\n echo \"# Automatically generated by pb2py\" > $TMPDIR/$INDEX\n echo >> $TMPDIR/$INDEX\n PB2PY_OPTS=\"-l $TMPDIR/$INDEX\"\nfi\n\n# convert google protobuf library to trezor's internal format\nfor file in $PROTO_FILES; do\n ./pb2py $PB2PY_OPTS -P \"trezorlib.protobuf\" -p \"$PB2_OUT\" \"$file\" \"$TMPDIR\"\ndone\n\nif [ -n \"$IS_CORE\" ]; then\n cp \"$TMPDIR/MessageType.py\" \"$TMPDIR/wire_types.py\"\nfi\n\n# ensure $GENPATH exists and is empty of messages\nmkdir -p \"$GENPATH\"\n# only remove messages - there could possibly be other files not starting with capital letter\nrm -f \"$GENPATH\"/[A-Z]*.py\n\n# move generated files to the destination\n# (this assumes $INDEX is *.py, otherwise we'd have to add $INDEX separately)\nmv \"$TMPDIR\"/*.py \"$GENPATH\"\n\n# the exit trap handles removing the tmp directory\n"} {"doc_id": "01657ba11c55fa50a997d7f4b8c44c11", "text": "#!/bin/bash\n\nfunction _mask_ip_digit() {\n if [[ ${1} -ge 8 ]]; then\n MASK=255\n elif [[ ${1} -le 0 ]]; then\n MASK=0\n else\n VALUES=(0 128 192 224 240 248 252 254 255)\n MASK=${VALUES[${1}]}\n fi\n\n local DVAL=${2}\n ((DVAL&=MASK))\n\n echo \"${DVAL}\"\n}\n\n# Transforms a specific IP with CIDR suffix\n# like 1.2.3.4/16 to subnet with cidr suffix\n# like 1.2.0.0/16.\n# Assumes correct IP and subnet are provided.\nfunction _sanitize_ipv4_to_subnet_cidr() {\n local DIGIT_PREFIX_LENGTH=\"${1#*/}\"\n\n declare -a MASKED_DIGITS DIGITS\n IFS='.' ; read -r -a DIGITS < <(echo \"${1%%/*}\") ; unset IFS\n\n for ((i = 0 ; i < 4 ; i++)); do\n MASKED_DIGITS[i]=$(_mask_ip_digit \"${DIGIT_PREFIX_LENGTH}\" \"${DIGITS[i]}\")\n DIGIT_PREFIX_LENGTH=$((DIGIT_PREFIX_LENGTH - 8))\n done\n\n echo \"${MASKED_DIGITS[0]}.${MASKED_DIGITS[1]}.${MASKED_DIGITS[2]}.${MASKED_DIGITS[3]}/${1#*/}\"\n}\n"} {"doc_id": "017a228e53dfaa2278a66a3c9f20eb2e", "text": "#!/bin/bash\n\nfunction tryrun {\n MESSAGE=$(\"$@\" 2>&1)\n local exitcode=$?\n if [ $exitcode -ne 0 ]; then\n echo \" - FAILED\"\n echo \"$MESSAGE\" | sed \"s/^/ /\"\n else\n \techo \" - SUCCESS\"\n fi\n return $exitcode\n}\n\nfunction cleanupandexit {\n\tif [ $? -ne 0 ]; then\n echo -e \" * Cleaning up\"\n rm -r \"$PROJECT_DIR\"\n exit 1\n fi\n}\n\nif [ $# = 2 ]; then\n START_DIR=\"$(pwd)\"\n PROJECT_NAME=\"$1\"\n PROJECT_DIR=\"$(pwd)/$PROJECT_NAME\"\n PROJECT_TYPE=\"$2\"\n TEMPLATE_DIR=\"$(dirname $(dirname $(readlink -f \"$0\")))\"\n \n case $PROJECT_TYPE in\n nodejs)\n ;;\n rust)\n ;;\n *)\n\techo \"ERROR: Unknown project type\"\n exit 1\n ;;\n esac\n\n echo \"--------------\"\n echo \"Project name: $PROJECT_NAME\"\n echo \"Project directory: $PROJECT_DIR\"\n echo \"Project type: $PROJECT_TYPE\"\n #echo \"Template directory: $TEMPLATE_DIR\"\n echo \"--------------\"\n read -s -p \"Proceed [Y/n]\" -n 1 PROCEED\n echo\n if [[ \"$PROCEED\" =~ [Yy] || \"$PROCEED\" = \"\" ]]; then\n echo -n \" * Creating project directory\"\n tryrun mkdir \"$PROJECT_DIR\"\n # Cleanup and exit\n if [ $? -ne 0 ]; then\n exit 1\n fi\n \n echo -n \" * Cloning project template\"\n tryrun rsync -az --exclude=node_modules \"$TEMPLATE_DIR/$PROJECT_TYPE/\" \"$PROJECT_DIR\"\n # Cleanup and exit\n cleanupandexit\n\n echo \" * Running project type specific init scripts\"\n \"$TEMPLATE_DIR\"/scripts/init-\"$PROJECT_TYPE\".sh \"$PROJECT_NAME\" \"$PROJECT_DIR\"\n cleanupandexit\n\n echo -e \"\\nDone\\n\"\n else\n exit 1\n fi\nelse\n echo \"USAGE: new-project.sh PROJECT_NAME PROJECT_TYPE\"\n exit 1\nfi"} {"doc_id": "017feaed45522a5e730fc5c2a6402169", "text": "export VENV_HOME=\"$HOME/.venv\"\n[[ -d $VENV_HOME ]] || mkdir $VENV_HOME\n\nlsvenv() {\n EXISTING_VENVS=$(ls $VENV_HOME)\n if [ \"$EXISTING_VENVS\" = \"\" ]; then\n (>&2 echo \"You currently have no virtual environment.\")\n (>&2 echo \"To make one, type \\`mkvenv name_of_env\\`\")\n else\n (>&2 echo \"Here is the list of existing virtual environments:\")\n (>&2 echo \"--------------------------------------------------\")\n (>&2 echo $EXISTING_VENVS)\n fi\n}\n\nvenv() {\n # Check that exactly one and only one argument was passed to the function\n if [ $# -eq 1 ]; then\n source \"$VENV_HOME/$1/bin/activate\" 2> /dev/null\n # If previous command returned an error code\n if [ ! $? -eq 0 ]; then\n (>&2 echo \"Virtual environment \\`$1\\` does not exist.\")\n while true; do\n read -q \"yn?Do you want to create it? [y/n]\"\n echo\n if [[ \"$yn\" = \"y\" ]]; then\n mkvenv \"$1\"\n break\n elif [[ \"$yn\" = \"n\" ]]; then\n return 1\n fi\n done\n fi\n else\n (>&2 echo \"Type \\`venv name_of_env\\` to activate a virtual environment.\\n\")\n lsvenv\n return 1\n fi\n}\n\nmkvenv() {\n # Check that exactly one and only one argument was passed to the function\n if [ $# -eq 1 ]; then\n VENV_NAME=$(_venv_name)\n if [ $? -eq 0 ]; then\n (>&2 echo \"You must first deactivate your current virtual environment before creating a new one,\")\n (>&2 echo \"by typing: \\`deactivate\\`\")\n return 1\n fi\n if [ -d \"${VENV_HOME}/$1\" ]; then\n (>&2 echo \"Virtual environment $1 already exists.\")\n (>&2 echo \"To remove it, run \\`deactivate; rmvenv $1\\`\")\n return 1\n else\n ${VENV_WRAPPER_PYTHON:-python3} -m venv $VENV_HOME/$1\n venv $1\n echo \"Created and activated venv $1\"\n fi\n else\n (>&2 echo \"Type \\`mkvenv name_of_env\\` to make a new virtual environment.\")\n return 1\n fi\n}\n\nrmvenv() {\n # Check that exactly one and only one argument was passed to the function\n if [ $# -gt 0 ]; then\n for arg in \"$@\"; do\n _rmvenv \"$arg\"\n done\n else\n (>&2 echo \"Type \\`rmvenv name_of_env\\` to remove an existing virtual environment.\\n\")\n lsvenv\n return 1\n fi\n}\n\n_rmvenv() {\n VENV_NAME=$(_venv_name)\n if [ $? -eq 0 ]; then\n if [ \"$VENV_NAME\" = \"$1\" ]; then\n (>&2 echo \"You must first deactivate your virtual environment before removing it,\")\n (>&2 echo \"by typing: \\`deactivate; rmvenv $1\\`\")\n return 1\n fi\n fi\n if [ -d \"$VENV_HOME/$1\" ]; then\n rm -r $VENV_HOME/$1\n echo \"Removed venv $1\"\n else\n (>&2 echo \"venv $1 does not exist.\\n\")\n lsvenv\n return 1\n fi\n}\n\n_is_in_venv() {\n # Inside a virtual environment, sys.prefix points to the virtual environment,\n # whereas base_prefix points to a parent directory of the \"real\" python\n python -c \"import sys; import os; assert hasattr(sys, 'base_prefix'); assert sys.base_prefix != sys.prefix\" 2> /dev/null\n return $?\n}\n\n_venv_name() {\n # Print the venv name if in a venv, else return an error code\n _is_in_venv\n if [ $? -eq 0 ]; then\n python -c \"import sys; import os; print(os.path.basename(sys.prefix))\"\n else\n return $?\n fi\n}\n\npurgenv() {\n ORI_VENV_NAME=$(_venv_name)\n if [ $? -eq 0 ]; then\n echo \"You are in the matrix\"\n deactivate\n rmvenv $ORI_VENV_NAME\n mkvenv $ORI_VENV_NAME\n else\n echo \"You are in the real world\"\n return 1\n fi\n}\n\n_venv_completion () {\n _values echo $(ls -1 $VENV_HOME)\n}\n\ncompdef _venv_completion venv rmvenv\n"} {"doc_id": "0190434dfcd569c0463fba32799fdd72", "text": "#!/bin/bash\n\n# Check if user exits\nUSER=mqttnetsrv\nUSEREXISTS=$(id -u $USER >/dev/null 2>&1; echo $?)\nEC=0\nBASEPATH=/opt\nINSTALLPATH=$BASEPATH/MQTTnetServer\n\n# If user does not exist, create it\nif (( $USEREXISTS == 1 )); then\n useradd -d $INSTALLPATH -r $USER\n EC=$(echo $?)\n\n if (( $EC == 1 )); then\n exit 1;\n fi\nfi\n\n# Set permissions on files\nchown -R root:root $INSTALLPATH\n\n# Check if config does not exist and create it\nif [ ! -f \"$INSTALLPATH/appsettings.json\" ]; then\n cp $INSTALLPATH/appsettings.template.json $INSTALLPATH/appsettings.json\nfi\n\n\n# Check if setcap exists, does not exist in docker containers\nSCAP=$(which setcap >/dev/null; echo $?)\nif [ \"$SCAP\" -eq \"0\" ]; then\n # Enable MQTTServer.NET to bind to IP interface\n setcap CAP_NET_BIND_SERVICE=+eip $INSTALLPATH/MQTTnet.Server\nfi\n\nchmod 644 /etc/systemd/system/mqttnet-server.service\n\n# Check if systemctl exists, does not exist in docker containers\nSCTL=$(which systemctl >/dev/null; echo $?)\n\nif [ \"$SCTL\" -eq \"0\" ]; then\n # Reload systemd because of new service file\n systemctl daemon-reload\nfi"} {"doc_id": "01aa42759fe041fb68f2a077596b9686", "text": "#!/bin/bash\n#***********************************************************************************\n# AWS VPC Creation Shell Script\n#***********************************************************************************\n#\n# SYNOPSIS\n# Automates the CREATION of a custom IPv4 VPC, having public subnet, private subnet,\n# Internet gateway attached to VPC and Route tables\n#\n# DESCRIPTION\n# This shell script leverages the AWS Command Line Interface (AWS CLI) to\n# automatically create a custom VPC.\n\n\nif [ $# -eq 0 ]; then\necho \"PLEASE PASS as parameter while running your script\"\nexit 1\nfi\n\nregion=\"us-east-1\"\nvpcName=\"$1-csye6225-vpc-1\"\ninternetGatewayName=\"$1-csye6225-InternetGateway-1\"\nvpc_cidr=\"10.0.0.0/16\"\npublicRouteTableName=\"$1-csye6225-public-route-table\"\nprivateRouteTableName=\"$1-csye6225-private-route-table\"\nZONE1=\"us-east-1a\"\nZONE2=\"us-east-1b\"\nZONE3=\"us-east-1c\"\nPublicSubnet1=\"$1-csye-public-subnet-1\"\nPublicSubnet2=\"$1-csye-public-subnet-2\"\nPublicSubnet3=\"$1-csye-public-subnet-3\"\nPrivateSubnet1=\"$1-csye-private-subnet-1\"\nPrivateSubnet2=\"$1-csye-private-subnet-2\"\nPrivateSubnet3=\"$1-csye-private-subnet-3\"\n\n# Create VPC\necho -e \"\\n\"\necho \"CREATE VPC\"\nVPC_ID=$(aws ec2 create-vpc \\\n --cidr-block $vpc_cidr \\\n --query 'Vpc.{VpcId:VpcId}' \\\n --output text \\\n --region $region 2>&1)\nVPC_CREATE_STATUS=$?\nif [ $VPC_CREATE_STATUS -eq 0 ]; then\n echo \" VPC ID '$VPC_ID' CREATED in '$region' region.\"\nelse\n\techo \"Error:VPC not created!!\"\n echo \" $VPC_ID \"\n\texit $VPC_CREATE_STATUS\nfi\n\n# Rename VPC\necho -e \"\\n\"\necho \"RENAME VPC\"\nVPC_RENAME=$(aws ec2 create-tags \\\n --resources $VPC_ID \\\n --tags \"Key=Name,Value=$vpcName\" \\\n --region $region 2>&1)\nVPC_RENAME_STATUS=$?\nif [ $VPC_RENAME_STATUS -eq 0 ]; then\n echo \" VPC ID '$VPC_ID' NAMED as '$vpcName'.\"\nelse\n echo \"Error:VPC name not added!!\"\n echo \" $VPC_RENAME \"\n exit $VPC_RENAME_STATUS\nfi\n\n# Create Internet gateway\necho -e \"\\n\"\necho \"CREATE INTERNET GATEWAY\"\nIGW_ID=$(aws ec2 create-internet-gateway \\\n --query 'InternetGateway.{InternetGatewayId:InternetGatewayId}' \\\n --output text \\\n --region $region 2>&1)\nIGW_CREATE_STATUS=$?\nif [ $IGW_CREATE_STATUS -eq 0 ]; then\n echo \" Internet Gateway ID '$IGW_ID' CREATED.\"\nelse\n echo \"Error:Gateway not created\"\n echo \" $IGW_ID \"\n exit $IGW_CREATE_STATUS\nfi\n\n# Rename Internet gateway\necho -e \"\\n\"\necho \"RENAME INTERNET GATEWAY\"\nIGW_RENAME=$(aws ec2 create-tags \\\n --resources $IGW_ID \\\n --tags \"Key=Name,Value=$internetGatewayName\" 2>&1)\nIGW_RENAME_STATUS=$?\nif [ $IGW_RENAME_STATUS -eq 0 ]; then\n echo \" Internet gateway ID '$IGW_ID' NAMED as '$internetGatewayName'.\"\nelse\n echo \"Error:internetGatewayName name not added!!\"\n echo \" $IGW_RENAME \"\n exit $IGW_RENAME_STATUS\nfi\n\n# Attach Internet gateway to your VPC\necho -e \"\\n\"\necho \"ATTACH IGW to VPC\"\nIGW_ATTACH=$(aws ec2 attach-internet-gateway \\\n --vpc-id $VPC_ID \\\n --internet-gateway-id $IGW_ID \\\n --region $region 2>&1)\nIGW_ATTACH_STATUS=$?\nif [ $IGW_ATTACH_STATUS -eq 0 ]; then\n echo \" Internet Gateway ID '$IGW_ID' ATTACHED to VPC ID '$VPC_ID'.\"\nelse\n echo \"Error:Gateway not attached to VPC: $?\"\n echo \" $IGW_ATTACH \"\n exit $IGW_ATTACH_STATUS\nfi\n\necho -e \"\\n\"\necho \"Please provide IP Address for subnet 1 in x.x.x.x/x\"\nread PUBLIC_SUBNET1\n\n#echo \"Please provide Availability zones for Public subnet 1\"\nPUBLIC_SUBNET_1=$(aws ec2 create-subnet \\\n --vpc-id $VPC_ID \\\n --cidr-block $PUBLIC_SUBNET1 \\\n --availability-zone $ZONE1 \\\n --query 'Subnet.{SubnetId:SubnetId}' \\\n --output text \\\n --region $region)\n\necho \"Subnet ID '$PUBLIC_SUBNET_1' is created in '$ZONE1'\" \"Availability Zone.\"\n\n# Rename Public Subnet 1\necho -e \"\\n\"\necho \"RENAME PUBLIC SUBNET 1\"\nSUBNET_RENAME=$(aws ec2 create-tags \\\n --resources $PUBLIC_SUBNET_1 \\\n --tags \"Key=Name,Value=$PublicSubnet1\" 2>&1)\nSUBNET_RENAME_STATUS=$?\nif [ $SUBNET_RENAME_STATUS -eq 0 ]; then\n echo \"Public Subnet ID '$PUBLIC_SUBNET_1' NAMED as '$PublicSubnet1'.\"\nelse\n echo \"Error:PublicSubnet1 name not added!!\"\n echo \" $SUBNET_RENAME \"\n exit $SUBNET_RENAME_STATUS\nfi\n\necho -e \"\\n\"\necho \"Please provide IP Address for Public subnet 2 in x.x.x.x/x\"\nread PUBLIC_SUBNET2\n\n#echo \"Please provide Availability zones for Public subnet 2\"\nPUBLIC_SUBNET_2=$(aws ec2 create-subnet \\\n --vpc-id $VPC_ID \\\n --cidr-block $PUBLIC_SUBNET2 \\\n --availability-zone $ZONE2 \\\n --query 'Subnet.{SubnetId:SubnetId}' \\\n --output text \\\n --region $region)\n\necho \"Subnet ID '$PUBLIC_SUBNET_2' is created in '$ZONE2'\" \"Availability Zone.\"\n\n# Rename Public Subnet 2\necho -e \"\\n\"\necho \"RENAME PUBLIC SUBNET 2\"\nSUBNET_RENAME=$(aws ec2 create-tags \\\n --resources $PUBLIC_SUBNET_2 \\\n --tags \"Key=Name,Value=$PublicSubnet2\" 2>&1)\nSUBNET_RENAME_STATUS=$?\nif [ $SUBNET_RENAME_STATUS -eq 0 ]; then\n echo \"Public Subnet ID '$PUBLIC_SUBNET_2' NAMED as '$PublicSubnet2'.\"\nelse\n echo \"Error:PublicSubnet2 name not added!!\"\n echo \" $SUBNET_RENAME \"\n exit $SUBNET_RENAME_STATUS\nfi\n\n\necho -e \"\\n\"\necho \"Please provide IP Address for Public subnet 3 in x.x.x.x/x\"\nread PUBLIC_SUBNET3\n\n# echo \"Please provide Availability zones for Public subnet 3\"\nPUBLIC_SUBNET_3=$(aws ec2 create-subnet \\\n --vpc-id $VPC_ID \\\n --cidr-block $PUBLIC_SUBNET3 \\\n --availability-zone $ZONE3 \\\n --query 'Subnet.{SubnetId:SubnetId}' \\\n --output text \\\n --region $region)\n\necho \"Subnet ID '$PUBLIC_SUBNET_3' is created in '$ZONE3'\" \"Availability Zone.\"\n\n# Rename Public Subnet 3\necho -e \"\\n\"\necho \"RENAME PUBLIC SUBNET 3\"\nSUBNET_RENAME=$(aws ec2 create-tags \\\n --resources $PUBLIC_SUBNET_3 \\\n --tags \"Key=Name,Value=$PublicSubnet3\" 2>&1)\nSUBNET_RENAME_STATUS=$?\nif [ $SUBNET_RENAME_STATUS -eq 0 ]; then\n echo \"Public Subnet ID '$PUBLIC_SUBNET_3' NAMED as '$PublicSubnet3'.\"\nelse\n echo \"Error:PublicSubnet3 name not added!!\"\n echo \" $SUBNET_RENAME \"\n exit $SUBNET_RENAME_STATUS\nfi\n\necho -e \"\\n\"\necho \"Please provide IP Address for Private subnet 1 in x.x.x.x/x\"\nread PRIVATE_SUBNET1\n\n#echo \"Please provide Availability zones for Private subnet 1\"\nPRIVATE_SUBNET_1=$(aws ec2 create-subnet \\\n --vpc-id $VPC_ID \\\n --cidr-block $PRIVATE_SUBNET1 \\\n --availability-zone $ZONE1 \\\n --query 'Subnet.{SubnetId:SubnetId}' \\\n --output text \\\n --region $region)\n\necho \"Subnet ID '$PRIVATE_SUBNET_1' is created in '$ZONE1'\" \"Availability Zone.\"\n\n# Rename Private Subnet 1\necho -e \"\\n\"\necho \"RENAME PRIVATE SUBNET 1\"\nSUBNET_RENAME=$(aws ec2 create-tags \\\n --resources $PRIVATE_SUBNET_1 \\\n --tags \"Key=Name,Value=$PrivateSubnet1\" 2>&1)\nSUBNET_RENAME_STATUS=$?\nif [ $SUBNET_RENAME_STATUS -eq 0 ]; then\n echo \"Public Subnet ID '$PRIVATE_SUBNET_1' NAMED as '$PrivateSubnet1'.\"\nelse\n echo \"Error:PrivateSubnet1 name not added!!\"\n echo \"$SUBNET_RENAME\"\n exit $SUBNET_RENAME_STATUS\nfi\n\necho -e \"\\n\"\necho \"Please provide IP Address for Private subnet 2 in x.x.x.x/x\"\nread PRIVATE_SUBNET2\n\n#echo \"Please provide Availability zones for Private subnet 2\"\nPRIVATE_SUBNET_2=$(aws ec2 create-subnet \\\n --vpc-id $VPC_ID \\\n --cidr-block $PRIVATE_SUBNET2 \\\n --availability-zone $ZONE2 \\\n --query 'Subnet.{SubnetId:SubnetId}' \\\n --output text \\\n --region $region)\n\necho \"Subnet ID '$PRIVATE_SUBNET_2' is created in '$ZONE2'\" \"Availability Zone.\"\n\n\n# Rename Private Subnet 2\necho -e \"\\n\"\necho \"RENAME PRIVATE SUBNET 2\"\nSUBNET_RENAME=$(aws ec2 create-tags \\\n --resources $PRIVATE_SUBNET_2 \\\n --tags \"Key=Name,Value=$PrivateSubnet2\" 2>&1)\nSUBNET_RENAME_STATUS=$?\nif [ $SUBNET_RENAME_STATUS -eq 0 ]; then\n echo \"Public Subnet ID '$PRIVATE_SUBNET_2' NAMED as '$PrivateSubnet2'.\"\nelse\n echo \"Error:PrivateSubnet2 name not added!!\"\n echo \"$SUBNET_RENAME\"\n exit $SUBNET_RENAME_STATUS\nfi\n\necho -e \"\\n\"\necho \"Please provide IP Address for Private subnet 3 in x.x.x.x/x\"\nread PRIVATE_SUBNET3\n\n#echo \"Please provide Availability zones for Private subnet 3\"\nPRIVATE_SUBNET_3=$(aws ec2 create-subnet \\\n --vpc-id $VPC_ID \\\n --cidr-block $PRIVATE_SUBNET3 \\\n --availability-zone $ZONE3 \\\n --query 'Subnet.{SubnetId:SubnetId}' \\\n --output text \\\n --region $region)\n\necho \"Subnet ID '$PRIVATE_SUBNET_3' is created in '$ZONE3'\" \"Availability Zone.\"\n\n# Rename Private Subnet 3\necho -e \"\\n\"\necho \"RENAME PRIVATE SUBNET 3\"\nSUBNET_RENAME=$(aws ec2 create-tags \\\n --resources $PRIVATE_SUBNET_3 \\\n --tags \"Key=Name,Value=$PrivateSubnet3\" 2>&1)\nSUBNET_RENAME_STATUS=$?\nif [ $SUBNET_RENAME_STATUS -eq 0 ]; then\n echo \"Public Subnet ID '$PRIVATE_SUBNET_3' NAMED as '$PrivateSubnet3'.\"\nelse\n echo \"Error:PrivateSubnet3 name not added!!\"\n echo \"$SUBNET_RENAME\"\n exit $SUBNET_RENAME_STATUS\nfi\n\n# Create Public Route Table\necho -e \"\\n\"\necho \"***CREATE ROUTE TABLE***\"\nPUBLIC_ROUTE_TABLE_ID=$(aws ec2 create-route-table \\\n --vpc-id $VPC_ID \\\n --query 'RouteTable.{RouteTableId:RouteTableId}' \\\n --output text \\\n --region $region 2>&1)\n ROUTE_TABLE_CREATE_STATUS=$?\nif [ $ROUTE_TABLE_CREATE_STATUS -eq 0 ]; then\n echo \"Route Table ID '$PUBLIC_ROUTE_TABLE_ID' CREATED.\"\nelse\n echo \"Error:Route table not created!!\"\n echo \"$PUBLIC_ROUTE_TABLE_ID \"\n exit $ROUTE_TABLE_CREATE_STATUS\nfi\n\n# Rename to Public Route Table\necho -e \"\\n\"\necho \"***RENAME ROUTE TABLE***\"\nROUTE_TABLE_RENAME=$(aws ec2 create-tags \\\n --resources $PUBLIC_ROUTE_TABLE_ID \\\n --tags \"Key=Name,Value=$publicRouteTableName\" 2>&1)\nROUTE_TABLE_RENAME_STATUS=$?\nif [ $ROUTE_TABLE_RENAME_STATUS -eq 0 ]; then\n echo \"Route table ID '$PUBLIC_ROUTE_TABLE_ID' NAMED as '$publicRouteTableName'.\"\nelse\n echo \"Error:ROUTE_TABLE name not added!!\"\n echo \" $ROUTE_TABLE_RENAME \"\n exit $ROUTE_TABLE_RENAME_STATUS\nfi\n\n# Create Private Route Table\necho -e \"\\n\"\necho \"***CREATE ROUTE TABLE***\"\nPRIVATE_ROUTE_TABLE_ID=$(aws ec2 create-route-table \\\n --vpc-id $VPC_ID \\\n --query 'RouteTable.{RouteTableId:RouteTableId}' \\\n --output text \\\n --region $region 2>&1)\n ROUTE_TABLE_CREATE_STATUS=$?\nif [ $ROUTE_TABLE_CREATE_STATUS -eq 0 ]; then\n echo \"Route Table ID '$PRIVATE_ROUTE_TABLE_ID' CREATED.\"\nelse\n echo \"Error:Route table not created!!\"\n echo \"$PRIVATE_ROUTE_TABLE_ID \"\n exit $ROUTE_TABLE_CREATE_STATUS\nfi\n\n# Rename to Private Route Table\necho -e \"\\n\"\necho \"***RENAME PRIVATE ROUTE TABLE***\"\nROUTE_TABLE_RENAME=$(aws ec2 create-tags \\\n --resources $PRIVATE_ROUTE_TABLE_ID \\\n --tags \"Key=Name,Value=$privateRouteTableName\" 2>&1)\nROUTE_TABLE_RENAME_STATUS=$?\nif [ $ROUTE_TABLE_RENAME_STATUS -eq 0 ]; then\n echo \"Route table ID '$PRIVATE_ROUTE_TABLE_ID' NAMED as '$privateRouteTableName'.\"\nelse\n echo \"Error:ROUTE_TABLE name not added!!\"\n echo \" $ROUTE_TABLE_RENAME \"\n exit $ROUTE_TABLE_RENAME_STATUS\nfi\n\n\n#Create route to Internet Gateway\necho -e \"\\n\"\necho \"***CREATE ROUTE TO IGW***\"\nRESULT=$(aws ec2 create-route \\\n --route-table-id $PUBLIC_ROUTE_TABLE_ID \\\n --destination-cidr-block 0.0.0.0/0 \\\n --gateway-id $IGW_ID \\\n --region $region 2>&1)\nRESULT_STATUS=$?\nif [ $RESULT_STATUS -eq 0 ]; then\n echo \"Route to '0.0.0.0/0' via Internet Gateway ID '$IGW_ID' ADDED to Route Table ID '$PUBLIC_ROUTE_TABLE_ID'.\"\nelse\n echo \"Error:Route to Internet gateway not created!!\"\n echo \" $RESULT \"\n exit $RESULT_STATUS\nfi\n\n\n# Associate a Route Table with a Public subnet\necho -e \"\\n\"\necho \"***BEGIN SUBNET TO ROUTE TABLE ASSOCIATION***\"\nPublic_Associate_1=$(aws ec2 associate-route-table \\\n --subnet-id $PUBLIC_SUBNET_1 \\\n --route-table-id $PUBLIC_ROUTE_TABLE_ID \\\n --region $region)\necho \"Public Subnet ID '$PUBLIC_SUBNET_1' ASSOCIATED with Route Table ID\" \\\n \"'$PUBLIC_ROUTE_TABLE_ID'.\"\n\necho -e \"\\n\"\nPublic_Associate_2=$(aws ec2 associate-route-table \\\n --subnet-id $PUBLIC_SUBNET_2 \\\n --route-table-id $PUBLIC_ROUTE_TABLE_ID \\\n --region $region)\necho \"Public Subnet ID '$PUBLIC_SUBNET_2' ASSOCIATED with Route Table ID\" \\\n \"'$PUBLIC_ROUTE_TABLE_ID'.\"\n\necho -e \"\\n\"\nPublic_Associate_3=$(aws ec2 associate-route-table \\\n --subnet-id $PUBLIC_SUBNET_3 \\\n --route-table-id $PUBLIC_ROUTE_TABLE_ID \\\n --region $region)\necho \"Public Subnet ID '$PUBLIC_SUBNET_3' ASSOCIATED with Route Table ID\" \\\n \"'$PUBLIC_ROUTE_TABLE_ID'.\"\n\n\n# Associate a Route Table with a Private Subnet\necho -e \"\\n\"\necho \"***BEGIN SUBNET TO ROUTE TABLE ASSOCIATION***\"\nPrivate_Associate_1=$(aws ec2 associate-route-table \\\n --subnet-id $PRIVATE_SUBNET_1 \\\n --route-table-id $PRIVATE_ROUTE_TABLE_ID \\\n --region $region)\necho \"Private Subnet ID '$PRIVATE_SUBNET_1' ASSOCIATED with Route Table ID\" \\\n \"'$PRIVATE_ROUTE_TABLE_ID'.\"\n\necho -e \"\\n\"\nPrivate_Associate_2=$(aws ec2 associate-route-table \\\n --subnet-id $PRIVATE_SUBNET_2 \\\n --route-table-id $PRIVATE_ROUTE_TABLE_ID \\\n --region $region)\necho \"Private Subnet ID '$PRIVATE_SUBNET_2' ASSOCIATED with Route Table ID\" \\\n \"'$PRIVATE_ROUTE_TABLE_ID'.\"\n\necho -e \"\\n\"\nPrivate_Associate_3=$(aws ec2 associate-route-table \\\n --subnet-id $PRIVATE_SUBNET_3 \\\n --route-table-id $PRIVATE_ROUTE_TABLE_ID \\\n --region $region)\necho \"Private Subnet ID '$PRIVATE_SUBNET_3' ASSOCIATED with Route Table ID\" \\\n \"'$PRIVATE_ROUTE_TABLE_ID'.\"\n"} {"doc_id": "01b902dacaabea74d8dae48f597adf12", "text": "#!/bin/bash\nvalidateArgs() {\n if (( $# != 2 )); then\n echo \"Illegal number of parameters\" >&2\n exit 1\n fi\n \n if [ ! -d \"$1\" ] && [ ! -f \"$1\" ]\n then\n echo file or directory does not exists >&2\n exit 1\n fi\n \n checkIfNotNumber='^[0-9]+$'\n if ! [[ $2 =~ $checkIfNotNumber ]] ; then\n echo \"not a number\" >&2\n exit 1\n fi\n}\n\nremoveOldBackups() {\n filePattern=$1--??????????????????????????????.tar.gz\n filesInBackups=$(ls $filePattern -1)\n filesCount=$(ls $filePattern | wc -l)\n \n for fileName in $filesInBackups\n do\n if (( filesCount >= $2 )); then\n filesCount=$((filesCount-1))\n rm -f $fileName\n fi\n done\n}\n\ncreateBackUpRouteIfNotExist() {\n if [ ! -d \"$1\" ]\n then\n mkdir $1\n fi \n}\n\n#validate args\nvalidateArgs $1 $2\n\n# process backup folder\nbackupRoute='/tmp/backups'\ncreateBackUpRouteIfNotExist $backupRoute\ncd $backupRoute\n\n# replace / with - and remove first one \nbckpName=$(echo $1 | tr / - )\nif [[ $bckpName == -* ]]; then\n bckpName=${bckpName:1}\nfi\n\n# remove old backupds and genereate the new one if allowed\nremoveOldBackups $bckpName $2\nif (( $2 > 0 )); then\n bckpName=${bckpName}--$(date +%F--%H-%M-%S-%N).tar.gz\n tar -zcf \"$backupRoute/$bckpName\" \"$1\" >/dev/null 2>&1\nelse\n echo \"only 0 backups allowed\" >&2 \nfi\n\nexit 0"} {"doc_id": "01ce23fffe256bd27487c02ae504b0f3", "text": "#!/bin/bash\n\n# Define some defaults\nusers=\nsystems=\ndefault_password=\ndefault_algo=\"rsa\"\ndefault_bits=\"2048\"\nverbose=0\nret=0\n\n\n# Help system function\nfunction usage()\n{\n # Handle error if present\n [ \"${1}\" != \"\" ] && error=\"${1}\"\n\n # Print a friendly menu\n cat < 0 abort and notify user\n if [ ${#proc[@]} -gt 0 ]; then\n\n [ ${verbose} -gt 0 ] && echo \" Error: Found '${#proc[@]}' PID's matching '${hosts}' running as '${user}', aborting new key creation...\"\n ret=1\n continue\n fi\n\n\n # Perform backup of ${home}/.ssh if it exists\n if [ -d ${home}/.ssh ]; then\n echo \" Making backup of '${home}/.ssh'\"\n ocwd=\"$(pwd)\"\n cd ${home}\n tar -cf .ssh-$(date +%Y%m%d).tar .ssh\n gzip -f .ssh-$(date +%Y%m%d).tar\n rm -r .ssh/id* 2>/dev/null\n cd ${ocwd}\n fi\n\n # Create and set permissions on the .ssh folder\n group=\"$(groups \"${user}\" | cut -d\" \" -f1)\"\n if [ ! -d ${home}/.ssh ]; then\n mkdir -p ${home}/.ssh\n chown ${user}:${group} ${home}/.ssh\n chmod 0700 ${home}/.ssh\n fi\n\n\n # Export the ${algo}, ${bits} & ${path}\n export algo=${algo}\n export bits=${bits}\n export path=\"${home}/.ssh/id_${algo}\"\n\n\n # Change to ${user} & create a password less private key\n if [ \"${password}\" == \"\" ]; then\n su ${user} -c 'cat /dev/zero 2>/dev/null | ssh-keygen -q -f ${path} -t ${algo} -b ${bits} -N \"\" -C \"${user}@${hname}\"' &> /dev/null\n else\n su ${user} -c 'ssh-keygen -q -f ${path} -t ${algo} -b ${bits} -N \"${password}\" -C \"${user}@${hname}\"' &> /dev/null\n fi\n\n # Just in case the PRNG for ssh-keygen wasn't ready for a large primes\n wait\n\n # Validate key creation\n if [ ! -f ${home}/.ssh/id_${algo} ]; then\n [ ${verbose} -gt 0 ] && echo \" An error occurred generating private key for '${user}'\"\n ret=1\n continue\n fi\n\n # Get the fingerprint associated with the public key\n fp=\"$(echo \"${home}/.ssh/id_${algo}.pub\" | ssh-keygen -l 2>/dev/null | awk '{print $2}')\"\n\n # Let the user know\n [ ${verbose} -gt 0 ] && echo \" Generated key pair for '${user}' (${fp})\"\ndone\n\nexit ${ret}\n"} {"doc_id": "0210ceacd69456c48a22119937b49eda", "text": "#!/bin/bash\n# (c) Copyright 2017-2018 SUSE LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\ndie() {\n echo \"$@\" >&2\n exit 1\n}\n\n# install npm dependencies to run the build\nnpm install\n\n# build the neccessary UI files\n./build_ui.sh || die \"building UI files failed, exiting\"\n\n# whether to create a tarball of the dist, set to true with -t\nTARBALL=false\n\n# whether to delete the previous tarballs for the same git revision, set to true with -d\nDELETEPREV=false\n\n# indicates whether to produce a sha256 file of the tarball, no-op if tarball isnt built, set to true with -s\nCREATESHA=false\n\n# if -t is specified, build a tarball of the venv \nwhile getopts tds option\ndo\n case \"${option}\" in\n t) TARBALL=true;;\n d) DELETEPREV=true;;\n s) CREATESHA=true;;\n esac\ndone\n\n# if the tarball flag is true, build the tarball\nif $TARBALL\nthen\n # create a version variable using the commit hash\n SHA=$(git rev-parse HEAD | cut -c1-6)\n echo ${SHA} > dist/buildinfo.txt\n\n DATE=`date -u +\"%Y%m%dT%H%M%SZ\"`\n\n if $DELETEPREV\n then\n # if an existing tarball exists for the same commit, delete it\n # and any sha256/md5 sums associated with those files\n rm -f cloudinstaller-*-${SHA}.tgz\n rm -f cloudinstaller-*-${SHA}.tgz.sha256\n rm -f cloudinstaller-*-${SHA}.tgz.md5\n fi\n\n FILENAME=cloudinstaller-${DATE}-${SHA}.tgz\n # create a tarball of the venv\n cd dist\n tar -czvf ../${FILENAME} .\n cd ..\n\n if $CREATESHA\n then\n # create sha256 and md5 checksums of the tgz file\n sha256sum ${FILENAME} > ${FILENAME}.sha256\n md5sum ${FILENAME} > ${FILENAME}.md5\n fi\nfi\n"} {"doc_id": "024f9bbf63687581e60cf8d56a88cb37", "text": "#!/usr/bin/env bash\n# \n# install script for asprint\n# (c) 2009-2010 Ali Rantakari\n# \n\nDN=\"`dirname \\\"$0\\\"`\"\nTHISDIR=\"`cd \\\"$DN\\\"; pwd`\"\n\nBINDIR=/usr/local/bin\nMANDIR=/usr/local/share/man/man1\n\nBINFILE=\"${THISDIR}/asprint\"\nMANFILE=\"${THISDIR}/asprint.1\"\n\n\n\nif [ ! -e \"${BINFILE}\" ];then\n\techo \"Error: can not find \\\"${BINFILE}\\\". Make sure you're running this script from within the distribution directory (the same directory where asprint resides.) If you already are, run 'make' to build asprint and then try running this script again.\"\n\texit 1\nfi\nif [ ! -e \"${MANFILE}\" ];then\n\techo \"Error: can not find \\\"${MANFILE}\\\" (the man page.) Make sure you're running this script from within the distribution directory (the same directory where asprint resides.)\"\n\texit 1\nfi\necho \"=================================\"\necho\necho \"This script will install:\"\necho\nprintf \"asprint executable to: \\e[36m${BINDIR}\\e[m\\n\"\nprintf \"asprint man page to: \\e[36m${MANDIR}\\e[m\\n\"\necho\necho $'We\\'ll need administrator rights to install to these locations so \\e[33mplease enter your admin password when asked\\e[m.'\necho $'\\e[1mPress any key to continue installing or Ctrl-C to cancel.\\e[m'\nread\necho\nsudo -v\nif [ ! $? -eq 0 ];then echo \"error! aborting.\" >&2; exit 10; fi\necho\n\necho -n \"Creating directories...\"\nsudo mkdir -p ${BINDIR}\nif [ ! $? -eq 0 ];then echo \"...error! aborting.\" >&2; exit 10; fi\nsudo mkdir -p ${MANDIR}\nif [ ! $? -eq 0 ];then echo \"...error! aborting.\" >&2; exit 10; fi\necho \"done.\"\n\necho -n \"Installing the binary executable...\"\nsudo cp -f \"${BINFILE}\" \"${BINDIR}\"\nif [ ! $? -eq 0 ];then echo \"...error! aborting.\" >&2; exit 10; fi\necho \"done.\"\n\necho -n \"Installing the man page...\"\nsudo cp -f \"${MANFILE}\" \"${MANDIR}\"\nif [ ! $? -eq 0 ];then echo \"...error! aborting.\" >&2; exit 10; fi\necho \"done.\"\n\necho \necho $'\\e[32masprint has been successfully installed.\\e[m'\necho\n\n"} {"doc_id": "0251552c3d85d275fd0f989dac39c730", "text": "#!/bin/sh\n#\n# Entrypoint for the git server docker container\n#\n# This script will create the /home/git/.ssh/authorized_keys file and copy the\n# value of the $AUHTORIZED_KEYS environment variable into it. Then it will run\n# either /usr/bin/top or the command provided as arguments to this script.\n#\n# Adopted from https://github.com/docker-library/postgres/blob/master/docker-entrypoint.sh\nset -eufo pipefail\n\n# Configure OpenSSH\n# - generate host keys\n# - disallow password based logins - the user git may only use key-based auth\n# - allow the users matching AUTHORIZED_KEYS to log in as user \"git\"\nssh-keygen -A\n\n# Toggle the PasswordAuthentication flag from \"yes\" to \"no\"\nsed -i '/#PasswordAuthentication/ s/yes/no/' /etc/ssh/sshd_config\n\n# Uncomment the PasswordAuthentication flag\nsed -i '/#PasswordAuthentication no/ s/#//' /etc/ssh/sshd_config\n\necho \"$AUTHORIZED_KEYS\" | sed 's/\\\\n/\\n/g' >/home/git/.ssh/authorized_keys\nchown git.git /home/git/.ssh/authorized_keys\nchmod 600 /home/git/.ssh/authorized_keys\n\n# Enable the git user by configuring a random 64 byte password\nexport PASSWD=\"$(LC_ALL=C tr -dc 'A-Za-z0-9!#$%&()*+,-./:;<=>?@[]_{|}' $CONF_FILE\n echo \"User root password: ${CONF_USER_ROOT_PWD}\" >> $CONF_FILE\n echo \"MySQL root password: ${CONF_MYSQL_ROOT_PWD}\" >> $CONF_FILE\n echo \"MySQL moneta DB user: ${CONF_MYSQL_USER}\" >> $CONF_FILE\n echo \"MySQL moneta DB password: ${CONF_MYSQL_USER_PWD}\" >> $CONF_FILE\n echo \"MySQL moneta DB database: ${CONF_MYSQL_USER_DB}\" >> $CONF_FILE\n echo \"====================================================\" >> $CONF_FILE\n}\n\nfunction initRootPwd {\n INFO \"Setting root password\"\n echo \"root:${CONF_USER_ROOT_PWD}\" | chpasswd\n}\n\nfunction printConfLog {\n INFO \"User and Database created with the following credentials\"\n cat $CONF_FILE\n}\n\nfunction createIniFile {\n INFO \"Creating moneta conf file in ${MONETA_INI}\"\n\n echo \"[database]\" > $MONETA_INI\n echo \"db_type = \\\"mysql\\\"\" >> $MONETA_INI\n echo \"db_hostname = \\\"127.0.0.1\\\"\" >> $MONETA_INI\n echo \"db_port = \\\"3306\\\"\" >> $MONETA_INI\n echo \"db_name = \\\"${CONF_MYSQL_USER_DB}\\\"\" >> $MONETA_INI\n echo \"db_username = \\\"${CONF_MYSQL_USER}\\\"\" >> $MONETA_INI\n echo \"db_password = \\\"${CONF_MYSQL_USER_PWD}\\\"\" >> $MONETA_INI\n}\n\nfunction initMySQL {\n if [ ! -d \"/run/mysqld\" ]; then\n mkdir -p /run/mysqld\n chown -R mysql:mysql /run/mysqld\n fi\n\n if [ -d /var/lib/mysql/mysql ]; then\n INFO 'MySQL directory already present, skipping creation'\n else\n INFO \"MySQL data directory not found, creating initial DBs\"\n\n chown -R mysql:mysql /var/lib/mysql\n\n # init database\n echo 'Initializing database'\n mysql_install_db --user=mysql > /dev/null\n echo 'Database initialized'\n\n INFO \"MySql root password: $CONF_MYSQL_ROOT_PWD\"\n\n # create temp file\n tfile=`mktemp`\n if [ ! -f \"$tfile\" ]; then\n return 1\n fi\n\n # save sql\n cat << EOF > $tfile\nUSE mysql;\nFLUSH PRIVILEGES;\nDELETE FROM mysql.user;\nGRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '$CONF_MYSQL_ROOT_PWD' WITH GRANT OPTION;\nGRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '$CONF_MYSQL_ROOT_PWD' WITH GRANT OPTION;\nGRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '$CONF_MYSQL_ROOT_PWD' WITH GRANT OPTION;\nEOF\n\n # Create new database\n if [ \"$CONF_MYSQL_USER_DB\" != \"\" ]; then\n INFO \"Creating database: $CONF_MYSQL_USER_DB\"\n # echo \"CREATE DATABASE IF NOT EXISTS \\`$CONF_MYSQL_USER_DB\\` CHARACTER SET utf8 COLLATE utf8_general_ci;\" >> $tfile\n\n # set new User and Password\n if [ \"$CONF_MYSQL_USER\" != \"\" ] && [ \"$CONF_MYSQL_USER_PWD\" != \"\" ]; then\n INFO \"Creating user: $CONF_MYSQL_USER with password $CONF_MYSQL_USER_PWD\"\n echo \"GRANT ALL ON *.* to '$CONF_MYSQL_USER'@'%' IDENTIFIED BY '$CONF_MYSQL_USER_PWD';\" >> $tfile\n fi\n else\n # don`t need to create new database,Set new User to control all database.\n if [ \"$CONF_MYSQL_USER\" != \"\" ] && [ \"$CONF_MYSQL_USER_PWD\" != \"\" ]; then\n INFO \"Creating user: $CONF_MYSQL_USER with password $CONF_MYSQL_USER_PWD\"\n echo \"GRANT ALL ON *.* to '$CONF_MYSQL_USER'@'%' IDENTIFIED BY '$CONF_MYSQL_USER_PWD';\" >> $tfile\n fi\n fi\n\n echo 'FLUSH PRIVILEGES;' >> $tfile\n echo 'EXIT;' >> $tfile\n\n # run sql in tempfile\n INFO \"Flushing permissions on MySQL\"\n /usr/sbin/mysqld --user=mysql --bootstrap --verbose=0 < $tfile\n rm -f $tfile\n fi\n}\n\ninitRootPwd\ncreateConfLog\ncreateIniFile\ninitMySQL\nprintConfLog\n\n"} {"doc_id": "0261061246c9abde9626bfc6df9adbf9", "text": "#!/bin/sh\n#\n# Start stop script. Following commands could be called:\n#\n# start\n# stop\n# help\n#\n#\n#\n#\n\nif [ ! -a log ] \nthen\n\tmkdir log\nfi\n\n\n#\n# Kill all processes containing parameter value\n#\nfind_and_kill () {\n\tif [ $1 == \"\" ]\n\tthen\n\t\techo \"missing parameter \"\n\telse\n\t\tfor i in `ps ax | grep SNAPSHOT | grep -v grep | awk '{print $1}'`\n\t\tdo\n \t\t\tkill -9 $i\n\t\tdone\n\tfi\n}\n\n\nstart () {\n\techo \"starting coidi\"\n\t./run-test-op.sh > ./log/op.log 2>&1 &\n\t./run-test-rp.sh > ./log/rp.log 2>&1 &\n}\n\nstop () {\n\techo \"stopping coidi\"\n\tfind_and_kill coidi-test-op-1.0-SNAPSHOT.war\n#\tfind_and_kill coidi-test-or-1.0-SNAPSHOT.war\n}\n\nhelp () {\n\techo \"help\"\n}\n\ncase \"$1\" in\n start)\n start\n ;;\n stop)\n stop\n ;;\n help)\n help\n ;;\n *)\n SCRIPTNAME=`basename $0`\n echo \"Usage: $SCRIPTNAME {start|stop|help}\"\n exit 1\n ;;\nesac\n\nexit 0\n\n"} {"doc_id": "0267e9e1a0f176d50597814be0bdc34a", "text": "#!/bin/sh\n\n####################################\n# iTunes Command Line Control v1.0\n# written by David Schlosnagle\n# created 2001.11.08\n####################################\n\nshowHelp () {\n echo \"-----------------------------\";\n echo \"iTunes Command Line Interface\";\n echo \"-----------------------------\";\n echo \"Usage: $(basename \"$0\")