Skip to content

Instantly share code, notes, and snippets.

@chasebolt
chasebolt / install_eon_purge_data.sh
Last active July 8, 2019 22:50 — forked from tentious/install_deletion_job.sh
installs EON cron job that automatically purges oldest video when used space is greater than the MAX_USED_PERCENT limit
#!/bin/env bash
set -e
# install via curl
# curl -sL https://gist.github.com/chasebolt/fd5210b4c2a44a2b0db383162a66632c/raw/install_eon_purge_data.sh | bash
# create purge script
mkdir -p /data/local
cat <<'EOF' > /data/local/purge-data.sh
#!/bin/sh
# docker run -v '/home:/home:ro' -it alpine /bin/sh
{
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": true,
"AttachStdout": true,
"AttachStderr": true,
"Tty": true,
# docker run -v '/home' -it alpine /bin/sh`
{
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": true,
"AttachStdout": true,
"AttachStderr": true,
"Tty": true,
@chasebolt
chasebolt / docker-cli-debug.sh
Last active October 23, 2020 14:34
copy and paste this one-liner into a terminal of the docker host you want to debug. this will dump all the cli api calls between the client and docker host. requires root and the app socat.
mv /var/run/docker.sock /var/run/docker.sock.orig \
&& socat -v UNIX-LISTEN:/var/run/docker.sock,group=docker,perm=0660,reuseaddr,fork UNIX-CONNECT:/var/run/docker.sock.orig; \
mv /var/run/docker.sock.orig /var/run/docker.sock
➜ chef-docker git:(ports) ✗ kitchen converge resources-183-ubuntu-1504
-----> Starting Kitchen (v1.4.2)
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/httpclient-2.6.0.1/lib/httpclient/webagent-cookie.rb:458: warning: already initialized constant HTTPClient::CookieManager
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/httpclient-2.6.0.1/lib/httpclient/cookie.rb:8: warning: previous definition of CookieManager was here
-----> Converging <resources-183-ubuntu-1504>...
Preparing files for transfer
Preparing dna.json
Resolving cookbook dependencies with Berkshelf 4.0.1...
Removing non-cookbook files before transfer
Preparing validation.pem
➜ chef-docker git:(ports) ✗ kitchen converge resources-183-ubuntu-1504
-----> Starting Kitchen (v1.4.2)
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/httpclient-2.6.0.1/lib/httpclient/webagent-cookie.rb:458: warning: already initialized constant HTTPClient::CookieManager
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/httpclient-2.6.0.1/lib/httpclient/cookie.rb:8: warning: previous definition of CookieManager was here
-----> Converging <resources-183-ubuntu-1504>...
Preparing files for transfer
Preparing dna.json
Resolving cookbook dependencies with Berkshelf 4.0.1...
Removing non-cookbook files before transfer
Preparing validation.pem
chef 12.4.3:
{
:name=>"/hammer",
:noop=>nil,
:before=>nil,
:params=>{},
:provider=>nil,
:allowed_actions=>[:nothing,
:create],
:action=>[:create],
@chasebolt
chasebolt / mkfs_data.sh
Last active November 13, 2015 02:01
cloud-init: run in bootcmd. image is expected to have ephemeral devices letters b-e.
#!/bin/bash
set -e
if lvs ephemeral/data > /dev/null 2>&1; then
echo 'lvm already created; exiting'
exit 0
fi
if ls /dev/xvd* > /dev/null 2>&1; then map='xvd'; fi
if ls /dev/sd* > /dev/null 2>&1; then map='sd'; fi
root@resources-182-ubuntu-1504-chef-latest:~# docker run --name hammer_time -d busybox nc -ll -p 187 -e /bin/cat
70fbaeada1097170a3ef6274ae5e17ffea2ea8a02bc17f8f77092027e9c77e9a
root@resources-182-ubuntu-1504-chef-latest:~# docker exec hammer_time ps auxw
PID USER TIME COMMAND
1 root 0:00 nc -ll -p 187 -e /bin/cat
5 root 0:00 ps auxw
root@resources-182-ubuntu-1504-chef-latest:~# time docker stop hammer_time
real 0m10.540s
user 0m0.008s
sys 0m0.020s
case node.environment
when 'prod'
default['docker-containers'] = {
"cadvisor": {
"repo": "docker.io",
"image": "google/cadvisor",
"tag": "v1",
"port-8080": 8190
}
}