Skip to content

Instantly share code, notes, and snippets.

View jhrcz's full-sized avatar

Jan Horacek jhrcz

View GitHub Profile
@jhrcz
jhrcz / one-reinstantiate-vm.sh
Last active August 29, 2015 14:04
one-reinstantiate-vm.sh
#!/bin/bash
#
# reinstantiate-vm.sh
#
# reinstantiate vms based on current vmid
# to prevent data loss vm is checked that it does not contain nonpersistent volumes
#
# reinstantiation consists of
# get template from which vm was started
# shutdown vm
@jhrcz
jhrcz / Makefile
Created July 30, 2014 13:24
one-onetemplate-dump
all: clean dump commit ok
dump:
onetemplate list --list ID | grep -v ID | while read id rest ; do onetemplate show $$id > $$id.xml ; done
clean:
rm *.xml
commit:
git add -u
@jhrcz
jhrcz / sample-batch-virsh-edit.txt
Created August 18, 2014 10:06
batch virsh edit
# rename volume to have .img suffix (it's volume not a file)
lvrename vg_storage $NODENAME.img $NODENAME
cat > /tmp/virsh-editor.sh << _EOF_
#!/bin/bash
sed -ie "/source dev/s/$NODENAME.img/$NODENAME/" \$1
_EOF_
chmod +x /tmp/virsh-editor.sh
EDITOR=/tmp/virsh-editor.sh
virsh edit $NODENAME
rm -f /tmp/virsh-editor.sh
@jhrcz
jhrcz / one-check-in-template-image-vs-image-owner.sh
Created August 26, 2014 22:01
one-check-in-template-image-vs-image-owner
#!/bin/bash
# cat | bash -ls
# cat | VERBOSE=YES bash -ls
while read tplid
do
[ -n "$tplid" ] || continue
[ "$VERBOSE" = "YES" ] \
@jhrcz
jhrcz / gist:bf63826060de97cc156a
Created November 18, 2014 11:06
calculate listed files size with rsync
find /var/lib/jenkins/.m2/repository -type f -mtime +30 -print0 | rsync -n --stats -h --files-from=- --from0 / /tmp/none | grep "Total file size:"
Total file size: 11.26G bytes
@jhrcz
jhrcz / reformat-json-pipe.sh
Last active August 29, 2015 14:16
reformat-json-pipe
curl --header "PRIVATE-TOKEN: xxxx" "https://mygitlab/api/v3/projects/mynamespace%252Fmyproject" -s \
| python -msimplejson.tool
curl --header "PRIVATE-TOKEN: xxxx" "https://mygitlab/api/v3/projects/mynamespace%252Fmyproject" -s \
| python -c 'import sys; import simplejson as json; print json.dumps( json.loads( sys.stdin.read() ), sort_keys=False, indent=4); '
@jhrcz
jhrcz / README.md
Last active August 29, 2015 14:26
use interpreter like python based on script path

script has the same shebang in all cases. it depends on the path to the script which interpreter is used

no special environment setup, not additional wrappers, without changing shebang in scripts

just one configuration file/directory to specify which tool should use which environment. compatible with SCL, virtualenv and other available ways to get different version in one system

#!./python
@jhrcz
jhrcz / fix-abrt-missing-python-argparse.yml
Last active September 16, 2015 16:47
fix missing abrt dependency python-argparse
---
#
# i use this way to detect and report (as changed state) when its missing when running in --check mode
#
# it installs this package only when its the only package to install
# so i'm workarounding the problem of yum, could not install only one package
#
#
@jhrcz
jhrcz / tmux-ansible.sh
Last active September 22, 2020 08:08
combining tmux, tmux-cssh and ansible - cluster ssh alternative with ansible inventory, uses https://github.com/dennishafemann/tmux-cssh
#!/bin/bash
login=root
grp="$1"
shift
tmux-cssh -u $login -sc `ansible ${grp:-all} -i ${CSSH_ANSIBLE_INVENTORY:-hosts.ini} --list-hosts` "$@"
@jhrcz
jhrcz / diff_file_with_rpm_content
Last active March 19, 2016 20:10
diff existing file with its original content from rpm
diff_file_with_rpm_content()
{
#
# EXAMPLES:
#
# diff_file_with_rpm_content /etc/sysconfig/somefile
# diff_file_with_rpm_content /etc/sysconfig/somefile.rpmsave /etc/sysconfig/somefile
#