From 689ba38adacaa0602e274fe8609acfa121ce76d2 Mon Sep 17 00:00:00 2001 From: Josip Rodin Date: Fri, 18 Sep 2009 15:50:51 +0200 Subject: [PATCH] skripta za generiranje openvz template cachea --- linux/gen-vz-template.sh | 65 ++++++++++++++++++++++++++++++++++++++++ linux/rc.local | 12 ++++++++ 2 files changed, 77 insertions(+) create mode 100755 linux/gen-vz-template.sh create mode 100755 linux/rc.local diff --git a/linux/gen-vz-template.sh b/linux/gen-vz-template.sh new file mode 100755 index 0000000..43f34ec --- /dev/null +++ b/linux/gen-vz-template.sh @@ -0,0 +1,65 @@ +#!/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 diff --git a/linux/rc.local b/linux/rc.local new file mode 100755 index 0000000..116945c --- /dev/null +++ b/linux/rc.local @@ -0,0 +1,12 @@ +#!/bin/sh -e +# +# rc.local +# +# This script is executed at the end of each multiuser runlevel. +# Make sure that the script will "exit 0" on success or any other +# value on error. + +# IMUNES trigger +touch /tmp/imunes-boot-done + +exit 0 -- 2.39.5