Skip to content

Instantly share code, notes, and snippets.

View jhrcz's full-sized avatar

Jan Horacek jhrcz

View GitHub Profile
@jhrcz
jhrcz / yum-updinfo-3.sh
Last active December 29, 2015 20:29
list version differences in package version for yum update
#!/bin/bash
# based on
# http://arstechnica.com/civis/viewtopic.php?f=16&t=1081335
echo \"package name\",\"current version\",\"update version\"
yum -q check-update| while read i
do
i=$(echo $i) #this strips off yum's irritating use of whitespace
if [ "${i}x" != "x" ]
@jhrcz
jhrcz / pidgin-latest-messages.sh
Created November 30, 2013 21:19
list latest messages in pidgin - whis is useful when new message notification window is accidentaly closed.
ls -l -d --time-style long-iso ~/.purple/logs/jabber/*/* | awk '{print $6 " " $7 " " $8 }' | sort | tail
@jhrcz
jhrcz / README.md
Last active October 1, 2016 17:08
This is a quick hack for generating part of /etc/hosts to be used with dnsmasq to provide vmid specific dns names for vms running on opennebula. vm with id 456 will have dns record 456.vms.mydomain.local pointing to correct IP. in my test environment, used for generating /etc/host (prepending /etc/hosts.template) from cron to feed dnsmasq ;o)

opennebula addon for dynamic per-vm dns names

this tool allows to have delegated dns domain to opennebula with dns names for every vm.

vm dns names with vmid look like 3456.vms.my.domain.int. additionaly, there are dns names based on vm name with truncated suffix with vmid. this has sideefect for vms with the same base name - it allow having round robin ballancing.

currently we use /etc/hosts.dnsmasq to not interferre with system /etc/hosts. using hosts file has some drawbacks, like nonexistent wildcards.

sample usage

@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
@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 / 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 / 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 / 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 / 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 / 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 )