Skip to content

Instantly share code, notes, and snippets.

View qxo's full-sized avatar

qxo qxo

  • hangzhou,china
View GitHub Profile
@qxo
qxo / gist:4af8f31efe04319c3c90
Last active August 29, 2015 14:06 — forked from isaacs/gist:11404998
Gist generate registry.npmjs.org hosts for dnsmasq
ips=$(host -t any a.sni.fastly.net | awk '{print $4}' | egrep '^[0-9]') ; echo $ips; ipList="";ipCount=0;okCount=0; for ip in $ips ; do echo "checking $ip ..."; ipCount=$[ipCount+1];p='archy';s=$(curl -k https://$ip/$p -H host:registry.npmjs.org --connect-timeout 1 -m 3 -s -H accept:application/json | jq '._id') ; echo " result:$s"; if [ "$s" = "\"$p\"" ] ; then ipList="$ipList $ip";okCount=$[okCount+1]; echo "$ip is ok"; else echo "$ip is not ok:("; fi ; done ; echo " $ipCount ok ip list $okCount: $ipList" ; echo "====>"; echo "copy one of below lines to hosts:"; for ip in $ipList; do echo "$ip registry.npmjs.org" ; done
@qxo
qxo / docker-enter
Last active August 7, 2016 17:58
a shell script for enter a container (using nsenter)
#!/bin/sh
# a shell script for enter a container (using nsenter)
bin=$(which nsenter)
if [ -z "$bin" ] ; then
echo "please get nsenter using ( docker run --rm -v /usr/local/bin:/target jpetazzo/nsenter ) \n from https://github.com/jpetazzo/nsenter "
exit 1
fi
c="";
if [ -z "$1" ] ; then
@qxo
qxo / docker-merge-image-dir
Last active August 29, 2015 14:05
merge old image dir to new base image
#!/bin/bash
# a script for merge one image dir to another
if [ -z "$1" -o -z "$2" -o -z "$3" ] ; then
echo 'usage:'
echo ' docker-merge-image-dir merge-into-image-tag old-image-tag old-image-dir [in-container-cmd,out-container-cmd]'
echo ' after merge old-image-tag = merge-into-image-tag + old-image-dir '
exit
fi
@qxo
qxo / docker-replace-base-image.sh
Last active August 29, 2015 14:05
a script for replace base image
#!/bin/bash
# a script for replace base image
# using "docker history --no-trunc base-image-tag " to found the right base base-image-id
if [ -z "$1" -o -z "$2" -o -z "$3" ] ; then
echo 'usage:'
echo ' replace supper image id:'
echo ' 1. using "docker history --no-trunc base-image-tag " to found the right base image id need to be replaced'
echo ' 2. docker-replace-base-image.sh registry-store-location sub-image-tag base-image-id super-base-image-id '
echo ' or if sub-image-parent-id need replaced with base-image-id:'
echo ' docker-replace-base-image.sh registry-store-location sub-image-tag base-image-tag '
#!/bin/bash
# apt-get install jq
#set -eu
shopt -s nullglob
readonly base_dir=$1
if [ -z "$base_dir" ] ; then
echo 'please location docker registry store location!';
exit;
fi