Install Docker Compose

When I started playing with Docker I was running a lot of commands to build image, delete containers running on old image, run containers based on new image, etc… A lot of log commands with links, volumes, etc… Then I started searching for something to automate this task and here I get to docker-compse command, this is how you may install it: pip install docker-compose And install additional bash completions (run as root): ...

2016-02-12 · 1 min · timor

Manual installation of Docker on Debian/Ubuntu

I’ve played with Docker a little in it early days but didn’t stick for longer with it. It’s stable now so I wanted to check how it’s running now. I really can’t accept this method of installation: curl -fsSL https://get.docker.com/ | sh I think that world is going to it’s end when I see such scritps… I prefer to do this manually, knowing exactly what I have to do. Install prerequisites: ...

2016-02-11 · 2 min · timor

Some useful commands in Docker

I started playing with Docker and here I will write some commands that where not so obvious at beginning 😃 List running containers: docker ps List also not running containers: docker ps -a Remove all containers (be careful with that): docker rm $(docker ps -a -q) Remove all images: docker rmi $(docker images -q) Docker won’t remove any old volumes used by containers, so after some time you may be interested in deleting them all: ...

2016-02-11 · 1 min · timor

Mass replace in WordPress posts via MySQL query

I was doing a lot of changes to my old posts, switched to HTTPS, etc. Sometimes it was useful to change some particular text in all my old posts at a time, but there is no such feature in WordPress. But WordPress runs on MySQL and I could use SQL query to update such posts. Make backup - it’s not required but strongly advised 😃 Now use this query as template to replace in place whatever you need: UPDATE wp_posts SET post_content = REPLACE(post_content, " ", ""); You should see something like: ...

2016-02-09 · 1 min · timor

Use www.horizon.tv with Pipelight/Silverlight on Linux/Ubuntu

From few days I have access to UPC’s www.horizon.tv  external link platform - until now it was useless on Linux. But there is Pipelight that will use Wine to emulate Silverlight on Linux and it’s working pretty well - you’re just few commands away from achieving that: # stop browser killall firefox # remove old version if you have it sudo apt-get remove pipelight Now configure repos and install packages: ...

2016-02-09 · 1 min · timor

Prepare for DoS like Cloudflare do

I watched nice presentation about how Cloudflare protects itself against DoS. Most of us are not able to do that exactly like them but some of tips were general enough to be used on typical web front server. I took notes from this presentation and presented here. Thanks to Marek agreement I also reposted all examples (in easier to copy paste way). Howto prepare against ACK/FIN/RST/X-mas flood Use conntrack rule: ...

2016-02-05 · 4 min · timor

Zeitgeist activity.sqlite-wal getting huge

I was looking at backup task running on my desk and saw that it’s spending a lot of time on ~/.local/share/zeitgeist directory. I checked and it had 4.6GB: du -sh ~/.local/share/zeitgeist/* 118M activity.sqlite 44M activity.sqlite.bck 32K activity.sqlite-shm 4,4G activity.sqlite-wal 311M fts.index WTF? Fortunately I found here  external link that I could easily delete some of this: zeitgeist-daemon --quit Now check that it’s not running: ...

2016-02-04 · 1 min · timor

Optimize Nginx for performance

There are many possible real life cases and not all optimization technics will be suitable for you but I hope it will be a good starting place. Also you shouldn’t copy paste examples with faith that they will make your server fly 😃 You have to support your decisions with excessive tests and help of monitoring system (ex. Grafana ). Cache static and dynamic content Setting caching static and dynamic content strategy may offload your server from additional load from repetitive downloads of same, rarely updated files. This will make your site to load faster for frequent visitors. ...

2016-01-14 · 7 min · timor

XenServer - export VM to file

Sometime you need to make quick and dirty image backup of VM running on XenServer and this post is about such case 😃 List machines: xl list Name ID Mem VCPUs State Time(s) Domain-0 0 4066 8 r----- 3526567.3 webfront1.example.com 1 4096 4 r----- 3186487.2 webfront2.example.com 2 2048 2 -b---- 920408.2 Now you may export one: xe vm-export vm=webfront1.example.com filename=/srv/backup/webfront.xva Export succeeded You may also use uuid for that - list machines with xe vm-list (best with less) and then: ...

2016-01-12 · 1 min · timor

Nagios - downtime on host/service from command line with curl

Sometimes deployment process or other heavy task may cause some Nagios checks to rise below normal levels and bother admin1. If this is expected and you want to add downtime on host/service during this task you may use this script: #!/bin/bash function die { echo $1; exit 1; } if [[ $# -eq 0 ]] ; then die "Give hostname and time in minutes as parameter!" fi if [[ $# -eq 1 ]] ; then MINUTES=15 else MINUTES=$2 fi HOST=$1 NAGURL=http://nagios.example.com/nagios/cgi-bin/cmd.cgi USER=nagiosuser PASS=nagiospassword SERVICENAME=someservice COMMENT="Deploying new code" export MINUTES echo "Scheduling downtime on $HOST for $MINUTES minutes..." # The following is urlencoded already STARTDATE=`date "+%d-%m-%Y %H:%M:%S"` # This gives us the date/time X minutes from now ENDDATE=`date "+%d-%m-%Y %H:%M:%S" -d "$MINUTES min"` curl --silent --show-error \ --data cmd_typ=56 \ --data cmd_mod=2 \ --data host=$HOST \ --data-urlencode "service=$SERVICENAME" \ --data-urlencode "com_data=$COMMENT" \ --data trigger=0 \ --data-urlencode "start_time=$STARTDATE" \ --data-urlencode "end_time=$ENDDATE" \ --data fixed=1 \ --data hours=2 \ --data minutes=0 \ --data btnSubmit=Commit \ --insecure \ $NAGURL -u "$USER:$PASS"| grep -q "Your command request was successfully submitted to Nagios for processing." || die "Failed to con tact nagios"; echo Scheduled downtime on nagios from $STARTDATE to $ENDDATE Threat this script as template with some tips: ...

2016-01-11 · 2 min · timor