Skip to content

Instantly share code, notes, and snippets.

View jhrcz's full-sized avatar

Jan Horacek jhrcz

View GitHub Profile
@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 / 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 / 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 / clusterssh-declutter.txt
Last active August 29, 2015 14:02
clusterssh-declutter
( Xnest :1 & export DISPLAY=:1 ; icewm & cssh -lroot `ansible all --list-hosts` ; kill %1 )
@jhrcz
jhrcz / docker-mkinstaller-images.txt
Created June 6, 2014 13:33
docker-mkinstaller-images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
mkinstaller-javatomcat latest b4c35b04d591 7 minutes ago 2.469 GB
mkinstaller-base latest 214eb8e79796 16 minutes ago 1.478 GB
mkinstaller-centospostinst latest 9c6312fe4a7d 24 hours ago 1.089 GB
@jhrcz
jhrcz / wordpress-data-conf-relocated.txt
Created May 21, 2014 11:51
wordpress data conf relocated
zmeny v confu
diff wp-config.php wp-config.php.orig
73c72
< define('WPLANG', 'cs_CZ');
---
> define('WPLANG', '');
90,99d88
< # ETN: data moved to data dir
@jhrcz
jhrcz / grep-in-all-cron-tasks-sample.md
Last active August 29, 2015 13:55
grep in all cron tasks

sample cmd:

header () { echo "#" ; echo "#" ; echo "# $1" ; echo "#" ; echo "#" ; }  ; ( header "/etc/crontab" ; grep -H . /etc/crontab ; header "system cron scripts cron.d, daily,... " ; grep -H . /etc/cron.*/* ; header "users" ; grep -H . /var/spool/cron/* ) | grep httpd

output:

@jhrcz
jhrcz / one-check-nonok-vm-state.sh
Created January 17, 2014 13:46
without proper monitoring (nagios for example) this is the easy way to catch vms in incorrect states - other than running, suspend, stopped..
#!/bin/bash
[ "$DEBUG" = "YES" ] \
&& set -x
qverbose ()
{
[ "$VERBOSE" = "YES" ] \
&& return 0 || return 1
}
@jhrcz
jhrcz / one-check-double-none.sh
Created January 17, 2014 13:18
there are some situations, when after incorrectly finished vm migration in opennebula. there are two last history reasons as 'none' (0) and this causes that opennebula does not allow next live migration. this is first try to catch the problem early and not at the migration moment.
#!/bin/bash
[ "$DEBUG" = "YES" ] \
&& set -x
qverbose ()
{
[ "$VERBOSE" = "YES" ] \
&& return 0 || return 1
}
@jhrcz
jhrcz / java--jenkins-sbt-env-hack.sh
Last active January 3, 2016 05:29
jenkins sbt plugin does not have a working option to expand environment variables given thorough plugin parameters in jenkins. sooooooo - there is an evil bash wrapper for doing this ;o)
#!/bin/sh
# 1. move java to create place for weapper
# mv java java.bin
# 2. save this wrapper as 'java'
# 3. then use java as expected, wrapper just executes the moved original java binary
# /opt/etnpol-sun-java-1.7.0-envhack/bin/java
# 4. for passing sbt arguments use env injecting from file created with this build bash script
# echo "SBT_ARGS=\"jenkins-release release-version=$RELEASE_VERSION next-version=$NEXT_VERSION\"" > /tmp/some-tmp-file-blabla.tmp
# 5. in actions use