blob_id
stringlengths 40
40
| language
stringclasses 1
value | repo_name
stringlengths 4
115
| path
stringlengths 2
970
| src_encoding
stringclasses 28
values | length_bytes
int64 31
5.38M
| score
float64 2.52
5.28
| int_score
int64 3
5
| detected_licenses
listlengths 0
161
| license_type
stringclasses 2
values | text
stringlengths 31
5.39M
| download_success
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
6d982a3a61b400646a93a72d6cc2cce10a2ea7ce
|
Shell
|
inoxx03/newdoc-bulk-validate
|
/pv2-validate.sh
|
UTF-8
| 486
| 3.78125
| 4
|
[] |
no_license
|
#!/bin/bash
#default_dir=$(pwd)
target_dir=$1
files=$(ls ${target_dir})
validator_cmd="newdoc -l"
if ! command -v newdoc &> /dev/null
then
echo "newdoc not found. Exiting."
exit 2
fi
validate ()
{
if [[ -f $file && "$file" == *.adoc ]]
then
#echo "Checking: ${target_dir}/${file}"
${validator_cmd} ${file};
echo
fi
}
#if [ $target_dir -ne $(pwd) ]
#then
pushd $target_dir &> /dev/null
#fi
for file in $files
do
validate $file
done
popd &> /dev/null
exit 0
| true
|
df45b4ab20cc677781f5ffe24f879ff4e54ba013
|
Shell
|
yangzpag/SecureStreams-DEBS17
|
/docker-images/sgx/build_files/start.sh
|
UTF-8
| 996
| 3.796875
| 4
|
[] |
no_license
|
#!/bin/bash
LUASGX=./luasgx
SRC_DIR=/root/worker
SGX=/dev/isgx
if [[ ! (-c $SGX) ]]; then
echo "Device $SGX not found"
echo "Use 'docker run' flag --device: --device=$SGX"
exit 0
fi
if [[ -z $1 ]]; then
echo "No file provided - you have to pass the filename of the LUA code as argument"
exit 1
fi
if [[ ! (-e $SRC_DIR) ]]; then
echo "No volume mounted - you have to mount a volume including the LUA code you want to embed in the container"
echo "Use 'docker run' flag -v: -v /my/lua/src:$SRC_DIR"
exit 0
fi
if [[ ! (-e $SRC_DIR/$1) ]]; then
echo "File $SRC_DIR/$1 not found"
exit 0
fi
echo "Run AESM service"
/opt/intel/sgxpsw/aesm/aesm_service &
echo "Wait 1s for AESM service to be up"
sleep 1
echo "Link source files from $SRC_DIR into $(pwd)"
ln -s $SRC_DIR/* .
echo "$(pwd) content"
ls -al .
echo "Run LUA_PATH='$SRC_DIR/?.lua;;' $LUASGX $SRC_DIR/$1"
LUA_PATH="$SRC_DIR/?.lua;;" $LUASGX $SRC_DIR/$1
#echo "Run bash for debugging"
#bash
| true
|
3714bd38ab6eff5b2fabb998d4a8afbcda79bca0
|
Shell
|
aoles/BBS
|
/2.1/mybbs/config.sh
|
UTF-8
| 1,188
| 2.765625
| 3
|
[] |
no_license
|
#!/bin/bash
# ======================================================================
# Settings shared by all the Unix nodes involved in the 2.1-mybbs builds
# ======================================================================
export BBS_MODE="bioc"
export BBS_BIOC_MANIFEST_FILE="bioc_2.1.manifest"
# What type of meat? Only 2 types are supported:
# 1: svn repo (contains pkg dirs)
# 2: CRAN-style local repo containing .tar.gz pkgs
export BBS_MEAT0_TYPE=1
# Where is it?
#export BBS_MEAT0_RHOST="gladstone"
#export BBS_MEAT0_RUSER="biocbuild"
#export BBS_MEAT0_RDIR="/home/biocbuild/bioc-trunk-Rpacks"
# Triggers a MEAT0 update at beginning of prerun (stage1)
export BBS_UPDATE_MEAT0=0
# Local meat copy
export BBS_MEAT_PATH="$BBS_WORK_TOPDIR/meat"
# Node local settings
. ../../nodes/$BBS_NODE/local-settings.sh
export BBS_BIOC_VERSION="2.1"
#export BBS_BIOC_VERSIONED_REPO_PATH="$BBS_BIOC_VERSION/$BBS_MODE"
export BBS_R_CMD="$BBS_R_HOME/bin/R"
export BBS_STAGE2_R_SCRIPT="$BBS_HOME/$BBS_BIOC_VERSION/bioc/STAGE2.R"
export BBS_CENTRAL_RDIR="/home/$USER/public_html/BBS/$BBS_BUILD_LABEL"
export BBS_CENTRAL_BASEURL="http://$BBS_NODE/~$USER/BBS/$BBS_BUILD_LABEL"
| true
|
51edbdb84f9c48ef54cfc4660d839e4e5a24ce2a
|
Shell
|
cristiklein/stateless-workstation-config
|
/lint.sh
|
UTF-8
| 450
| 3.296875
| 3
|
[] |
no_license
|
#!/bin/bash
set -e
: ${BASE_DOCKER_IMAGE:=python:3.7}
DOCKER_IMAGE=${BASE_DOCKER_IMAGE}-precommit
docker build -t $DOCKER_IMAGE - <<EOF
FROM ${BASE_DOCKER_IMAGE}
RUN pip3 install pre-commit
EOF
USE_TTY=
if [ -t 1 ]; then
USE_TTY="-ti"
fi
docker run \
$USE_TTY \
-u $(id -u):$(id -g) \
-v $HOME:$HOME \
-v /etc/passwd:/etc/passwd:ro \
-v /etc/group:/etc/group:ro \
-w $(pwd) \
$DOCKER_IMAGE pre-commit run --all
| true
|
145889836b0cfeb7a6ee8aebde555a83e996f448
|
Shell
|
YIKAILucas/mybash
|
/database.sh
|
UTF-8
| 616
| 3.234375
| 3
|
[] |
no_license
|
#!/bin/bash
if [ $1 = redis -a $2 = start ]; then
redis-server /usr/local/etc/redis.conf
elif [ $1 = redis -a $2 = stop ]; then
redis-cli shutdown
elif [ $1 = mongodb -a $2 = start ]; then
mongod --fork --logpath ~/data/log/mongodb.log --dbpath ~/data/db
elif [ $1 = mongodb -a $2 = stop ]; then
echo -e "依次输入
mongo \t进入数据库\n
use admin \t选择数据库\n
db.shutdownServer() \t关闭\n"
elif [ $1 = mysql -a $2 = start ]; then
mysql.server start
elif [ $1 = mysql -a $2 = stop ]; then
mysql.server stop
else echo "输入错误"
fi
| true
|
8d68a485f4a382f5ff953827810a96b0ee62f72c
|
Shell
|
MhmdRyhn/Shell_Scripts
|
/HackerRank/Linux_Shell/Cut #8.sh
|
UTF-8
| 201
| 3.34375
| 3
|
[] |
no_license
|
#!/bin/bash
# To know about `cut` command -> https://www.computerhope.com/unix/ucut.htm
while read line; do
# Get first 3 FIELDS, DELIMITED by `Space`
printf "$line" | cut -f -3 -d ' '
done
| true
|
6bd85b54588ce24794f1e3242cefcb274dad0123
|
Shell
|
njau-sri/hpc
|
/root/local/install-pcre.sh
|
UTF-8
| 187
| 2.71875
| 3
|
[
"MIT"
] |
permissive
|
#!/bin/bash
VER=8.40
TOP=`pwd`
PREFIX=/share/apps/local
tar zxf pcre-$VER.tar.gz
cd pcre-$VER
./configure --prefix=$PREFIX --enable-utf8
make
make install
cd $TOP
rm -rf pcre-$VER
| true
|
3db65d7f0ed0851ba1ccad793838d8d40722e159
|
Shell
|
rrice/shell-scripts
|
/tokenize
|
UTF-8
| 1,882
| 3.6875
| 4
|
[] |
no_license
|
#!/usr/bin/env sh
#
# -*- mode: shell-script; fill-column: 75; comment-column: 50; -*-
#
# Copyright (c) 2013 Ralph Allan Rice <ralph.rice@gmail.com>
#
# 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.
#
SCRIPT=$(basename "${0}")
show_usage() {
echo "Usage: ${1} [OPTIONS]" 1>&2
}
show_help() {
show_usage "${1}"
cat 1>&2 <<-HELPDOC
Tokens all lines from standard input and print
each token to standard output one token per line.
Options:
-h Shows this help message.
HELPDOC
}
# Parse options
while getopts ":h" OPTION; do
case ${OPTION} in
h)
show_help
exit 1
;;
?)
echo "${SCRIPT}: invalid option -- ${OPTARG}" 1>&2
show_usage "${SCRIPT}"
echo "Try '${SCRIPT} -h' for more information."
exit 1
;;
esac
done
AWK="$(which awk)"
exec ${AWK} '
{
for ( i = 1; i <= NF; i++ ) {
print $i
}
}' "$@"
| true
|
16481661bd84eeb2701c563e725a337f85606f75
|
Shell
|
jcwearn/priceatronic
|
/deploy/deploy.sh
|
UTF-8
| 1,165
| 3.46875
| 3
|
[] |
no_license
|
DATE=$(date +%s)
FILE=priceatronic-$DATE.tar.gz
EXCLUDE="./node_modules"
EXCLUDE2="*.tar.gz"
EXCLUDE3="./.git"
APPLICATION_NAME=priceatronic
DEPLOYMENT_GROUP_NAME=priceatronic_deployment
BUCKET=priceatronic
if [ ! -f ./package.json ]; then
echo "You must run this script from the project's root directory"
else
if [ ! $(command -v gtar) ]; then
echo "Install the gnu version of tar to use this utility"
echo "brew install gnu-tar"
else
echo "============================================="
echo "==== PACKAGING $FILE ===="
echo "============================================="
gtar zcvf $FILE --exclude=$EXCLUDE --exclude=$EXCLUDE2 --exclude=$EXCLUDE3 ./
echo "============================================="
echo "==== DEPLOYING $FILE ===="
echo "============================================="
aws s3 cp $FILE s3://$BUCKET/deployments/
aws deploy create-deployment --application-name $APPLICATION_NAME --region=us-east-1 --deployment-group-name $DEPLOYMENT_GROUP_NAME --s3-location bucket=$BUCKET,bundleType=tgz,key=deployments/$FILE
rm -rf $FILE
fi
fi
| true
|
413e27ca23592a365970172cc4ce5f5ff54246e8
|
Shell
|
buenaonda-chile/xwork
|
/eclipse-workspace/dioneRepository/DNKR/bin/aijm/aijmLogServerStart.sh
|
UTF-8
| 6,544
| 3.375
| 3
|
[] |
no_license
|
#!/bin/bash
# ****************************************************************************
# ** [JP] ファイル名 : aijmLogServerStart.sh **
# ** [JP] 処理概要 : AijmLogServerの起動 **
# ** [JP] **
# ** [JP] AijmLogServerの起動はバックグラウンドで実行します。 **
# ** [JP] **
# ** [JP] 引数 : なし **
# ** [JP] 戻り値 : 0(正常終了)/16(異常終了) **
# ** **
# ** [EN] File name : aijmLogServerStart.sh **
# ** [EN] Outline of processing : Starting AijmLogServer **
# ** [EN] **
# ** [EN] AijmLogServer start to run in the background. **
# ** [EN] **
# ** [EN] Argument : None **
# ** [EN] Return value : 0(Stopping services)/16(Exit Warning) **
# ** **
# ** ---------------------------------------------------------------------- **
# ** [JP] 変更履歴 : 2012/01/23 新規作成 **
# ** [JP] : 2012/12/04 プロセス名短縮対応(チケット136) **
# ** **
# ** [EN] Change history : 2012/01/23 Create new **
# ** [EN] : 2012/12/04 Process name corresponding reduction (Ticket 136) **
# ** **
# ** $ aijmLogServerStart.sh 1495 2015-05-11 07:56:47Z 815372040074 $
# ** **
# ****************************************************************************
# [JP] ==== 環境に応じて各自で設定してください ====================================
# [EN] ==== Depending on your environment, please set your own ====================================
# [JP] ==== パラメータ設定 ========================================================
# [EN] ==== Setting Parameters ========================================================
# ----------------------------------------------------------------------------
# [JP] JAVA_XMX : AijmLogServerの最大ヒープサイズ(MB)
# [JP] JAVA_XMS : AijmLogServerの初期ヒープサイズ(MB)
# [EN] JAVA_XMX : Maximum heap size of AijmLogServer (MB)
# [EN] JAVA_XMS : Initial heap size of AijmLogServer (MB)
# ----------------------------------------------------------------------------
JAVA_XMX=256
JAVA_XMS=128
# [JP] ==== 起動クラスの設定 ======================================================
# [EN] ==== Setting the startup class ======================================================
EXECUTE_CLASS=com.globaldenso.ai.akatsuki.aijm.logserver.LogServer
# [JP] ==== log4jの設定 ===========================================================
# [EN] ==== Setting the log4j ===========================================================
LOG_XML=log4j2-Server.xml
# [JP] ==== 共通環境変数の設定 ====================================================
# [EN] ==== Setting common environment variables ====================================================
PRGDIR=`dirname $0`
. ${PRGDIR}/setenv.sh
if [ $? -ne 0 ]; then
# [JP] ==== 共通環境変数設定失敗 ログ出力 戻り値を16に設定 ========================
# [EN] ==== Failure of common environment variables Log output The return value is set to 16 ========================
echo [boot] [`date "+%Y/%m/%d %T"`] [ERROR] setenv.sh Execute Failed >> ${PRGDIR}/aijmLogServerStart.log
exit 16
fi
# [JP] ==== ログ出力先設定 ========================================================
# [EN] ==== Log output destination setting ========================================================
LOGFILE=${AIJM_DIR}/logs/aijmLogServerStart.log
# [JP] ==== 処理開始ログ出力 ======================================================
# [EN] ==== Log output process starts ======================================================
echo `date "+%Y/%m/%d %T"` INFO :START AijmLogServer StartBatch >> $LOGFILE 2>&1
# [JP] ==== PSコマンドによるサービス起動確認 ======================================
# [EN] ==== Confirm start-up of services by PS command ======================================
echo `date "+%Y/%m/%d %T"` INFO :Start CheckProcess >> $LOGFILE 2>&1
PROCESS_CNT=`ps -ef | grep java | grep $EXECUTE_CLASS | grep start | grep -v grep | wc -l`
echo `date "+%Y/%m/%d %T"` INFO :End CheckProcess >> $LOGFILE 2>&1
# [JP] ==== 既にサービスが起動している場合、ログに出力し処理終了 ==================
# [EN] ==== If the service is already running, the end of processing the log ==================
if [ $PROCESS_CNT -ne 0 ]; then
echo `date "+%Y/%m/%d %T"` WARN :AijmLogServer service was already started. >> $LOGFILE 2>&1
echo `date "+%Y/%m/%d %T"` INFO :END AijmLogServer StartBatch >> $LOGFILE 2>&1
echo -------------------------------------------------------------------------------- >> $LOGFILE 2>&1
exit 0
fi
# [JP] ==== 処理実行 ==============================================================
# [EN] ==== Process execution ==============================================================
echo `date "+%Y/%m/%d %T"` INFO :Start start command >> $LOGFILE 2>&1
export CLASSPATH
${JAVA_HOME}/bin/java -Xrs -Xmx${JAVA_XMX}m -Xms${JAVA_XMS}m -Dlog4j.configurationFile=${LOG_XML} ${EXECUTE_CLASS} start >> $LOGFILE 2>&1 &
echo `date "+%Y/%m/%d %T"` INFO :End start command >> $LOGFILE 2>&1
# [JP] ==== 処理終了ログ出力 ======================================================
# [EN] ==== End of processing logging output ======================================================
echo `date "+%Y/%m/%d %T"` INFO :END AijmLogServer StartBatch >> $LOGFILE 2>&1
echo -------------------------------------------------------------------------------- >> $LOGFILE 2>&1
exit
| true
|
c4f57b1abc8952385780dd9bbea424bfb3853dc0
|
Shell
|
TarsCloud/K8STARS
|
/baseserver/replace_img_version.sh
|
UTF-8
| 233
| 3.1875
| 3
|
[
"BSD-3-Clause"
] |
permissive
|
#!/bin/bash
from_version=":latest"
to_version=":v1.1.0"
if [[ "$OSTYPE" == "darwin"* ]]; then
alias sed="sed -i ''"
else
alias sed="sed -i"
fi
for f in `ls yaml/*.yaml`; do
sed "s/$from_version/$to_version/g" $f
done
| true
|
1d2e0c3a4c2e3767112fa00043ba13560c8299d4
|
Shell
|
aur-archive/eclipse-php
|
/PKGBUILD
|
UTF-8
| 1,582
| 2.921875
| 3
|
[] |
no_license
|
# Maintainer: Giovanne Castro <giovannefc@gmail.com>
# Based on official standard package (eclipse) maintained by Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
pkgname=eclipse-php
pkgver=4.4.1
pkgrel=2
_release=luna-SR1
pkgdesc="An IDE for PHP and other web development languages"
license=("EPL")
arch=('i686' 'x86_64')
url="http://eclipse.org"
depends=('gtk2' 'unzip' 'webkitgtk2' 'libxtst')
install=eclipse-php.install
source=("http://ftp-stud.fht-esslingen.de/pub/Mirrors/eclipse/technology/epp/downloads/release/${_release/-//}/$pkgname-$_release-linux-gtk.tar.gz"
"http://ftp-stud.fht-esslingen.de/pub/Mirrors/eclipse/technology/epp/downloads/release/${_release/-//}/$pkgname-$_release-linux-gtk-x86_64.tar.gz"
'eclipse-php.sh' 'eclipse-php.desktop')
md5sums=('a88f0c4e1de5f8aee6b88e12c6fbfc21'
'a029bcb02bac476a2678a2039f515519'
'96b5e07608f2fbb8e1f8e15e6e603f2e'
'268cf8b4e6f8242362fbde6a877b428a')
if (( ! GENINTEG )); then
if [[ $CARCH == x86_64 ]]; then
source=("${source[@]:1}")
md5sums=("${md5sums[@]:1}")
else
source=("${source[0]}" "${source[@]:2}")
md5sums=("${md5sums[0]}" "${md5sums[@]:2}")
fi
fi
package_eclipse-php() {
install -d "$pkgdir/usr/share"
cp -a eclipse "$pkgdir/usr/share/eclipse-php"
install -D eclipse-php.sh "$pkgdir/usr/bin/eclipse-php"
install -Dm644 eclipse-php.desktop "$pkgdir/usr/share/applications/eclipse-php.desktop"
for _i in 16 32 48 256; do
install -Dm644 eclipse/plugins/org.eclipse.platform_*/eclipse${_i}.png \
"$pkgdir/usr/share/icons/hicolor/${_i}x${_i}/apps/eclipse-php.png"
done
}
| true
|
1e9c258d8a91f3cf56a5f2bd7adb9e01e1baf1dd
|
Shell
|
Code-DigitalArt/ServersOpen
|
/fetch/wheatridge.sh
|
UTF-8
| 1,437
| 3.4375
| 3
|
[] |
no_license
|
#!/bin/bash
#
name="wrc"
hasMage=1
hasEE=1
timeFormat='%Y%m%d.%H%M'
timeNow=$(date +"${timeFormat}")
remoteHost="68.64.209.250"
remoteUserMage="${name}_mage"
remotePasswordMage="XDXn4cwzVz2k06ie-i*jaRMoVietviKf1zP3fNz0"
remoteUserEE="${name}_ee"
remotePasswordEE="asbmAfKd0qCyVy*G4wSV-DD1pXwBrt#yxMJw3on4"
DBMage="${remoteUserMage}"
DBEE="${remoteUserEE}"
mageFile="/home/radosun/Data/${DBMage}.${timeNow}.sql"
eeFile="/home/radosun/Data/${DBEE}.${timeNow}.sql"
localUser="root"
localPassword="password"
localhost="127.0.0.1"
getMageDB(){
echo "Grabbing Mage DB"
mysqldump --user=${remoteUserMage} --password=${remotePasswordMage} -h ${remoteHost} --skip-triggers --single-transaction ${DBMage} > ${mageFile}
echo "Mage DB drop and create"
mysql --user=${localUser} --password=${localPassword} -h ${localhost} -e "DROP DATABASE IF EXISTS ${DBMage}; CREATE DATABASE ${DBMage};"
echo "Importing Mage DB"
mysql --user=${localUser} --password=${localPassword} -h ${localhost} ${DBMage} < ${mageFile}
}
getEEDB(){
echo "Grabbing EE DB"
mysqldump --user=${remoteUserEE} --password=${remotePasswordEE} -h ${remoteHost} ${DBEE} > ${eeFile}
echo "EE DB drop and create"
mysql --user=${localUser} --password=${localPassword} -h ${localhost} -e "DROP DATABASE IF EXISTS ${DBEE}; CREATE DATABASE ${DBEE};"
echo "Importing EE DB"
mysql --user=${localUser} --password=${localPassword} -h ${localhost} ${DBEE} < ${eeFile}
}
[ $hasMage -eq 1 ] && getMageDB
[ $hasEE -eq 1 ] && getEEDB
| true
|
12eb349d46e529bc77219990e095f075ea303cd9
|
Shell
|
jmcerrejon/PiKISS
|
/scripts/tweaks/autologin.sh
|
UTF-8
| 1,142
| 3.609375
| 4
|
[
"MIT"
] |
permissive
|
#!/bin/bash
#
# Description : Autologin
# Author : Jose Cerrejon Gonzalez (ulysess@gmail_dot._com)
# Version : 1.3 (16/Mar/15)
# Compatible : Raspberry Pi 1 & 2 (tested), ODROID-C1 (tested)
#
clear
. ../helper.sh || . ./scripts/helper.sh || . ./helper.sh || wget -q 'https://github.com/jmcerrejon/PiKISS/raw/master/scripts/helper.sh'
check_board || { echo "Missing file helper.sh. I've tried to download it for you. Try to run the script again." && exit 1; }
fn_autologin_RPi(){
# Add comment to 1:2345:respawn:/sbin/getty...
sudo sed -i '/1:2345/s/^/#/' /etc/inittab
# Insert new file on pattern position
sudo sed -i 's/.*tty1.*/&\n1:2345:respawn:\/bin\/login -f pi tty1 <\/dev\/tty1> \/dev\/tty1 2>\&1/' /etc/inittab
}
fn_autologin_ODROID(){
sudo sed -i '/38400/s/^/#/' /etc/init/tty1.conf
sudo sed -i 's/.*38400.*/&\nexec \/bin\/login -f '$USER' < \/dev\/tty1 > \/dev\/tty1 2>\&1/' /etc/init/tty1.conf
}
if [[ ${MODEL} == 'Raspberry Pi' ]]; then
fn_autologin_RPi
elif [[ ${MODEL} == 'ODROID-C1' ]]; then
fn_autologin_ODROID
fi
read -p "Done!. Warning: Your distro have free access and no need to login on boot now!. Press [Enter] to continue..."
| true
|
7f943de3b9048f82f13e5cbdfbb8733a802da738
|
Shell
|
bopie/Bash
|
/run
|
UTF-8
| 210
| 3.609375
| 4
|
[] |
no_license
|
#!/bin/bash
name=${1%%.*}
[[ -e $name ]] && read -p "target file exist, overwrite?" -n 1 answer || answer=y
if [ "$answer" == "y" ]; then
gcc $1 -o $name && $name
rm $name > /dev/null 2>&1
else
exit 1
fi
| true
|
491521b6a3d9acef540a3a96d566f8a105434cdc
|
Shell
|
xdjiangyang/ESXi-crontab
|
/local.sh
|
UTF-8
| 706
| 2.90625
| 3
|
[] |
no_license
|
#!/bin/sh
# local configuration options
# Note: modify at your own risk! If you do/use anything in this
# script that is not part of a stable API (relying on files to be in
# specific places, specific tools, specific output, etc) there is a
# possibility you will end up with a broken system after patching or
# upgrading. Changes are not supported unless under direction of
# VMware support.
# Gets the cron service pid and simply kills it.
/bin/kill $(cat /var/run/crond.pid)
# The next line writes a typical cron line to the crontab
/bin/echo "40 17 * * * /bin/poweroff" >> /var/spool/cron/crontabs/root
# Finally we start the cron service again
/usr/lib/vmware/busybox/bin/busybox crond
exit 0
| true
|
fed7c932f4e4add363796750930184252a70f43f
|
Shell
|
mikesovic/Sistrurus_SinglePop_FSC
|
/PowerAnalyses/Simulate_SFS.sh
|
UTF-8
| 966
| 3.875
| 4
|
[] |
no_license
|
#!/bin/bash
#Run this script with ./Simulate_SFS.sh par_file_name [# of sim datasets to generate]
#needs a par file that is indicated as the first argument on the command line and the fsc252 executable.
if [ $2 ]; then #if we are simulating multiple sfs from a single par file
if [ ! -d SimlatedSFS ]; then
mkdir SimulatedSFS #store the simulated sfs here;
fi
for sim in $(eval echo "{1..$2}"); do
mkdir sim$sim #make a temporary directory to do the simulation
cp fsc252 *.par sim$sim
cd sim$sim
./fsc252 -i $1 -n 1 -s 0 -m #perform the simulation with fsc
model=`echo $1 | sed s/\.par//`
rm $model/*Sites.obs
mv $model/*.obs ../SimulatedSFS/${model}_${sim}_MAFpop0.obs #copy the simulated sfs to the SimulatedSFS directory that stores all the simulated sfs.
cd ..
rm -r sim$sim
done;
else #only performing one simulation from the par file
./fsc252 -i $1 -n 1 -s 0 -m
fi
| true
|
97afad21fdd75716f0c12686f268a4a01a3b7460
|
Shell
|
HirbodBehnam/Java-Testcase-Checker
|
/generator.sh
|
UTF-8
| 315
| 3.125
| 3
|
[
"MIT"
] |
permissive
|
#!/bin/bash
# Compile
mkdir build
javac -d build -sourcepath ./src src/*.java
# Loop tests
COUNTER=1
while :
do
[ ! -f "in/in$COUNTER.txt" ] && break
echo "Generating in$COUNTER.txt..."
java -classpath ./build Main < "in/in$COUNTER.txt" > "out/out$COUNTER.txt"
COUNTER=$((COUNTER+1))
done
# Cleanup
rm -rf build
| true
|
b6f2a41ac7424af6d18fa776910e27924ad171a5
|
Shell
|
BC-MO/SnowConvertDDLExportScripts
|
/Teradata/bin/create_load_to_sf.sh
|
UTF-8
| 3,070
| 3.5625
| 4
|
[
"MIT"
] |
permissive
|
# Modified by:
# Modified Date:
# Description:
## ---------------------------------------------------------------
## Modify the following settings
## ---------------------------------------------------------------
SNOWFLAKE_DB_NAME="ADVENTUREWORKSDW"
SNOWFLAKE_WAREHOUSE_NAME="KVANCZ"
SNOWFLAKE_FILE_FORMAT_NAME="PIPE_DELIMITED"
SNOWFLAKE_STAGE_NAME="TERADATA_SOURCE_STAGE"
# Location of the data extract files
DATA_FILE_LOCATION="../output/data_extracts"
## Enter the Teradata Database Names to Generate Load Scripts
TERADATA_DATABASES_TO_LOAD=(ADVENTUREWORKSDW)
## ---------------------------------------------------------------
## Do not change below
## ---------------------------------------------------------------
for TERADATA_DATABASE in "${TERADATA_DATABASES_TO_LOAD[@]}"
do
SNOWFLAKE_SCHEMA_NAME=$(echo ${TERADATA_DATABASE})
OUTPUT_FILE="../output/object_extracts/load_files_to_snowflake.$TERADATA_DATABASE.sql"
touch $OUTPUT_FILE;
USE_DB_SCHEMA_WH="
use ${SNOWFLAKE_DB_NAME}.${SNOWFLAKE_SCHEMA_NAME};
use warehouse ${SNOWFLAKE_WAREHOUSE_NAME};
"
CREATE_FILE_FORMAT="
CREATE OR REPLACE FILE FORMAT ${SNOWFLAKE_DB_NAME}.${SNOWFLAKE_SCHEMA_NAME}.${SNOWFLAKE_FILE_FORMAT_NAME}
TYPE = 'CSV'
COMPRESSION = 'AUTO'
FIELD_DELIMITER = '|'
RECORD_DELIMITER = '\n'
SKIP_HEADER = 0
FIELD_OPTIONALLY_ENCLOSED_BY = 'NONE'
TRIM_SPACE = FALSE
ERROR_ON_COLUMN_COUNT_MISMATCH = TRUE
ESCAPE = '\134'
ESCAPE_UNENCLOSED_FIELD = '\134'
DATE_FORMAT = 'AUTO'
TIMESTAMP_FORMAT = 'AUTO'
NULL_IF = ('\\N');
"
CREATE_STAGE="
CREATE OR REPLACE STAGE ${SNOWFLAKE_DB_NAME}.${SNOWFLAKE_SCHEMA_NAME}.${SNOWFLAKE_STAGE_NAME};
"
PUT_STATEMENT="
-- This PUT needs to be executed from snowsql and have access to the data files locally
put file://${DATA_FILE_LOCATION}/${TERADATA_DATABASE}*.dat* @${SNOWFLAKE_DB_NAME}.${SNOWFLAKE_SCHEMA_NAME}.${SNOWFLAKE_STAGE_NAME} auto_compress=true;
"
echo "$USE_DB_SCHEMA_WH" > $OUTPUT_FILE
echo "$CREATE_FILE_FORMAT" >> $OUTPUT_FILE
echo "$CREATE_STAGE" >> $OUTPUT_FILE
echo "$PUT_STATEMENT" >> $OUTPUT_FILE
COPY_INTO="
copy into ${SNOWFLAKE_DB_NAME}.${SNOWFLAKE_SCHEMA_NAME}.TD_TABLE_NAME
from @${SNOWFLAKE_STAGE_NAME}
pattern = '.*TD_DATABASE_NAME[.]TD_TABLE_NAME[.].*'
file_format = (format_name = ${SNOWFLAKE_FILE_FORMAT_NAME} ENCODING = 'iso-8859-1')
FORCE = TRUE on_error = 'skip_file';
"
while read p; do
COPY_TEMP=$COPY_INTO
IFS='|' read -ra NAMES <<< "$p"
td_database_name=$(echo ${NAMES[0]})
td_table_name=$(echo ${NAMES[1]})
UPPER_TD_DATABASE_NAME=$(echo $td_database_name | tr a-z A-Z)
UPPER_TD_TABLE_NAME=$(echo $td_table_name | tr a-z A-Z)
if [ $TERADATA_DATABASE = $UPPER_TD_DATABASE_NAME ]; then
replace1=$(echo ${COPY_TEMP//TD_DATABASE_NAME/$UPPER_TD_DATABASE_NAME})
echo ${replace1//TD_TABLE_NAME/$UPPER_TD_TABLE_NAME} >> $OUTPUT_FILE
fi
done < ../output/object_extracts/Reports/table_list.txt
done
## End of Script
| true
|
6abca700ce805ac86d4b4a520944af0eee56b035
|
Shell
|
marieke-bijlsma/Imputation
|
/protocols/GenotypeHarmonizer.sh
|
UTF-8
| 1,567
| 3.4375
| 3
|
[] |
no_license
|
#MOLGENIS walltime=04:59:59 mem=5gb ppn=1
#string genotypeHarmonizerVersion
#string outputPerChr
#string referenceGenome
#string tempDir
#string intermediateDir
#string chr
#string pathToReference1000G
#string pathToReferenceGoNL
#string pathToReferenceHRC
#Load modules and list currently loaded modules
module load ${genotypeHarmonizerVersion}
module list
#Create tmp/tmp to save unfinished results
makeTmpDir ${outputPerChr}
tmpOutputPerChr=${MC_tmpFile}
#Reference genome should be one of the following: 1000G, GoNL or HRC, otherwise exit script
if [ "${referenceGenome}" == "1000G" ]
then
pathToReference=${pathToReference1000G}
elif [ "${referenceGenome}" == "gonl" ]
then
pathToReference=${pathToReferenceGoNL}
elif [ "${referenceGenome}" == "HRC" ]
then
pathToReference=${pathToReferenceHRC}
else
echo "Unsupported reference genome!"
exit 1
fi
#Align study data to reference data (1000G or GoNL)
#tempDir to store Java output
java -XX:ParallelGCThreads=2 -Djava.io.tmpdir=${tempDir} -Xmx8g -jar ${EBROOTGENOTYPEHARMONIZER}/GenotypeHarmonizer.jar \
--input ${intermediateDir}/chr${chr}.phased \
--inputType SHAPEIT2 \
--ref ${pathToReference} \
--refType VCF \
--forceChr ${chr} \
--output ${tmpOutputPerChr}.gh \
--outputType SHAPEIT2
echo -e "\nmv ${tmpOutputPerChr}.{gh.sample,gh.haps,gh.log,gh_snpLog.log} ${intermediateDir}\n"
mv "${tmpOutputPerChr}".{gh.sample,gh.haps,gh.log,gh_snpLog.log} "${intermediateDir}"
echo -e "Alignment is finished, resulting new haps and sample files can be found here: ${intermediateDir}\n"
| true
|
02f9ac231d30d5c25ac55509304c0effa7978fa5
|
Shell
|
boberito/jamfscripts
|
/office365-install.sh
|
UTF-8
| 986
| 3.4375
| 3
|
[] |
no_license
|
#!/bin/sh
CurrentOfficeRelease=$(curl -s https://macadmins.software | grep "Office 365 Suite Install" | awk -F "a href" '{ print $1 }' | awk -F ">" '{print $10}' | awk -F " " '{print $1}')
CurrentOfficeInstalled=$(defaults read /Applications/Microsoft\ Word.app/Contents/Info.plist CFBundleVersion)
if [ "$CurrentOfficeRelease" = "$CurrentOfficeInstalled" ]; then
/Library/Application\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -title "Microsoft Office 2016" -description "You currently have the most recent version of Microsoft Office installed" -button1 "Ok" -defaultButton 1
exit 0
else
mkdir /tmp/downloads
cd /tmp/downloads
OfficeURL=$(curl -s https://macadmins.software | grep "Office 365 Suite Install" | awk -F "a href" '{ print $2 }' | awk -F "'" '{ print $2 }')
curl -s -o office.pkg -L $OfficeURL
installer -target / -pkg "/tmp/downloads/office.pkg"
rm office.pkg
rm -rf /tmp/downloads
exit 0
fi
| true
|
8396148e90007dbfca6cb30bb9ce768de1267be8
|
Shell
|
YashPareek1/Shell-Programs
|
/day6/coin11.sh
|
UTF-8
| 212
| 3
| 3
|
[] |
no_license
|
#! /bin/bash
headcount=0
totalcount=0
while [ $headcount -lt 11 ]
do
if [ $(( RANDOM%2 )) -eq 0 ]
then
headcount=$(( headcount+1 ))
fi
totalcount=$(( totalcount+1 ))
done
echo "$totalcount"
| true
|
f55edb0380a5f99e41998fbde5e9c5512f8b4eea
|
Shell
|
reklis/pukcab
|
/backup.sh
|
UTF-8
| 2,407
| 4
| 4
|
[] |
no_license
|
#!/usr/bin/env bash
defaultconfig="${HOME}/.config/pukcab.conf"
usage() {
echo
echo "usage: $0 [-c config] [-v] [-n]"
echo " -c path to non-default config file"
echo " -v verbose tarballing"
echo " -n do not unmount after backing up"
echo
}
configfile="${defaultconfig}"
verbose=""
shouldunmount=true
while getopts ":c:vn" o; do
case "${o}" in
c)
configfile=${OPTARG}
;;
v)
verbose="vv"
;;
n)
shouldunmount=false
;;
esac
done
shift $((OPTIND-1))
if [ ! -f $configfile ]
then
echo
echo "error: config file not found! ${configfile}"
echo
echo example config:
echo
echo mount /mnt/san
echo target /mnt/san/backup
echo source /home/user1
echo source /etc
echo exclude /home/user1/.cache
echo exclude /home/user1/Downloads
echo
echo default config location: ${defaultconfig}
usage
exit 1
fi
mount=`grep ^mount ${configfile} | sed 's/^mount //' | head -n 1`
if [ -n "${mount}" ]
then
echo "mounting ${mount}..."
sudo mount ${mount}
fi
sources=`grep ^source ${configfile} | sed 's/^source //' | xargs`
if [ "" = "${sources}" ]
then
echo
echo "error: $configfile missing source entries"
echo
usage
exit 1
fi
excludes=`grep ^exclude ${configfile} | sed 's/^exclude //' | xargs printf " --exclude %s"`
if [ " --exclude " = "${excludes}" ]
then
excludes=""
fi
target=`grep ^target ${configfile} | sed 's/^target //' | head -n 1`
if [ "" = "${target}" ]
then
echo
echo "error: $configfile missing target entry"
echo
usage
exit 1
fi
datestamp=`date +'%Y-%m'`
target=`grep ^target ${configfile} | sed 's/^target //' | head -1`
target="${target}/${datestamp}"
mkdir -p ${target}
echo "backing up to ${target}..."
lastindex=`ls -1 ${target}/*.snar 2>/dev/null | tail -n 1`
nextindex=0
if [ "${lastindex}" != "" ]
then
lastindex=`echo $lastindex | egrep -o '[0-9]+\.snar$' | sed 's/\.snar$//'`
nextindex=$(( lastindex + 1 ))
cp ${target}/backup_${lastindex}.snar ${target}/backup_${nextindex}.snar
fi
backupfile="backup_${nextindex}"
tar --ignore-failed-read \
--no-check-device \
--listed-incremental=${target}/${backupfile}.snar \
${excludes} \
-czp${verbose} \
-f ${target}/${backupfile}.tgz ${sources}
du -ah ${target}
if [ -n "${mount}" ]
then
if [ true = $shouldunmount ]
then
echo "unmounting ${mount}..."
sudo umount ${mount}
fi
fi
| true
|
ebd43ebebbea2423fdb0adc56a9e51914e82859c
|
Shell
|
ming-kwee/labamap
|
/run_labamap_services.sh
|
UTF-8
| 1,171
| 3.140625
| 3
|
[] |
no_license
|
#!/bin/bash
# This will start all the services required for tests or running the service.
# All services will have their output prefixed with the name of the service.
ctrl_c() {
docker compose down
echo "===> Shutting down Labamap Service"
kill "$labamap_pid"
lsof -ti tcp:8080 | xargs kill
lsof -ti tcp:8081 | xargs kill
lsof -ti tcp:9000 | xargs kill
lsof -ti tcp:9001 | xargs kill
lsof -ti tcp:8085 | xargs kill
}
lsof -ti tcp:9000 | xargs kill
lsof -ti tcp:9001 | xargs kill
lsof -ti tcp:8085 | xargs kill
lsof -ti tcp:8080 | xargs kill
lsof -ti tcp:8081 | xargs kill
cd /Users/admin/work/Akka/labamap && docker compose down &
echo "===> Starting Docker Compose Up"
cd /Users/admin/work/Akka/labamap && docker compose up &
sleep 30
echo "===> Starting Labamap Service"
cd /Users/admin/work/Akka/labamap && mvn compile exec:exec &
labamap_pid=$!
sleep 30
bash set_central_attributes.sh
# sleep 30
# open -n -a /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --user-data-dir="/tmp/chrome_dev_test" --disable-web-security
trap ctrl_c INT
wait $labamap_pid
echo "===> All services stopped"
| true
|
89797232520eed673009241fe13961568de2d348
|
Shell
|
Nellix/onap
|
/kubernetes/contrib/tools/rke/rke_setup.sh
|
UTF-8
| 9,976
| 3
| 3
|
[
"Apache-2.0"
] |
permissive
|
#!/bin/bash
#############################################################################
# Copyright © 2019 Bell.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#############################################################################
#
# This installation is for an RKE install of kubernetes
# after this run the standard oom install
# this installation can be run on any ubuntu 16.04/18.04 VM, RHEL 7.6 (root only), physical or cloud azure/aws host
# https://wiki.onap.org/display/DW/OOM+RKE+Kubernetes+Deployment
# source from https://jira.onap.org/browse/OOM-1598
#
# master/dublin
# RKE 0.1.16 Kubernetes 1.11.6, kubectl 1.11.6, Helm 2.9.1, Docker 18.06
# 20190428 RKE 0.2.1, Kubernetes 1.13.5, kubectl 1.13.5, Helm 2.12.3, Docker 18.09.5
# single node install, HA pending
usage() {
cat <<EOF
Usage: $0 [PARAMs]
example
sudo ./rke_setup.sh -b master -s rke.onap.cloud -e onap -l amdocs -v true
-u : Display usage
-b [branch] : branch = master or dublin (required)
-s [server] : server = IP or DNS name (required)
-e [environment] : use the default (onap)
-k [key] : ssh key name
-l [username] : login username account (use ubuntu for example)
EOF
}
install_onap() {
#constants
PORT=8880
KUBERNETES_VERSION=
RKE_VERSION=0.2.1
KUBECTL_VERSION=1.13.5
HELM_VERSION=2.12.3
DOCKER_VERSION=18.09
# copy your private ssh key and cluster.yml file to the vm
# on your dev machine
#sudo cp ~/.ssh/onap_rsa .
#sudo chmod 777 onap_rsa
#scp onap_rsa ubuntu@192.168.241.132:~/
# on this vm
#sudo chmod 400 onap_rsa
#sudo cp onap_rsa ~/.ssh
# make sure public key is insetup correctly in
# sudo vi ~/.ssh/authorized_keys
echo "please supply your ssh key as provided by the -k keyname - it must be be chmod 400 and chown user:user in ~/.ssh/"
echo "The RKE version specific cluster.yaml is already integrated in this script for 0.2.1 no need for below generation..."
echo "rke config --name cluster.yml"
echo "specifically"
echo "address: $SERVER"
echo "user: $USERNAME"
echo "ssh_key_path: $SSHPATH_PREFIX/$SSHKEY"
RKETOOLS=
HYPERCUBE=
POD_INFRA_CONTAINER=
RKETOOLS=0.1.27
HYPERCUBE=1.13.5-rancher1
POD_INFRA_CONTAINER=rancher/pause:3.1
cat > cluster.yml <<EOF
# generated from rke_setup.sh
nodes:
- address: $SERVER
port: "22"
internal_address: ""
role:
- controlplane
- worker
- etcd
hostname_override: ""
user: $USERNAME
docker_socket: /var/run/docker.sock
ssh_key: ""
ssh_key_path: $SSHPATH_PREFIX/$SSHKEY
ssh_cert: ""
ssh_cert_path: ""
labels: {}
services:
etcd:
image: ""
extra_args: {}
extra_binds: []
extra_env: []
external_urls: []
ca_cert: ""
cert: ""
key: ""
path: ""
snapshot: null
retention: ""
creation: ""
backup_config: null
kube-api:
image: ""
extra_args: {}
extra_binds: []
extra_env: []
service_cluster_ip_range: 10.43.0.0/16
service_node_port_range: ""
pod_security_policy: false
always_pull_images: false
kube-controller:
image: ""
extra_args: {}
extra_binds: []
extra_env: []
cluster_cidr: 10.42.0.0/16
service_cluster_ip_range: 10.43.0.0/16
scheduler:
image: ""
extra_args: {}
extra_binds: []
extra_env: []
kubelet:
image: ""
extra_args:
max-pods: 900
extra_binds: []
extra_env: []
cluster_domain: cluster.local
infra_container_image: ""
cluster_dns_server: 10.43.0.10
fail_swap_on: false
kubeproxy:
image: ""
extra_args: {}
extra_binds: []
extra_env: []
network:
plugin: canal
options: {}
authentication:
strategy: x509
sans: []
webhook: null
system_images:
etcd: rancher/coreos-etcd:v3.2.24-rancher1
alpine: rancher/rke-tools:v$RKETOOLS
nginx_proxy: rancher/rke-tools:v$RKETOOLS
cert_downloader: rancher/rke-tools:v$RKETOOLS
kubernetes_services_sidecar: rancher/rke-tools:v$RKETOOLS
kubedns: rancher/k8s-dns-kube-dns:1.15.0
dnsmasq: rancher/k8s-dns-dnsmasq-nanny:1.15.0
kubedns_sidecar: rancher/k8s-dns-sidecar:1.15.0
kubedns_autoscaler: rancher/cluster-proportional-autoscaler:1.0.0
kubernetes: rancher/hyperkube:v$HYPERCUBE
flannel: rancher/coreos-flannel:v0.10.0-rancher1
flannel_cni: rancher/flannel-cni:v0.3.0-rancher1
calico_node: rancher/calico-node:v3.4.0
calico_cni: rancher/calico-cni:v3.4.0
calico_controllers: ""
calico_ctl: rancher/calico-ctl:v2.0.0
canal_node: rancher/calico-node:v3.4.0
canal_cni: rancher/calico-cni:v3.4.0
canal_flannel: rancher/coreos-flannel:v0.10.0
wave_node: weaveworks/weave-kube:2.5.0
weave_cni: weaveworks/weave-npc:2.5.0
pod_infra_container: $POD_INFRA_CONTAINER
ingress: rancher/nginx-ingress-controller:0.21.0-rancher3
ingress_backend: rancher/nginx-ingress-controller-defaultbackend:1.4-rancher1
metrics_server: rancher/metrics-server:v0.3.1
ssh_key_path: $SSHPATH
ssh_cert_path: ""
ssh_agent_auth: false
authorization:
mode: rbac
options: {}
ignore_docker_version: false
kubernetes_version: "$KUBERNETES_VERSION"
private_registries: []
ingress:
provider: ""
options: {}
node_selector: {}
extra_args: {}
cluster_name: ""
cloud_provider:
name: ""
prefix_path: ""
addon_job_timeout: 0
bastion_host:
address: ""
port: ""
user: ""
ssh_key: ""
ssh_key_path: ""
ssh_cert: ""
ssh_cert_path: ""
monitoring:
provider: ""
options: {}
restore:
restore: false
snapshot_name: ""
dns: null
EOF
echo "Installing on ${SERVER} for ${BRANCH}: RKE: ${RKE_VERSION} Kubectl: ${KUBECTL_VERSION} Helm: ${HELM_VERSION} Docker: ${DOCKER_VERSION} username: ${USERNAME}"
sudo echo "127.0.0.1 ${SERVER}" >> /etc/hosts
echo "Install docker - If you must install as non-root - comment out the docker install below - run it separately, run the user mod, logout/login and continue this script"
curl https://releases.rancher.com/install-docker/$DOCKER_VERSION.sh | sh
sudo usermod -aG docker $USERNAME
echo "Install RKE"
sudo wget https://github.com/rancher/rke/releases/download/v$RKE_VERSION/rke_linux-amd64
mv rke_linux-amd64 rke
sudo chmod +x rke
sudo mv ./rke /usr/local/bin/rke
echo "Install make - required for beijing+ - installed via yum groupinstall Development Tools in RHEL"
# ubuntu specific
sudo apt-get install make -y
sudo curl -LO https://storage.googleapis.com/kubernetes-release/release/v$KUBECTL_VERSION/bin/linux/amd64/kubectl
sudo chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
sudo mkdir ~/.kube
wget http://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-linux-amd64.tar.gz
sudo tar -zxvf helm-v${HELM_VERSION}-linux-amd64.tar.gz
sudo mv linux-amd64/helm /usr/local/bin/helm
echo "Bringing RKE up - using supplied cluster.yml"
sudo rke up
echo "wait 2 extra min for the cluster"
sleep 60
echo "1 more min"
sleep 60
echo "copy kube_config_cluter.yaml generated - to ~/.kube/config"
sudo cp kube_config_cluster.yml ~/.kube/config
# avoid using sudo for kubectl
sudo chmod 777 ~/.kube/config
echo "Verify all pods up on the kubernetes system - will return localhost:8080 until a host is added"
echo "kubectl get pods --all-namespaces"
kubectl get pods --all-namespaces
echo "install tiller/helm"
kubectl -n kube-system create serviceaccount tiller
kubectl create clusterrolebinding tiller --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
helm init --service-account tiller
kubectl -n kube-system rollout status deploy/tiller-deploy
echo "upgrade server side of helm in kubernetes"
if [ "$USERNAME" == "root" ]; then
helm version
else
sudo helm version
fi
echo "sleep 30"
sleep 30
if [ "$USERNAME" == "root" ]; then
helm init --upgrade
else
sudo helm init --upgrade
fi
echo "sleep 30"
sleep 30
echo "verify both versions are the same below"
if [ "$USERNAME" == "root" ]; then
helm version
else
sudo helm version
fi
echo "start helm server"
if [ "$USERNAME" == "root" ]; then
helm serve &
else
sudo helm serve &
fi
echo "sleep 30"
sleep 30
echo "add local helm repo"
if [ "$USERNAME" == "root" ]; then
helm repo add local http://127.0.0.1:8879
helm repo list
else
sudo helm repo add local http://127.0.0.1:8879
sudo helm repo list
fi
echo "To enable grafana dashboard - do this after running cd.sh which brings up onap - or you may get a 302xx port conflict"
echo "kubectl expose -n kube-system deployment monitoring-grafana --type=LoadBalancer --name monitoring-grafana-client"
echo "to get the nodeport for a specific VM running grafana"
echo "kubectl get services --all-namespaces | grep graf"
sudo docker version
helm version
kubectl version
kubectl get services --all-namespaces
kubectl get pods --all-namespaces
echo "finished!"
}
BRANCH=
SERVER=
ENVIRON=
VALIDATE=false
USERNAME=ubuntu
SSHPATH_PREFIX=~/.ssh
while getopts ":b:s:e:u:l:k:v" PARAM; do
case $PARAM in
u)
usage
exit 1
;;
b)
BRANCH=${OPTARG}
;;
e)
ENVIRON=${OPTARG}
;;
s)
SERVER=${OPTARG}
;;
l)
USERNAME=${OPTARG}
;;
k)
SSHKEY=${OPTARG}
;;
v)
VALIDATE=${OPTARG}
;;
?)
usage
exit
;;
esac
done
if [[ -z $BRANCH ]]; then
usage
exit 1
fi
install_onap $BRANCH $SERVER $ENVIRON $USERNAME $SSHPATH_PREFIX $SSHKEY $VALIDATE
| true
|
7eacbbfdba6631dad6b5dd6b888c0d1a33ce368e
|
Shell
|
SoftwareHeritage/swh-environment
|
/docker/services/swh-objstorage/entrypoint.sh
|
UTF-8
| 490
| 2.84375
| 3
|
[] |
no_license
|
#!/bin/bash
set -e
source /srv/softwareheritage/utils/pyutils.sh
setup_pip
echo Installed Python packages:
pip list
if [ "$1" = 'shell' ] ; then
exec bash -i
else
echo Starting the swh-objstorage API server
exec gunicorn --bind 0.0.0.0:5003 \
--log-level DEBUG \
--threads 4 \
--workers 2 \
--reload \
--timeout 3600 \
--config 'python:swh.core.api.gunicorn_config' \
'swh.objstorage.api.server:make_app_from_configfile()'
fi
| true
|
656296ef35656ad55bf361ff34641e4e26d0f31b
|
Shell
|
yhfudev/bash-mrnative
|
/app-ns2/e2map.sh
|
UTF-8
| 11,514
| 3.25
| 3
|
[
"MIT"
] |
permissive
|
#!/bin/bash
# -*- tab-width: 4; encoding: utf-8 -*-
#
#####################################################################
## @file
## @brief Run ns2 using Map/Reduce paradigm -- Step 2 Map part
##
## In this part, the script run the ns2, and plotting some basic figures,
## generate stats files.
##
## @author Yunhui Fu <yhfudev@gmail.com>
## @copyright GPL v3.0 or later
## @version 1
##
#####################################################################
## @fn my_getpath()
## @brief get the real name of a path
## @param dn the path name
##
## get the real name of a path, return the real path
my_getpath() {
local PARAM_DN="$1"
shift
#readlink -f
local DN="${PARAM_DN}"
local FN=
if [ ! -d "${DN}" ]; then
FN=$(basename "${DN}")
DN=$(dirname "${DN}")
fi
local DNORIG=$(pwd)
cd "${DN}" > /dev/null 2>&1
DN=$(pwd)
cd "${DNORIG}"
if [ "${FN}" = "" ]; then
echo "${DN}"
else
echo "${DN}/${FN}"
fi
}
DN_EXEC=$(dirname $(my_getpath "$0") )
if [ ! "${DN_EXEC}" = "" ]; then
DN_EXEC="$(my_getpath "${DN_EXEC}")/"
else
DN_EXEC="${DN_EXEC}/"
fi
DN_TOP="$(my_getpath "${DN_EXEC}/../")"
DN_BIN="$(my_getpath "${DN_TOP}/bin/")"
DN_EXEC="$(my_getpath ".")"
#####################################################################
if [ -f "${DN_EXEC}/liball.sh" ]; then
. ${DN_EXEC}/liball.sh
fi
if [ ! "${DN_EXEC_4HADOOP}" = "" ]; then
DN_EXEC="${DN_EXEC_4HADOOP}"
DN_TOP="${DN_TOP_4HADOOP}"
FN_CONF_SYS="${FN_CONF_SYS_4HADOOP}"
fi
RET=$(is_file_or_dir "${FN_CONF_SYS}")
if [ ! "${RET}" = "f" ]; then
FN_CONF_SYS="${DN_EXEC}/mrsystem-working.conf"
RET=$(is_file_or_dir "${FN_CONF_SYS}")
if [ ! "${RET}" = "f" ]; then
FN_CONF_SYS="${DN_TOP}/mrsystem.conf"
RET=$(is_file_or_dir "${FN_CONF_SYS}")
if [ ! "${RET}" = "f" ]; then
mr_trace "not found config file: ${FN_CONF_SYS}"
fi
fi
fi
#####################################################################
# the default
EXEC_NS2="$(my_getpath "${DN_TOP}/../../ns")"
RET0=$(is_file_or_dir "${FN_CONF_SYS}")
if [ ! "$RET0" = "f" ]; then
echo -e "debug\t$(hostname)\tgenerated_config\t${FN_CONF_SYS}"
mr_trace "Warning: not found config file '${FN_CONF_SYS}'!"
mr_trace "generating new config file '${FN_CONF_SYS}' ..."
generate_default_config | save_file "${FN_CONF_SYS}"
fi
FN_TMP_2m="/tmp/config-$(uuidgen)"
copy_file "${FN_CONF_SYS}" "${FN_TMP_2m}" > /dev/null 2>&1
read_config_file "${FN_TMP_2m}"
rm_f_dir "${FN_TMP_2m}" > /dev/null 2>&1
check_global_config
mr_trace "e2map, HDFF_DN_SCRATCH=${HDFF_DN_SCRATCH}"
#####################################################################
# generate session for this process and its children
# use mp_get_session_id to get the session id later
mp_new_session
libapp_prepare_app_binary
#####################################################################
## @fn worker_check_ns2()
## @brief check one data folder
## @param session_id the session id
## @param config_file config file
## @param prefix the prefix of the test
## @param type the test type, one of "udp", "tcp", "has", "udp+has", "tcp+has"
## @param sche the scheduler, such as "PF", "DRR"
## @param num the number of flows
##
## check if one data folder contains the correct data
worker_check_ns2() {
PARAM_SESSION_ID="$1"
shift
PARAM_CONFIG_FILE="$1"
shift
# the prefix of the test
PARAM_PREFIX=$1
shift
# the test type, "udp", "tcp", "has", "udp+has", "tcp+has"
PARAM_TYPE=$1
shift
# the scheduler, such as "PF", "DRR"
PARAM_SCHE=$1
shift
# the number of flows
PARAM_NUM=$1
shift
DN_TEST=$(simulation_directory "${PARAM_PREFIX}" "${PARAM_TYPE}" "${PARAM_SCHE}" "${PARAM_NUM}")
mr_trace "check_one_tcldir '$(basename ${PARAM_CONFIG_FILE})' '${DN_TEST}' '/dev/stdout' ..."
RET=$(check_one_tcldir "${PARAM_CONFIG_FILE}" "${HDFF_DN_OUTPUT}/dataconf/${DN_TEST}" "/dev/stdout")
if [ ! "$RET" = "" ]; then
# error
mr_trace "detected error at ${DN_TEST}"
echo -e "error-check\t${PARAM_CONFIG_FILE}\t${PARAM_PREFIX}\t${PARAM_TYPE}\tunknown\t${PARAM_SCHE}\t${PARAM_NUM}" | tee -a "${DN_EXEC}/checkerror.txt"
fi
mp_notify_child_exit ${PARAM_SESSION_ID}
}
## @fn worker_check_run()
## @brief check one data folder and run again if not finished
## @param session_id the session id
## @param config_file config file
## @param prefix the prefix of the test
## @param type the test type, one of "udp", "tcp", "has", "udp+has", "tcp+has"
## @param sche the scheduler, such as "PF", "DRR"
## @param num the number of flows
##
worker_check_run() {
PARAM_SESSION_ID="$1"
shift
PARAM_CONFIG_FILE="$1"
shift
# the prefix of the test
PARAM_PREFIX=$1
shift
# the test type, "udp", "tcp", "has", "udp+has", "tcp+has"
PARAM_TYPE=$1
shift
# the scheduler, such as "PF", "DRR"
PARAM_SCHE=$1
shift
# the number of flows
PARAM_NUM=$1
shift
DN_TEST=$(simulation_directory "${PARAM_PREFIX}" "${PARAM_TYPE}" "${PARAM_SCHE}" "${PARAM_NUM}")
RET=$(check_one_tcldir "${PARAM_CONFIG_FILE}" "${HDFF_DN_OUTPUT}/dataconf/${DN_TEST}" "/dev/stdout")
if [ "$RET" = "" ]; then
# the task was finished successfully
prepare_figure_commands_for_one_stats "${PARAM_CONFIG_FILE}" "${PARAM_PREFIX}" "${PARAM_TYPE}" "${PARAM_SCHE}" "${PARAM_NUM}"
else
TM_START=$(date +%s.%N)
mr_trace "run_one_ns2 ${HDFF_DN_OUTPUT}/dataconf ${DN_TEST} ${PARAM_CONFIG_FILE}"
run_one_ns2 "${HDFF_DN_OUTPUT}/dataconf" "${DN_TEST}" "${PARAM_CONFIG_FILE}" 1>&2
TM_END=$(date +%s.%N)
# check the result
RET=$(check_one_tcldir "${PARAM_CONFIG_FILE}" "${HDFF_DN_OUTPUT}/dataconf/${DN_TEST}" "/dev/stdout")
mr_trace check_one_tcldir "${PARAM_CONFIG_FILE}" "${HDFF_DN_OUTPUT}/dataconf/${DN_TEST}" return $RET
if [ ! "$RET" = "" ]; then
# error
mr_trace "Error in ${DN_TEST}, ${TM_START}, ${TM_END}"
echo -e "error-run\t${PARAM_CONFIG_FILE}\t${PARAM_PREFIX}\t${PARAM_TYPE}\tunknown\t${PARAM_SCHE}\t${PARAM_NUM}"
else
echo -e "time-run\t${PARAM_CONFIG_FILE}\t${PARAM_PREFIX}\t${PARAM_TYPE}\tunknown\t${PARAM_SCHE}\t${PARAM_NUM}\t${TM_START}\t${TM_END}"
prepare_figure_commands_for_one_stats "${PARAM_CONFIG_FILE}" "${PARAM_PREFIX}" "${PARAM_TYPE}" "${PARAM_SCHE}" "${PARAM_NUM}"
fi
fi
mp_notify_child_exit ${PARAM_SESSION_ID}
}
## @fn worker_plotonly()
## @brief plot figures
## @param session_id the session id
## @param config_file config file
## @param prefix the prefix of the test
## @param type the test type, one of "udp", "tcp", "has", "udp+has", "tcp+has"
## @param sche the scheduler, such as "PF", "DRR"
## @param num the number of flows
##
worker_plotonly() {
PARAM_SESSION_ID="$1"
shift
PARAM_CONFIG_FILE="$1"
shift
# the prefix of the test
PARAM_PREFIX=$1
shift
# the test type, "udp", "tcp", "has", "udp+has", "tcp+has"
PARAM_TYPE=$1
shift
# the scheduler, such as "PF", "DRR"
PARAM_SCHE=$1
shift
# the number of flows
PARAM_NUM=$1
shift
DN_TEST=$(simulation_directory "${PARAM_PREFIX}" "${PARAM_TYPE}" "${PARAM_SCHE}" "${PARAM_NUM}")
prepare_figure_commands_for_one_stats "${PARAM_CONFIG_FILE}" "${PARAM_PREFIX}" "${PARAM_TYPE}" "${PARAM_SCHE}" "${PARAM_NUM}"
mp_notify_child_exit ${PARAM_SESSION_ID}
}
## @fn worker_clean()
## @brief clean data dir
## @param session_id the session id
## @param config_file config file
## @param prefix the prefix of the test
## @param type the test type, one of "udp", "tcp", "has", "udp+has", "tcp+has"
## @param sche the scheduler, such as "PF", "DRR"
## @param num the number of flows
##
worker_clean() {
PARAM_SESSION_ID="$1"
shift
PARAM_CONFIG_FILE="$1"
shift
# the prefix of the test
PARAM_PREFIX=$1
shift
# the test type, "udp", "tcp", "has", "udp+has", "tcp+has"
PARAM_TYPE=$1
shift
# the scheduler, such as "PF", "DRR"
PARAM_SCHE=$1
shift
# the number of flows
PARAM_NUM=$1
shift
DN_TEST=$(simulation_directory "${PARAM_PREFIX}" "${PARAM_TYPE}" "${PARAM_SCHE}" "${PARAM_NUM}")
mr_trace "remove file tmp-*, fig-* from ${HDFF_DN_OUTPUT}/figures/${PARAM_PREFIX}"
find_file "${HDFF_DN_OUTPUT}/figures/${PARAM_PREFIX}" -name "tmp-*" | xargs -n 1 rm_f_dir > /dev/null 2>&1
find_file "${HDFF_DN_OUTPUT}/figures/${PARAM_PREFIX}" -name "fig-*" | xargs -n 1 rm_f_dir > /dev/null 2>&1
clean_one_tcldir "${HDFF_DN_OUTPUT}/dataconf/${DN_TEST}"
#prepare_figure_commands_for_one_stats "${PARAM_CONFIG_FILE}" "${PARAM_PREFIX}" "${PARAM_TYPE}" "${PARAM_SCHE}" "${PARAM_NUM}"
mp_notify_child_exit ${PARAM_SESSION_ID}
}
#<command> <config_file> <prefix> <type> <flow type> <scheduler> <number_of_node>
#sim <config_file> <prefix> <type> <flow type> <scheduler> <number_of_node>
# sim "config-xx.sh" "jjmbase" "tcp" "unknown" "PF" 24
while read MR_CMD MR_CONFIG_FILE MR_PREFIX MR_TYPE MR_FLOW_TYPE MR_SCHEDULER MR_NUM_NODE ; do
FN_CONFIG_FILE=$( unquote_filename "${MR_CONFIG_FILE}" )
MR_PREFIX1=$( unquote_filename "${MR_PREFIX}" )
MR_TYPE1=$( unquote_filename "${MR_TYPE}" )
MR_FLOW_TYPE1=$( unquote_filename "${MR_FLOW_TYPE}" )
MR_SCHEDULER1=$( unquote_filename "${MR_SCHEDULER}" )
GROUP_STATS="${MR_PREFIX1}|${MR_TYPE1}|${MR_SCHEDULER1}|${FN_CONFIG_FILE}|"
mr_trace received: "${MR_CMD}\t${MR_CONFIG_FILE}\t${MR_PREFIX}\t${MR_TYPE}\t${MR_FLOW_TYPE}\t${MR_SCHEDULER}\t${MR_NUM_NODE}"
case "${MR_CMD}" in
sim)
worker_check_run "$(mp_get_session_id)" "${FN_CONFIG_FILE}" ${MR_PREFIX1} ${MR_TYPE1} ${MR_SCHEDULER1} ${MR_NUM_NODE} &
PID_CHILD=$!
mp_add_child_check_wait ${PID_CHILD}
;;
plot)
worker_plotonly "$(mp_get_session_id)" "${FN_CONFIG_FILE}" ${MR_PREFIX1} ${MR_TYPE1} ${MR_SCHEDULER1} ${MR_NUM_NODE} &
PID_CHILD=$!
mp_add_child_check_wait ${PID_CHILD}
;;
check)
worker_check_ns2 "$(mp_get_session_id)" "${FN_CONFIG_FILE}" ${MR_PREFIX1} ${MR_TYPE1} ${MR_SCHEDULER1} ${MR_NUM_NODE} &
PID_CHILD=$!
mp_add_child_check_wait ${PID_CHILD}
;;
clean)
worker_clean "$(mp_get_session_id)" "${FN_CONFIG_FILE}" ${MR_PREFIX1} ${MR_TYPE1} ${MR_SCHEDULER1} ${MR_NUM_NODE} &
PID_CHILD=$!
mp_add_child_check_wait ${PID_CHILD}
;;
error-run)
mr_trace "regenerate the TCL scripts for ${MR_PREFIX1} ${MR_TYPE1} ${MR_SCHEDULER1} ${MR_NUM_NODE}"
DN_TMP_CREATECONF="${HDFF_DN_SCRATCH}/tmp-createconf-$(uuidgen)"
prepare_one_tcl_scripts "${MR_PREFIX1}" "${MR_TYPE1}" "${MR_SCHEDULER1}" "${MR_NUM_NODE}" "${DN_EXEC}" "${DN_COMM}" "${DN_TMP_CREATECONF}"
copy_file "${DN_TMP_CREATECONF}/"* "${HDFF_DN_OUTPUT}/dataconf/" > /dev/null 2>&1
rm_f_dir "${DN_TMP_CREATECONF}/"* > /dev/null 2>&1
mr_trace "redo unfinished run: ${MR_CONFIG_FILE}\t${MR_PREFIX}\t${MR_TYPE}\t${MR_FLOW_TYPE}\t${MR_SCHEDULER}\t${MR_NUM_NODE}"
worker_check_run "$(mp_get_session_id)" "${FN_CONFIG_FILE}" ${MR_PREFIX1} ${MR_TYPE1} ${MR_SCHEDULER1} ${MR_NUM_NODE} &
PID_CHILD=$!
mp_add_child_check_wait ${PID_CHILD}
;;
*)
mr_trace "Warning: unknown mr command '${MR_CMD}'."
# throw the command to output again
echo -e "${MR_CMD}\t${MR_CONFIG_FILE}\t${MR_PREFIX}\t${MR_TYPE}\t${MR_FLOW_TYPE}\t${MR_SCHEDULER}\t${MR_NUM_NODE}"
ERR=1
;;
esac
done
mp_wait_all_children
| true
|
faef8f5f14255b4e892ad9be96f38d1602956f74
|
Shell
|
Aloike/bash-resources
|
/prompt/elements-ps1/420-kubernetes.bash
|
UTF-8
| 11,884
| 3.328125
| 3
|
[] |
no_license
|
# ##############################################################################
## @see https://github.com/jonmosco/kube-ps1/blob/master/kube-ps1.sh
# ##############################################################################
# Declare the function to be called by the PS1 prompt.
PROMPT_PS1_FUNCTIONS+=("bash_prompt_command_kubernetes")
# ##############################################################################
# ##############################################################################
# Default values for the prompt
# Override these values in ~/.zshrc or ~/.bashrc
KUBE_PS1_BINARY="${KUBE_PS1_BINARY:-kubectl}"
KUBE_PS1_SYMBOL_ENABLE="${KUBE_PS1_SYMBOL_ENABLE:-true}"
KUBE_PS1_SYMBOL_DEFAULT=${KUBE_PS1_SYMBOL_DEFAULT:-$'\u2388 '}
KUBE_PS1_SYMBOL_USE_IMG="${KUBE_PS1_SYMBOL_USE_IMG:-true}"
KUBE_PS1_NS_ENABLE="${KUBE_PS1_NS_ENABLE:-true}"
KUBE_PS1_CONTEXT_ENABLE="${KUBE_PS1_CONTEXT_ENABLE:-true}"
KUBE_PS1_PREFIX="${KUBE_PS1_PREFIX-(}"
KUBE_PS1_SEPARATOR="${KUBE_PS1_SEPARATOR-|}"
KUBE_PS1_DIVIDER="${KUBE_PS1_DIVIDER-:}"
KUBE_PS1_SUFFIX="${KUBE_PS1_SUFFIX-)}"
KUBE_PS1_KUBECONFIG_CACHE="${KUBECONFIG}"
KUBE_PS1_DISABLE_PATH="${HOME}/.kube/kube-ps1/disabled"
KUBE_PS1_LAST_TIME=0
KUBE_PS1_CLUSTER_FUNCTION="${KUBE_PS1_CLUSTER_FUNCTION}"
KUBE_PS1_NAMESPACE_FUNCTION="${KUBE_PS1_NAMESPACE_FUNCTION}"
PROMPT_FMT_K8S_CONTEXT="${PROMPT_FMT_K8S_CONTEXT-${COL_FG_LMAG}}"
PROMPT_FMT_K8S_NAME="${PROMPT_FMT_K8S_NAME-${COL_FG_SVR}}"
PROMPT_FMT_K8S_NAMESPACE="${PROMPT_FMT_K8S_NAMESPACE-${COL_FG_CYN}}"
PROMPT_FMT_K8S_SYMBOL="${PROMPT_FMT_K8S_SYMBOL-${COL_FG_BLU}}"
# Determine our shell
if [ "${ZSH_VERSION-}" ]; then
KUBE_PS1_SHELL="zsh"
elif [ "${BASH_VERSION-}" ]; then
KUBE_PS1_SHELL="bash"
fi
# ##############################################################################
# ##############################################################################
_kube_ps1_binary_check() {
command -v $1 >/dev/null
}
# ##############################################################################
# ##############################################################################
_kube_ps1_get_context() {
if [[ "${KUBE_PS1_CONTEXT_ENABLE}" == true ]]; then
KUBE_PS1_CONTEXT="$(${KUBE_PS1_BINARY} config current-context 2>/dev/null)"
# Set namespace to 'N/A' if it is not defined
KUBE_PS1_CONTEXT="${KUBE_PS1_CONTEXT:-N/A}"
if [[ ! -z "${KUBE_PS1_CLUSTER_FUNCTION}" ]]; then
KUBE_PS1_CONTEXT=$($KUBE_PS1_CLUSTER_FUNCTION $KUBE_PS1_CONTEXT)
fi
fi
}
# ##############################################################################
# ##############################################################################
_kube_ps1_get_context_ns() {
# Set the command time
if [[ "${KUBE_PS1_SHELL}" == "bash" ]]; then
if ((BASH_VERSINFO[0] >= 4 && BASH_VERSINFO[1] >= 2)); then
KUBE_PS1_LAST_TIME=$(printf '%(%s)T')
else
KUBE_PS1_LAST_TIME=$(date +%s)
fi
elif [[ "${KUBE_PS1_SHELL}" == "zsh" ]]; then
KUBE_PS1_LAST_TIME=$EPOCHSECONDS
fi
_kube_ps1_get_context
_kube_ps1_get_ns
}
# ##############################################################################
# ##############################################################################
_kube_ps1_get_ns() {
if [[ "${KUBE_PS1_NS_ENABLE}" == true ]]; then
KUBE_PS1_NAMESPACE="$(${KUBE_PS1_BINARY} config view --minify --output 'jsonpath={..namespace}' 2>/dev/null)"
# Set namespace to 'default' if it is not defined
KUBE_PS1_NAMESPACE="${KUBE_PS1_NAMESPACE:-default}"
if [[ ! -z "${KUBE_PS1_NAMESPACE_FUNCTION}" ]]; then
KUBE_PS1_NAMESPACE=$($KUBE_PS1_NAMESPACE_FUNCTION $KUBE_PS1_NAMESPACE)
fi
fi
}
# ##############################################################################
# ##############################################################################
_kube_ps1_init() {
[[ -f "${KUBE_PS1_DISABLE_PATH}" ]] && KUBE_PS1_ENABLED=off
case "${KUBE_PS1_SHELL}" in
"zsh")
_KUBE_PS1_OPEN_ESC="%{"
_KUBE_PS1_CLOSE_ESC="%}"
_KUBE_PS1_DEFAULT_BG="%k"
_KUBE_PS1_DEFAULT_FG="%f"
setopt PROMPT_SUBST
autoload -U add-zsh-hook
add-zsh-hook precmd _kube_ps1_update_cache
zmodload -F zsh/stat b:zstat
zmodload zsh/datetime
;;
"bash")
_KUBE_PS1_OPEN_ESC=$'\001'
_KUBE_PS1_CLOSE_ESC=$'\002'
_KUBE_PS1_DEFAULT_BG=$'\033[49m'
_KUBE_PS1_DEFAULT_FG=$'\033[39m'
[[ $PROMPT_COMMAND =~ _kube_ps1_update_cache ]] || PROMPT_COMMAND="_kube_ps1_update_cache;${PROMPT_COMMAND:-:}"
;;
esac
}
# ##############################################################################
# ##############################################################################
##
## @brief Draw the context box.
##
## This box shows the selected context name. Context configuration can be found
## in the `~/.kube/config` file.
##
_kube_ps1_box_context()
{
if [[ "${KUBE_PS1_CONTEXT_ENABLE}" != true ]]
then
return
fi
local lFormat="${PROMPT_FMT_K8S_CONTEXT}"
local lData="${KUBE_PS1_CONTEXT}"
_prompt_echo_box \
"${lFormat}" \
"${lData}"
}
# ##############################################################################
# ##############################################################################
##
## @brief Draw the main box (with the "k8s" name in it).
##
_kube_ps1_box_name()
{
# # Symbol
# echo -en "${PROMPT_FMT_K8S_SYMBOL}$(_kube_ps1_symbol)"
local lFormat="${PROMPT_FMT_K8S_NAME}"
local lData=""
# lData+="$(_kube_ps1_symbol) "
lData+="k8s"
_prompt_echo_box \
"${lFormat}" \
"${lData}"
}
# ##############################################################################
# ##############################################################################
##
## @brief Draw the namespace box.
##
## This box shows the selected namespace. Available namespaces can be found
## in the `~/.kube/config` file.
##
_kube_ps1_box_namespace()
{
if [[ "${KUBE_PS1_NS_ENABLE}" != true ]]
then
return
fi
local lFormat="${PROMPT_FMT_K8S_NAMESPACE}"
local lData="${KUBE_PS1_NAMESPACE}"
_prompt_echo_box \
"${lFormat}" \
"${lData}"
}
# ##############################################################################
# ##############################################################################
_kube_ps1_file_newer_than() {
local mtime
local file=$1
local check_time=$2
if [[ "${KUBE_PS1_SHELL}" == "zsh" ]]; then
mtime=$(zstat +mtime "${file}")
elif stat -c "%s" /dev/null &> /dev/null; then
# GNU stat
mtime=$(stat -L -c %Y "${file}")
else
# BSD stat
mtime=$(stat -L -f %m "$file")
fi
[[ "${mtime}" -gt "${check_time}" ]]
}
# ##############################################################################
# ##############################################################################
_kube_ps1_split() {
type setopt >/dev/null 2>&1 && setopt SH_WORD_SPLIT
local IFS=$1
echo $2
}
# ##############################################################################
# ##############################################################################
_kube_ps1_symbol() {
[[ "${KUBE_PS1_SYMBOL_ENABLE}" == false ]] && return
case "${KUBE_PS1_SHELL}" in
bash)
if ((BASH_VERSINFO[0] >= 4)) && [[ $'\u2388 ' != "\\u2388 " ]]; then
KUBE_PS1_SYMBOL="${KUBE_PS1_SYMBOL_DEFAULT}"
# KUBE_PS1_SYMBOL=$'\u2388 '
KUBE_PS1_SYMBOL_IMG=$'\u2638\ufe0f '
else
KUBE_PS1_SYMBOL=$'\xE2\x8E\x88 '
KUBE_PS1_SYMBOL_IMG=$'\xE2\x98\xB8 '
fi
;;
zsh)
KUBE_PS1_SYMBOL="${KUBE_PS1_SYMBOL_DEFAULT}"
KUBE_PS1_SYMBOL_IMG="\u2638 ";;
*)
KUBE_PS1_SYMBOL="k8s"
esac
if [[ "${KUBE_PS1_SYMBOL_USE_IMG}" == true ]]; then
KUBE_PS1_SYMBOL="${KUBE_PS1_SYMBOL_IMG}"
fi
echo "${KUBE_PS1_SYMBOL}"
}
# ##############################################################################
# ##############################################################################
_kube_ps1_update_cache() {
local return_code=$?
[[ "${KUBE_PS1_ENABLED}" == "off" ]] && return $return_code
if ! _kube_ps1_binary_check "${KUBE_PS1_BINARY}"; then
# No ability to fetch context/namespace; display N/A.
KUBE_PS1_CONTEXT="BINARY-N/A"
KUBE_PS1_NAMESPACE="N/A"
return
fi
if [[ "${KUBECONFIG}" != "${KUBE_PS1_KUBECONFIG_CACHE}" ]]; then
# User changed KUBECONFIG; unconditionally refetch.
KUBE_PS1_KUBECONFIG_CACHE=${KUBECONFIG}
_kube_ps1_get_context_ns
return
fi
# kubectl will read the environment variable $KUBECONFIG
# otherwise set it to ~/.kube/config
local conf
for conf in $(_kube_ps1_split : "${KUBECONFIG:-${HOME}/.kube/config}"); do
[[ -r "${conf}" ]] || continue
if _kube_ps1_file_newer_than "${conf}" "${KUBE_PS1_LAST_TIME}"; then
_kube_ps1_get_context_ns
return
fi
done
return $return_code
}
# ##############################################################################
# ##############################################################################
_kubeon_usage() {
cat <<"EOF"
Toggle kube-ps1 prompt on
Usage: kubeon [-g | --global] [-h | --help]
With no arguments, turn on kube-ps1 status for this shell instance (default).
-g --global turn on kube-ps1 status globally
-h --help print this message
EOF
}
# ##############################################################################
# ##############################################################################
_kubeoff_usage() {
cat <<"EOF"
Toggle kube-ps1 prompt off
Usage: kubeoff [-g | --global] [-h | --help]
With no arguments, turn off kube-ps1 status for this shell instance (default).
-g --global turn off kube-ps1 status globally
-h --help print this message
EOF
}
# ##############################################################################
# ##############################################################################
kubeon() {
if [[ "${1}" == '-h' || "${1}" == '--help' ]]; then
_kubeon_usage
elif [[ "${1}" == '-g' || "${1}" == '--global' ]]; then
rm -f -- "${KUBE_PS1_DISABLE_PATH}"
elif [[ "$#" -ne 0 ]]; then
echo -e "error: unrecognized flag ${1}\\n"
_kubeon_usage
return
fi
KUBE_PS1_ENABLED=on
}
# ##############################################################################
# ##############################################################################
kubeoff() {
if [[ "${1}" == '-h' || "${1}" == '--help' ]]; then
_kubeoff_usage
elif [[ "${1}" == '-g' || "${1}" == '--global' ]]; then
mkdir -p -- "$(dirname "${KUBE_PS1_DISABLE_PATH}")"
touch -- "${KUBE_PS1_DISABLE_PATH}"
elif [[ $# -ne 0 ]]; then
echo "error: unrecognized flag ${1}" >&2
_kubeoff_usage
return
fi
KUBE_PS1_ENABLED=off
}
# ##############################################################################
# ##############################################################################
function bash_prompt_command_kubernetes()
{
if [ "${KUBE_PS1_ENABLED}" != "on" ]
then
return
fi
_kube_ps1_get_context_ns
_prompt_echo_startOfLine_intermediary
_kube_ps1_box_name
# local KUBE_PS1
# local KUBE_PS1_RESET_COLOR="${_KUBE_PS1_OPEN_ESC}${_KUBE_PS1_DEFAULT_FG}${_KUBE_PS1_CLOSE_ESC}"
local KUBE_PS1_RESET_COLOR="${FMT_STD}"
# Context
_prompt_echo_boxSeparator
_kube_ps1_box_context
# Namespace
_prompt_echo_boxSeparator
_kube_ps1_box_namespace
# echo -e "${KUBE_PS1}"
}
# ##############################################################################
# ##############################################################################
# Set kube-ps1 shell defaults
_kube_ps1_init
# Toggle kube-ps1 prompt on
# Made in the k8s_alias function: KUBE_PS1_ENABLED=on
# ##############################################################################
# ##############################################################################
| true
|
c1537cb010d0be26970af3fb0982126d1b87795e
|
Shell
|
huit/cloudlet-rails
|
/provisioners/puppet/scripts/deploy
|
UTF-8
| 283
| 2.828125
| 3
|
[
"MIT"
] |
permissive
|
#!/bin/sh
echo "Beginning deployment"
# send a sample capistrano deploy file via SES
if [ -r '/root/capistrano-deploy.rb' ]; then
mail -s "$(facter ec2_public_hostname) Capistrano deploy.rb" steve_huff@harvard.edu < /root/capistrano-deploy.rb
fi
echo "Finished deployment"
# vim: set ft=sh
| true
|
fcb03f57972ed0d0d731588ad4f9e2ace5d0d862
|
Shell
|
nlharris/RAST_SDK
|
/scripts/entrypoint.sh
|
UTF-8
| 897
| 2.90625
| 3
|
[
"MIT"
] |
permissive
|
#!/bin/bash
. /kb/deployment/user-env.sh
python ./scripts/prepare_deploy_cfg.py ./deploy.cfg ./work/config.properties
export PATH=$PATH:$KB_TOP/services/genome_annotation/bin:$KB_TOP/services/cdmi_api/bin
export KB_DEPLOYMENT_CONFIG=/kb/module/deploy.cfg
( cd /kb/deployment/services/kmer_annotation_figfam/;./start_service & )
if [ $# -eq 0 ] ; then
sh ./scripts/start_server.sh
elif [ "${1}" = "test" ] ; then
echo "Run Tests"
make test
elif [ "${1}" = "async" ] ; then
sh ./scripts/run_async.sh
elif [ "${1}" = "init" ] ; then
echo "Initialize module"
cd /data
mkdir kmer
cd kmer
curl http://bioseed.mcs.anl.gov/~chenry/kmer.tgz|tar xzf -
if [ -d Data.2 ] ; then
cd ..
touch __READY__
fi
elif [ "${1}" = "bash" ] ; then
bash
elif [ "${1}" = "report" ] ; then
export KB_SDK_COMPILE_REPORT_FILE=./work/compile_report.json
make compile
else
echo Unknown
fi
| true
|
a833e7f7adf058275d0b44b3832de979384f8d96
|
Shell
|
AshishBokil/Cab-Hailing-springboot
|
/pods-project1-main/tests/phase1/Custom7.sh
|
UTF-8
| 1,783
| 3.234375
| 3
|
[] |
no_license
|
#! /bin/sh
# This test case checks whether the "interest" mechanism works
# reset RideService and Wallet.
# every test case should begin with these two steps
curl -s http://localhost:8081/reset
curl -s http://localhost:8082/reset
testPassed="yes"
#cab 101 signs in
resp=$(curl -s "http://localhost:8080/signIn?cabId=101&initialPos=0")
if [ "$resp" = "true" ];
then
echo "Cab 101 signed in"
else
echo "Cab 101 could not sign in"
testPassed="no"
fi
#customer 201 requests a ride
rideId=$(curl -s "http://localhost:8081/requestRide?custId=201&sourceLoc=2&destinationLoc=10" | { read a b c; echo $a; })
if [ "$rideId" != "-1" ];
then
echo "Ride by customer 201 started"
else
echo "Ride to customer 201 denied"
testPassed="no"
fi
#customer 201's ride ends successfully
resp=$(curl -s "http://localhost:8080/rideEnded?cabId=101&rideId=$rideId")
if [ "$resp" = "true" ];
then
echo "Ride by customer 201 ended successfully"
else
echo "Ride by customer 201 could not be ended"
testPassed="no"
fi
#customer 202 requests a ride, but the cab is not interested
rideId=$(curl -s "http://localhost:8081/requestRide?custId=202&sourceLoc=20&destinationLoc=5" | { read a b c; echo $a; })
if [ "$rideId" != "-1" ];
then
echo "Ride by customer 202 started even though cab is not interested"
testPassed="no"
else
echo "Ride by customer 202 denied because cab is not interested"
fi
#customer 202 requests a ride again, and this time it is accepted
rideId=$(curl -s "http://localhost:8081/requestRide?custId=202&sourceLoc=20&destinationLoc=5" | { read a b c; echo $a; })
if [ "$rideId" != "-1" ];
then
echo "Ride by customer 202 started"
else
echo "Ride by customer 202 denied"
testPassed="no"
fi
echo "Test Passing Status: " $testPassed
| true
|
c44f702c289c40afd44c64cdd28e739d1b72685f
|
Shell
|
treejames/devices-p6_t00
|
/custom_app.sh
|
UTF-8
| 554
| 3.203125
| 3
|
[] |
no_license
|
#!/bin/bash
apkBaseName=$1
tempSmaliDir=$2
if [ "$apkBaseName" = "Settings" ];then
echo ">>> in custom_app $apkBaseName"
if [ -f $tempSmaliDir/res/xml/security_settings_picker.xml ];then
echo ">>> begin delete unlock_set_baidu_slide in $tempSmaliDir/res/xml/security_settings_picker.xml"
sed -i '/unlock_set_baidu_slide/d' $tempSmaliDir/res/xml/security_settings_picker.xml
fi
sed -i '/com.android.settings.ManageApplicationsSettings/r Settings/settings_headers.xml.part' $tempSmaliDir/res/xml/settings_headers.xml
fi
| true
|
9b6239b53d9f74cb0f4641eab050e37e749344c6
|
Shell
|
kxingit/macro
|
/stack_wavelet.sh
|
UTF-8
| 290
| 2.84375
| 3
|
[
"MIT"
] |
permissive
|
#!/bin/bash
paste *Wavelet > all_Wavelet
awk '{
s=n=0;
for(i=1;i<=NF;i++)
if($i!="NA"){
s+=$i*1;n++
}
if(n!=0){
print s/n
}
}' all_Wavelet > ave_all_Wavelet
rm -f all_Wavelet
echo -e "Stacked wavelet is \033[36m ave_all_Wavelet \033[0m"
| true
|
ac6b44d92f57477d5de08e5bafec2f6866e80282
|
Shell
|
dburaglio/Cyber333_Projects
|
/lab7/script.sh
|
UTF-8
| 242
| 3.046875
| 3
|
[] |
no_license
|
eval "$(
declare | LC_ALL=C grep 'test.*=' | while read opt; do
echo "echo Processing $opt"
optname=${opt%%=*}
echo "echo Optname is $optname"
optvalue=${opt#*=}
echo "echo Optvalue is: $optvalue"
echo "echo $optname=$optvalue"
done
)"
| true
|
31d0ab853b858d2ae6c2853fb3f7247acc1babb9
|
Shell
|
alex1701c/KDevelopTemplates
|
/package.sh
|
UTF-8
| 1,129
| 3.28125
| 3
|
[] |
no_license
|
#!/bin/bash
# This automatically updates/installs the template in your local templates folder
if [[ $(basename "$PWD") == "KDevelopTemplates" ]];then
mkdir -p build
cd build
rm ./*.tar.bz2
rm ./*/*.tar.bz2
rm ./*/*/*.tar.bz2
rm ./*/*/*/*.tar.bz2
cmake -DKDE_INSTALL_KTEMPLATESDIR=~/.local/share/kdevappwizard/templates ..
make install -j4
cp ./*.desktop ~/.local/share/kdevappwizard/template_descriptions 2>>/dev/null
cp ./*.kdevtemplate ~/.local/share/kdevappwizard/template_descriptions 2>>/dev/null
cp ./*/*.desktop ~/.local/share/kdevappwizard/template_descriptions 2>>/dev/null
cp ./*/*.kdevtemplate ~/.local/share/kdevappwizard/template_descriptions 2>>/dev/null
cp ./*/*/*.desktop ~/.local/share/kdevappwizard/template_descriptions 2>>/dev/null
cp ./*/*/*.kdevtemplate ~/.local/share/kdevappwizard/template_descriptions 2>>/dev/null
cp ./*/*/*/*.desktop ~/.local/share/kdevappwizard/template_descriptions 2>>/dev/null
cp ./*/*/*/*.kdevtemplate ~/.local/share/kdevappwizard/template_descriptions 2>>/dev/null
else
echo "Please go to the project root"
fi
| true
|
28f1bddb47854609e8d33493086dfe72bb9770b1
|
Shell
|
richzjc/IntentArgs
|
/convert_to_webp.sh
|
UTF-8
| 545
| 3.71875
| 4
|
[] |
no_license
|
# bin/bash
export lujing=$PWD
function compressToWeb(){
file=$1
fileName=${file%.*}
echo "${file##*.}"
if [ ${file##*.} = "png" && ${fileName##*.} != "9" ]
then
echo $fileName
cwebp -q 90 $2/$1 -o "$2/${fileName}.webp"
rm -f $2/$1
fi
}
function convertToWeb(){
for entry in $(ls $1)
do
if test -d $1/$entry;then
echo "convertToWeb $1/$entry"
convertToWeb $1/$entry
else
echo "compressToWeb $entry"
compressToWeb $entry $1
fi
done
}
convertToWeb $lujing
| true
|
59b49f950c8f2fd4db1b27c54c94f744ea281d5c
|
Shell
|
nrsyed/files
|
/scripts/install_opencv.sh
|
UTF-8
| 1,034
| 2.828125
| 3
|
[] |
no_license
|
#!/bin/bash
CPUS=$(lscpu | grep -i "^cpu(s):" | awk {'print $2'})
sudo apt update
sudo apt install -y build-essential cmake pkg-config
sudo apt install -y libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev
sudo apt install -y libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt install -y libxvidcore-dev libx264-dev
sudo apt install -y libgtk2.0-dev libgtk-3-dev
sudo apt install -y libatlas-base-dev gfortran
sudo apt install -y python2.7-dev python3-dev
mkdir ~/envs
cd ~/envs
virtualenv -p python3 cv_env
source cv_env/bin/activate
pip install numpy
cd ~
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
cd ~/opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
-D PYTHON_EXECUTABLE=~/envs/cv_env/bin/python \
-D BUILD_EXAMPLES=ON \
-D BUILD_OPENCV_PYTHON3=YES ..
make -j$CPUS
sudo make install
sudo ldconfig
| true
|
49635361fe29d1dad7cb14a1b428d881c6d7106e
|
Shell
|
swyder/LINUX_SHELL_4
|
/SOLUTIONS/example_nested_commands.sh
|
UTF-8
| 141
| 3.21875
| 3
|
[] |
no_license
|
# Use backticks ` to execute a command inside another
for i in `ls`
do
echo $i
done
for i in `ls | grep foo | tr a-z A-Z`
do
echo $i
done
| true
|
5ff92e193ea2705a2150da679cd5c86bedfbdebe
|
Shell
|
OpenModelica/OpenModelicaBuildScripts
|
/docker/build-deps-qt4-xenial.sh
|
UTF-8
| 289
| 2.859375
| 3
|
[] |
no_license
|
#!/bin/sh -xe
docker login docker.openmodelica.org
TAG=docker.openmodelica.org/build-deps:v1.16-qt4-xenial
if true; then
ARGS="--build-arg REPO=ubuntu:xenial"
else
ARGS="--build-arg REPO=$TAG"
fi
docker build --pull $ARGS -t "$TAG" - < Dockerfile.build-deps-qt4
docker push "$TAG"
| true
|
ef7b0f4525fd60c8b9509fdf2fa68f854677f751
|
Shell
|
k0smik0/opennebula_utils
|
/bin/one_build_cluster
|
UTF-8
| 6,026
| 3.6875
| 4
|
[] |
no_license
|
#!/bin/bash
ONE_HOME=/var/lib/one
function pop {
local array=($@)
local popped_array=(${array[@]:0:$((${#array[@]}-1))})
echo ${popped_array[@]}
}
function last {
[ $# -eq 1 ] && echo $@
local array=($@)
local li=$((${#array[@]}-1))
local last=(${array[@]:li:li})
echo $last
}
function create_cluster {
local cluster_id=$1
echo "### cluster begin ###"
echo -n "creating cluster $cluster_id: "
onecluster create $cluster_id
echo "### cluster end ###"
echo
}
function create_hosts {
echo "### hosts begin ###"
local cluster_id=$(last ${@})
local hosts=$(pop ${@})
for host in ${hosts[@]}
do
echo -n "creating host $host: "
onehost create $host -i kvm -v kvm -n dummy
echo "adding host $host to cluster $cluster_id"
onecluster addhost $cluster_id $host
done
echo "### hosts end ###"
}
function create_vnet {
echo "### vnet begin ###"
vnet_file=$1
# vnet_name=${vnet_file/.vnet/}
vnet_name=$(grep NAME ${vnet_file} | awk -F"=" '{print $2}' | sed 's/ //g' | sed 's/"//g')
local cluster_id=$2
echo -n "creating vnet ${vnet_name}: "
onevnet create ${vnet_file}
echo "adding vnet ${vnet_name} to cluster ${cluster_id}. "
onecluster addvnet ${cluster_id} ${vnet_name}
echo "### vnet end ###"
}
function create_datastores {
echo "### datastores begin ###"
local cluster_id=$(last ${@})
local datastores_files=$(pop ${@})
[ -d datastores/${cluster_id} ] || mkdir datastores/${cluster_id}
for ds in ${datastores_files[@]}
do
local ds_name=$(grep NAME ${ds} | awk '{print $3}')
echo -n "creating datastore ${ds_name} from ${ds}: "
onedatastore create ${ds}
echo -n "adding datastore ${ds_name} to cluster ${cluster_id}: "
onecluster adddatastore ${cluster_id} ${ds_name}
done
echo
echo "copy this line below and add to template, using command \"onecluster update ${cluster_id}\""
echo "DATASTORE_LOCATION=$ONE_HOME/datastores/${cluster_id}"
echo "### datastores end ###"
}
function create_image {
echo "### image begin ###"
local image_name=$1
local image_path=$2
local cluster_id=$3
local fmt=$(echo "${image_path}" | awk -F"__" '{print $2}' | cut -d"." -f1)
echo $fmt
echo -n "creating $fmt image ${image_name} from ${image_path}: "
oneimage create --name "${image_name}" --path "${image_path}" --driver $fmt --datastore ${cluster_id}__images_qcow2
echo "### image end ###"
# echo
}
function create_template {
echo "### template begin ###"
local template_name=$1
local image_name=$2
local vnet_name=$3
echo -n "creating template ${template_name} from image ${image_name} on vnet ${vnet_name}: "
onetemplate create --name "${template_name}" --cpu 0.5 --memory 1024 --arch x86_64 --disk ${image_name} --nic "${vnet_name}" --vnc --ssh
echo "### template end ###"
echo
}
function update_pubkey {
echo -e "copy this line below and add to template, using command \"EDITOR=vi oneuser update oneadmin\"\n"
echo SSH_PUBLIC_KEY="`cat ~/.ssh/id_rsa.pub`"
}
ON=/data/opennebula
#create_cluster $cluster
#create_hosts "cavallo-pazzo_one" "n-johnny-5_one" $cluster
#create_vnet ${name}.vnet $cluster
#create_datastores "iubris__*ds" $cluster
#create_image "Debian-7.3_x86_64" "$ON/disk-images/debian-7.3.0-amd64-reiserfs_qcow2.img" $cluster
#create_template "Debian-7.3 x86_64" "Debian-7.3_x86_64" ${vnet_name} $cluster
#update_pubkey
function usage {
echo "Usage: `basename $0` <build_action: all|cluster|hosts|vnet|datastores|image|template> [argument(s)]"
}
function check_cluster_exists {
onecluster list -l NAME -x | grep -w $1 >/dev/null 2>&1 && return 0 || (echo "cluster $cluster does not exist" && return 1)
}
[ $# -lt 1 ] && usage && exit 1
action=$1
shift
cluster=$(last ${@})
cluster=`echo "$cluster" | sed 's/ /_/g'`
declare -x argv=($(pop ${@}))
case $action in
cluster)
[ $# -ne 1 ] && echo "<cluster> option requires [cluster_name]" && exit 1
create_cluster $cluster
update_pubkey
;;
hosts)
[ $# -lt 2 ] && echo "<hosts> option requires: [host(s)] [cluster_name]" && exit 1
check_cluster_exists $cluster || exit 1
hosts=${argv[@]}
create_hosts ${hosts} $cluster
;;
vnet)
[ $# -lt 2 ] && echo "<vnet> option requires: [.vnet_file] [cluster_name]" && exit 1
check_cluster_exists $cluster || exit 1
vnet_file="${argv[0]}"
[ ! -f "$vnet_file" ] && echo "$vnet_file file not found" && exit 1
create_vnet ${vnet_file} $cluster
;;
datastores)
[ $# -lt 2 ] && echo "<datastores> option requires: [.ds_datastore(s)_file(s)] [cluster]" && exit 1
check_cluster_exists $cluster || exit 1
ds_files=${argv[@]}
echo ${ds_files[@]} | egrep -ve "__files.ds$|__images_qcow2.ds$|__system.ds" >/dev/null && echo "you must provide a [somename]__files.ds, a [somename]__image_qcow2.ds and a [somename]__system.ds file" && exit 1
create_datastores ${ds_files} $cluster
;;
image)
[ $# -lt 3 ] && echo "<image> option requires: [image_name] [image_path] [cluster] as arguments" && exit 1
image_name="${argv[0]}"
image_path="${argv[1]}"
[ ! -f ${image_path} ] && echo ${image_path} "does not exist" && exit 1
create_image "${image_name}" "${image_path}" ${cluster}
;;
template)
[ $# -lt 3 ] && echo "<image> option requires: [template_name] [image_name] [vnet_name] as arguments" && exit 1
template_name="${argv[0]}"
image_disk="${argv[1]}"
vnet_name="${argv[2]}"
oneimage list -l NAME -x | grep -w "${image_disk}" >/dev/null 2>&1 || (echo "image ${image_disk} does not exist" && exit 1)
onevnet list -l NAME -x | grep -w "${vnet_name}" >/dev/null 2>&1 || (echo "vnet ${vnet_name} does not exist" && exit 1)
create_template ${template_name} ${image_disk} ${vnet_name} ${cluster}
;;
all)
echo TODO
;;
*)
usage && exit 1
;;
esac
| true
|
abf4a5a7d17ff89e379cee9a878086a39cbc57f3
|
Shell
|
kalaivairamuthu/terraform
|
/terra_ubuntu_log/install_arc_agent.sh.tmpl
|
UTF-8
| 506
| 2.53125
| 3
|
[] |
no_license
|
#!/bin/bash
# Download the installation package
wget https://aka.ms/azcmagent -O ~/install_linux_azcmagent.sh
# Install the hybrid agent
sudo bash ~/install_linux_azcmagent.sh
# Import the config variables set in vars.sh
# Run connect command
sudo azcmagent connect \
--service-principal-id "${client_id}" \
--service-principal-secret "${client_secret}" \
--tenant-id "${tenant_id}" \
--subscription-id "${subscription_id}" \
--location "${location}" \
--resource-group "${resourceGroup}" \
| true
|
ae3d11abcafd32892a839639bd3460469a57f261
|
Shell
|
kdemidov/dotfiles
|
/zsh/completion.zsh
|
UTF-8
| 5,775
| 2.921875
| 3
|
[] |
no_license
|
#
# Tab completion configuration
#
# Load and initialize the completion system ignoring insecure directories
autoload -Uz compinit && compinit -i
# Load completion listings module
zmodload -i zsh/complist
#
# Options
#
# Complete from both ends of a word
setopt COMPLETE_IN_WORD
# Move cursor to the end of a completed word
setopt ALWAYS_TO_END
# Perform path search even on command names with slashes
setopt PATH_DIRS
# Show completion menu on a successive tab press
setopt AUTO_MENU
# Automatically list choices on ambiguous completion
setopt AUTO_LIST
# If completed parameter is a directory, add a trailing slash
setopt AUTO_PARAM_SLASH
# Whenever a command completion or spelling correction is attempted,
# make sure the entire command path is hashed first.
# This makes the first completion slower but avoids false reports of spelling errors.
setopt HASH_LIST_ALL
# Try to correct the spelling of commands
setopt CORRECT
# Prevents aliases on the command line from being internally substituted before completion is attempted
setopt COMPLETE_ALIASES
# Complete as much of a completion until it gets ambiguous
setopt LIST_AMBIGUOUS
# Do not autoselect the first completion entry
unsetopt MENU_COMPLETE
# Disable start/stop characters in shell editor
unsetopt FLOW_CONTROL
# Treat these characters as part of a word
WORDCHARS='*?_-.[]~&;!#$%^(){}<>'
#
# Styles
#
# Group matches and describe
zstyle ':completion:*:*:*:*:*' menu select
zstyle ':completion:*:matches' group 'yes'
zstyle ':completion:*:options' description 'yes'
zstyle ':completion:*:options' auto-description '%d'
zstyle ':completion:*:corrections' format ' %F{green}-- %d (errors: %e) --%f'
zstyle ':completion:*:descriptions' format ' %F{yellow}-- %d --%f'
zstyle ':completion:*:messages' format ' %F{purple} -- %d --%f'
zstyle ':completion:*:warnings' format ' %F{red}-- no matches found --%f'
zstyle ':completion:*:default' list-prompt '%S%M matches%s'
zstyle ':completion:*' format ' %F{yellow}-- %d --%f'
# For all completions: grouping the output
zstyle ':completion:*' group-name ''
# For all completions: show comments when present
zstyle ':completion:*' verbose 'yes'
# Completion of .. directories
zstyle ':completion:*' special-dirs 'true'
# Auto rehash commands
zstyle ':completion:*' rehash true
# Case insensitivity
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
# Caching of completion stuff
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path "$ZSH/cache"
# Fuzzy match mistyped completions
zstyle ':completion:*' completer _complete _match _approximate
zstyle ':completion:*:match:*' original only
zstyle ':completion:*:approximate:*' max-errors 1 numeric
# Increase the number of errors based on the length of the typed word
zstyle -e ':completion:*:approximate:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)'
# Don't complete unavailable commands
zstyle ':completion:*:functions' ignored-patterns '(_*|pre(cmd|exec))'
# Array completion element sorting
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
# Directories
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*:*:cd:*' tag-order local-directories directory-stack path-directories
zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
zstyle ':completion:*:-tilde-:*' group-order 'named-directories' 'path-directories' 'users' 'expand'
zstyle ':completion:*' squeeze-slashes true
# History
zstyle ':completion:*:history-words' stop yes
zstyle ':completion:*:history-words' remove-all-dups yes
zstyle ':completion:*:history-words' list false
zstyle ':completion:*:history-words' menu yes
# Environmental Variables
zstyle ':completion::*:(-command-|export):*' fake-parameters ${${${_comps[(I)-value-*]#*,}%%,*}:#-*-}
# Populate hostname completion
zstyle -e ':completion:*:hosts' hosts 'reply=(
${=${=${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) 2>/dev/null)"}%%[#| ]*}//\]:[0-9]*/ }//,/ }//\[/ }
${=${(f)"$(cat /etc/hosts(|)(N) <<(ypcat hosts 2>/dev/null))"}%%\#*}
${=${${${${(@M)${(f)"$(cat ~/.ssh/config 2>/dev/null)"}:#Host *}#Host }:#*\**}:#*\?*}}
)'
# ... unless we really want to
zstyle '*' single-ignored show
# Ignore multiple entries
zstyle ':completion:*:(rm|kill|diff):*' ignore-line other
zstyle ':completion:*:rm:*' file-patterns '*:all-files'
# Kill
zstyle ':completion:*:*:*:*:processes' command 'ps -u $LOGNAME -o pid,user,command -w'
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;36=0=01'
zstyle ':completion:*:*:kill:*' menu yes select
zstyle ':completion:*:*:kill:*' force-list always
zstyle ':completion:*:*:kill:*' insert-ids single
# Man
zstyle ':completion:*:manuals' separate-sections true
zstyle ':completion:*:manuals.(^1*)' insert-sections true
# SSH/SCP/RSYNC
zstyle ':completion:*:(scp|rsync):*' tag-order 'hosts:-host:host hosts:-domain:domain hosts:-ipaddr:ip\ address *'
zstyle ':completion:*:(scp|rsync):*' group-order users files all-files hosts-domain hosts-host hosts-ipaddr
zstyle ':completion:*:ssh:*' tag-order 'hosts:-host:host hosts:-domain:domain hosts:-ipaddr:ip\ address *'
zstyle ':completion:*:ssh:*' group-order users hosts-domain hosts-host users hosts-ipaddr
zstyle ':completion:*:(ssh|scp|rsync):*:hosts-host' ignored-patterns '*(.|:)*' loopback ip6-loopback localhost ip6-localhost broadcasthost
zstyle ':completion:*:(ssh|scp|rsync):*:hosts-domain' ignored-patterns '<->.<->.<->.<->' '^[-[:alnum:]]##(.[-[:alnum:]]##)##' '*@*'
zstyle ':completion:*:(ssh|scp|rsync):*:hosts-ipaddr' ignored-patterns '^(<->.<->.<->.<->|(|::)([[:xdigit:].]##:(#c,2))##(|%*))' '127.0.0.<->' '255.255.255.255' '::1' 'fe80::*'
# Complete "g" as "git"
compdef g=git
zstyle :compinstall filename $HOME/.zshrc
| true
|
75088e9139d53250250f790493a0cf3d0adbe1b9
|
Shell
|
rajiv-ranjan/consulting-utilities
|
/Openshift/installation/dockerStorage/setDockerStorageToThinPoolStorage.sh
|
UTF-8
| 2,708
| 2.796875
| 3
|
[] |
no_license
|
#!/bin/bash
for host in \
master-0.rajranja.lab.pnq2.cee.redhat.com \
master-1.rajranja.lab.pnq2.cee.redhat.com \
master-2.rajranja.lab.pnq2.cee.redhat.com \
infra-0.rajranja.lab.pnq2.cee.redhat.com \
infra-1.rajranja.lab.pnq2.cee.redhat.com \
node-0.rajranja.lab.pnq2.cee.redhat.com \
node-1.rajranja.lab.pnq2.cee.redhat.com \
node-2.rajranja.lab.pnq2.cee.redhat.com \
node-3.rajranja.lab.pnq2.cee.redhat.com \
node-4.rajranja.lab.pnq2.cee.redhat.com \
node-5.rajranja.lab.pnq2.cee.redhat.com \
node-6.rajranja.lab.pnq2.cee.redhat.com \
node-7.rajranja.lab.pnq2.cee.redhat.com \
node-8.rajranja.lab.pnq2.cee.redhat.com \
node-9.rajranja.lab.pnq2.cee.redhat.com \
lb-0.rajranja.lab.pnq2.cee.redhat.com; \
do echo "##### checking the block devices attached : $host ##########" && ssh -t -i quicklab.key -l quicklab $host "sudo lsblk --fs"; \
done
###### RUN ALL COMMAND AS ROOT
### check for the deives attached
ll /dev/disk/by-path/
lsblk --fs
### observe if the device is already mounted. If yes then unmount and then proceed with docker storage setup
# assuming the vdb is the block storage device attached
fdisk -l /dev/vdb
### create the docker storage setup config
# mark WIPE_SIGNATURES is required when the device already has signature
# below is what i used with my clusters
clear
sudo su -
#umount /mnt
lsblk -fs
cat <<EOF > /etc/sysconfig/docker-storage-setup
WIPE_SIGNATURES=true
DEVS=/dev/vdb
VG=docker-vg
EOF
### Run the docker storage setup
sudo docker-storage-setup
lsblk -fs
exit
exit
### Verify docker-storage is correctly populated
for host in \
master-0.rajranja.lab.pnq2.cee.redhat.com \
master-1.rajranja.lab.pnq2.cee.redhat.com \
master-2.rajranja.lab.pnq2.cee.redhat.com \
infra-0.rajranja.lab.pnq2.cee.redhat.com \
infra-1.rajranja.lab.pnq2.cee.redhat.com \
node-0.rajranja.lab.pnq2.cee.redhat.com \
node-1.rajranja.lab.pnq2.cee.redhat.com \
node-2.rajranja.lab.pnq2.cee.redhat.com \
node-3.rajranja.lab.pnq2.cee.redhat.com \
node-4.rajranja.lab.pnq2.cee.redhat.com \
node-5.rajranja.lab.pnq2.cee.redhat.com \
node-6.rajranja.lab.pnq2.cee.redhat.com \
node-7.rajranja.lab.pnq2.cee.redhat.com \
node-8.rajranja.lab.pnq2.cee.redhat.com \
node-9.rajranja.lab.pnq2.cee.redhat.com \
lb-0.rajranja.lab.pnq2.cee.redhat.com; \
do echo "##### checking the docker-pool lv for : $host ##########" && ssh -t -i quicklab.key -l quicklab $host "sudo grep -i --color dm.thinpooldev /etc/sysconfig/docker-storage && sudo grep -i --color docker--pool /etc/sysconfig/docker-storage && if [ $? -eq 0 ]; then echo 'SUCCESS'; else echo 'FAIL'; fi;"; \
done
| true
|
765c2a77675e00c950b7f4a048ed84026d8709e7
|
Shell
|
facebook/chef-cookbooks
|
/cookbooks/fb_less/files/default/profile.d/fbless.sh
|
UTF-8
| 287
| 2.9375
| 3
|
[
"Apache-2.0"
] |
permissive
|
# shellcheck shell=sh
# Set some useful LESS options. If you prefer your own, set it in
# your shell startup script and it will be honored.
if [ -z "${LESS+set}" ]; then
export LESS='-n -i'
fi
if [ -z "${LESSOPEN+set}" ]; then
export LESSOPEN='||/usr/local/bin/lesspipe.sh %s'
fi
| true
|
71697d115ccf085b70acbde644b14d2718a044a0
|
Shell
|
GAIMJKP/expLinkage
|
/bin/runDiffSeed.sh
|
UTF-8
| 154
| 3.171875
| 3
|
[
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
#!/bin/sh
set -xu
startSeed=$1
shift
endSeed=$1
shift
command=$1
for seed in $(seq $startSeed $endSeed)
do
echo $seed
$command --seed=$seed
done
| true
|
aec24518ad6671ec1b1d3485c57df8872ddbb3e3
|
Shell
|
cgzones/ctguard
|
/itests/research/test2/test.sh
|
UTF-8
| 710
| 3.421875
| 3
|
[
"MIT",
"BSD-3-Clause"
] |
permissive
|
#!/bin/sh
set -eu
BIN=../../../src/research/ctguard-research
if ! [ -e ${BIN} ]; then
echo "Could not find binary at '${BIN}'!"
exit 1
fi
cleanup () {
rm -f test.output
}
cleanup
chmod 640 rules.xml test.conf
OUTPUT=$(${BIN} --cfg-file test.conf --input -f << EOF
Sep 24 12:10:03 desktopdebian unix_chkpwd[12490]: password check failed for user (christian)
Sep 24 12:10:03 desktopdebian unix_chkpwd[12490]: password check failed for user (root)
Sep 24 12:10:03 desktopdebian unix_chkpwd[12490]: password check failed for user (christian)
quit
EOF
)
echo "$OUTPUT" > test.output
echo "Comparing expected vs actual output:"
diff -u test.output.expected test.output
cleanup
echo "SUCCESS!"
| true
|
f61ce5d09002bf54e8f1a3d38ae1fd4e9ad9f506
|
Shell
|
leva24/levproject
|
/factorial.sh
|
UTF-8
| 174
| 3.375
| 3
|
[] |
no_license
|
#factorial
echo "enter a number"
read num
fact=1
numb=$num
while [ $num -ge 1 ]
do
fact=` expr $fact \* $num `
num=` expr $num - 1 `
done
echo "factorial of $numb is $fact"
| true
|
954ffca170f5607f80ac392705061781d62935cc
|
Shell
|
sara-sabr/poc-network-vpn-split-tunnel
|
/Server/install.sh
|
UTF-8
| 822
| 2.65625
| 3
|
[
"LicenseRef-scancode-proprietary-license",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] |
permissive
|
#!/bin/sh
# Install docker on the VM assuming Ubuntu.
sudo apt-get update
sudo apt install docker.io -y
sudo apt install docker-compose -y
sudo systemctl start docker
sudo systemctl enable docker
sudo ufw allow ssh
sudo ufw allow 53
sudo ufw allow 500,4500/udp
sudo sed -i '\/net\/ipv4\/ip_forward/s/^#//g' /etc/ufw/sysctl.conf
echo "net/ipv4/conf/all/send_redirects=0
net/ipv4/ip_no_pmtu_disc=1" | sudo tee -a /etc/ufw/sysctl.conf
sudo ufw enable
sudo ufw reload
# Install Git to do the pull down since we have no docker repo
sudo apt install git-core -y
# Running as current user
mkdir -p ~/poc-setup
cd ~/poc-setup
# Checkout the code
git clone https://github.com/sara-sabr/poc-network-vpn-split-tunnel.git
cd poc-network-vpn-split-tunnel/Server
sudo chmod 700 start.sh
sudo chmod 700 stop.sh
sudo ./start.sh
| true
|
4e5aaf42be5ad1a49e03c2508ad9028d64fdb201
|
Shell
|
jrevillard/biomed-support-tools
|
/SE/monitor-se-space/list-users-voms.sh
|
UTF-8
| 1,575
| 4.25
| 4
|
[
"MIT"
] |
permissive
|
#!/bin/bash
# list-voms-users.sh, v1.0
# Author: F. Michel, CNRS I3S, biomed VO support
VO=biomed
VOMS_HOST=voms-biomed.in2p3.fr
VOMS_PORT=8443
VOMS_USERS=`pwd`/voms-users.txt
help()
{
echo
echo "This script gets the list of users from the VOMS server using the voms-admin command."
echo "The result file is replacedi/created only if the voms-admin commands succeeds, otherwise "
echo "the existing file remains unchanged."
echo
echo "Usage:"
echo "$0 [-h|--help]"
echo "$0 [--vo <VO>] [--voms-host <hostname>] [--voms-port <port>] [--out <file name>]"
echo
echo " --vo <VO>: the Virtual Organisation to query. Defaults to biomed."
echo
echo " --voms-host <hostname>: VOMS server hostname. Defaults to voms-biomed.in2p3.fr."
echo
echo " --voms-port <post>: VOMS server hostname. Defaults to 8443."
echo
echo " --out <file name>: where to store results. Defaults to './voms-users.txt'."
echo
echo " -h, --help: display this help"
echo
exit 1
}
# Check parameters
while [ ! -z "$1" ]
do
case "$1" in
--vo ) VO=$2; shift;;
--out ) VOMS_USERS=$2; shift;;
--voms-host ) VOMS_HOST=$2; shift;;
--voms-port ) VOMS_PORT=$2; shift;;
-h | --help ) help;;
*) help;;
esac
shift
done
# Get the current list of users from the VOMS server
voms-admin --vo=$VO --host $VOMS_HOST --port $VOMS_PORT list-users > $VOMS_USERS.temp
if test $? -eq 0; then
mv $VOMS_USERS.temp $VOMS_USERS
echo "Users list built successfully: $VOMS_USERS."
exit 0
else
echo "Failed to build list of users from VOMS."
exit 1
fi
| true
|
878a5243da3637a2331ac0181aaca58c2c237cbe
|
Shell
|
ch3rag/BASH
|
/Programs/Function/EuclideanGCD.sh
|
UTF-8
| 949
| 3.421875
| 3
|
[] |
no_license
|
########################################################################
# Author: Bharat Singh Rajput #
# File Name: EuclideanGCD.sh #
# Creation Date: April 16, 2020 08:58 PM #
# Last Updated: September 10, 2020 01:15 PM #
# Source Language: shellscript #
# Repository: https://github.com/ch3rag/BASH.git #
# #
# --- Code Description --- #
# Function To Evaluate GCD Of Two Numbers Using Recursive Euclidean #
# Algorithm #
########################################################################
gcd() {
if [ $1 -eq 0 ]; then echo $2
else echo $(gcd $(($2 % $1)) $1); fi
}
| true
|
0257287ca8b6bf5651a1dc7d6555ed5878dc0a57
|
Shell
|
YingLin-NOAA/pcpverif_metplus
|
/scripts/run_rtma_urma_st4.sh
|
UTF-8
| 3,689
| 3.28125
| 3
|
[] |
no_license
|
#!/bin/ksh
set -x
. ~/dots/dot.for.metplus
echo 'Actual output starts here:'
if [ $# -eq 0 ]
then
export vday=`date +%Y%m%d -d "2 day ago"`
else
export vday=$1
fi
run_pcprtma=1
run_pcprtma2p8=1
run_pcpurma=1
run_pcpurma2p8=1
run_st4=1
run_st4x=1
# export for ${model}_24h.conf:
MET=/gpfs/dell2/emc/verification/noscrub/Ying.Lin/metplus/yl
export polydir=$MET/masks/rfcs
export obspath=/gpfs/dell2/emc/verification/noscrub/Ying.Lin/gauge_nc
# v2.8 para runs on prod wcoss phase 2. Find out where to get the data.
# 2019/10/25: move the METplus verif for pcprtma/urma/st4 to prod dell, to
# minimize disruptions.
h1=`hostname | cut -c 1-1`
if [ $h1 = m ]; then
disk2=tp2
otherdell=venus
elif [ $h1 = v ]; then
disk2=gp2
otherdell=mars
else
echo Marchine is neither Mars nor Venus. Exit.
exit
fi
# Find out if the gauge .nc file exists. If not, try getting it from $otherdell
gaugefile=good-usa-dlyprcp-${vday}.nc
gaugefileok=NO
if [ -s $obspath/$gaugefile ]; then
gaugefileok=YES
else
scp Ying.Lin@${otherdell}:$obspath/$gaugefile $obspath/.
err=$?
if [ $err -eq 0 ]; then
gaugefileok=YES
else
$MET/util/prep_gauges/dailygauge_ascii2nc.sh $vday
if [ -s $obspath/$gaguefile ]; then
gaugefileok=YES
else
echo gauge file not available, remake failed. Exit
exit
fi
fi # copy from the other dell machine successful?
fi # nc gauge file already on disk?
if [ $run_pcprtma -eq 1 ]; then
export model=pcprtma
export MODEL=`echo $model | tr a-z A-Z`
export modpath=/gpfs/dell2/nco/ops/com/rtma/prod
${YLMETPLUS_PATH}/ush/master_metplus.py \
-c ${YLMETPLUS_PATH}/yl/parm/models/pcprtma_24h.conf \
-c ${YLMETPLUS_PATH}/yl/parm/system.conf.dell.pointstat
fi
if [ $run_pcprtma2p8 -eq 1 ]; then
export model=pcprtma2p8
export MODEL=`echo $model | tr a-z A-Z`
export modpath=/gpfs/${disk2}/ptmp/emc.rtmapara/com/rtma/para
${YLMETPLUS_PATH}/ush/master_metplus.py \
-c ${YLMETPLUS_PATH}/yl/parm/models/pcprtma_24h.conf \
-c ${YLMETPLUS_PATH}/yl/parm/system.conf.dell.pointstat
fi
if [ $run_pcpurma -eq 1 ]; then
export model=pcpurma
export MODEL=`echo $model | tr a-z A-Z`
export modpath=/gpfs/dell2/nco/ops/com/urma/prod
${YLMETPLUS_PATH}/ush/master_metplus.py \
-c ${YLMETPLUS_PATH}/yl/parm/models/pcpurma_24h.conf \
-c ${YLMETPLUS_PATH}/yl/parm/system.conf.dell.pointstat
fi
if [ $run_pcpurma2p8 -eq 1 ]; then
export model=pcpurma2p8
export MODEL=`echo $model | tr a-z A-Z`
export modpath=/gpfs/${disk2}/ptmp/emc.rtmapara/com/urma/para
${YLMETPLUS_PATH}/ush/master_metplus.py \
-c ${YLMETPLUS_PATH}/yl/parm/models/pcpurma_24h.conf \
-c ${YLMETPLUS_PATH}/yl/parm/system.conf.dell.pointstat
fi
# Prod ST4 is gzip'd. Copy it over to metplus.out:
if [ $run_st4 -eq 1 ]; then
PRDST4DIR=/gpfs/dell2/nco/ops/com/pcpanl/prod/pcpanl.$vday
METPLUS_OUT=/gpfs/dell2/ptmp/Ying.Lin/metplus.out
MYPRDST4=${METPLUS_OUT}/st4/gunzpd
if [ ! -d $MYPRDST4 ]
then
mkdir -p $MYPRDST4
fi
gunzip -c $PRDST4DIR/ST4.${vday}12.24h.gz > $MYPRDST4/ST4.${vday}12.24h
export model=st4
export MODEL=`echo $model | tr a-z A-Z`
export modpath=$MYPRDST4
${YLMETPLUS_PATH}/ush/master_metplus.py \
-c ${YLMETPLUS_PATH}/yl/parm/models/${model}_24h.conf \
-c ${YLMETPLUS_PATH}/yl/parm/system.conf.dell.pointstat
fi
if [ $run_st4x -eq 1 ]; then
export model=st4x
export MODEL=`echo $model | tr a-z A-Z`
export modpath=/gpfs/${disk2}/ptmp/emc.rtmapara/com/pcpanl/para
${YLMETPLUS_PATH}/ush/master_metplus.py \
-c ${YLMETPLUS_PATH}/yl/parm/models/${model}_24h.conf \
-c ${YLMETPLUS_PATH}/yl/parm/system.conf.dell.pointstat
fi
exit
| true
|
0eef3a539c0c062e88ea37b84545846ae810be53
|
Shell
|
mnewt/teleprompt
|
/sh/__prompt_functions
|
UTF-8
| 2,351
| 3.75
| 4
|
[
"MIT"
] |
permissive
|
#!/usr/bin/env bash
__prompt_status () {
[ $__prompt_last_status -eq 0 ] && return 1
echo $__prompt_last_status
}
__prompt_directory () {
printf ${PWD/$HOME/"~"}
}
__prompt_short_directory () {
local length=20
local p=${PWD/#$HOME/\~} b s
while [ "$p" ] && [ ${#p} -gt $length ]; do
re_match "$p" '^(\/?\.?.)[^\/]*(.*)$'
b+=${re_match[1]}
p=${re_match[2]}
done
echo "$b$p"
}
__prompt_username () {
[ -n "$SSH_CLIENT" ] && echo "$USER"
}
export __prompt_hostname=$(hostname -s)
__prompt_hostname () {
[ -n "$SSH_CLIENT" ] && echo $__prompt_hostname
}
__prompt_git () {
if hash git 2>/dev/null; then
if branch=$( { git symbolic-ref --quiet HEAD || git rev-parse --short HEAD; } 2>/dev/null ); then
branch=${branch##*/}
printf "%s" "${branch:-unknown}"
return
fi
fi
return 1
}
__prompt_rbenv () {
[ "$RBENV_VERSION" ] && [ "$RBENV_VERSION" != "system" ] && printf "$RBENV_VERSION"
}
__prompt_virtualenv () {
[ "$VIRTUAL_ENV" ] && printf "${VIRTUAL_ENV##*/}"
}
__prompt_node () {
# detect package.json
# print "name" field
local package && package="$(upsearch package.json)" && \
re_match "$(cat "$package")" '\"name\": \"?([^\",]*)' && \
printf "${re_match[1]}"
}
__prompt_vagrant () {
# detect Vagrantfile
# print .vagrant/machines/$machine_name
local vagrantfile && vagrantfile="$(upsearch Vagrantfile)" || return 1
local vagrantdir="${vagrantfile%/*}/.vagrant/machines"
[ -d "$vagrantdir" ] \
&& for f in $vagrantdir/*; do printf "${f##*/}"; done \
|| return 1
}
__prompt_clojure () {
# detect project.clj or build.boot
# print project name
local file
if file="$(upsearch project.clj)"; then
re_match "$(cat "$file")" "\(defproject +([^ )]+)" && \
printf "${re_match[1]}"
elif file="$(upsearch build.boot)"; then
re_match "$(cat "$file")" ":project +'([^ ]+)" && \
printf "${re_match[1]}"
else
return 1
fi
}
__prompt_jobs () {
local job_count
job_count=$(count_lines "$(jobs -p)")
[[ $job_count -gt 0 ]] || return 1;
printf "%s" "$job_count"
}
__prompt_tmux () {
[ "$TMUX" ] && return 1
local session_count=$(count_lines $(tmux ls 2>/dev/null))
[ $session_count -gt 0 ] && printf "%s" $session_count
}
__prompt_datetime () {
date +"%r"
}
__prompt_short_datetime () {
date +"%H:%M:%S"
}
| true
|
1cb740b0ef9f6ebec0fe2c213bbfa160f4a3d48f
|
Shell
|
red-lever-solutions/aws-meetup-vienna-20151126
|
/provision/nginx/bootstrap.sh
|
UTF-8
| 371
| 2.859375
| 3
|
[] |
no_license
|
#!/bin/bash
HOSTNAME=`hostname`
mkdir -p /opt/nginx/data
cat >/opt/nginx/data/index.html <<EOF
<!doctype html>
<html>
<head><title>Hello, AWS enthusiasts!</title></head>
<body>
<p>
Hi, this is <strong>${HOSTNAME}</strong> speaking!
</p>
</body>
</html>
EOF
cp /tmp/bootstrap/docker-compose.yml /opt/nginx
cp /tmp/bootstrap/start.sh /opt/nginx
cd /opt/nginx
./start.sh
| true
|
460db62d216f3e799e3a1ebabfd99804ee7f5b4c
|
Shell
|
kavod/TvShowWatch-2
|
/syno/scripts/postinst
|
UTF-8
| 464
| 2.6875
| 3
|
[] |
no_license
|
#!/bin/sh
PIP="/var/packages/python/target/bin/pip"
PYTHON="/var/packages/python/target/bin/python"
${PIP} install --upgrade pip > '/tmp/TSW2.log'
cd "${SYNOPKG_PKGDEST}" && ${PYTHON} utils/execute_color.py "Installing JSAG3" ${PYTHON} utils/pkg_manager.py "install" "JSAG3" >> '/tmp/TSW2.log' 2>&1
cd "${SYNOPKG_PKGDEST}" && cp utils/directory_syno.conf utils/directory.conf >> '/tmp/TSW2.log' 2>&1
${PIP} install -r requirements.txt >> '/tmp/TSW2.log' 2>&1
| true
|
6cc345d33a2ce691d235e6b49d8e85588b9c5831
|
Shell
|
chessai/ghc
|
/ghc-4335c07/.circleci/fetch-submodules.sh
|
UTF-8
| 457
| 2.609375
| 3
|
[] |
no_license
|
#!/nix/store/nkq0n2m4shlbdvdq0qijib5zyzgmn0vq-bash-4.4-p12/bin/bash
set -euo pipefail
# Use github.com/ghc for those submodule repositories we couldn't connect to.
git config remote.origin.url git://github.com/ghc/ghc.git
git config --global url."git://github.com/ghc/packages-".insteadOf git://github.com/ghc/packages/
git submodule init # Don't be quiet, we want to show these urls.
git submodule --quiet update --recursive # Now we can be quiet again.
| true
|
b39ea36d055300d504adf5faedcd8f0724125c2d
|
Shell
|
IvanLJF/My_InSAR_Codes
|
/tli_scr/plot_goecoded
|
UTF-8
| 1,079
| 2.625
| 3
|
[] |
no_license
|
#!/bin/sh
echo '****************************************'
echo '* Plotting geocoded deformation map... *'
echo '****************************************'
pdeffile='lel6vdh_merge_geocode_GMT'
psfile='lel6_geocoded.ps'
sz=0.01i # Size of the points
gmtset ANNOT_FONT_SIZE 9p ANNOT_OFFSET_PRIMARY 0.07i FRAME_WIDTH 0.04i MAP_SCALE_HEIGHT 0.04i \
LABEL_FONT_SIZE 10p LABEL_OFFSET 0.05i TICK_LENGTH 0.05i
makecpt -Ctli_def -T-52.241060/0.0000000/0.100000 -I -V -Z > g.cpt
######################################################
# plot geocoded results.
psbasemap -R113.8868/113.9563/22.2859/22.3265 -JX4.73i/3i -Ba0.02f0.01::WeSn -P -K -V > $psfile
psimage HK_googleearth.ras -Gtblack -W4.73i/3i -O -V -K >> $psfile
psxy $pdeffile -R -J -Cg.cpt -V -Sc$sz -K -O >> $psfile #Some problems emerged. This reconstructed an unexpected basemap. solution: remove the keyword '-B'
psscale -Cg.cpt -D4.8i/1.88i/2.9i/0.08i -E -I -O -B5::/:mm/\y: -V >> $psfile
ps2raster -A -Tt $psfile
imgbasename=`basename $psfile '.ps'`
convert $imgbasename.tif $imgbasename.jpg
geeqie $imgbasename.jpg
| true
|
9431ac7a1c3dbd501878dc369e4ef79f18409608
|
Shell
|
leschultz/analysis_scripts
|
/gather_apd
|
UTF-8
| 245
| 2.53125
| 3
|
[] |
no_license
|
#!/bin/bash
# Gather APD values from analysis
# Inputs:
# <analysis data from jobs>
# <name of file containing APD>
# <export directory>
gather_apd.py\
'../export'\
'apd_last.txt'\
'../export/analysis_data'
| true
|
8e579c2ce3de01013f0b9dd9a4dff5d68c497b2a
|
Shell
|
flexiOPSResources/FCONodeMonitoringScripts
|
/scripts/storage/storage10min.sh
|
UTF-8
| 1,929
| 3.40625
| 3
|
[
"Apache-2.0"
] |
permissive
|
#!/bin/bash -X
STORAGEDIR="/opt/extility/skyline/war/storage10/"
DATE=$(date "+%Y-%m-%dT%H:%M:%S")
storagec1 ()
{
STORAGE1KB=$(ceph df -f json-pretty | grep total_used | awk '{print $2}' | sed -e 's/,//g')
STORAGE1=$(echo $STORAGE1KB*1024 | bc)
AVAILABLESTORAGE1KB=$(ceph df -f json-pretty | grep total_avail | awk '{print $2}' | sed -e 's/,//g' | sed -e 's/}//g')
AVAILABLESTORAGE1=$(echo $AVAILABLESTORAGE1KB*1024 | bc)
PERCENTSTORAGE1=$(echo "scale=2; $STORAGE1KB*100/$AVAILABLESTORAGE1KB" | bc)
echo $DATE,$STORAGE1,$AVAILABLESTORAGE1,$PERCENTSTORAGE1 >> $STORAGEDIR/Cluster1.csv
}
storagec2 ()
{
STORAGE2KB=$(sshe 10.0.0.1 ceph df -f json-pretty | grep total_used | awk '{print $2}' | sed -e 's/,//g')
STORAGE2=$(echo $STORAGE2KB*1024 | bc)
AVAILABLESTORAGE2KB=$(sshe 10.0.0.1 ceph df -f json-pretty | grep total_avail | awk '{print $2}' | sed -e 's/,//g' | sed -e 's/}//g')
AVAILABLESTORAGE2=$(echo $AVAILABLESTORAGE2KB*1024 | bc)
PERCENTSTORAGE2=$(echo "scale=2; $STORAGE2KB*100/$AVAILABLESTORAGE2KB" | bc)
echo $DATE,$STORAGE2,$AVAILABLESTORAGE2,$PERCENTSTORAGE2 >> $STORAGEDIR/Cluster2.csv
}
if [[ -n $( grep $(date -d"10 minutes ago" +%H:%M) $STORAGEDIR/Cluster1.csv ) ]] ; then
rm -f $STORAGEDIR/Cluster1.csv
touch $STORAGEDIR/Cluster1.csv
echo "DATE,Used Bytes,Available,UsedPercent" > $STORAGEDIR/Cluster1.csv
storagec1
else
storagec1
fi
if [[ -n $( grep $(date -d"10 minutes ago" +%H:%M) $STORAGEDIR/Cluster2.csv ) ]] ; then
rm -f $STORAGEDIR/Cluster2.csv
touch $STORAGEDIR/Cluster2.csv
echo "DATE,Used Bytes,Available,UsedPercent" > $STORAGEDIR/Cluster2.csv
storagec2
else
storagec2
fi
| true
|
2cf621c31c3697724ef10d9b644477aa99558a94
|
Shell
|
buildpacks/samples
|
/extensions/curl/bin/generate
|
UTF-8
| 191
| 2.59375
| 3
|
[
"Apache-2.0"
] |
permissive
|
#!/usr/bin/env bash
set -eo pipefail
# 1. GET ARGS
output_dir=$CNB_OUTPUT_DIR
# 2. GENERATE run.Dockerfile
cat >>"${output_dir}/run.Dockerfile" <<EOL
FROM localhost:5000/run-image-curl
EOL
| true
|
6c3af8ada8be5daa1c2f5d8a1c397383019b78d5
|
Shell
|
arashkaffamanesh/hivemq-mqtt-tensorflow-kafka-realtime-iot-machine-learning-training-inference
|
/infrastructure/confluent/01_installConfluentPlatform.sh
|
UTF-8
| 12,646
| 3.28125
| 3
|
[
"Apache-2.0"
] |
permissive
|
#!/usr/bin/env bash
set -e
# set current directory of script
MYDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
until gcloud container clusters list --zone europe-west1-b | grep 'RUNNING' >/dev/null 2>&1; do
echo "kubeapi not available yet..."
sleep 3
done
echo "Deploying prometheus..."
# Make sure the tiller change is rolled out
kubectl rollout status -n kube-system deployment tiller-deploy
# Commented next command, please do a helm repo update before executing terraform
# helm repo update
# Make upgrade idempotent by first deleting all the CRDs (the helm chart will error otherwise)
kubectl delete crd alertmanagers.monitoring.coreos.com podmonitors.monitoring.coreos.com prometheuses.monitoring.coreos.com prometheusrules.monitoring.coreos.com servicemonitors.monitoring.coreos.com 2>/dev/null || true
helm delete --purge prom 2>/dev/null || true
helm install --namespace monitoring --replace --name prom --version 6.8.1 stable/prometheus-operator --wait
echo "Deploying metrics server..."
helm upgrade --install metrics stable/metrics-server --version 2.8.4 --wait --force || true
echo "Deploying K8s dashboard..."
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta4/aio/deploy/recommended.yaml
echo "Kubernetes Dashboard token:"
gcloud config config-helper --format=json | jq -r '.credential.access_token'
echo "Download Confluent Operator"
# check if Confluent Operator still exist
DIR="confluent-operator/"
if [ -d "$DIR" ]; then
# Take action if $DIR exists. #
echo "Operator is installed..."
cd confluent-operator/
else
mkdir confluent-operator
cd confluent-operator/
wget https://platform-ops-bin.s3-us-west-1.amazonaws.com/operator/confluent-operator-20190912-v0.65.1.tar.gz
tar -xvf confluent-operator-20190912-v0.65.1.tar.gz
rm confluent-operator-20190912-v0.65.1.tar.gz
cp ${MYDIR}/gcp.yaml helm/providers/
fi
cd helm/
echo "Install Confluent Operator"
#helm delete --purge operator
helm install \
-f ${MYDIR}/gcp.yaml \
--name operator \
--namespace operator \
--set operator.enabled=true \
./confluent-operator || true
echo "After Operator Installation: Check all pods..."
kubectl get pods -n operator
kubectl rollout status deployment -n operator cc-operator
kubectl rollout status deployment -n operator cc-manager
echo "Patch the Service Account so it can pull Confluent Platform images"
kubectl -n operator patch serviceaccount default -p '{"imagePullSecrets": [{"name": "confluent-docker-registry" }]}'
echo "Install Confluent Zookeeper"
#helm delete --purge zookeeper
helm install \
-f ${MYDIR}/gcp.yaml \
--name zookeeper \
--namespace operator \
--set zookeeper.enabled=true \
./confluent-operator || true
echo "After Zookeeper Installation: Check all pods..."
kubectl get pods -n operator
sleep 10
kubectl rollout status sts -n operator zookeeper
echo "Install Confluent Kafka"
#helm delete --purge kafka
helm install \
-f ${MYDIR}/gcp.yaml \
--name kafka \
--namespace operator \
--set kafka.enabled=true \
./confluent-operator || true
echo "After Kafka Broker Installation: Check all pods..."
kubectl get pods -n operator
sleep 10
kubectl rollout status sts -n operator kafka
echo "Install Confluent Schema Registry"
#helm delete --purge schemaregistry
helm install \
-f ${MYDIR}/gcp.yaml \
--name schemaregistry \
--namespace operator \
--set schemaregistry.enabled=true \
./confluent-operator || true
echo "After Schema Registry Installation: Check all pods..."
kubectl get pods -n operator
sleep 10
kubectl rollout status sts -n operator schemaregistry
echo "Install Confluent KSQL"
# helm delete --purge ksql
helm install \
-f ${MYDIR}/gcp.yaml \
--name ksql \
--namespace operator \
--set ksql.enabled=true \
./confluent-operator || true
echo "After KSQL Installation: Check all pods..."
kubectl get pods -n operator
sleep 10
kubectl rollout status sts -n operator ksql
echo "Install Confluent Control Center"
# helm delete --purge controlcenter
helm install \
-f ${MYDIR}/gcp.yaml \
--name controlcenter \
--namespace operator \
--set controlcenter.enabled=true \
./confluent-operator || true
echo "After Control Center Installation: Check all pods..."
kubectl get pods -n operator
sleep 10
kubectl rollout status sts -n operator controlcenter
# TODO Build breaks if we don't wait here until all components are ready. Is there a better solution for a check?
sleep 200
echo "Create LB for KSQL"
helm upgrade -f ${MYDIR}/gcp.yaml \
--set ksql.enabled=true \
--set ksql.loadBalancer.enabled=true \
--set ksql.loadBalancer.domain=mydevplatform.gcp.cloud ksql \
./confluent-operator
kubectl rollout status sts -n operator ksql
echo "Create LB for Kafka"
helm upgrade -f ${MYDIR}/gcp.yaml \
--set kafka.enabled=true \
--set kafka.loadBalancer.enabled=true \
--set kafka.loadBalancer.domain=mydevplatform.gcp.cloud kafka \
./confluent-operator
kubectl rollout status sts -n operator kafka
echo "Create LB for Schemaregistry"
helm upgrade -f ${MYDIR}/gcp.yaml \
--set schemaregistry.enabled=true \
--set schemaregistry.loadBalancer.enabled=true \
--set schemaregistry.loadBalancer.domain=mydevplatform.gcp.cloud schemaregistry \
./confluent-operator
kubectl rollout status sts -n operator schemaregistry
echo "Create LB for Control Center"
helm upgrade -f ${MYDIR}/gcp.yaml \
--set controlcenter.enabled=true \
--set controlcenter.loadBalancer.enabled=true \
--set controlcenter.loadBalancer.domain=mydevplatform.gcp.cloud controlcenter \
./confluent-operator
kubectl rollout status sts -n operator controlcenter
echo " Loadbalancers are created please wait a couple of minutes..."
sleep 60
kubectl get services -n operator | grep LoadBalancer
echo " After all external IP Adresses are seen, add your local /etc/hosts via "
echo "sudo /etc/hosts"
echo "EXTERNAL-IP ksql.mydevplatform.gcp.cloud ksql-bootstrap-lb ksql"
echo "EXTERNAL-IP schemaregistry.mydevplatform.gcp.cloud schemaregistry-bootstrap-lb schemaregistry"
echo "EXTERNAL-IP controlcenter.mydevplatform.gcp.cloud controlcenter controlcenter-bootstrap-lb"
echo "EXTERNAL-IP b0.mydevplatform.gcp.cloud kafka-0-lb kafka-0 b0"
echo "EXTERNAL-IP b1.mydevplatform.gcp.cloud kafka-1-lb kafka-1 b1"
echo "EXTERNAL-IP b2.mydevplatform.gcp.cloud kafka-2-lb kafka-2 b2"
echo "EXTERNAL-IP kafka.mydevplatform.gcp.cloud kafka-bootstrap-lb kafka"
kubectl get services -n operator | grep LoadBalancer
sleep 10
echo "After Load balancer Deployments: Check all Confluent Services..."
kubectl get services -n operator
kubectl get pods -n operator
echo "Confluent Platform into GKE cluster is finished."
echo "Create Topics on Confluent Platform for Test Generator"
# Create Kafka Property file in all pods
kubectl rollout status sts -n operator kafka
echo "deploy kafka.property file into all brokers"
kubectl -n operator exec -it kafka-0 -- bash -c "printf \"bootstrap.servers=kafka:9071\nsasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username=\"test\" password=\"test123\";\nsasl.mechanism=PLAIN\nsecurity.protocol=SASL_PLAINTEXT\" > /opt/kafka.properties"
kubectl -n operator exec -it kafka-1 -- bash -c "printf \"bootstrap.servers=kafka:9071\nsasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username=\"test\" password=\"test123\";\nsasl.mechanism=PLAIN\nsecurity.protocol=SASL_PLAINTEXT\" > /opt/kafka.properties"
kubectl -n operator exec -it kafka-2 -- bash -c "printf \"bootstrap.servers=kafka:9071\nsasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username=\"test\" password=\"test123\";\nsasl.mechanism=PLAIN\nsecurity.protocol=SASL_PLAINTEXT\" > /opt/kafka.properties"
# Create Topic sensor-data
echo "Create Topic sensor-data"
# Topic might exist already, make idempotent by ignoring errors here
kubectl -n operator exec -it kafka-0 -- bash -c "kafka-topics --bootstrap-server kafka:9071 --command-config kafka.properties --create --topic sensor-data --replication-factor 3 --partitions 10 --config retention.ms=100000" || true
echo "Create Topic model-predictions"
# Topic might exist already, make idempotent by ignoring errors here
kubectl -n operator exec -it kafka-0 -- bash -c "kafka-topics --bootstrap-server kafka:9071 --command-config kafka.properties --create --topic model-predictions --replication-factor 3 --partitions 10 --config retention.ms=100000" || true
# list Topics
kubectl -n operator exec -it kafka-0 -- bash -c "kafka-topics --bootstrap-server kafka:9071 --list --command-config kafka.properties"
kubectl -n operator exec -it ksql-0 -- bash -c "curl -X \"POST\" \"http://ksql:8088/ksql\" \
-H \"Content-Type: application/vnd.ksql.v1+json; charset=utf-8\" \
-d $'{
\"ksql\": \"TERMINATE QUERY CTAS_SENSOR_DATA_EVENTS_PER_5MIN_T_2;\",
\"streamsProperties\": {}
}'" || true
kubectl -n operator exec -it ksql-0 -- bash -c "curl -X \"POST\" \"http://ksql:8088/ksql\" \
-H \"Content-Type: application/vnd.ksql.v1+json; charset=utf-8\" \
-d $'{
\"ksql\": \"DROP TABLE IF EXISTS SENSOR_DATA_EVENTS_PER_5MIN_T;\",
\"streamsProperties\": {}
}'"
kubectl -n operator exec -it ksql-0 -- bash -c "curl -X \"POST\" \"http://ksql:8088/ksql\" \
-H \"Content-Type: application/vnd.ksql.v1+json; charset=utf-8\" \
-d $'{
\"ksql\": \"TERMINATE QUERY CSAS_SENSOR_DATA_S_AVRO_REKEY_1;\",
\"streamsProperties\": {}
}'" || true
kubectl -n operator exec -it ksql-0 -- bash -c "curl -X \"POST\" \"http://ksql:8088/ksql\" \
-H \"Content-Type: application/vnd.ksql.v1+json; charset=utf-8\" \
-d $'{
\"ksql\": \"DROP STREAM IF EXISTS SENSOR_DATA_S_AVRO_REKEY;\",
\"streamsProperties\": {}
}'"
kubectl -n operator exec -it ksql-0 -- bash -c "curl -X \"POST\" \"http://ksql:8088/ksql\" \
-H \"Content-Type: application/vnd.ksql.v1+json; charset=utf-8\" \
-d $'{
\"ksql\": \"TERMINATE QUERY CSAS_SENSOR_DATA_S_AVRO_0;\",
\"streamsProperties\": {}
}'" || true
kubectl -n operator exec -it ksql-0 -- bash -c "curl -X \"POST\" \"http://ksql:8088/ksql\" \
-H \"Content-Type: application/vnd.ksql.v1+json; charset=utf-8\" \
-d $'{
\"ksql\": \"DROP STREAM IF EXISTS SENSOR_DATA_S_AVRO;\",
\"streamsProperties\": {}
}'"
kubectl -n operator exec -it ksql-0 -- bash -c "curl -X \"POST\" \"http://ksql:8088/ksql\" \
-H \"Content-Type: application/vnd.ksql.v1+json; charset=utf-8\" \
-d $'{
\"ksql\": \"DROP STREAM IF EXISTS SENSOR_DATA_S;\",
\"streamsProperties\": {}
}'"
# Create STREAMS
# CURL CREATE
echo "CREATE STREAM SENSOR_DATA_S"
kubectl -n operator exec -it ksql-0 -- bash -c "curl -X \"POST\" \"http://ksql:8088/ksql\" \
-H \"Content-Type: application/vnd.ksql.v1+json; charset=utf-8\" \
-d $'{
\"ksql\": \"CREATE STREAM SENSOR_DATA_S (coolant_temp DOUBLE, intake_air_temp DOUBLE, intake_air_flow_speed DOUBLE, battery_percentage DOUBLE, battery_voltage DOUBLE, current_draw DOUBLE, speed DOUBLE, engine_vibration_amplitude DOUBLE, throttle_pos DOUBLE, tire_pressure11 INT, tire_pressure12 INT, tire_pressure21 INT, tire_pressure22 INT, accelerometer11_value DOUBLE, accelerometer12_value DOUBLE, accelerometer21_value DOUBLE, accelerometer22_value DOUBLE, control_unit_firmware INT, failure_occurred STRING) WITH (kafka_topic=\'sensor-data\', value_format=\'JSON\');\",
\"streamsProperties\": {}
}'"
echo "CREATE STREAM SENSOR_DATA_S_AVRO"
kubectl -n operator exec -it ksql-0 -- bash -c "curl -X \"POST\" \"http://ksql:8088/ksql\" \
-H \"Content-Type: application/vnd.ksql.v1+json; charset=utf-8\" \
-d $'{
\"ksql\": \"CREATE STREAM SENSOR_DATA_S_AVRO WITH (VALUE_FORMAT=\'AVRO\') AS SELECT * FROM SENSOR_DATA_S;\",
\"streamsProperties\": {}
}'"
echo "CREATE STREAM SENSOR_DATA_S_AVRO_REKEY"
kubectl -n operator exec -it ksql-0 -- bash -c "curl -X \"POST\" \"http://ksql:8088/ksql\" \
-H \"Content-Type: application/vnd.ksql.v1+json; charset=utf-8\" \
-d $'{
\"ksql\": \"CREATE STREAM SENSOR_DATA_S_AVRO_REKEY AS SELECT ROWKEY as CAR, * FROM SENSOR_DATA_S_AVRO PARTITION BY CAR;\",
\"streamsProperties\": {}
}'"
echo "CREATE TABLE SENSOR_DATA_EVENTS_PER_5MIN_T"
kubectl -n operator exec -it ksql-0 -- bash -c "curl -X \"POST\" \"http://ksql:8088/ksql\" \
-H \"Content-Type: application/vnd.ksql.v1+json; charset=utf-8\" \
-d $'{
\"ksql\": \"CREATE TABLE SENSOR_DATA_EVENTS_PER_5MIN_T AS SELECT car, count(*) as event_count FROM SENSOR_DATA_S_AVRO_REKEY WINDOW TUMBLING (SIZE 5 MINUTE) GROUP BY car;\",
\"streamsProperties\": {}
}'"
echo "####################################"
echo "## Confluent Deployment finshed ####"
echo "####################################"
| true
|
ae8dc597617e5f4f1ad51f15160539ebd367aea3
|
Shell
|
idosch/misc
|
/scripts/kernel/post-receive
|
UTF-8
| 3,940
| 3.46875
| 3
|
[] |
no_license
|
#!/bin/bash
source hooks/post-receive.config
read OLD_REV NEW_REV BRANCH
check_err()
{
local err="$1"
local msg="$2"
if [[ $err -eq 0 ]]; then
printf "STEP: %-65s [ OK ]\n" "$msg"
else
printf "STEP: %-65s [FAIL]\n" "$msg"
fi
}
log_step()
{
local name="$1"
printf "\n######################## "$name" ########################\n\n"
}
ssh_cmd()
{
local machine="$1"
local cmd="$2"
ssh -t -o LogLevel=QUIET "$machine" "$cmd"
}
init()
{
log_step "INIT"
export GIT_DIR="$(pwd)"
echo "Build start: $(date)"
echo "Git branch: "$BRANCH""
echo "Git HEAD: $(git log -1 --pretty="%h %s" --abbrev=12 "$BRANCH")"
}
deploy_code()
{
echo "Deploying code to: "$DEPLOY_DIR""
GIT_WORK_TREE="$DEPLOY_DIR" git checkout "$BRANCH" -f &> /dev/null
cd "$DEPLOY_DIR" && cp "$COMPILE_SCRIPT" compile.sh
}
static_checkers_run()
{
cd "$DEPLOY_DIR"
rm -f static.log
make C=2 CF="-D__CHECK_ENDIAN__" \
M=drivers/net/ethernet/mellanox/mlxsw/ 2>&1 | \
grep 'mlxsw' | egrep 'error|warn|info' | tee static.log
test $(cat static.log | wc -l) -eq 0
check_err $? "Sparse"
rm -f static.log
make CHECK="smatch -p=kernel" C=2 \
M=drivers/net/ethernet/mellanox/mlxsw/ 2>&1 | \
grep 'mlxsw' | egrep 'error|warn|info' | tee static.log
test $(cat static.log | wc -l) -eq 0
check_err $? "Smatch"
rm -f static.log
make includecheck | egrep '*mlxsw*' | tee static.log
test $(cat static.log | wc -l) -eq 0
check_err $? "Includecheck"
}
compile()
{
cd "$DEPLOY_DIR"
rm -f static.log
./compile.sh 2>&1 | egrep 'error|warn|info' | grep 'mlxsw' | \
tee static.log
check_err $? "Compilation"
}
build()
{
log_step "BUILD"
deploy_code
compile
static_checkers_run
}
dut_install()
{
ssh_cmd "$DUT" "cd "$DEPLOY_DIR_DUT" && \
sudo kexec -l arch/x86_64/boot/bzImage --reuse-cmdline && \
echo sudo kexec -e | at now +1 minutes &> /dev/null"
check_err $? "DUT installation"
}
dut_firmware_get()
{
local cmd
cmd="/usr/sbin/ethtool -i "$DUT_NETDEV" | grep firmware"
ssh_cmd "$DUT" "$cmd" | awk -F ':' '{ print $2 }'
}
dut_params_log()
{
local hostname=$(ssh_cmd "$DUT" "hostname")
local kernel=$(ssh_cmd "$DUT" "uname -r")
local firmware=$(dut_firmware_get)
echo "DUT hostname: "$hostname""
echo "DUT kernel: "$kernel""
echo "DUT firmware: "$firmware""
}
deploy()
{
log_step "DEPLOY"
dut_install
sleep "$DUT_WAIT"
dut_params_log
}
forwarding_test_run()
{
local test_name="$1"
local desc="$2"
local tests="$3"
if [[ "$tests" = "all" ]]; then
tests=""
fi
ssh_cmd "$DUT" "${chdir_cmd} && export TESTS="$tests" && \
sudo ./"$test_name".sh &> /dev/null"
check_err $? "Forwarding: $desc test"
}
test_run()
{
local chdir_cmd
log_step "TEST"
ssh_cmd "$DUT" "sudo /usr/sbin/sysctl -qw kernel.panic_on_oops=1"
ssh_cmd "$DUT" "sudo /usr/sbin/sysctl -qw kernel.panic_on_warn=1"
### Forwarding tests ###
cp "$FORWARDING_CONF" \
"$DEPLOY_DIR"/tools/testing/selftests/net/forwarding
chdir_cmd="cd "$DEPLOY_DIR_DUT" && \
cd tools/testing/selftests/net/forwarding"
forwarding_test_run "bridge_vlan_aware" "Bridge VLAN aware" "all"
forwarding_test_run "router" "Router" "all"
forwarding_test_run "router_multipath" "Multipath routing" \
"ping_ipv4 ping_ipv6"
forwarding_test_run "router_multicast" "Multicast routing" "all"
forwarding_test_run "tc_flower" "TC flower" \
"match_dst_mac_test match_src_mac_test match_dst_ip_test \
match_src_ip_test"
forwarding_test_run "ipip_hier_gre" "Hierarchical GRE" "all"
forwarding_test_run "vxlan_bridge_1q" "VXLAN VLAN-aware" "all"
chdir_cmd="cd "$DEPLOY_DIR_DUT" && \
cd tools/testing/selftests/drivers/net/mlxsw"
forwarding_test_run "rtnetlink" "Rtnetlink" "all"
ssh_cmd "$DUT" "sudo /usr/sbin/sysctl -qw kernel.panic_on_oops=0"
ssh_cmd "$DUT" "sudo /usr/sbin/sysctl -qw kernel.panic_on_warn=0"
}
fini()
{
log_step "FINI"
export GIT_DIR=""
echo -e "Build end: $(date)\n"
}
init
build
deploy
test_run
fini
| true
|
2af70e182d5dc4d54f5492f15f14832929ab746c
|
Shell
|
dbeley/scripts
|
/buku.sh
|
UTF-8
| 237
| 2.8125
| 3
|
[] |
no_license
|
#!/bin/bash
# This script allows searching in buku bookmarks
pgrep -x rofi && exit 1
pgrep -x buku && exit 1
link="$(buku -p -f 10 | sed '/^waiting/ d' | rofi -p "Favoris " -i -dmenu)"
[ -z "$link" ] && exit 1
xdg-open "$link"
exit 0
| true
|
c3beee9d34841007cb38d6b540ea9d6ab96593e6
|
Shell
|
harimurtie/ndotfiles
|
/scripts/gitpush
|
UTF-8
| 498
| 3.546875
| 4
|
[] |
no_license
|
#!/bin/bash
# A helper script to push content to GitHub
# Cheers! Addy
# Check if there is unfetched online files
echo -e "\e[34mChecking if there is an unfetched file from the repository\e[0m"
git pull
# Add every files in the project folder
git add --all .
# Add commit message
echo -e "\e[33mWrite your commit comment!\e[0m"
read -e COMMENT
# Add some details to commit message
git commit -m "$COMMENT"
# Push the local files to github
git push -u origin master
echo -e "\e[35mDone!\e[0m"
| true
|
e166b8a3734a6656f13fb77fed7671f628ad97a8
|
Shell
|
paultag/dockerfiles
|
/postgres/paultag-psqld
|
UTF-8
| 828
| 3.59375
| 4
|
[] |
no_license
|
#!/bin/bash
# Copyright (c) Paul R. Tagliamonte, MIT/Expat
set -e
VERSION="9.4" # XXX: Update this with the rest of the dockerfiles.
DATABASEDIR="/var/lib/postgresql/${VERSION}/main"
DB_OWNER=$(stat -c "%U" ${DATABASEDIR})
if [ "x${DB_OWNER}" != "xpostgres" ]; then
chown -R postgres:postgres ${DATABASEDIR}
fi
chmod 0700 ${DATABASEDIR}
if [ ! -e "${DATABASEDIR}/PG_VERSION" ]; then
PW_FILE=$(mktemp)
echo "postgres" > ${PW_FILE}
chmod 666 ${PW_FILE} # \m/
# We need to set up the DB before we kickoff.
su -l postgres -c \
"/usr/lib/postgresql/${VERSION}/bin/initdb --pwfile=${PW_FILE} -D ${DATABASEDIR}"
rm ${PW_FILE}
fi
exec sudo -u postgres \
/usr/lib/postgresql/${VERSION}/bin/postgres \
-D ${DATABASEDIR} \
-c config_file=/etc/postgresql/${VERSION}/main/postgresql.conf
| true
|
62488850d39df5250d5da9a6689303314b386577
|
Shell
|
Nax/Forsaken-Souls
|
/utils/mkspritesheet.sh
|
UTF-8
| 644
| 3.28125
| 3
|
[] |
no_license
|
#!/usr/bin/env zsh
# $1 -> Folder
# $2 -> Size
# $3 -> Outfile
rm -rf /tmp/mini;
mkdir /tmp/mini;
rm -rf /tmp/line;
mkdir /tmp/line;
num=0;
for file in $1/Anim*/*.png; do
convert $file -resize $2 /tmp/mini/img`printf '%08d' $num`.png;
num=`expr $num + 1`;
done;
sqrt=`ruby -e "p Math::sqrt($num).ceil"`;
used=0;
for i in `seq $sqrt`; do
arr="";
for j in `seq $used $(expr $used + $sqrt - 1)`; do
arr="$arr /tmp/mini/img`printf '%08d' $j`.png"
done;
used=`expr $used + $sqrt`;
convert ${=arr} +append -background none /tmp/line/line`printf '%08d' $i`.png &> /dev/null;
done;
convert /tmp/line/*.png -append -background none $3;
| true
|
4b201df58ca36b8df2a8eee737748e3a234f228d
|
Shell
|
felixonmars/sample-media-qmlvideo
|
/scripts/device-monitor.sh
|
UTF-8
| 743
| 3.40625
| 3
|
[
"Apache-2.0"
] |
permissive
|
#!/bin/sh
CMAKE_SOURCE_DIR=$1
MON_TYPE=$2
if [ -z $CMAKE_SOURCE_DIR ]; then
echo 'Source dir not specified!'
exit 1
fi
case ${MON_TYPE} in
"mem")
MON_COL=rss
MON_UNIT='KB'
;;
"cpu")
MON_COL=pcpu
MON_UNIT='%'
;;
*)
echo "Unrecognized monitor type ${MON_TYPE}"
exit 1
;;
esac
APP_META_DIR=$CMAKE_SOURCE_DIR/webos-metadata
PKG_NAME=$(jq -r .id ${APP_META_DIR}/appinfo.json)
EXE_NAME=$(jq -r .main ${APP_META_DIR}/appinfo.json)
DEVICE=hometv-nopass
ssh $DEVICE "while true; do ps -o $MON_COL,command -A | grep ${PKG_NAME} | grep -v gdb | grep -v grep; sleep 1; done" \
| awk '{print $1; fflush();}' \
| $CMAKE_SOURCE_DIR/tools/ttyplot-amd64-linux -t "${PKG_NAME} Memory Usage" -u $MON_UNIT
| true
|
8832c860ecc6b7cdaf072a634d842746291e2aff
|
Shell
|
neotys-keptn-orders/keptn-orders-setup
|
/provisionAks.sh
|
UTF-8
| 2,972
| 3.546875
| 4
|
[
"Apache-2.0"
] |
permissive
|
#!/bin/bash
AZURE_SUBSCRIPTION=$(cat creds.json | jq -r '.azureSubscription')
AZURE_RESOURCE_GROUP=$(cat creds.json | jq -r '.azureResourceGroup')
CLUSTER_NAME=$(cat creds.json | jq -r '.clusterName')
AZURE_LOCATION=$(cat creds.json | jq -r '.azureLocation')
AKS_VERSION=1.11.9
echo "===================================================="
echo "About to provision Azure Resources"
echo "Azure Subscription : $AZURE_SUBSCRIPTION"
echo "Azure Resource Group : $AZURE_RESOURCE_GROUP"
echo "Azure Location : $AZURE_LOCATION"
echo "Cluster Name : $CLUSTER_NAME"
echo "AKS Version : $AKS_VERSION"
echo ""
echo The provisioning will take several minutes
echo "===================================================="
read -rsp $'Press ctrl-c to abort. Press any key to continue...\n' -n1 key
echo "------------------------------------------------------"
echo "Creating Resource group: $AZURE_RESOURCE_GROUP"
echo "------------------------------------------------------"
az account set -s $AZURE_SUBSCRIPTION
az group create --name "$AZURE_RESOURCE_GROUP" --location $AZURE_LOCATION
echo "------------------------------------------------------"
echo "Creating Serice Principal: $AZURE_SERVICE_PRINCIPAL"
echo "------------------------------------------------------"
AZURE_WORKSPACE="$CLUSTER_NAME-workspace"
AZURE_DEPLOYMENTNAME="$CLUSTER_NAME-deployment"
AZURE_SERVICE_PRINCIPAL="http://$CLUSTER_NAME-sp"
AZURE_SUBSCRIPTION_ID=2673104e-2246-4e67-a844-b3255a665ebb
az ad sp create-for-rbac -n "$AZURE_SERVICE_PRINCIPAL" \
--role contributor \
--scopes /subscriptions/"$AZURE_SUBSCRIPTION_ID"/resourceGroups/"$AZURE_RESOURCE_GROUP" > azure_service_principal.json
AZURE_SERVICE_PRINCIPAL_APPID=$(jq -r .appId azure_service_principal.json)
AZURE_SERVICE_PRINCIPAL_PASSWORD=orders-demo=$(jq -r .password azure_service_principal.json)
echo "Generated Serice Principal App ID: $AZURE_SERVICE_PRINCIPAL_APPID"
echo "Generated Serice Principal Password: $AZURE_SERVICE_PRINCIPAL_PASSWORD"
echo "Letting service principal persist properly (30 sec) ..."
sleep 30
echo "------------------------------------------------------"
echo "Creating AKS Cluster: $CLUSTER_NAME"
echo "------------------------------------------------------"
az aks create \
--resource-group $AZURE_RESOURCE_GROUP \
--name $CLUSTER_NAME \
--node-count 1 \
--generate-ssh-keys \
--kubernetes-version $AKS_VERSION \
--service-principal $AZURE_SERVICE_PRINCIPAL_APPID \
--client-secret $AZURE_SERVICE_PRINCIPAL_PASSWORD \
--location $AZURE_LOCATION
echo "------------------------------------------------------"
echo "Getting Cluster Credentials"
echo "------------------------------------------------------"
az aks get-credentials --resource-group $AZURE_RESOURCE_GROUP --name $CLUSTER_NAME
echo ""
echo "------------------------------------------------------"
echo "Azure cluster deployment complete."
echo "------------------------------------------------------"
echo ""
| true
|
968ddfd585bf9676e4eea574e86c51a2e6b73f9a
|
Shell
|
Elitebigboss90/Redwood
|
/util/notification-broadcast
|
UTF-8
| 714
| 3.15625
| 3
|
[] |
no_license
|
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
# url="https://hook.bearychat.com/=bw9wd/incoming/db3496029696c0fa8774b14fdb957f0e"
echo $1
curl "$1" \
-H 'Content-Type: application/json' \
-d '
{
"text": "'"$2"'",
"attachments": [
{
"title": "link",
"url": "'"$3"'",
"color": "#ffa500"
}
]
}'
| true
|
f2993dcc349c0bb648a7ca6b078eca1d100b9543
|
Shell
|
touch123/csgear
|
/loganly/filespider/pick
|
UTF-8
| 1,443
| 3.75
| 4
|
[] |
no_license
|
#!/bin/sh
alias AWK=awk
DB_ORG_NAME=$WORK_DIR/db.json
function pick(){
app=$1
date=$2
echo "{ " >> $WORK_DIR/db.json
for logfile in $WORK_DIR/$app/output/$date-*.txt
do
echo "\"$logfile\" : {" >> $WORK_DIR/db.json
AWK -f pick.$app.awk $logfile >> $WORK_DIR/db.json
echo "}," >> $WORK_DIR/db.json
echo -n "."
done
echo '"":{}' >> $WORK_DIR/db.json
echo "}" >> $WORK_DIR/db.json
}
date=$1
datestr=`echo $date | tr "," " " `
if [ "$datestr" == "$date" ]; then
begin_date=`echo $date | cut -d \: -f1`
end_date=`echo $date | cut -d \: -f2`
[[ ${#begin_date} -eq 4 ]] && begin_date="2019"$begin_date
[[ ${#end_date} -eq 4 ]] && end_date="2019"$end_date
[[ ${#begin_date} -ne 8 || ${#end_date} -ne 8 ]] && exit 1
[[ ! $begin_date || ! $end_date ]] && exit 1
date -d $begin_date +%Y%m%d || exit 1
date -d $end_date +%Y%m%d || exit 1
curdate=$begin_date
datestr=$curdate
while [ $curdate != $end_date ]
do
curdate=`date -d "+1 day $curdate" +%Y%m%d`
datestr="$datestr $curdate"
done
else
firstdate=`echo $datestr | cut -d " " -f1`
if [ ${#firstdate} -eq 4 ] ; then
datestrbk=$datestr
datestr=""
for tdate in $datestrbk
do
datestr=$datestr" "`date +%Y`$tdate
done
fi
echo $datestr
fi
rm -f $WORK_DIR/db.json
for item in $SUBDIR
do
for tdate in $datestr
do
pick $item $tdate
echo -n "."
done
done
echo 'pick end.'
exit 0
| true
|
481b24f3631a0c7e17587a1b2ddeb4e7945e09ba
|
Shell
|
jnehlt/sdg
|
/packer/pscr/net.sh
|
UTF-8
| 3,079
| 2.796875
| 3
|
[] |
no_license
|
#!/usr/bin/env bash
yum remove firewalld -y
yum install iptables iptables-services -y
rm -f /etc/sysconfig/iptables
cat << 'EOF' >> ./iptables
*filter
# Clear all iptables rules (everything is open)
-X
-F
-Z
# Allow loopback interface (lo0) and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A OUTPUT -o lo -j ACCEPT
-A INPUT -d 127.0.0.0/8 -j REJECT
-A OUTPUT -d 127.0.0.0/8 -j REJECT
# Keep all established connections
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
# Allow ping
-A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT
-A INPUT -p icmp --icmp-type echo-reply -j ACCEPT
-A INPUT -p icmp --icmp-type echo-request -j ACCEPT
-A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT
# Protect from ping of death
-N PING_OF_DEATH
-A PING_OF_DEATH -p icmp --icmp-type echo-request -m hashlimit --hashlimit 1/s --hashlimit-burst 10 --hashlimit-htable-expire 300000 --hashlimit-mode srcip --hashlimit-name t_PING_OF_DEATH -j RETURN
-A PING_OF_DEATH -j DROP
-A INPUT -p icmp --icmp-type echo-request -j PING_OF_DEATH
# Prevent port scanning
-N PORTSCAN
-A PORTSCAN -p tcp --tcp-flags ACK,FIN FIN -j DROP
-A PORTSCAN -p tcp --tcp-flags ACK,PSH PSH -j DROP
-A PORTSCAN -p tcp --tcp-flags ACK,URG URG -j DROP
-A PORTSCAN -p tcp --tcp-flags FIN,RST FIN,RST -j DROP
-A PORTSCAN -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
-A PORTSCAN -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
-A PORTSCAN -p tcp --tcp-flags ALL ALL -j DROP
-A PORTSCAN -p tcp --tcp-flags ALL NONE -j DROP
-A PORTSCAN -p tcp --tcp-flags ALL FIN,PSH,URG -j DROP
-A PORTSCAN -p tcp --tcp-flags ALL SYN,FIN,PSH,URG -j DROP
-A PORTSCAN -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
# Drop fragmented packages
-A INPUT -f -j DROP
# SYN packets check
-A INPUT -p tcp ! --syn -m state --state NEW -j DROP
# Open ports for outgoing UDP traffic
-A INPUT -p udp --sport 53 -j ACCEPT
-A OUTPUT -p udp --dport 53 -j ACCEPT
-A INPUT -p udp --sport 123 -j ACCEPT
-A OUTPUT -p udp --dport 123 -j ACCEPT
# Open TCP ports for incoming traffic
-A INPUT -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
-A INPUT -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT
-A INPUT -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp --sport 443 -m state --state ESTABLISHED -j ACCEPT
# Open TCP ports for outgoing traffic
-A INPUT -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
-A INPUT -p tcp --sport 443 -m state --state ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
# Drop all other traffic
-A INPUT -j DROP
-A FORWARD -j DROP
-A OUTPUT -j DROP
COMMIT
EOF
mv ./iptables /etc/sysconfig/iptables
restorecon -Rv /etc/sysconfig/iptables
systemctl enable iptables.service
exec /bin/bash -c "sleep 4; rm -f $(basename $0);"
| true
|
3fd760b1abc421728ecd2370d429a2adaa8fc174
|
Shell
|
ndouglas/dotfiles
|
/ansible/roles/ndouglas.deploy_dotfiles/files/bash/library/get_prompt_atsign.sh
|
UTF-8
| 168
| 3.171875
| 3
|
[
"Unlicense"
] |
permissive
|
#!/usr/bin/env bash
# The kind of at-sign we'd like to use in a prompt.
nd_get_prompt_atsign() {
echo "$(printf "\[$(tput sgr0)$(tput bold)\]@\[$(tput sgr0)\]")";
}
| true
|
3ba8222b9701070065419e25d278140535b7e21e
|
Shell
|
AlexBezuska/photo-tools
|
/extract-photos.sh
|
UTF-8
| 1,145
| 3.8125
| 4
|
[] |
no_license
|
#!/bin/sh
# This script uses gmv which is part of `coretils` (install via homebrew) on Mac OS, if you are on Linux you can change all instances of `gmv` to `mv`
photoDestination='/path/to/photos/'
videoDestination='/path/to/photos/'
if [ -z "$1" ]; then
echo "Please add a path to a folder containing images\n Example: \n sh extract-photos.sh /original/folder/ \n"
else
mkdir $photoDestination
find "${1}" -name '*.jpg' -exec gmv -v {} $photoDestination \;
find "${1}" -name '*.JPG' -exec gmv -v {} $photoDestination \;
find "${1}" -name '*.jpeg' -exec gmv -v {} $photoDestination \;
find "${1}" -name '*.png' -exec gmv -v {} $photoDestination \;
find "${1}" -name '*.PNG' -exec gmv -v {} $photoDestination \;
mkdir $videoDestination
find "${1}" -name '*.mov' -exec gmv -v {} $videoDestination \;
find "${1}" -name '*.MOV' -exec gmv -v {} $videoDestination \;
find "${1}" -name '*.mp4' -exec gmv -v {} $videoDestination \;
find "${1}" -name '*.m4v' -exec gmv -v {} $videoDestination \;
find "${1}" -name '*.avi' -exec gmv -v {} $videoDestination \;
find "${1}" -name '*.AVI' -exec gmv -v {} $videoDestination \;
fi
| true
|
145779b2cfe909b351ab331bcdd7af2664b1bd0a
|
Shell
|
funduck/pytest_fingate
|
/database/restore_test_db.sh
|
UTF-8
| 1,036
| 3.734375
| 4
|
[] |
no_license
|
#!/bin/bash
cd $(dirname $0)
file=$(basename $1)
if [ -e $file ]; then
echo Performing backup of current database to prev.test_db.tar in case you want to rollback
[ -e prev.test_db.tar ] && rm prev.test_db.tar
./backup_test_db.sh prev.test_db.tar
echo Restore from $file
docker exec -i --env PGPASSWORD=root pg_container psql -U root -d test_db -v search_path=public -c 'drop schema public cascade'
docker exec -i --env PGPASSWORD=root pg_container psql -U root -d test_db -v search_path=public -c 'create schema public'
if [ -e data/admin/storage/$file ]; then
sudo rm data/admin/storage/$file
fi
sudo cp $file data/admin/storage/$file
sudo chown 5050 data/admin/storage/$file
sudo chgrp 5050 data/admin/storage/$file
docker exec -i --env PGPASSWORD=root pgadmin4_container /usr/local/pgsql-13/pg_restore --clean --if-exists -U root --dbname test_db --host pg_container --port 5432 --verbose /var/lib/pgadmin/storage/$file
else
echo File $file not found
exit 1
fi
| true
|
c84c2f03ca5ef151b558fc26d02877bb646001b9
|
Shell
|
anitaNeutrino/anitaTreeMaker
|
/reProduceAllHeaders.sh
|
UTF-8
| 163
| 2.59375
| 3
|
[] |
no_license
|
#!/bin/bash
firstRun=$1;
lastRun=$2
for irun in `seq $firstRun $lastRun`; do
echo Reproducing headTree for run $irun
./runLDBHeadFileMaker.sh $irun
done
| true
|
4860ae1e42f634ff93f503019058afe52c0d7951
|
Shell
|
alisawyj/python
|
/Shell/zipjpg.sh
|
UTF-8
| 664
| 3.796875
| 4
|
[] |
no_license
|
#!/bin/bash
JPG=$(date -d +1day "+%Y%m%d")
curDate=$(date "+%Y%m%d")
SRC_DIR="/d/code_test"
function batch_convert() {
for FILENAME in `ls $1`
do
if [ -d "$1/$FILENAME" ]
then
cd "$1/$FILENAME"
batch_convert ./
else
if [ "${FILENAME##*.}" = "jpg" ];then
NAME=${FILENAME##*/}
NEW_FILE_NAME=${JPG}_${NAME}
echo $FILENAME"---->"$NEW_FILE_NAME
mv $FILENAME $NEW_FILE_NAME
fi
fi
done
}
cd $SRC_DIR
if [ $? -ne 0 ];then
echo "can not open target directory!"
exit 2
fi
batch_convert ./
zip -r ${curDate}.zip ./*.jpg
| true
|
5ede7a5fc98342f36139db230b66c4541cacbce6
|
Shell
|
Schetkiglobe7/GVirtuS
|
/gvirtus.cusparse/install.sh
|
UTF-8
| 386
| 2.734375
| 3
|
[
"Apache-2.0"
] |
permissive
|
#!/bin/bash
INSTALL_FOLDER=$1
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=${INSTALL_FOLDER} \
-G "Unix Makefiles" -j 4 \
. \
--graphviz=.graphviz/gvirtus.cusparse.dot
make
make install
dot -T pdf .graphviz/gvirtus.cusparse.dot -o gvirtus.cusparse.pdf
echo
/bin/echo -e "\e[1;30;102mGVIRTUS CUDA SPARSE MODULE INSTALLATION COMPLETE!\e[0m"
echo
echo
| true
|
1559b8e524be8450e7a99be8c0c9fe3e917fb0e6
|
Shell
|
guilherme/aliases
|
/scripts/build-release-debian.sh
|
UTF-8
| 412
| 3.140625
| 3
|
[] |
no_license
|
#!/bin/bash -u
VERSION_NUMBER=${1}
docker build -t alias-debian-pkg-builder -f packagers/debian/Dockerfile .
CONTAINER_ID=$(docker create -e VERSION_NUMBER="$VERSION_NUMBER" alias-debian-pkg-builder)
docker start -ai ${CONTAINER_ID}
docker cp ${CONTAINER_ID}:/tmp/aliases_${VERSION_NUMBER}.deb .
mkdir -p releases/$VERSION_NUMBER/debian && mv aliases_${VERSION_NUMBER}.deb releases/$VERSION_NUMBER/debian/
| true
|
8f627784354235c439b0b39adfff47f63d44605d
|
Shell
|
paradisepilot/test-pachyderm
|
/docker-edges/DELETEME/2020-04-29.01/build-image.sh
|
UTF-8
| 293
| 2.84375
| 3
|
[] |
no_license
|
#!/usr/bin/env bash
set -e
test -z "$1" && echo Need version number && exit 1
IMAGE="demo-pachyderm$1"
docker build . -t $IMAGE > stdout.docker.build 2> stderr.docker.build
# docker tag $IMAGE paradisepilot/test-pachyderm:$IMAGE
# docker push paradisepilot/test-pachyderm:$IMAGE
| true
|
5c8eb999977bd1112b930ca2a2527bfc6a22f472
|
Shell
|
FAruba611/COMP9041
|
/17s2/test05/missing_include.sh
|
UTF-8
| 853
| 3.421875
| 3
|
[] |
no_license
|
#!/bin/sh
src_file="$@"
#cat $@
for src_file in "$@"
do
while read line
do
if [ `echo $line | wc -L` -lt 8 ]
then
#this line's length is shorter than 8
:
elif [ `echo $line | wc -L` -ge 8 ]
then
if [ "`echo $line | cut -c1-8`" = "#include" ] # compulsory to add "" on the both side
then
#line length greater and equal to 8 which starts with #include
inc_file=`echo $line | cut -d\ -f2 | egrep -o '[A-Z.a-z]*'` #get rid of "" or <>
file_tag=`echo $line | cut -c10` # only select "" or <>
if [ -e $inc_file -a $file_tag = "\"" ]||[ $file_tag = "<" ]
then
#find the file
:
else
echo $inc_file included into $src_file does not exist
fi
else
#other line length greater and equal to 8 which not starts with #include
:
fi
else
exit 1
fi
done < "$src_file"
done
| true
|
6a0f4e74de6777c38eb12c55d64d97608fcff3d6
|
Shell
|
gdamaskinos/isim
|
/utils/deploy_cluster.sh
|
UTF-8
| 5,533
| 3.21875
| 3
|
[
"MIT"
] |
permissive
|
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "usage: RUN_TESTS=1 bash $0 <'STANDALONE' || 'YARN'> <temp_dir>"
exit 1
fi
temp_dir=$(readlink -f $2)
host=`hostname -I | awk '{print $1}'`
SCRIPT=`realpath -s $0`
SCRIPTPATH=`dirname $SCRIPT`
#### STANDALONE SPARK ####
if [ "$1" = STANDALONE ]; then
cp $SPARK_HOME/conf/spark-env.sh.template $SPARK_HOME/conf/spark-env.sh
echo "export JAVA_HOME=$JAVA_HOME" >> $SPARK_HOME/conf/spark-env.sh
echo "export SPARK_LOCAL_DIRS=$temp_dir" >> $SPARK_HOME/conf/spark-env.sh
echo "export SPARK_LOG_DIR=$temp_dir/logs" >> $SPARK_HOME/conf/spark-env.sh
echo "export SPARK_MASTER_HOST=$host" >> $SPARK_HOME/conf/spark-env.sh
echo "export SPARK_PUBLIC_DNS=$host" >> $SPARK_HOME/conf/spark-env.sh
cp $SPARK_HOME/conf/spark-defaults.conf.template $SPARK_HOME/conf/spark-defaults.conf
freeMem=$(free -m | awk '/Mem/ {print $4;}') #if memory below 32GB make pointers 4B
if [ $freeMem -lt 32768 ]; then
echo spark.executor.extraJavaOptions -XX:+UseCompressedOops >> $SPARK_HOME/conf/spark-defaults.conf
fi
#cp $SPARK_HOME/conf/log4j.properties.template $SPARK_HOME/conf/log4j.properties
echo 'log4j.rootCategory=WARN, console' > $SPARK_HOME/conf/log4j.properties
echo 'log4j.appender.console=org.apache.log4j.ConsoleAppender' >> $SPARK_HOME/conf/log4j.properties
echo 'log4j.appender.console.target=System.err' >> $SPARK_HOME/conf/log4j.properties
echo 'log4j.appender.console.layout=org.apache.log4j.PatternLayout' >> $SPARK_HOME/conf/log4j.properties
echo 'log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n' >> $SPARK_HOME/conf/log4j.properties
#uniq $OAR_NODEFILE | sed "/$HOSTNAME/d" > $SPARK_HOME/conf/slaves
#uniq $OAR_NODEFILE | head -n $2 > $SPARK_HOME/conf/slaves
echo "Getting configuration from $SPARK_HOME/conf/slaves. Must have set it before."
echo "Starting Spark cluster..."
start-all.sh
#start-history-server.sh
fi
#### SPARK on YARN with EXECO ####
if [ "$1" = YARN ]; then
#hadoop
hg5k --create $OAR_FILE_NODES --version 2
hg5k --bootstrap ~/opt/tarballs/hadoop-2.6.0.tar.gz
hg5k --initialize
#fix problem
#hg5k --changeconf yarn.resourcemanager.scheduler.address=$(hostname):8030
#hg5k --changeconf yarn.resourcemanager.resource-tracker.address=$(hostname):8031
hg5k --start
#spark
spark_g5k --create YARN --hid 1
spark_g5k --bootstrap ~/opt/tarballs/spark-1.6.0-bin-hadoop2.6.tgz
spark_g5k --initialize --start
#spark conf
echo spark.eventLog.enabled true >> /tmp/spark/conf/spark-defaults.conf
#echo spark.eventLog.dir file:/tmp/spark_events >> /tmp/spark/conf/spark-defaults.conf
echo spark.eventLog.dir hdfs:///spark_events >> /tmp/spark/conf/spark-defaults.conf
echo spark.history.fs.logDirectory hdfs:///spark_events >> /tmp/spark/conf/spark-defaults.conf
# kryoserializer causes bad gc in driver for broadcast variables
#echo spark.serializer org.apache.spark.serializer.KryoSerializer >> /tmp/spark/conf/spark-defaults.conf
#echo spark.kryoserializer.buffer.max 2047m >> /tmp/spark/conf/spark-defaults.conf
freeMem=$(free -m | awk '/Mem/ {print $4;}') #if memory below 32GB make pointers 4B
if [ $freeMem -lt 32768 ]; then
echo spark.executor.extraJavaOptions -XX:+UseCompressedOops >> /tmp/spark/conf/spark-defaults.conf
fi
echo 'log4j.rootCategory=WARN, console' >> /tmp/spark/conf/log4j.properties
echo 'log4j.appender.console=org.apache.log4j.ConsoleAppender' >> /tmp/spark/conf/log4j.properties
echo 'log4j.appender.console.target=System.err' >> /tmp/spark/conf/log4j.properties
echo 'log4j.appender.console.layout=org.apache.log4j.PatternLayout' >> /tmp/spark/conf/log4j.properties
echo 'log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n' >> /tmp/spark/conf/log4j.properties
# python verion
#echo 'PYSPARK_PYTHON=/home/gdamaskinos/Python-3.5.0/python' >> /tmp/spark/conf/spark-env.sh
#spark_history_server
#mkdir /tmp/spark_events
hg5k --execute 'fs -mkdir /spark_events'
/tmp/spark/sbin/start-history-server.sh
export SPARK_HOME=/tmp/spark
export PATH=$SPARK_HOME/bin:$PATH
export PATH=$SPARK_HOME/sbin:$PATH
#hive
##change the xml files
#cp $HIVE_HOME/conf/hive-site.template.xml $HIVE_HOME/conf/hive-site.xml
#sed -i 's/master/'$HOSTNAME'/g' $HIVE_HOME/conf/hive-site.xml
#
##copy to spark
#cp $HIVE_HOME/conf/hive-site.xml /tmp/spark/conf/
#
##start hive
#cd $DERBY_HOME/data/
#rm -r metastore_db
#
#nohup $DERBY_HOME/bin/startNetworkServer -h 0.0.0.0 &
#
#schematool -dbType derby -initSchema
#schematool -dbType derby -info
#
#rm $HIVE_HOME/hcatalog/sbin/../var/log/hcat.pid
#$HIVE_HOME/hcatalog/sbin/hcat_server.sh start
#$HIVE_HOME/hcatalog/sbin/webhcat_server.sh start
fi
echo "Starting CASSANDRA..."
cassandra -p $CASSANDRA_HOME/cassandra.pid > /dev/null
i=0
while ! cqlsh $host -e 'describe cluster' 2> /dev/null ; do
sleep 1;
i=$((i+1))
if [ $((i%10)) = 0 ]; then
echo "CASSANDRA takes too long to start...consider checking $CASSANDRA_HOME/logs/system.log for issues"
fi
done
if [ "$RUN_TESTS" = 1 ]; then
echo "Running Cassandra-Spark Tests ..."
spark-submit --master spark://$host:7077 \
--conf spark.driver.memory=6G --executor-memory 6G \
--packages anguenot:pyspark-cassandra:2.4.0 \
--conf spark.cassandra.connection.host=$host \
$SCRIPTPATH/cassandraSparkTest.py
if [ "$?" = 0 ]; then
echo -e "CASSANDRA-SPARK TEST: \e[32mSUCCESSFUL\e[39m"
else
echo -e "CASSANDRA-SPARK TEST: \e[31mFAILED\e[39m"
fi
fi
| true
|
f79e25da38c7ea986de9971c8db6f8ed9592051f
|
Shell
|
sashaman/mailcow-CloudFlare-DNS
|
/mailcow_cloudflare_dns.sh
|
UTF-8
| 8,999
| 3.0625
| 3
|
[
"MIT"
] |
permissive
|
#!/usr/local/bin/zsh
#
scriptVersion="v0.9"
# Manual Config (0 input)
#################### CLOUDFLARE ACCOUNT CONFIG #####################
auth_mail="enter-your-cloudflare-email" # CF Email
auth_key="enter-your-cloudflare-api-key" # CF API Key
zone_id="enter-your-cloudflare-zone-key" # CF DNS Zone Key
DOMAIN="your-domain.com" # domain.tld
DMARC_RECORD="v=DMARC1; p=reject; rua=mailto:postmaster@<your domain>" # TRY NOT TO CHANGE other than your domain, of course.
DKIM_SELECTOR="dkim._domainkey" # Replace <dkim>._domainkey if you change the selector
DKIM_RECORD="v=DKIM1;k=rsa;t=s;s=email;p=.....your dkim key...." # Replace with the DKIM generated.
MX="mx.yourdomain.com"
#################### /CLOUDFLARE ACCOUNT CONFIG #####################
#####################################################################
# !!! DO NOT EDIT BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING !!! #
#####################################################################
#
# Add CloudFlare DNS records for mail - not a chance in hell i was configuring anymore domains with this many records!
# .^,
# ||)\
# ||{,\
# ||{@}\
# || \{@\
# ||--\@}\
# /|| \{&\
# //||====\#\\
# // ||(GBR)\#}\
# //==||======\}}\
# // || \(}\
# //====||--------\{(\
# // GBR || \@@),
# //======||ññññññññññ\{*},
# //-------|| /\\ '' `/}`
# //________||,` \\ -=={/___
# <<<+,_______##_____\\___[£££]
# \-==-"TODO LIST"-==-/|dD]
# ~~~~~~~~~~~~~~~~~~~~~~~~~~\--0--0--0--0--0--/~P#,)~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~\_______________/~~L.D)~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# TODO: commandline args
# TODO logic to check if config file exists, check params are set and if not, check if they are hardcoded in, if not then as to set defaults.
# - write the changes to config file.
# TODO: function to update status of record creation.
# TODO: error handling for curl status codes if != 200 --> check public DNS w/ dig? --> failing that use zonal lookup via CF - maybe not populated yet.
# TODO: Add conditional logic if the fields above are not set to read input from stdin
# echo -e "Cloudflare Email: \n"
# read auth_mail
# echo -e "Cloudflare API Key: \n"
# read auth_key
# echo -e "Domain: \n"
# read DOMAIN
# echo -e "ZoneID: \n"
# read ZONEID
CLR="\e[0m"
redFG="\e[91m"
redBG="\e[101m"
greenFG="\e[92m"
blueFG="\e[34m"
greenBG="\e[102m"
greyBG="\e[100m"
BLD="\e[1m"
DIM="\e[2m"
BLI="\e[5m"
UL="\e[4m"
greenBGd="\e[100m\e[1m"
RECORDNAME="imap"
RECORDPORT=143
clear
echo -e "${greenBG} ${CLR}${greenBGd} ${CLR}"
echo -e "${greenBG} ${greyBG}${BLD} ${scriptVersion} - CloudFlare mailserver DNS record config ${CLR}${greenBG} ${CLR}${greenBGd} ${CLR}"
echo -e "${greenBG} ${CLR}${greenBGd} ${CLR}"
echo -e "${greenBG} ${greyBG}${BLD} (c) Dan Horner ${CLR}${greenBG} ${CLR}${greenBGd} ${CLR}"
echo -e "${greenBG} ${CLR}${greenBGd} ${CLR}"
echo -e "${greenBGd} ${CLR}\n\n\n"
_post_cf_srv () {
RES=$(curl -w '%{http_code}\n' -so /dev/null -X POST "https://api.cloudflare.com/client/v4/zones/${zone_id}/dns_records" \
-H "X-Auth-Email: "$auth_mail \
-H "X-Auth-Key: "$auth_key \
-H "Content-Type: application/json" \
--data "{\"type\": \"SRV\", \"name\": \"_${RECORDNAME}._tcp.${DOMAIN}.\", \"content\": \"SRV 0 1 ${RECORDPORT} ${MX}.\", \"ttl\": 1, \"data\": {\"priority\": 0, \"weight\": 1, \"port\": ${RECORDPORT}, \"target\": \"${TARGET}.\", \"service\": \"_${RECORDNAME}\", \"proto\": \"_tcp\", \"name\": \"${DOMAIN}.\"},\"proxied\": false}");
if [[ $RES -eq 200 ]]; then
OUT=$(printf "%7s %30s %20s %20s %7s\n" "[${greyBG} ${BLD}SRV ${CLR}]" "_${RECORDNAME}._tcp.${DOMAIN}." "IN SRV 0 1" "${RECORDPORT} ${MX}." "[${greenBG}${BLD} OK ${CLR}]"); echo $OUT >&2
else
OUT=$(printf "%7s %30s %20s %20s %7s\n" "[${greyBG} ${BLD}SRV ${CLR}]" "_${RECORDNAME}._tcp.${DOMAIN}." "IN SRV 0 1" "${RECORDPORT} ${MX}." "[${redBG}${BLD}${BLI}ERROR${CLR}]"); echo $OUT >&2
fi
}
_post_cf_cname () {
RES=$(curl -w '%{http_code}\n' -so /dev/null -X POST "https://api.cloudflare.com/client/v4/zones/$zone_id/dns_records" \
-H "X-Auth-Email: "$auth_mail \
-H "X-Auth-Key: "$auth_key \
-H "Content-Type: application/json" \
--data "{\"type\": \"CNAME\", \"name\": \"${RECORDNAME}\", \"content\": \"${TARGET}.\", \"ttl\": 120, \"priority\": 0, \"proxied\": true}");
if [[ $RES -eq 200 ]]; then
OUT=$(printf "%7s %30s %20s %20s %7s\n" "[${greyBG}${BLD}CNAME${CLR}]" "${RECORDNAME}" "IN CNAME" "${TARGET}." "[${greenBG}${BLD} OK ${CLR}]"); echo $OUT >&2
else
OUT=$(printf "%7s %30s %20s %20s %7s\n" "[${greyBG}${BLD}CNAME${CLR}]" "${RECORDNAME}" "IN CNAME" "${TARGET}." "[${redBG}${BLD}${BLI}ERROR${CLR}]"); echo $OUT >&2
fi
}
_post_cf_txt () {
RES=$(curl -w '%{http_code}\n' -so /dev/null -X POST "https://api.cloudflare.com/client/v4/zones/$zone_id/dns_records" \
-H "X-Auth-Email: "$auth_mail \
-H "X-Auth-Key: "$auth_key \
-H "Content-Type: application/json" \
--data "{\"type\": \"TXT\", \"name\": \"${RECORDNAME}\", \"content\": \"${TXT}\", \"ttl\": 120, \"priority\": 0}");
if [[ $RES -eq 200 ]]; then
OUT=$(printf "%7s %30s %20s %20s %7s\n" "[${greyBG} ${BLD}TXT ${CLR}]" "${RECORDNAME}" "IN TXT" "$(printf %-.20s ${TXT})" "[${greenBG}${BLD} OK ${CLR}]"); echo $OUT >&2
else
OUT=$(printf "%7s %30s %20s %20s %7s\n" "[${greyBG} ${BLD}TXT ${CLR}]" "${RECORDNAME}" "IN TXT" "$(printf %-.20s ${TXT})" "[${redBG}${BLD}${BLI}ERROR${CLR}]"); echo $OUT >&2
fi
}
_post_cf_mx () {
RES=$(curl -w '%{http_code}\n' -so /dev/null -X POST "https://api.cloudflare.com/client/v4/zones/$zone_id/dns_records" \
-H "X-Auth-Email: "$auth_mail \
-H "X-Auth-Key: "$auth_key \
-H "Content-Type: application/json" \
--data "{\"type\": \"MX\", \"name\": \"@\", \"content\": \"${MX}\", \"ttl\": 120, \"priority\": 10}");
if [[ $RES -eq 200 ]]; then
OUT=$(printf "%7s %30s %20s %20s %7s\n" "[${greyBG} ${BLD}MX ${CLR}]" "@" "IN MX 10" "${MX}" "[${greenBG}${BLD} OK ${CLR}]"); echo $OUT >&2
else
OUT=$(printf "%7s %30s %20s %20s %7s\n" "[${greyBG} ${BLD}MX ${CLR}]" "@" "IN MX 10" "${MX}" "[${redBG}${BLD}${BLI}ERROR${CLR}]"); echo $OUT >&2
fi
}
# imap
RECORDPORT=143
RECORDNAME="imap"
TARGET=${MX}
$(_post_cf_srv)
# imaps
RECORDPORT=993
RECORDNAME="imaps"
TARGET=${MX}
$(_post_cf_srv)
# pop3
RECORDPORT=110
RECORDNAME="pop3"
TARGET=${MX}
$(_post_cf_srv)
# pop3s
RECORDPORT=995
RECORDNAME="pop3s"
TARGET=${MX}
$(_post_cf_srv)
# submission
RECORDPORT=587
RECORDNAME="submission"
TARGET=${MX}
$(_post_cf_srv)
# smtps
RECORDPORT=465
RECORDNAME="smtps"
TARGET=${MX}
$(_post_cf_srv)
# sieve
RECORDPORT=4190
RECORDNAME="sieve"
TARGET=${MX}
$(_post_cf_srv)
# autodiscover
RECORDPORT=443
RECORDNAME="autodiscover"
TARGET=${MX}
$(_post_cf_srv)
# MX: to mailhost TODO: add other SRV record
RECORDNAME="mail.${DOMAIN}"
TARGET=${MX}
$(_post_cf_mx)
# TODO: autoconfig
RECORDNAME="autodiscover.${DOMAIN}"
TARGET=${MX}
$(_post_cf_cname)
RECORDNAME="autoconfig.${DOMAIN}"
TARGET=${MX}
$(_post_cf_cname)
# carddavs
RECORDPORT=443
RECORDNAME="carddavs"
TARGET=${MX}
$(_post_cf_srv)
# --DONE-- add txt record for carddavs
RECORDNAME="_carddavs._tcp"
TXT="path=/SOGo/dav/"
$(_post_cf_txt)
# SRV: caldavs
RECORDPORT=443
RECORDNAME="caldavs"
TARGET=${MX}
$(_post_cf_srv)
# TXT: caldavs
RECORDNAME="_caldavs._tcp"
TXT="path=/SOGo/dav/"
$(_post_cf_txt)
# SPF:
RECORDNAME="@"
TXT="v=spf1 mx ~all"
$(_post_cf_txt)
# TODO: add _dmarc txt record
# echo -e "[ ? ] What is the _dmarc RECORD?\n"
# read TXT
RECORDNAME="_dmarc"
TXT=${DMARC_RECORD}
$(_post_cf_txt)
# TODO: add dkim TXT record
# echo -e "[ ? ] What is the _dkim SELECTOR?\n"
# read RECORDNAME
# echo -e "[ ? ] What is the _dkim RECORD?\n"
# read TXT
RECORDNAME=${DKIM_SELECTOR}
TXT=${DKIM_RECORD}
$(_post_cf_txt)
# TODO: add CNAME to mail --> mxhost
echo -e "\n\n\n"
echo -e "[${greenBG} *** ${CLR}]${greyBG} ${CLR}[${greenBG}${BLD} GOOGLE POSTMASTER ${CLR}]${greyBG} Setup TXT record on ${DOMAIN} @ ${UL}${blueFG}https://postmaster.google.com/ ${CLR}"
echo -e "\n\n\n"
| true
|
c728f6a941fa574dfee6540f4224b94d50e7bf66
|
Shell
|
dthoma141/Scripting
|
/securityscript.sh
|
UTF-8
| 2,612
| 3.796875
| 4
|
[] |
no_license
|
#!/bin/bash
#!/bin/bash
#tThis is a sscript to
`
1) Based on a user input parameter display the status of security - firewalld and selinux on a Linux system
2) Based on a user input parameter temporally enable or disable security - firewalld and selinux
3) Based on a user input parameter permanently enable or disable firewalld and selinux - This means the altered status will survive a system reboot
4) Manually rerun the script to check the status of the services to validate changes made to the configuration
5) The script should output to the user the progress of changing the status to services
6) On your submission, provide
a) the script you built (standard .sh file is ok)
b) word doc of screenshots notifying the user of the status and progress of changes to security services
`
while test $# -gt 0; do
case "$1" in
-h|--help)
echo '-se'
echo 'For SElinux Options'
echo '-fd'
echo 'For Firewall do Options'
exit
;;
-se)
shift
if test $# -gt 0; then
sestatus
echo 'would you like to enable or diable selinux?'
echo '0 to disable'
echo '1 to enable'
read userChoice
case $serChoice
0)
shift
setenforce 0
sestatus
;;
1)
shift
setenforce 1
sestatus
;;
*)
echo 'your imput makes me sad :('
else
echo 'you did not give me an option'
break
else
echo 'use -h for help'
exit 1
fi
exit
shift
;;
-fd)
shift
if test $# -gt 0; then
esac
done
| true
|
6c9bf193b36ec1403982d45121f3b71ba1bdc240
|
Shell
|
PPinto22/PROMOS
|
/scripts/neat_sampling.sh
|
UTF-8
| 456
| 2.703125
| 3
|
[] |
no_license
|
#!/bin/bash
evolver="python ../src/py/evolver.py"
options="-d ./data/2weeks/best_idf_train.csv -t ../data/2weeks/best_idf_test.csv -P ../params/neat.txt -o ../results/sampling -m neat -T20 -p8"
runs=10
for i in $(seq 1 $runs)
do
( ${evolver} ${options} -s 100 --id="100(${i})" ) &
( ${evolver} ${options} -s 1000 --id="1K(${i})" ) &
( ${evolver} ${options} -s 10000 --id="10K(${i})" ) &
( ${evolver} ${options} --id="ALL(${i})" ) &
wait;
done
exit 0
| true
|
78367e7e9ce8b6b33e9ba1ee37043a3c7087efe8
|
Shell
|
col1985/ionic-template
|
/preinstall.sh
|
UTF-8
| 490
| 3.90625
| 4
|
[] |
no_license
|
#!/bin/bash
NODE_VERSION="v6.9.5"
function versionCheck {
printf "\n"
printf "Checking NodeJS version is compatiblie with project configuration..."
node --version | grep ${NODE_VERSION}
if [ "$?" != "0" ]; then
printf "\n"
printf "Unable to " >&2
printf "\n"
printf "\n"
exit 1
else
printf "\n"
printf "Correct NodeJS version: ${NODE_VERSION} found, continuing install process..." >&2
printf "\n"
printf "\n"
exit 0
fi
}
versionCheck
| true
|
93c9cf7f1d34870f05d69811c947d1debdb6b0b5
|
Shell
|
FFrabetti/Cooperative-container-migration
|
/experiments/utils/get_filler_file.sh
|
UTF-8
| 883
| 4.03125
| 4
|
[] |
no_license
|
#!/bin/bash
SIZE=$1 # in KB (or xxxMB)
INDEX=$2 # 1..95 -> +31 -> 32..126 DEC (see: man ascii)
INDEX=$(((INDEX - 1) % 95 + 1))
DEC=$((INDEX + 31))
# awk 'BEGIN { printf("%c", '$DEC') }'
filename="filler$INDEX"
# create filler files if not present
if [ ! -f $filename ]; then
# awk 'BEGIN { for(i=0; i<1024; i++) printf("%c", '$DEC') }' > $filename
awk 'BEGIN { srand('$DEC'); for(i=0; i<1024; i++) printf("%c", int(rand()*1000) % 95 + 32) }' > $filename
fi
if [[ $SIZE =~ ([0-9]+)M ]]; then
SIZE=${BASH_REMATCH[1]}
mfile="${filename}M"
if [ ! -f $mfile ]; then
for i in {1..1024}; do
cat $filename >> $mfile
done
fi
filename=$mfile
fi
echo "filler file $filename $SIZE times" >&2
count=0
# now SIZE and filename are independent of KB or MB
for j in $(seq 1 $SIZE); do
cat $filename
count=$((count+1))
done
echo "count = $count (it should be $SIZE)" >&2
| true
|
582da58dc574e39f2b12251d3c48a6dc6e76c1dc
|
Shell
|
tanawit-dev/spring-message-with-rabbitmq
|
/build.sh
|
UTF-8
| 315
| 2.9375
| 3
|
[] |
no_license
|
if [ -z "$1" ]
then
projects="customer-service email-service"
for project in $projects
do
mvn -f $project/pom.xml clean package -DskipTests
docker build -t tanawit17/$project $project/
done
else
mvn -f $1/pom.xml clean package -DskipTests
docker build -t tanawit17/$1 $1/
fi
| true
|
54b9ec664faca17b68f1a94adf60cbbb384f172f
|
Shell
|
williamthorsen/mount-project-aws-cicd
|
/src/aws/ec2/helpers/ssh-via-jump-host.sh
|
UTF-8
| 833
| 3.859375
| 4
|
[] |
no_license
|
#!/usr/bin/env bash
# This script is meant for connecting to a host with a private IP address (the private host)
# via a host with a public IP address (the jump host).
#
# Typical use case:
# - the private host is in a private subnet of a VPC
# - the jump host is in a public subnet of the same VPC
# - the connection is made from outside the private subnet
#
# The identity (.pem) file is assumed to be the same for the private host and the jump host.
# Usage:
# ssh-via-jump-host.sh PRIVATE_HOST JUMP_HOST IDENTITY_FILE
# Check parameters
if [[ $# -lt 3 ]]
then
echo 'Usage: ssh-via-jump-host.sh PRIVATE_HOST JUMP_HOST IDENTITY_FILE'
exit 1
fi
PRIVATE_HOST=$1
JUMP_HOST=$2
IDENTITY_FILE=$3
ssh -i ${IDENTITY_FILE} \
-o "proxycommand ssh -W %h:%p -i ${IDENTITY_FILE} ec2-user@${JUMP_HOST}" \
ec2-user@${PRIVATE_HOST}
| true
|
a6f0883cf0524ecfd219d7c5542d09290d8da61d
|
Shell
|
philip-park/idv
|
/scripts/config-vgpu.sh
|
UTF-8
| 3,088
| 3.6875
| 4
|
[] |
no_license
|
#!/bin/bash
#===========================================
# select_mdev node
# locate and list the node for user to select.
# The default will be display in Green color
# i915-GVTg_V5_1 (1920x1200)
# i915-GVTg_V5_2 (1920x1200)
# i915-GVTg_V5_4 (1920x1200) <-- default
# i915-GVTg_V5_8 (1024x768)
#
# Require:
# scripts/custom-function for selectWithDefault
#===========================================
#idv_config_file=./test
function update_idv_config_deleteme() {
variable=$1
string=$2
(grep -qF "$variable=" $idv_config_file) \
&& sed -i "s/^$variable=.*$/$variable=${string//\//\\/}/" $idv_config_file \
|| echo "$variable=$string" >> $idv_config_file
}
function select_mdev_type_deleteme() {
mdev_type=( /sys/bus/pci/devices/0000:00:02.0/mdev_supported_types/i915-GVTg_V5_* )
# This actually the total number of available node and set to default node
current_option=${#mdev_type[@]}
# set to default option
[[ "$current_option" > 2 ]] && current_option=2
for (( i=0; i<${#mdev_type[@]}; i++ )); do
resolution="`grep resolution ${mdev_type[$i]}/description`"
[[ $current_option -eq "$i" ]] \
&& list+=(${mdev_type[$i]##*/} "(${resolution##* })" on "${mdev_type[$i]}") \
|| list+=(${mdev_type[$i]##*/} "(${resolution##* })" off "${mdev_type[$i]}")
done
mdev_type_option=$(dialog --item-help --backtitle "Select patches file" \
--radiolist "<patches file name>.tar.gz \n\
Select the mdev type from the following list found in ~/mdev_supported_types." 20 80 10 \
"${list[@]}" \
3>&1 1>&2 2>&3 )
update_idv_config "mdev_type" "$mdev_type_option"
}
default_guid=( f50aab10-7cc8-11e9-a94b-6b9d8245bfc1 f50aab10-7cc8-11e9-a94b-6b9d8245bfc2 f50aab10-7cc8-11e9-a94b-6b9d8245bfc3 f50aab10-7cc8-11e9-a94b-6b9d8245bfc4 )
function set_display_port_mask() {
card0=( /sys/devices/pci0000\:00/0000\:00\:02.0/drm/card0/gvt_disp_ports_status )
available_ports=$(grep "Available display ports" $card0)
ports="${available_ports#*: }"
# detected=0
port_mask=""
j=1
for (( i=0; i<${#default_guid[@]}; i++)); do
nibble=$((ports&0xf)); ports=$((ports>>4))
# guid=$( grep "^VGPU$i=" $idv_config_file )
# [[ ! -z ${guid##*=} ]] && continue && echo "same guil"
if [[ $nibble -ne "0" ]]; then
string="`grep -A $j "Available" $card0`" # ( PORT_B(2) )
temp=$(sed 's/.*( \(.*\) )/\1/' <<< "${string##*$'\n'}")
gfx_port+=( "${temp%(*}" )
port_num=$(sed 's/.*(\(.*\))/\1/' <<< "${temp}")
port_mask="0$((1<<(port_num-1)))"$port_mask
# if UUID already *not" exists then update
guid=$( grep "^VGPU$i=" $idv_config_file )
# [[ -z ${guid##*=} ]] && update_idv_config "VGPU$i" "$(uuid)"
[[ -z ${guid##*=} ]] && update_idv_config "VGPU$i" "${default_guid[$i]}"
# update_idv_config "VGPU$i" "$(uuid)"
# detected=1
j=$((j+1))
fi
done
echo "gfx_port: ${gfx_port[@]}"
update_idv_config "GFX_PORT" "\"${gfx_port[@]}\""
update_idv_config "port_mask" "0x$port_mask"
}
set_display_port_mask
#select_mdev_type
| true
|
42dbab3cb6c9bf1899b6bbb86394027acc60c8c9
|
Shell
|
DevoKun/dockerfiles
|
/asgard-centos/files/asgard-standalone.sh
|
UTF-8
| 303
| 2.53125
| 3
|
[] |
no_license
|
#!/bin/bash
MAXPERMSIZE="128m"
MAXPERMSIZE="512m"
export HTTP_PORT="8080"
export HTTP_HOST="localhost"
export ASGARD_HOME="/opt/asgard"
cd $ASGARD_HOME
java \
-Xmx1024M \
-XX:MaxPermSize=${MAXPERMSIZE} \
-DskipCacheFill=true \
-jar asgard-standalone.jar \
"" $HTTP_HOST $HTTP_PORT
echo $?
| true
|
3f155c3c186f308529795a06d3cd3d903e77d123
|
Shell
|
FusionPlmH/Fusion-Project
|
/vtools-scene/app/src/main/assets/custom/switchs/cloudmusic_ad_get.sh
|
UTF-8
| 645
| 3.1875
| 3
|
[] |
no_license
|
#!/system/bin/sh
if [[ ! -n "$SDCARD_PATH" ]]; then
if [[ -e /storage/emulated/0/Android ]]; then
SDCARD_PATH="/storage/emulated/0"
elif [[ -e /sdcard/Android ]]; then
SDCARD_PATH="/sdcard/"
elif [[ -e /data/media/0/Android ]]; then
SDCARD_PATH="/data/media/0"
fi
fi
path=$SDCARD_PATH/netease/cloudmusic/Ad
if [[ ! -e $path ]]; then
echo 1;
return
fi
if [[ -d $path ]]; then
echo 1;
return
fi
if [[ ! -n "$BUSYBOX" ]]; then
BUSYBOX=""
fi
attr=`$BUSYBOX lsattr $path | $BUSYBOX cut -f1 -d " "`
attr=`echo $attr | grep "i"`
if [[ -n "$attr" ]]; then
echo 0
else
echo 1
fi
| true
|
d722779552de547dff36a309c02a01efe6d4efb0
|
Shell
|
clelange/zshutils
|
/autoKerb/renew_kerb.sh
|
UTF-8
| 1,843
| 3.875
| 4
|
[] |
no_license
|
#!/bin/bash
######
## USER OPTIONS PLEASE ADAPT TO YOUR NEEDS
KERB_USER="clange";
REALM="CERN.CH";
server="cerndc.cern.ch";
### END OF USERS OPTIONS
######
title="Kerberos_Status";
chck_port="/System/Library/CoreServices/Applications/Network Utility.app/Contents/Resources/stroke";
# assume growlnotifier is installed (e.g. for Lion)
grwl="growlnotify -a com.apple.Ticket-Viewer --message";
# on MountainLion use the local teminal notifier (in this dir)
osver=`uname -r | cut -d'.' -f 1`
if [[ $osver -ge "12" ]]; then
grwl="/Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier -activate com.apple.Ticket-Viewer -title $title -message";
fi
test "$SHELLOPTS" && shopt -s xpg_echo
function renewKerbTicket {
/usr/bin/logger -t $0 : "Checking Kerberos".
/usr/bin/kinit --renew $KERB_USER@$REALM &> /dev/null || /usr/bin/kinit $KERB_USER@$REALM;
ticket=`/usr/bin/klist`
/usr/bin/logger -t $0 : "$Kerberos $ticket". \
&& $grwl "$KERB_USER@$REALM ticket acquired"
# activate the next line to also get an AFS token (if you have OpenAFS installed)
# /usr/bin/aklog && $grwl "$KERB_USER@$REALM AFS ticket acquired"
}
function checkNetworkPort() {
PINGS=0
delay=0
while [[ $PINGS -lt 1 ]]; do
"$chck_port" $server 88 88 | grep Open &>/dev/null
count=$?
if [[ $count -ne 0 ]]; then
/usr/bin/logger -t $0 : "KDC $REALM not reachable...Waiting".
((delay++))
sleep $((10*delay))
if [[ $delay -eq 25 ]]; then
/usr/bin/logger -t $0 : "KDC $REALM not reachable AFTER 5 MINUTES...Giving up".
$grwl "$server unreachable: Giving UP"$'\n'"KDC $REALM not reachable"
exit;
fi
else
/usr/bin/logger -t $0 : "KDC $REALM is reachable...Continuing".
PINGS=1
fi
done
}
## If port 88 (afp) is open and reachable, renew kerberos ticket
checkNetworkPort && renewKerbTicket
exit 0
| true
|
9a027e15e8bc00dd107804f79a10f870eb0588ea
|
Shell
|
abhilash07/kong-boshrelease
|
/jobs/kong/templates/ctl.erb
|
UTF-8
| 1,011
| 3.34375
| 3
|
[
"Apache-2.0"
] |
permissive
|
#!/bin/bash -e
JOB_NAME=kong
BASE_DIR=/var/vcap
SYS_DIR=$BASE_DIR/sys
RUN_DIR=$SYS_DIR/run/$JOB_NAME
LOG_DIR=$SYS_DIR/log/$JOB_NAME
JOB_DIR=$BASE_DIR/jobs/$JOB_NAME
CONFIG_DIR=$JOB_DIR/etc/kong
CONFIG_FILE=$CONFIG_DIR/kong.conf
PIDFILE=$RUN_DIR/$JOB_NAME.pid
mkdir -p $RUN_DIR $LOG_DIR $CONFIG_DIR
case $1 in
start)
for package_bin_dir in $(ls -d /var/vcap/packages/*/*bin)
do
export PATH=${package_bin_dir}:$PATH
done
# eval $(luarocks path --bin)
touch /tmp/luapath.sh && chmod 777 /tmp/luapath.sh
luarocks path --bin > /tmp/luapath.sh
source /tmp/luapath.sh
export PATH=/var/vcap/packages/openresty/bin:$PATH
export PATH=/var/vcap/packages/openresty/nginx/sbin:$PATH
export PATH=/var/vcap/packages/kong/lib/openssl/bin:$PATH
export LD_LIBRARY_PATH=/var/vcap/packages/kong/lib/openssl/lib
kong migrations up
kong start --conf ${CONFIG_FILE}
;;
stop)
kill $(cat $PIDFILE)
;;
*)
echo "Usage: ctl {start|stop}"
;;
esac
| true
|
8df07c0b341732b9d613357151a748b566febb07
|
Shell
|
mayunlong89/bed_statistics
|
/parse_split_utr_hierarchy.sh
|
UTF-8
| 3,284
| 3.671875
| 4
|
[] |
no_license
|
#!/bin/bash
## parse_split_utr_hierarchy.sh
## alex amlie-wolf 07-16-2015
## a script that takes in the entrywise output from entrywise_bed_coverage.py and reports the number
## and proportion of entries in each type of genomic element, assuming that the coverage script
## was run using the split UTR (exons and introns) analysis
## this script assumes a hierarchy:
## 5' UTR exon > 5' UTR intron > 3' UTR exon > 3' UTR intron > promoter > exon > intron > repeat
if [ $# == 1 ]; then
INFILE=$1
## count the exclusive elements in each class
## 5' UTR exons:
NUM_FP_EXON=`tail -n +2 $INFILE | awk '{if ($4>0) print $0}' | wc -l`
## 5' UTR introns:
NUM_FP_INTRON=`tail -n +2 $INFILE | awk '{if ($4==0 && $6>0) print $0}' | wc -l`
## 3' UTR exons:
NUM_TP_EXON=`tail -n +2 $INFILE | awk '{if ($4==0 && $6==0 && $8>0) print $0}' | wc -l`
## 3' UTR introns:
NUM_TP_INTRON=`tail -n +2 $INFILE | awk '{if ($4==0 && $6==0 && $8==0 && $10>0) print $0}' | wc -l`
## promoter:
NUM_PROMOTER=`tail -n +2 $INFILE | awk '{if ($4==0 && $6==0 && $8==0 && $10==0 && $12>0) print $0}' | wc -l`
## exon:
NUM_EXON=`tail -n +2 $INFILE | awk '{if ($4==0 && $6==0 && $8==0 && $10==0 && $12==0 && $14>0) print $0}' | wc -l`
## intron:
NUM_INTRON=`tail -n +2 $INFILE | awk '{if ($4==0 && $6==0 && $8==0 && $10==0 && $12==0 && $14==0 && $16>0) print $0}' | wc -l`
## repeat:
NUM_REPEAT=`tail -n +2 $INFILE | awk '{if ($4==0 && $6==0 && $8==0 && $10==0 && $12==0 && $14==0 && $16==00 && $18>0) print $0}' | wc -l`
## intergenic
NUM_INTER=`tail -n +2 $INFILE | awk '{if ($4==0 && $6==0 && $8==0 && $10==0 && $12==0 && $14==0 && $16==00 && $18==00) print $0}' | wc -l`
## get the total
TOTAL_NUM=`tail -n +2 $INFILE | wc -l`
FP_EXON_PROP=`echo ${NUM_FP_EXON}/${TOTAL_NUM} | bc -l`
FP_INTRON_PROP=`echo ${NUM_FP_INTRON}/${TOTAL_NUM} | bc -l`
TP_EXON_PROP=`echo ${NUM_TP_EXON}/${TOTAL_NUM} | bc -l`
TP_INTRON_PROP=`echo ${NUM_TP_INTRON}/${TOTAL_NUM} | bc -l`
PROM_PROP=`echo ${NUM_PROMOTER}/${TOTAL_NUM} | bc -l`
EXON_PROP=`echo ${NUM_EXON}/${TOTAL_NUM} | bc -l`
INTRON_PROP=`echo ${NUM_INTRON}/${TOTAL_NUM} | bc -l`
REPEAT_PROP=`echo ${NUM_REPEAT}/${TOTAL_NUM} | bc -l`
INTER_PROP=`echo ${NUM_INTER}/${TOTAL_NUM} | bc -l`
TOTAL_PROP=`echo "(${NUM_FP_EXON}+${NUM_FP_INTRON}+${NUM_TP_EXON}+${NUM_TP_INTRON}+${NUM_PROMOTER}+${NUM_EXON}+${NUM_INTRON}+${NUM_REPEAT}+${NUM_INTER})/${TOTAL_NUM}" | bc -l`
printf "Summary of file %s:\n" "$INFILE"
printf "Type\tNumber\tProportion\n"
printf "5' UTR exons\t%d\t%.5f\n" "$NUM_FP_EXON" "$FP_EXON_PROP"
printf "5' UTR introns\t%d\t%.5f\n" "$NUM_FP_INTRON" "$FP_INTRON_PROP"
printf "3' UTR exons\t%d\t%.5f\n" "$NUM_TP_EXON" "$TP_EXON_PROP"
printf "3' UTR introns\t%d\t%.5f\n" "$NUM_TP_INTRON" "$TP_INTRON_PROP"
printf "Promoters\t%d\t%.5f\n" "$NUM_PROMOTER" "$PROM_PROP"
printf "Exons\t%d\t%.5f\n" "$NUM_EXON" "$EXON_PROP"
printf "Introns\t%d\t%.5f\n" "$NUM_INTRON" "$INTRON_PROP"
printf "Repeats\t%d\t%.5f\n" "$NUM_REPEAT" "$REPEAT_PROP"
printf "Intergenic\t%d\t%.5f\n" "$NUM_INTER" "$INTER_PROP"
printf "Total\t%d\t%.5f\n" "$TOTAL_NUM" "$TOTAL_PROP"
else
echo "Usage: $0 INPUT_FILE"
fi
| true
|
a81763f55fd8d25bb8e6b370fdf4e9d41a7df448
|
Shell
|
matthapenney/AmyloidPet-Pipeline
|
/3_native_to_pet.sh
|
UTF-8
| 4,590
| 3.328125
| 3
|
[] |
no_license
|
#!/bin/bash
#$ -S /bin/bash
#$ -o /ifshome/mhapenney/logs -j y
#$ -q compute.q
#------------------------------------------------------------------
# CONFIG - petproc.config
CONFIG=${1}
source utils.sh
utils_setup_config ${CONFIG}
#------------------------------------------------------------------
for subj in ${SUBJECT[@]}; do
for rr in ${reference[@]};do
utils_setup_config ${CONFIG}
#------------------------------------------------------------------
# Check if directory exists and make if it does not.
if [ ! -d ${PET_OUT} ]
then
mkdir -p ${PET_OUT}
fi
#------------------------------------------------------------------
# STEP 3 - PET Preprocessing and Initial Skullstrip
#------------------------------------------------------------------
# cp ${PET}/${subj}_PET_BL.nii.gz ${PET_NOTE}
# INSERT INITIAL STEP INTO TEXT FILE
echo -e "STAGE 3: --> ${subj} SKULLSTRIP MASK (SEE ${NOTE} FOR MORE INFORMATION ON PROCESSING STEPS) \r\n" >> ${NOTE}
# REORIENT TO STANDARD - PET
echo "STAGE 3: STEP 1 --> ${subj} reorient PET"
cmd="${FSLREOR2STD} ${PET}/${subj}/${subj}_PET_BL.nii.gz ${PET_OUT}/${subj}_PET_reorient.nii.gz"
eval $cmd
touch ${NOTE}
echo "STAGE 3: STEP 1 --> ${subj} reorient PET ## DONE ##"
echo -e "STAGE 3: STEP 1 --> ${subj} reorient PET \r\n" >> ${NOTE}
echo -e "COMMAND -> ${cmd}\r\n" >> ${NOTE}
# ROBUST FOV - PET
echo "STAGE 3: STEP 2 --> ${subj} APPLY ROBUST FOV to PET"
cmd="${FSLROBUST} -i ${PET_OUT}/${subj}_PET_reorient.nii.gz -r ${PET_OUT}/${subj}_PET_reorientrobust.nii.gz"
eval $cmd
touch ${NOTE}
echo "STAGE 3: STEP 2 --> ${subj} APPLY ROBUST FOV to PET ## DONE ##"
echo -e "STAGE 3: STEP 2 --> ${subj} APPLY ROBUST FOV to PET \r\n" >> ${NOTE}
echo -e "COMMAND -> ${cmd}\r\n" >> ${NOTE}
# PET PRELIMINARY SKULLSTRIP
echo "STAGE 3: STEP 3 --> ${subj} PET PRELIMINARY SKULLSTRIP"
cmd="${FSLBET} ${PET_OUT}/${subj}_PET_reorientrobust.nii.gz ${PET_OUT}/${subj}_PET_prelim_bet.nii.gz -R -f 0.63 -g 0.1"
eval $cmd
touch ${NOTE}
echo "STAGE 3: STEP 3 --> ${subj} PET PRELIMINARY SKULLSTRIP ## DONE ##"
echo -e "STAGE 3: STEP 3 --> ${subj} PET PRELIMINARY SKULLSTRIP \r\n" >> ${NOTE}
echo -e "COMMAND -> ${cmd}\r\n" >> ${NOTE}
#------------------------------------------------------------------
# PET Registration to MRI T1 Space
#------------------------------------------------------------------
# Calculate linear transformation matrix
cmd="${FSLFLIRT} \
-dof 6 \
-cost mutualinfo \
-in ${PET_OUT}/${subj}_PET_prelim_bet.nii.gz \
-ref ${MPRAGE}/${subj}_N4_brain.nii.gz \
-out ${PET_OUT}/${subj}_PET_to_native.nii.gz \
-omat ${PET_OUT}/${subj}_PETtomri.xfm"
cmd2="${FSLFLIRT} \
-dof 6 \
-cost mutualinfo \
-in ${PET_OUT}/${subj}_PET_prelim_bet.nii.gz \
-ref ${MPRAGE}/${subj}_orientROBUST_brain.nii.gz \
-out ${PET_OUT}/${subj}_PET_to_native.nii.gz \
-omat ${PET_OUT}/${subj}_PETtomri.xfm"
if [[ -f "$N4" ]]; then
eval ${cmd}
touch ${NOTE}
echo -e "STAGE 3: STEP 4 --> ${subj} LINEAR TRANSFORM PET TO MRI SPACE ## DONE ##"
echo -e "STAGE 3: STEP 4 --> ${subj} LINEAR TRANSFORM PET TO MRI SPACE \r\n" >> ${NOTE}
echo -e "COMMAND -> ${cmd}\r\n" >> ${NOTE}
else
eval ${cmd2}
touch ${NOTE}
echo -e "STAGE 3: STEP 4 --> ${subj} LINEAR TRANSFORM PET TO MRI SPACE ## DONE ##"
echo -e "STAGE 3: STEP 4 --> ${subj} LINEAR TRANSFORM PET TO MRI SPACE \r\n" >> ${NOTE}
echo -e "COMMAND -> ${cmd2}\r\n" >> ${NOTE}
fi
# Calculate inverse inverse transformation matrix
cmd="${FSLXFM} \
-omat ${PET_OUT}/${subj}_mritoPET.xfm
-inverse ${PET_OUT}/${subj}_PETtomri.xfm"
eval ${cmd}
touch ${NOTE}
echo -e "STAGE 3: STEP 5 --> ${subj} LINEAR TRANSFORM MRI TO PET SPACE ## DONE ##"
echo -e "STAGE 3: STEP 5 --> ${subj} LINEAR TRANSFORM MRI TO PET SPACE \r\n" >> ${NOTE}
echo -e "COMMAND -> ${cmd}\r\n" >> ${NOTE}
#------------------------------------------------------------------
# Register Reference Region (MRI Space) to PET Space
#------------------------------------------------------------------
echo "Registering ${subj} bl-cerebellum-WM from MRI space to PET space"
cmd="${FSLFLIRT} \
-in ${PET_OUT}/${subj}_aparc+aseg_native_ref_${rr}_bin.nii.gz \
-ref ${PET_OUT}/${subj}_PET_prelim_bet.nii.gz
-applyxfm -init ${PET_OUT}/${subj}_mritoPET.xfm
-out ${PET_OUT}/${subj}_aparc+aseg_PET_ref_${rr}_bin.nii.gz \
-interp nearestneighbour \
-datatype float"
eval ${cmd}
echo "Registering ${subj} bl-cerebellum-WM from MRI space to PET space ## DONE ##"
# Insert command with input and output
chmod -R 775 ${PET_OUT}
cd ${project_conf}
done
done
| true
|
54a49e232e517021c60f943700ab4f9f98d71155
|
Shell
|
rbax82/Bash-Admin-Scripts
|
/.zshrc
|
UTF-8
| 22,478
| 3.15625
| 3
|
[
"BSD-3-Clause",
"BSD-2-Clause"
] |
permissive
|
##################################
# Author : Jon Zobrist <jon@jonzobrist.com>
# Homepage : http://www.jonzobrist.com
# License : BSD http://en.wikipedia.org/wiki/BSD_license
# Copyright (c) 2019, Jon Zobrist
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
##################################
# .zshrc is sourced in interactive shells.
# It should contain commands to set up aliases,
# functions, options, key bindings, etc.
#
# To get this working to the max do these steps after installing ZSH
#
# Put this file (.zshrc) in your home dir
# $ curl -o ${HOME}/.zshrc https://raw.githubusercontent.com/jonzobrist/Bash-Admin-Scripts/master/.zshrc
# Setup zpresto from https://github.com/sorin-ionescu/prezto
# $ git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
# $ setopt EXTENDED_GLOB
# $ for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
# $ ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
# $ done
#
# Now change your default shell to zsh
# $ chsh -s `which zsh`
# Now logout and back in
##################################
# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi
UNAME=$(uname)
# HISTORY settings
setopt EXTENDED_HISTORY # store time in history
setopt HIST_EXPIRE_DUPS_FIRST # unique events are more usefull to me
setopt HIST_VERIFY # Make those history commands nice
setopt INC_APPEND_HISTORY # immediatly insert history into history file
HISTSIZE=160000 # spots for duplicates/uniques
SAVEHIST=150000 # unique events guaranteed
HISTFILE=~/.history
autoload -U compinit
compinit
bindkey "^[[3~" delete-char
bindkey "^[OH" beginning-of-line
bindkey "^[OF" end-of-line
bindkey "^H" backward-delete-word
#allow tab completion in the middle of a word
setopt COMPLETE_IN_WORD
#Fix zsh being stupid and not printing lines without newlines
setopt nopromptcr
## keep background processes at full speed
setopt NOBGNICE
## restart running processes on exit
#setopt HUP
## never ever beep ever
setopt NO_BEEP
## disable mail checking
MAILCHECK=0
autoload -U colors
# I really hate when BSD vs. *Nix (Linux)
# Crap like this comes up, c'mon guys
# let's all MD5 the *right* way
if [ "${UNAME}" = "Darwin" ]
then
alias md5sum='md5 -r '
fi
jitter() {
unset J1
J1=${RANDOM}
unset J2
J2=${RANDOM}
unset M1
M1=$(echo "${J1} * ${J2}" | bc)
JIT=$(echo "${M1} % 10 * .1" | bc)
echo "${JIT}"
}
retry() {
i=1
mi=60
while true
do
if [ "${DEBUG}" ]; then echo "trying $@ at `date` [attempt: ${i}]"; fi
$@
let "sleep_time = ${i} * ${i}"
echo "sleeping ${sleep_time}"
sleep ${sleep_time}
sleep $(jitter)
if [ ${i} -gt ${mi} ]; then i=1; fi
((i++))
done
}
# System aliases
alias sshrm="ssh-keygen -R "
alias lsort="sort | uniq -c | sort -n"
alias auxyul="retry ssh ${yul}"
alias ll='ls -FAlh'
alias l='ls -FAlh'
alias lg='ls -FAlh | grep -i '
alias lh='ls -FAlht | head -n 20 '
alias grep="grep --color=auto"
alias gvg=" grep -v 'grep' "
alias ducks='du -chs * | sort -rn | head'
alias duckx='du -chsx * | sort -rn | head'
pskill() {
ps -efl | grep $1 | grep -v grep | awk '{print $4}' | paste -sd " "
}
# Net aliases
alias p6='ping -c 6 -W 100 '
alias ra="dig +short -x "
alias ns="dig +short "
alias ds="dig +short "
alias wa="whois -h whois.arin.net "
alias tcurl='curl -w "%{remote_ip} time_namelookup: %{time_namelookup} tcp: %{time_connect} ssl:%{time_appconnect} start_transfer:%{time_starttransfer} total:%{time_total}\n" -sk -o /dev/null'
alias tcurlc='curl -w "%{remote_ip} time_namelookup: %{time_namelookup} tcp: %{time_connect} ssl:%{time_appconnect} start_transfer:%{time_starttransfer} total:%{time_total}\n" -sk -o /dev/null --cookie ${cookie} '
alias tcurlo='curl -w "%{remote_ip} time_namelookup: %{time_namelookup} tcp: %{time_connect} ssl:%{time_appconnect} start_transfer:%{time_starttransfer} total:%{time_total}\n" -sk '
alias tcurloc='curl -w "%{remote_ip} time_namelookup: %{time_namelookup} tcp: %{time_connect} ssl:%{time_appconnect} start_transfer:%{time_starttransfer} total:%{time_total}\n" -sk --cookie ${cookie} '
alias curlc='curl -skL --cookie ${cookie} '
alias watip="curl -s -X GET "https://www.dangfast.com/ip" -H "accept: application/json" | jq -r '.origin'"
alias watproxyip="curl -s -X GET "http://www.dangfast.com/ip" -H "accept: application/json" | jq -r '.origin'"
# Retry ssh as EC2 user! Get it!?
rse() {
retry ssh ec2-user@${1}
}
# Retry ssh as Ubuntu user! Get it!?
# Also RSU = stocks = money
# This function is money
rsu() {
retry ssh ubuntu@${1}
}
# Git aliases
alias gl='git lol'
alias gbl='git branch --list'
# Dev aliases
alias ipy="ipython -i ~/helpers.py"
nosetests () {
./runpy -m nose.core "$@" --verbose --nocapture
}
# Math aliases and functions
function is_int() { return $(test "$@" -eq "$@" > /dev/null 2>&1); }
autoload -U promptinit
promptinit
declare -x PATH="${HOME}/bin:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin:/usr/local/sbin:${HOME}/.local/bin"
possible_path_dirs=("/usr/local/app1/bin" "${HOME}/app2/bin")
for path_dir in ${possible_path_dirs[@]}
do
if [ -d ${path_dir} ]; then
declare -x PATH=$PATH:${path_dir}
fi
done
# Workflow aliases & functions
alias quicklinks="cat ${HOME}/notes/quicklinks"
alias notes="cd ${HOME}/notes"
alias src="cd ${HOME}/src"
alias elbdate="date -u +%FT%H:%M:%SZ "
function get_dropped_hosts_dmesg() {
for S in $(dmesg | grep DROPPED | awk '{ print $8, "\n", $9 }' | sed -e 's/ //g' | sed -e 's/DST=//' | sed -e 's/SRC=//' | sort | uniq); do echo $(dig +short -x ${S} | sed -e 's/\.$//'); done | sort | uniq
}
function get_dropped_hosts_kernlog() {
for S in $(grep DROPPED /var/log/kern.log* | awk '{ print $13, "\n", $14 }' | sed -e 's/ //g' | sed -e 's/DST=//' | sed -e 's/SRC=//' | sort | uniq); do echo $(dig +short -x ${S} | sed -e 's/\.$//'); done | sort | uniq
}
# I keep my local ssh agent info in this file, and if it's there we should source it
if [ -f "${HOME}/.ssh/myagent" ]
then
source ${HOME}/.ssh/myagent
fi
# Keep the HTTP address for my S3 bucket handy
declare -x ZS3="http://mybucket.s3-website-us-east-1.amazonaws.com"
# Common Iterables
UPPER="A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
lower="a b c d e f g h i j k l m n o p q r s t u v w x y z"
nums="0 1 2 3 4 5 6 7 8 9"
nums_and_such="0 1 2 3 4 5 6 7 8 9 - _"
hex_upper="0 1 2 3 4 5 6 7 8 9 A B C D E F"
HEX="0 1 2 3 4 5 6 7 8 9 A B C D E F"
hex="0 1 2 3 4 5 6 7 8 9 a b c d e f"
hour_list="00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23"
###################################################################
# TICKET WORKING ALIASES & FUNCTIONS
###################################################################
# We all work ticket like things, right?
# I like to keep information about specific tickets
# in the same place
# This brings consistency and I can later find information easily
# when looking for related info
# I also often backup this data to encrpyted S3 buckets
# these functions enable this type of workflow
function nott() {
# TT = working ticket identifier, matches dir name
# TD = working directory for that ticket, dir name matches ticket id/name
unset TT
unset TD
}
function tt() {
# Function to jump into a working directory for $1 (${TT}) if it exists
# If it doesn't exist, create it, and an env.sh file
if [ "${TT}" ]
then
declare -x TD="${HOME}/work/${TT}"
else
declare -x TD="${HOME}/work/${1}"
declare -x TT=${1}
fi
if [ ! -d "{TD}" ]
then
mkdir -p ${TD}
fi
ENV_FILE="${TD}/env.sh"
if [ ! -f ${ENV_FILE} ]
then
echo "declare -x TT=\"${TT}\"" > ${ENV_FILE}
fi
if [ ! -x ${ENV_FILE} ]
then
chmod uog+x ${ENV_FILE}
fi
DEBUG "Changing dir to ~/${TD}. TT=${TT}"
cd ${TD}
. ${ENV_FILE}
}
# I frequently use the pattern of setting F to the current file
# (like a pointer)
# I'm working on, so these aliases let me do common things with
# the current file
#
# less the file, display it in my pager less
function lf() {
if [ "${F} ]; then less ${F} 2>/dev/null
elif [ "${1} ]; then less ${F} 2>/dev/null
else echo "Usage lsf filename, or export F=filename"
fi
}
# wireshark the file
# often times I'm doing tshark -nn -r ${F}
# so this makes it easy to jump into wireshark
function wf() {
if [ "${F} ]; then wireshark ${F} 2>/dev/null &
elif [ "${1} ]; then wireshark ${F} 2>/dev/null &
else echo "Usage wf filename.pcap, or export F=filename.pcap"
fi
}
function rtt() {
# Function to 'return-to-ticket'
# looks at only your env variable ${TT}
# if it's set, it cd's to it
if [ "${TT}" ] && [ -d ${TD} ]
then
cd "${TD}"
else
echo "No active work item"
fi
}
###################################################################
# EC2 / AWS helper functions & aliases
###################################################################
#
function get_am2_ami() {
# Searches for the latest Amazon Linux 2 x86 64-bit ami
if [ "${1}" ] && [ ! "${R}" ]
then
R=${1}
fi
if [ "${R}" ]
then
aws ec2 describe-images --owners amazon --region ${R} --filters 'Name=name,Values=amzn2-ami-hvm-2.0.????????-x86_64-gp2' 'Name=state,Values=available' --output json | jq -r '.Images | sort_by(.CreationDate) | last(.[]).ImageId'
else
echo "Usage: ${0} region; or export R=region; ${0}"
fi
}
function get_ubuntu_ami() {
# Searches for the latest Amazon Linux 2 x86 64-bit ami
if [ "${1}" ] && [ ! "${R}" ]
then
R=${1}
fi
if [ "${UBU}" ]
then
case ${UBU} in
12)
UBUNTU="precise-12.04"
;;
14)
UBUNTU="trusty-14.04"
;;
16)
UBUNTU="xenial-16.04"
;;
18)
UBUNTU="bionic-18.04"
;;
19)
UBUNTU="disco-19.04"
;;
esac
else
UBUNTU="bionic-18.04"
fi
if [ "${R}" ]
then
aws ec2 describe-images --owners 099720109477 --region ${R} --filters "Name=name,Values=ubuntu/images/hvm-ssd/ubuntu-${UBUNTU}-amd64-server-????????" 'Name=state,Values=available' --output json | jq -r '.Images | sort_by(.CreationDate) | last(.[]).ImageId'
else
echo "Usage: ${0} region; or export R=region; ${0}"
fi
}
S3_BACKUP_BUCKET="my-s3-bucket" # Obviously you should change this
function ttup() {
# Given a work ticket (TT) you're working on, uploading to S3 bucket ${S3_BACKUP_BUCKET}
# This uses aws s3 sync, which should de-dupe uploads
# but will clobber objects
# Useful if you want to work on a ticket in multiple places
# or share data from a ticket with others
# Dont' forget to enable encryption on the bucket!
if [ ! "${TD}" ]
then
TD="${PWD##*/}"
fi
DEBUG "Backing up tt dir ${TT} at $(date)" | tee -a ~/tt-backup-$(date +%F).log
sleep 1.5
aws s3 sync ${TD} s3://${S3_BACKUP_BUCKET}/${TT}
}
function ttdown() {
# Given a TT, download it to ${TD}
if [ ! "${TT}" ]
then
TT="${PWD##*/}"
fi
DEBUG "Download tt dir ${TT} at $(date)" | tee -a ~/tt-download-$(date +%F).log
sleep 1.5
aws s3 sync s3://${S3_BACKUP_BUCKET}/${TT} ${TD}
}
function gt() {
# gt = Get Ticket
# Get a ticket directory from a host
if [ ! "${1}" ] || [ ! -d "${TD}" ] || [ ! "${TT}" ]
then
echo "Get TT, Usage ${0} host"
echo "Must have TD and TT envs set, and TD must be an existing directory"
else
TT="${PWD##*/}"
S=${2}
rsync -avz ${S}:${TD} ${TD}
fi
}
function pt() {
if [ ! "${1}" ] || [ ! -d "${TD}" ] || [ ! "${TT}" ]
then
echo "Push TT, Usage ${0} region"
echo "Must have TD and TT envs set, and TD must be an existing directory"
else
rsync -avz ${TD} ${S}:${TD}
fi
}
# I keep a list of regions in a local file
# This enables me to iterate easily over all AWS regions without calling the describe-regions API
update_ec2_regions() {
MY_TMP_FILE=$(mktemp)
aws ec2 describe-regions |grep 'RegionName' | awk -F'"' '{ print $4 }' | tee ${MY_TMP_FILE}
OC=$(cat ~/regions-ec2 | wc -l | sed -e 's/ //g')
NC=$(cat ${MY_TMP_FILE} | wc -l | sed -e 's/ //g')
if (( ${NC} >= ${OC}))
then
/bin/mv ${MY_TMP_FILE} ~/regions-ec2
else
echo "new file (${MY_TMP_FILE}) is not larger, did we lose regions?"
fi
}
# I often find myself on remote systems with files
# that I want locally
# instead of figuring out the hostname or exiting and pasting
# things to make an scp command
# just use this (if you use real hostnames)
# example: you want to get http80.pcap
# ph http80.pcap
# This will print out "scp username@my-server-name:http80.pcap ./
# Which I can copy and paste easily
# I tried having it push the file, but prefer this way
# as often I can connect to a remote system, but it cannot connect to me
# ala NAT
ph() {
FILE=$1
if [ -f $(pwd)/${FILE} ]
then
echo "scp ${USER}@$(hostname):$(pwd)/${FILE} ./"
elif [ -d ${FILE} ]
then
echo "scp -r ${USER}@$(hostname):${FILE} ./${FILE}"
else
echo "scp -r ${USER}@$(hostname):$(pwd) ./"
fi
}
# I often copy paths that I want to expore
# And a lot of the time the paths have a file at the end
# Some applications & computers handle this better than others
# But it's enough of a PITA that I use cdd <PASTE>
# Which looks to see if the thing I pasted is a file
# and cd's to its dirname if it is
#
function cdd() {
if [ ! -f "{1}" ]
then
D=$(dirname ${1})
else
D="${1}"
fi
cd ${F}
}
# What is with Apple lately?
# I feel like OS X is now as reliable as Windows 98 at its peak
# This puts me into a VIM temp file that I can rant into
# and then :x and easily save these tirades
# it has never come to anything
# and I honestly thing Apple doesn't care anymore
# RIP Steve Jobs
function newcrash() {
CRASH_DIR="${HOME}/mac-crashes-$(date +%Y)"
if [ ! -d "{CRASH_DIR}" ]
then
mkdir -p ${CRASH_DIR}
fi
CRASH_FILE="mac-crash-ya-$(date +%F-%s).txt"
vi ${CRASH_FILE}
}
# I like to leave old code around
# in case the new version turns on me while I'm sleeping
# function try_get {
# FILE=$1
# URL=$2
# TRIES=$3
# I=0
# if [ -z ${TRIES} ] || [ ${TRIES} -eq 0 ]; then TRIES=3; fi
# while [ ! -f ${FILE} ]
# do
# curl -s -o ${FILE} ${URL}
# let "SLEEP_TIME = ${I} * ${I}"
# sleep ${SLEEP_TIME}
# ((I++))
# done
# }
# Ever want to download something and NOT slip up and overwrite it
# while wildly CTRL+R'ing through your shell history?
# Also maybe you're cool and want to respect servers
# and try to get things with exponential backoff?
function try_get {
URL=$1
FILE=$2
TRIES=$3
START=$(date +%s)
I=0
if [ -z ${2} ]; then FILE_PREFIX=${URL##*/}; FILE=${FILE_PREFIX%%\?*}; fi
if [ -z ${TRIES} ] || [ ${TRIES} -eq 0 ]; then TRIES=3; fi
if [ "${DEBUG}" ]; then echo "Getting ${URL} to ${FILE} max ${TRIES} attempts at $(date)"; fi
while [ ! -f ${FILE} ]
do
if [ "${DEBUG}" ]; then echo "calling curl for attempt ${I}"; fi
CURL="curl -s -o ${FILE} ${URL}"
if [ "${DEBUG}" ]; then echo "${CURL}"; fi
${CURL}
RETURN=$?
if [ "${DEBUG}" ]; then echo "Return code: ${RETURN}"; fi
let "SLEEP_TIME = ${I} * ${I}"
if [ "${DEBUG}" ]; then echo "sleeping ${SLEEP_TIME}"; fi
sleep ${SLEEP_TIME}
((I++))
done
END=$(date +%s)
let "ELAPSED_TIME = ${END} - ${START}"
if [ ! ${RETURN} ]
then
echo "file exists"
/bin/ls -hl ${FILE}
elif [ ${RETURN} -gt 0 ]
then
echo "Failed to get ${FILE} from ${URL} after ${I} attempts and ${ELAPSED_TIME} seconds"
cat ${FILE}
else
if [ "${DEBUG}" ]
then
echo "Got $(/bin/ls -1 ${FILE}) ${I} attempts after and ${ELAPSED_TIME} seconds"
else
echo "${FILE} ${I}"
fi
fi
}
# Ansible is a great way to easily control a bunch of hosts
# I put them in ~/hosts and use this to remote ssh to all of them
alias arun="ansible -m shell --user ubuntu --become -i ~/hosts -a "
alias arun2="ansible -m shell --user ec2-user --become -i ~/hosts -a "
# I often want to just have a specific string *highlighted*
# while preserving the original contents of a text file
# grepe string filename
# just like you would grep string filename, but with more file
function grepe {
grep --color -E "$1|$" $2
}
# I often want to know the time in UTC vs Pacific
ddu() {
if [ ${TZ} ]; then PTZ=${TZ}; else PTZ=":US/Pacific"; fi
export TZ=":US/Pacific"
echo "Pacific time: $(date)"
export TZ=":UTC"
echo "UTC: $(date)"
export TZ=${PTZ}
}
# I often want to know the time in Pacific vs Eastern
edu() {
if [ ${TZ} ]; then PTZ=${TZ}; else PTZ=":US/Pacific"; fi
export TZ=":US/Pacific"
echo "Pacific time: $(date)"
export TZ=":US/Eastern"
echo "Eastern time: $(date)"
export TZ=${PTZ}
}
# Print current date in MY time format rounded to an hour
# YYYY-MM-DDTHH:00:00Z
# I use this for getting things like dates for metric analysis
my-time() {
echo "NOW $(date +%FT%H:00:00Z)"
echo "24HR AGO $(date +%FT%H:00:00Z)"
}
# This makes the left side of your command prompt so much cleaner
function collapse_pwd {
echo $(pwd | sed -e "s,^$HOME,~,")
}
# Everyone loves PRINT (errrr echo) statements right!
# I do
# I love DEBUG variables even more though
# and with this I can use this in my bash scripts like:
# DEBUG "this process just did something I really cared about when I was writing the code at $(date) on $(hostname)"
# and not be bugged by it after I'm less interested
function DEBUG() {
if [ "${DEBUG}" ]
then
echo "${1}"
fi
}
function used_mem() {
# This function reports the anon allocated memory
# Interesting because this is used by #@%REDACTED#@#@%@#
# Use like this to monitor % used memory
# while true; do echo "$(date) $(used_anon_mem)%"; sleep .1; done
MEM_TOT=$(grep MemTotal /proc/meminfo | awk '{ print $2 }')
MEM_FREE=$(grep MemFree /proc/meminfo | awk '{ print $2 }')
COMMIT_MEM=$(grep Committed_AS /proc/meminfo | awk '{ print $2 }')
ANON_MEM=$(grep AnonPages /proc/meminfo | awk '{ print $2 }')
ANON_USED_PERCENT=$(echo "scale=2; (${ANON_MEM} / ${MEM_TOT}) * 100" | bc -l)
COMMIT_USED_PERCENT=$(echo "scale=2; (${COMMIT_MEM} / ${MEM_TOT}) * 100" | bc -l)
echo "Mem Anon: ${ANON_USED_PERCENT}%, Commit ${COMMIT_USED_PERCENT}%, ${MEM_FREE} free of ${MEM_TOT} Total"
}
function used_anon_mem() {
# This function reports the anon allocated memory
# Interesting because this is used by #@%REDACTED#@#@%@#
# Use like this to monitor % used memory
# while true; do echo "$(date) $(used_anon_mem)%"; sleep .1; done
MEM_TOT=$(grep MemTotal /proc/meminfo | awk '{ print $2 }')
ANON_MEM=$(grep AnonPages /proc/meminfo | awk '{ print $2 }')
USED_PERCENT=$(echo "scale=2; (${ANON_MEM} / ${MEM_TOT}) * 100" | bc -l)
echo ${USED_PERCENT}
}
function aws_random_subnet() {
# Cuz' sometimes you just need a subnet...
# This works with your AWS CLI, needs to be setup and all that
# given region ${1} or ${R} or none
# describe VPC subnets, sort random, pick 1
if [ "${1}" ]
then
MY_REGION=${1}
elif [ "${R}" ]
then
MY_REGION=${R}
fi
if [ "${MY_REGION}" ]
then
MY_SUBNET=$(aws ec2 describe-subnets --region ${MY_REGION} | jq -r '.Subnets[].SubnetId' | sort -r | head -n 1)
else
MY_SUBNET=$(aws ec2 describe-subnets | jq -r '.Subnets[].SubnetId' | sort -r | head -n 1)
fi
echo "${MY_SUBNET}"
}
# global ZSH aliases
# SUS - get top 25 of whatever with counts
alias -g SUS=" | sort | uniq -c | sort -nr | head -n 25"
# More from https://grml.org/zsh/zsh-lovers.html
# alias -g ...='../..'
# alias -g ....='../../..'
# alias -g .....='../../../..'
# alias -g CA="2>&1 | cat -A"
# alias -g C='| wc -l'
# alias -g D="DISPLAY=:0.0"
# alias -g DN=/dev/null
# alias -g ED="export DISPLAY=:0.0"
# alias -g EG='|& egrep'
# alias -g EH='|& head'
# alias -g EL='|& less'
# alias -g ELS='|& less -S'
# alias -g ETL='|& tail -20'
# alias -g ET='|& tail'
# alias -g F=' | fmt -'
# alias -g G='| egrep'
# alias -g H='| head'
# alias -g HL='|& head -20'
# alias -g Sk="*~(*.bz2|*.gz|*.tgz|*.zip|*.z)"
# alias -g LL="2>&1 | less"
# alias -g L="| less"
# alias -g LS='| less -S'
# alias -g MM='| most'
# alias -g M='| more'
# alias -g NE="2> /dev/null"
# alias -g NS='| sort -n'
# alias -g NUL="> /dev/null 2>&1"
# alias -g PIPE='|'
# alias -g R=' > /c/aaa/tee.txt '
# alias -g RNS='| sort -nr'
# alias -g S='| sort'
# alias -g TL='| tail -20'
# alias -g T='| tail'
# alias -g US='| sort -u'
# alias -g VM=/var/log/messages
# alias -g X0G='| xargs -0 egrep'
# alias -g X0='| xargs -0'
# alias -g XG='| xargs egrep'
# alias -g X='| xargs'
| true
|
20a0db0ac92f647d0be269385598b488681cda80
|
Shell
|
yolial22/SI-T6acteva
|
/ej1.sh
|
UTF-8
| 201
| 3.140625
| 3
|
[] |
no_license
|
#!/bin/bash
read -p "Introduce un usuario: " usuario;
resultado= grep -c $usuario usuarios.txt;
if [[ $usuario -eq $resultado ]];
then
echo "$resultado";
else
echo "no se ha logeado nadie";
fi
| true
|
de86ddcdcc6562173b8383f00a2c1564d088fe10
|
Shell
|
openstack/ironic
|
/devstack/plugin.sh
|
UTF-8
| 3,256
| 3.015625
| 3
|
[
"Apache-2.0"
] |
permissive
|
#!/bin/bash
# plugin.sh - devstack plugin for ironic
# devstack plugin contract defined at:
# https://docs.openstack.org/devstack/latest/plugins.html
echo_summary "ironic devstack plugin.sh called: $1/$2"
source $DEST/ironic/devstack/lib/ironic
if is_service_enabled ir-api ir-cond; then
if [[ "$1" == "stack" ]]; then
if [[ "$2" == "install" ]]; then
# stack/install - Called after the layer 1 and 2 projects source and
# their dependencies have been installed
echo_summary "Installing Ironic"
if ! is_service_enabled nova; then
source $TOP_DIR/lib/nova_plugins/functions-libvirt
install_libvirt
fi
install_ironic
install_ironicclient
cleanup_ironic_config_files
downgrade_dnsmasq
elif [[ "$2" == "post-config" ]]; then
# stack/post-config - Called after the layer 1 and 2 services have been
# configured. All configuration files for enabled services should exist
# at this point.
echo_summary "Configuring Ironic"
configure_ironic
if is_service_enabled key; then
create_ironic_accounts
fi
if [[ "$IRONIC_BAREMETAL_BASIC_OPS" == "True" && "$IRONIC_IS_HARDWARE" == "False" ]]; then
echo_summary "Precreating bridge: $IRONIC_VM_NETWORK_BRIDGE"
install_package openvswitch-switch
sudo ovs-vsctl -- --may-exist add-br $IRONIC_VM_NETWORK_BRIDGE
fi
elif [[ "$2" == "extra" ]]; then
# stack/extra - Called near the end after layer 1 and 2 services have
# been started.
# Initialize ironic
init_ironic
if [[ "$IRONIC_BAREMETAL_BASIC_OPS" == "True" && "$IRONIC_IS_HARDWARE" == "False" ]]; then
echo_summary "Creating bridge and VMs"
create_bridge_and_vms
fi
if is_service_enabled neutron || [[ "$HOST_TOPOLOGY" == "multinode" ]]; then
echo_summary "Configuring Ironic networks"
configure_ironic_networks
fi
if [[ "$HOST_TOPOLOGY" == 'multinode' ]]; then
setup_vxlan_network
fi
# Start the ironic API and ironic taskmgr components
prepare_baremetal_basic_ops
echo_summary "Starting Ironic"
start_ironic
enroll_nodes
elif [[ "$2" == "test-config" ]]; then
# stack/test-config - Called at the end of devstack used to configure tempest
# or any other test environments
if is_service_enabled tempest; then
echo_summary "Configuring Tempest for Ironic needs"
ironic_configure_tempest
fi
fi
fi
if [[ "$1" == "unstack" ]]; then
# unstack - Called by unstack.sh before other services are shut down.
stop_ironic
cleanup_ironic_provision_network
cleanup_baremetal_basic_ops
fi
if [[ "$1" == "clean" ]]; then
# clean - Called by clean.sh before other services are cleaned, but after
# unstack.sh has been called.
cleanup_ironic
fi
fi
| true
|
d8af3ab312a9c6c32e48142fce06a9415d0a22e3
|
Shell
|
whoahbot/sonumator
|
/process_all_files.sh
|
UTF-8
| 533
| 3.421875
| 3
|
[] |
no_license
|
#!/bin/bash
set -o pipefail
args=("$@")
input_files=$(gsutil ls gs://sonumator/recordings/${args[0]}/*.wav);
trimmed_input_files=("${input_files[@]%.*}")
trimmed_output_files=("${output_files[@]%.*}")
for file in $input_files; do
base_file_name=$(basename ${file[@]%.*})
file_exists=$(gsutil ls gs://sonumator/csv/${base_file_name}.csv); rc=$?
if [ $rc == 1 ]
then
echo "Processing $file"
time python ./sonumator.py classify_file --file $file --training-set ./output/ --output ./csv/
fi
done
| true
|
3875568369c35d96ea7047a596a75dfc60f51ccc
|
Shell
|
jsatt/dotfiles
|
/dot_aliases
|
UTF-8
| 1,980
| 2.75
| 3
|
[] |
no_license
|
alias getip='wget -qO- icanhazip.com'
alias clearpyc='find . \( -type f -name "*.pyc" -o -type d -name __pycache__ \) -delete'
alias manage='python manage.py'
alias ipdbtest='manage test -sx --ipdb --ipdb-failures'
alias watchredis='redis-cli -n 1 monitor | cut -b -200'
alias watchtest='django-admin.py test --settings=test_settings --with-watcher --with-progressive --progressive-abs --progressive-bar-filled-color=154 --progressive-bar-empty-color=238 --progressive-function-color=214 --progressive-dim-color=51 --logging-clear-handlers'
# ls, the common ones I use a lot shortened for rapid fire usage
alias l='ls -lFh' #size,show type,human readable
alias la='ls -lAFh' #long list,show almost all,show type,human readable
alias lr='ls -tRFh' #sorted by date,recursive,show type,human readable
alias lt='ls -ltFh' #long list,sorted by date,show type,human readable
alias ll='ls -l' #long list
alias ldot='ls -ld .*'
alias lS='ls -1FSsh'
alias lart='ls -1Fcart'
alias lrt='ls -1Fcrt'
alias grep='grep --color -nIE --exclude-dir=htmlcov --exclude-dir=.hg --exclude-dir=.git'
alias rscp='rsync --progress -r --rsh=ssh'
alias fixscreen='rm -r ~/.local/share/kscreen'
alias serve='python3 -m http.server'
alias clear_dns='sudo systemd-resolve --flush-cache'
alias cm='chezmoi'
alias cmedit='chezmoi edit --apply'
alias cmgit='chezmoi git'
pip_exact_search() {
pip search "$1" | rg "$2" "^$1 \("
}
kubegetpod(){
kubectl get pods -l "$1" -o jsonpath='{.items[0].metadata.name}'
}
kubexec() {
kubectl exec -ti "$(kubegetpod "$1")" -- "$2"
}
kubelssecrets() {
kubectl get secrets "$1" --template='{{range $k, $v := .data}}{{printf "%s\n" $k}}{{end}}'
}
kubegetsecret() {
kubectl get secrets "$1" --template='$2{{"\n"}}{{if .data.$2 }}encoded: {{.data.$2}}{{"\n"}}decoded: {{.data.$2 | base64decode}}{{else}}Not Found{{end}}{{"\n"}}'
}
kubeevent(){
kubectl get event --field-selector "involvedObject.name=$1"
}
# vim: set filetype=sh:
| true
|
950867e88871e52351a319165d58f6654b0b6f2b
|
Shell
|
Freedom-Mr/casia-elasticsearch-shell
|
/write.sh
|
UTF-8
| 1,033
| 2.6875
| 3
|
[] |
no_license
|
#!/usr/bin/env bash
myJarPath=./lib/casia-elasticsearch-shell-5.6.3.1.14.jar
# 写入数据
#****************** 模式一 (已存在索引)**********************************
#参数1:数据源 , 参数2:数据主键, 参数3:数据文件夹路径, 参数4:索引名称, 参数5:索引类型
dataSource=test
id=id
dirPath=test/write
indexName=mblog_info
indexType=monitor_caiji
# 执行写入
nohup java -cp ${myJarPath} casia.isiteam.api.elasticsearch.xshell.WriteDatasMain $dataSource $id $dirPath $indexName $indexType>>log/write.log 2>&1 &
#****************** 模式二 (不存在索引,以文件名为索引名创建索引并写入数据)*********************************
#参数1:数据源 , 参数2:数据主键, 参数3:数据文件夹路径, 参数4:mapping 文件路径
dataSource=test
id=id
dirPath=test/write
mappingPath=test/mapping/mblog_info.mapping
# 执行写入
#nohup java -cp ${myJarPath} casia.isiteam.api.elasticsearch.xshell.WriteDatasMain $dataSource $id $dirPath $mappingPath>>log/write.log 2>&1 &
| true
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.