--- /dev/null
+#!/bin/sh -e
+
+if [ "`id -u`" != 0 ]; then
+ echo "you must be root to run this"
+ exit 1
+fi
+
+if [ ! "$1" ]; then
+ dir=/home/nas-template
+elif [ -d "$1" ]; then
+ dir=$1
+else
+ echo "bad directory specified: $1"
+ exit 1
+fi
+
+if [ "$2" = "debian" ]; then
+ dist=debian
+ mirror=http://ftp.hr.debian.org/debian/
+elif [ ! "$2" -o "$2" = "ubuntu" ]; then
+ dist=ubuntu
+ mirror=http://hr.archive.ubuntu.com/ubuntu/
+elif [ -f "/etc/vz/dists/$2.conf" && "$4" ]; then
+ dist=$2
+ mirror=$4
+else
+ echo "bad distro specified: $2"
+ exit 1
+fi
+
+if [ ! "$3" -a $dist = "ubuntu" ]; then
+ rel=jaunty
+elif [ ! "$3" -a $dist = "debian" ]; then
+ rel=lenny
+elif [ "$3" ]; then
+ rel=$3
+else
+ echo "no distro release specified"
+ exit 1
+fi
+
+test -d $dir || mkdir -p $dir
+
+if [ ! -x $dir/sbin/init ]; then
+ test -f /var/lib/dpkg/info/debootstrap.list || apt-get install debootstrap
+ debootstrap --variant=minbase $rel $dir $mirror
+fi
+
+# chroot $dir # sad smo tu instalirali iproute itd unutar childa
+
+# da ne podize sest gettya po childu
+rm -f $dir/etc/event.d/tty?
+
+# da ne podize cpufreq regulator
+rm -f $dir/etc/rc?.d/???ondemand
+
+# dodajemo touch da tocno znamo kad se VE bootao
+cp rc.local $dir/etc/rc.local
+
+cd $dir
+
+tar czf ../imunes-openvz.tar.gz *
+mv ../imunes-openvz.tar.gz /var/lib/vz/template/cache/
+
+ln -s $dist.conf /etc/vz/dists/imunes-openvz.conf