Skip to content

Instantly share code, notes, and snippets.

@bahamat
bahamat / quine.bash
Last active August 29, 2015 14:19 — forked from bahamas10/quine.bash
#!/usr/bin/env bash
s=(
'#!/usr/bin/env bash'
''
's=('
')'
''
'q=$(printf "\x27")'
'for ((i = 0; i < 3; i++ )); do'
@bahamat
bahamat / quine.js
Last active August 29, 2015 14:19 — forked from bahamas10/quine.js
#!/usr/bin/env node
var util = require("util");
var source = [
'#!/usr/bin/env node',
'',
'var util = require("util");',
'',
'var source = [',
@bahamat
bahamat / Makefile
Last active October 12, 2016 19:13 — forked from isaacs/Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@bahamat
bahamat / pipasswd
Last active January 5, 2017 19:45
Find the SmartDataCenter default root password for any installed platform image.
#!/bin/bash
if (( UID > 0 )); then
echo "You must elevate privileges."
exit 1
fi
usbkey_status=$(/opt/smartdc/bin/sdc-usbkey status)
passwd_file=/mnt/usbkey/private/root.password.$1
@bahamat
bahamat / moved.md
Last active May 16, 2017 22:31
Update all components of SDC.
#!/bin/bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Copyright (c) 2015, Brian Bennett <bahamat@digitalelf.net>
cn=$1; shift
action=$1; shift
#!/bin/bash
# This little hack-job will grab credentials from a running openvpn process in Linux
# Keep in mind this won't work if the user used the --auth-nocache flag
grep rw-p /proc/$1/maps | sed -n 's/^\([0-9a-f]*\)-\([0-9a-f]*\) .*$/\1 \2/p' | while read start stop; do gdb --batch-silent --silent --pid $1 -ex "dump memory $1-$start-$stop.dump 0x$start 0x$stop"; done
echo "Your credentials should be listed below as username/password"
strings *.dump | grep -B2 KnOQ | grep -v KnOQ
rm *.dump --force
@bahamat
bahamat / 00-illumos_SMF_manifests_for_CFengine.md
Last active November 11, 2015 17:49
illumos SMF manifests for Cfengine.

Download each file using the Raw link, or clone this gist then run the following commands:

svccfg import cf-serverd.xml
svccfg import cf-monitord.xml
svcdfg import cf-execd.xml

In your policy, cfe_internal/update/update_processes.cf should be updated accordingly to enable the SMF services instead of executing commands directly.

@bahamat
bahamat / nginx_log_format_bunyan.conf
Last active September 14, 2016 08:12
nginx log_format bunyan
log_format bunyan '{'
'"name": "nginx/$nginx_version",'
'"hostname": "$hostname",'
'"pid": "$pid",'
'"level": 30,'
'"time": "$time_iso8601",'
'"v": 0,'
'"msg": "access",'
'"remoteAddress": "$remote_addr",'
@bahamat
bahamat / no_compute_resources_available.md
Last active December 5, 2021 07:14
Diagnosing "No Compute Resources Available" messages in Triton.

No Compute Resources Available

This error is somewhat ambiguious because there is seemingly no indication which resource is exhausted.

Triton chooses compute nodes with a subcomponent called sdc-designation (also refered to as , DAPI). The full DAPI log for a provision job is embedded in the CNAPI log file and can be extracted with the workflow job uuid.

Note: The script below is no longer necessary because cnapi now includes /opt/smartdc/cnapi/bin/alloc-reasons.sh which does the same thing.

#!/bin/bash