From 0eaf4c257bd77783eca19a2ab17aa8bb73c7017c Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 8 Nov 2011 12:18:29 -0500 Subject: [PATCH 01/12] -add custom script for creating lxc container on Debian Squeeze. Should be used with this wiki: http://wiki.debian.org/LXC --- dev_tools/lxc/lxc-debian | 319 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 319 insertions(+) create mode 100755 dev_tools/lxc/lxc-debian diff --git a/dev_tools/lxc/lxc-debian b/dev_tools/lxc/lxc-debian new file mode 100755 index 000000000..8760341c2 --- /dev/null +++ b/dev_tools/lxc/lxc-debian @@ -0,0 +1,319 @@ +#!/bin/bash + +# +# lxc: linux Container library + +# Authors: +# Daniel Lezcano + +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. + +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +configure_debian() +{ + rootfs=$1 + hostname=$2 + + # configure the inittab + cat < $rootfs/etc/inittab +id:3:initdefault: +si::sysinit:/etc/init.d/rcS +l0:0:wait:/etc/init.d/rc 0 +l1:1:wait:/etc/init.d/rc 1 +l2:2:wait:/etc/init.d/rc 2 +l3:3:wait:/etc/init.d/rc 3 +l4:4:wait:/etc/init.d/rc 4 +l5:5:wait:/etc/init.d/rc 5 +l6:6:wait:/etc/init.d/rc 6 +# Normally not reached, but fallthrough in case of emergency. +z6:6:respawn:/sbin/sulogin +1:2345:respawn:/sbin/getty 38400 console +c1:12345:respawn:/sbin/getty 38400 tty1 linux +c2:12345:respawn:/sbin/getty 38400 tty2 linux +c3:12345:respawn:/sbin/getty 38400 tty3 linux +c4:12345:respawn:/sbin/getty 38400 tty4 linux +EOF + + # disable selinux in debian + mkdir -p $rootfs/selinux + echo 0 > $rootfs/selinux/enforce + + # configure the network using the dhcp + cat < $rootfs/etc/network/interfaces +auto lo +iface lo inet loopback + +auto eth0 +iface eth0 inet dhcp +EOF + + # set the hostname + cat < $rootfs/etc/hostname +$hostname +EOF + + # reconfigure some services + if [ -z "$LANG" ]; then + chroot $rootfs locale-gen en_US.UTF-8 + chroot $rootfs update-locale LANG=en_US.UTF-8 + else + chroot $rootfs locale-gen $LANG + chroot $rootfs update-locale LANG=$LANG + fi + + # remove pointless services in a container + chroot $rootfs /usr/sbin/update-rc.d -f umountfs remove + chroot $rootfs /usr/sbin/update-rc.d -f hwclock.sh remove + chroot $rootfs /usr/sbin/update-rc.d -f hwclockfirst.sh remove + + echo "root:root" | chroot $rootfs chpasswd + echo "Root password is 'root', please change !" + + return 0 +} + +download_debian() +{ + packages=\ +ifupdown,\ +locales,\ +libui-dialog-perl,\ +dialog,\ +isc-dhcp-client,\ +netbase,\ +net-tools,\ +iproute,\ +openssh-server + + cache=$1 + arch=$2 + + # check the mini debian was not already downloaded + mkdir -p "$cache/partial-$arch" + if [ $? -ne 0 ]; then + echo "Failed to create '$cache/partial-$arch' directory" + return 1 + fi + + # download a mini debian into a cache + echo "Downloading debian minimal ..." + debootstrap --verbose --variant=minbase --arch=$arch \ + --include $packages \ + squeeze $cache/partial-$arch http://ftp.debian.org/debian + if [ $? -ne 0 ]; then + echo "Failed to download the rootfs, aborting." + return 1 + fi + + mv "$1/partial-$arch" "$1/rootfs-$arch" + echo "Download complete." + + return 0 +} + +copy_debian() +{ + cache=$1 + arch=$2 + rootfs=$3 + + # make a local copy of the minidebian + echo -n "Copying rootfs to $rootfs..." + cp -a $cache/rootfs-$arch $rootfs || return 1 + return 0 +} + +install_debian() +{ + cache="/var/cache/lxc/debian-squeeze" + rootfs=$1 + mkdir -p /var/lock/subsys/ + ( + flock -n -x 200 + if [ $? -ne 0 ]; then + echo "Cache repository is busy." + return 1 + fi + + arch=$(arch) + if [ "$arch" == "x86_64" ]; then + arch=amd64 + fi + + if [ "$arch" == "i686" ]; then + arch=i386 + fi + + echo "Checking cache download in $cache/rootfs-$arch ... " + if [ ! -e "$cache/rootfs-$arch" ]; then + download_debian $cache $arch + if [ $? -ne 0 ]; then + echo "Failed to download 'debian base'" + return 1 + fi + fi + + copy_debian $cache $arch $rootfs + if [ $? -ne 0 ]; then + echo "Failed to copy rootfs" + return 1 + fi + + return 0 + + ) 200>/var/lock/subsys/lxc + + return $? +} + +copy_configuration() +{ + path=$1 + rootfs=$2 + name=$3 + + cat <> $path/config +lxc.tty = 4 +lxc.pts = 1024 +lxc.rootfs = $rootfs +lxc.cgroup.devices.deny = a +# /dev/null and zero +lxc.cgroup.devices.allow = c 1:3 rwm +lxc.cgroup.devices.allow = c 1:5 rwm +# consoles +lxc.cgroup.devices.allow = c 5:1 rwm +lxc.cgroup.devices.allow = c 5:0 rwm +lxc.cgroup.devices.allow = c 4:0 rwm +lxc.cgroup.devices.allow = c 4:1 rwm +# /dev/{,u}random +lxc.cgroup.devices.allow = c 1:9 rwm +lxc.cgroup.devices.allow = c 1:8 rwm +lxc.cgroup.devices.allow = c 136:* rwm +lxc.cgroup.devices.allow = c 5:2 rwm +# rtc +lxc.cgroup.devices.allow = c 254:0 rwm +#network +lxc.network.type = veth +lxc.network.flags = up +lxc.network.link = br0 + +# mounts point +lxc.mount.entry=proc $rootfs/proc proc nodev,noexec,nosuid 0 0 +lxc.mount.entry=devpts $rootfs/dev/pts devpts defaults 0 0 +lxc.mount.entry=sysfs $rootfs/sys sysfs defaults 0 0 +EOF + + if [ $? -ne 0 ]; then + echo "Failed to add configuration" + return 1 + fi + + return 0 +} + +clean() +{ + cache="/var/cache/lxc/debian-squeeze" + + if [ ! -e $cache ]; then + exit 0 + fi + + # lock, so we won't purge while someone is creating a repository + ( + flock -n -x 200 + if [ $? != 0 ]; then + echo "Cache repository is busy." + exit 1 + fi + + echo -n "Purging the download cache..." + rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 + exit 0 + + ) 200>/var/lock/subsys/lxc +} + +usage() +{ + cat < --clean +EOF + return 0 +} + +options=$(getopt -o hp:n:c -l help,path:,name:,clean -- "$@") +if [ $? -ne 0 ]; then + usage $(basename $0) + exit 1 +fi +eval set -- "$options" + +while true +do + case "$1" in + -h|--help) usage $0 && exit 0;; + -p|--path) path=$2; shift 2;; + -n|--name) name=$2; shift 2;; + -c|--clean) clean=$2; shift 2;; + --) shift 1; break ;; + *) break ;; + esac +done + +if [ ! -z "$clean" -a -z "$path" ]; then + clean || exit 1 + exit 0 +fi + +type debootstrap +if [ $? -ne 0 ]; then + echo "'debootstrap' command is missing" + exit 1 +fi + +if [ -z "$path" ]; then + echo "'path' parameter is required" + exit 1 +fi + +if [ "$(id -u)" != "0" ]; then + echo "This script should be run as 'root'" + exit 1 +fi + +rootfs=$path/rootfs + +install_debian $rootfs +if [ $? -ne 0 ]; then + echo "failed to install debian" + exit 1 +fi + +configure_debian $rootfs $name +if [ $? -ne 0 ]; then + echo "failed to configure debian for a container" + exit 1 +fi + +copy_configuration $path $rootfs +if [ $? -ne 0 ]; then + echo "failed write configuration file" + exit 1 +fi + +if [ ! -z $clean ]; then + clean || exit 1 + exit 0 +fi From d27768b99471193fd4d589583db49d8fb9064819 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 8 Nov 2011 12:23:32 -0500 Subject: [PATCH 02/12] -add usage notes to lxc-debian script. --- dev_tools/lxc/lxc-debian | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dev_tools/lxc/lxc-debian b/dev_tools/lxc/lxc-debian index 8760341c2..eb94429d7 100755 --- a/dev_tools/lxc/lxc-debian +++ b/dev_tools/lxc/lxc-debian @@ -5,6 +5,7 @@ # Authors: # Daniel Lezcano +# Martin Konecny # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -20,6 +21,12 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +#Martin's customizations: Note that this script adds the following changes: +# -Install debian squeeze instead of lenny +# -Configure separate network stack from the LXC container host. Requires +# bridge br0 to physical ethX port to exist +# This script is to be used with http://wiki.debian.org/LXC + configure_debian() { rootfs=$1 From 238728e12fdda0594a14b9d810bb428bb6931c42 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 8 Nov 2011 16:07:09 -0500 Subject: [PATCH 03/12] CC-3024: airtime-check-system: Please add Web_server, OS, CPU information. -done --- utils/airtime-check-system.php | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/utils/airtime-check-system.php b/utils/airtime-check-system.php index f5b71df51..6e8fca64f 100644 --- a/utils/airtime-check-system.php +++ b/utils/airtime-check-system.php @@ -34,6 +34,17 @@ class AirtimeCheck { exit(1); } } + + public static function GetCpuInfo() + { + $command = "cat /proc/cpuinfo |grep -m 1 'model name' "; + exec($command, $output, $result); + + $choppedStr = explode(":", $output[0]); + $status = trim($choppedStr[1]); + //output_status("CPU", $status); + return $status; + } public static function GetAirtimeConf() { @@ -46,6 +57,33 @@ class AirtimeCheck { return $ini; } + + public static function CheckOsTypeVersion(){ + + exec("lsb_release -ds", $output, $rv); + if ($rv != 0){ + $os_string = "Unknown"; + } else { + $os_string = $output[0]; + } + + unset($output); + + // Figure out if 32 or 64 bit + exec("uname -m", $output, $rv); + if ($rv != 0){ + $machine = "Unknown"; + } else { + $machine = $output[0]; + } + + return $os_string." ".$machine; + } + + public static function GetServerType(){ + $headerInfo = get_headers("http://localhost",1); + return $headerInfo['Server'][0]; + } public static function GetStatus($p_apiKey){ @@ -82,6 +120,9 @@ class AirtimeCheck { self::output_status("TOTAL_MEMORY_MBYTES", $data->platform->memory); self::output_status("TOTAL_SWAP_MBYTES", $data->platform->swap); self::output_status("AIRTIME_VERSION", $data->airtime_version); + self::output_status("OS", self::CheckOsTypeVersion()); + self::output_status("CPU", self::GetCpuInfo()); + self::output_status("WEB_SERVER", self::GetServerType()); if ($data->services->pypo){ self::output_status("PLAYOUT_ENGINE_PROCESS_ID", $data->services->pypo->process_id); self::output_status("PLAYOUT_ENGINE_RUNNING_SECONDS", $data->services->pypo->uptime_seconds); From 1a94d8bbdce9535f7871045697419bbcca83dc4c Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 8 Nov 2011 16:34:15 -0500 Subject: [PATCH 04/12] -update lxc script. locales are automatically setup. --- dev_tools/lxc/lxc-debian | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/dev_tools/lxc/lxc-debian b/dev_tools/lxc/lxc-debian index eb94429d7..e3612e6ef 100755 --- a/dev_tools/lxc/lxc-debian +++ b/dev_tools/lxc/lxc-debian @@ -21,11 +21,12 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -#Martin's customizations: Note that this script adds the following changes: +# This script is to be used with http://wiki.debian.org/LXC +# Martin's customizations: This script adds the following changes: # -Install debian squeeze instead of lenny # -Configure separate network stack from the LXC container host. Requires # bridge br0 to physical ethX port to exist -# This script is to be used with http://wiki.debian.org/LXC +# -Automatically set-up locales to en_US.UTF-8 configure_debian() { @@ -70,15 +71,10 @@ EOF $hostname EOF - # reconfigure some services - if [ -z "$LANG" ]; then - chroot $rootfs locale-gen en_US.UTF-8 - chroot $rootfs update-locale LANG=en_US.UTF-8 - else - chroot $rootfs locale-gen $LANG - chroot $rootfs update-locale LANG=$LANG - fi - + chroot $rootfs sed -i s/"# en_US.UTF-8 UTF-8"/"en_US.UTF-8 UTF-8"/ /etc/locale.gen + chroot $rootfs locale-gen + chroot $rootfs update-locale LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8 + # remove pointless services in a container chroot $rootfs /usr/sbin/update-rc.d -f umountfs remove chroot $rootfs /usr/sbin/update-rc.d -f hwclock.sh remove @@ -86,6 +82,7 @@ EOF echo "root:root" | chroot $rootfs chpasswd echo "Root password is 'root', please change !" + echo "Please run 'dpkg-reconfigure locales' after log-in" return 0 } From 6f3e6535de3ec3fc383993790e44fcdcd9dcd5ed Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 8 Nov 2011 16:35:33 -0500 Subject: [PATCH 05/12] -make it so that apache can call airtime-check-system --- utils/airtime-check-system.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/airtime-check-system.php b/utils/airtime-check-system.php index 6e8fca64f..d9bc445ab 100644 --- a/utils/airtime-check-system.php +++ b/utils/airtime-check-system.php @@ -29,7 +29,8 @@ class AirtimeCheck { public static function ExitIfNotRoot() { // Need to check that we are superuser before running this. - if(exec("whoami") != "root"){ + $user = exec("whoami"); + if($user != "root" && $user != "www-data"){ echo "Must be root user.\n"; exit(1); } From e1d447da61461b588a3298acc0329ecd9fedbca7 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 8 Nov 2011 16:55:07 -0500 Subject: [PATCH 06/12] -add wget to installed packages. --- dev_tools/lxc/lxc-debian | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dev_tools/lxc/lxc-debian b/dev_tools/lxc/lxc-debian index e3612e6ef..8987912e8 100755 --- a/dev_tools/lxc/lxc-debian +++ b/dev_tools/lxc/lxc-debian @@ -28,6 +28,8 @@ # bridge br0 to physical ethX port to exist # -Automatically set-up locales to en_US.UTF-8 +#TODO: Check if Debian squeeze and then add "deb http://www.debian-multimedia.org squeeze main non-free" to /etc/apt/sources.list + configure_debian() { rootfs=$1 @@ -82,7 +84,6 @@ EOF echo "root:root" | chroot $rootfs chpasswd echo "Root password is 'root', please change !" - echo "Please run 'dpkg-reconfigure locales' after log-in" return 0 } @@ -98,7 +99,8 @@ isc-dhcp-client,\ netbase,\ net-tools,\ iproute,\ -openssh-server +openssh-server,\ +wget cache=$1 arch=$2 From 2b060e0753c2eb59574cae52b1ce18c3626fcf54 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 8 Nov 2011 18:00:05 -0500 Subject: [PATCH 07/12] -removed lxc-debian from this repo --- dev_tools/lxc/lxc-debian | 325 --------------------------------------- 1 file changed, 325 deletions(-) delete mode 100755 dev_tools/lxc/lxc-debian diff --git a/dev_tools/lxc/lxc-debian b/dev_tools/lxc/lxc-debian deleted file mode 100755 index 8987912e8..000000000 --- a/dev_tools/lxc/lxc-debian +++ /dev/null @@ -1,325 +0,0 @@ -#!/bin/bash - -# -# lxc: linux Container library - -# Authors: -# Daniel Lezcano -# Martin Konecny - -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. - -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. - -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -# This script is to be used with http://wiki.debian.org/LXC -# Martin's customizations: This script adds the following changes: -# -Install debian squeeze instead of lenny -# -Configure separate network stack from the LXC container host. Requires -# bridge br0 to physical ethX port to exist -# -Automatically set-up locales to en_US.UTF-8 - -#TODO: Check if Debian squeeze and then add "deb http://www.debian-multimedia.org squeeze main non-free" to /etc/apt/sources.list - -configure_debian() -{ - rootfs=$1 - hostname=$2 - - # configure the inittab - cat < $rootfs/etc/inittab -id:3:initdefault: -si::sysinit:/etc/init.d/rcS -l0:0:wait:/etc/init.d/rc 0 -l1:1:wait:/etc/init.d/rc 1 -l2:2:wait:/etc/init.d/rc 2 -l3:3:wait:/etc/init.d/rc 3 -l4:4:wait:/etc/init.d/rc 4 -l5:5:wait:/etc/init.d/rc 5 -l6:6:wait:/etc/init.d/rc 6 -# Normally not reached, but fallthrough in case of emergency. -z6:6:respawn:/sbin/sulogin -1:2345:respawn:/sbin/getty 38400 console -c1:12345:respawn:/sbin/getty 38400 tty1 linux -c2:12345:respawn:/sbin/getty 38400 tty2 linux -c3:12345:respawn:/sbin/getty 38400 tty3 linux -c4:12345:respawn:/sbin/getty 38400 tty4 linux -EOF - - # disable selinux in debian - mkdir -p $rootfs/selinux - echo 0 > $rootfs/selinux/enforce - - # configure the network using the dhcp - cat < $rootfs/etc/network/interfaces -auto lo -iface lo inet loopback - -auto eth0 -iface eth0 inet dhcp -EOF - - # set the hostname - cat < $rootfs/etc/hostname -$hostname -EOF - - chroot $rootfs sed -i s/"# en_US.UTF-8 UTF-8"/"en_US.UTF-8 UTF-8"/ /etc/locale.gen - chroot $rootfs locale-gen - chroot $rootfs update-locale LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8 - - # remove pointless services in a container - chroot $rootfs /usr/sbin/update-rc.d -f umountfs remove - chroot $rootfs /usr/sbin/update-rc.d -f hwclock.sh remove - chroot $rootfs /usr/sbin/update-rc.d -f hwclockfirst.sh remove - - echo "root:root" | chroot $rootfs chpasswd - echo "Root password is 'root', please change !" - - return 0 -} - -download_debian() -{ - packages=\ -ifupdown,\ -locales,\ -libui-dialog-perl,\ -dialog,\ -isc-dhcp-client,\ -netbase,\ -net-tools,\ -iproute,\ -openssh-server,\ -wget - - cache=$1 - arch=$2 - - # check the mini debian was not already downloaded - mkdir -p "$cache/partial-$arch" - if [ $? -ne 0 ]; then - echo "Failed to create '$cache/partial-$arch' directory" - return 1 - fi - - # download a mini debian into a cache - echo "Downloading debian minimal ..." - debootstrap --verbose --variant=minbase --arch=$arch \ - --include $packages \ - squeeze $cache/partial-$arch http://ftp.debian.org/debian - if [ $? -ne 0 ]; then - echo "Failed to download the rootfs, aborting." - return 1 - fi - - mv "$1/partial-$arch" "$1/rootfs-$arch" - echo "Download complete." - - return 0 -} - -copy_debian() -{ - cache=$1 - arch=$2 - rootfs=$3 - - # make a local copy of the minidebian - echo -n "Copying rootfs to $rootfs..." - cp -a $cache/rootfs-$arch $rootfs || return 1 - return 0 -} - -install_debian() -{ - cache="/var/cache/lxc/debian-squeeze" - rootfs=$1 - mkdir -p /var/lock/subsys/ - ( - flock -n -x 200 - if [ $? -ne 0 ]; then - echo "Cache repository is busy." - return 1 - fi - - arch=$(arch) - if [ "$arch" == "x86_64" ]; then - arch=amd64 - fi - - if [ "$arch" == "i686" ]; then - arch=i386 - fi - - echo "Checking cache download in $cache/rootfs-$arch ... " - if [ ! -e "$cache/rootfs-$arch" ]; then - download_debian $cache $arch - if [ $? -ne 0 ]; then - echo "Failed to download 'debian base'" - return 1 - fi - fi - - copy_debian $cache $arch $rootfs - if [ $? -ne 0 ]; then - echo "Failed to copy rootfs" - return 1 - fi - - return 0 - - ) 200>/var/lock/subsys/lxc - - return $? -} - -copy_configuration() -{ - path=$1 - rootfs=$2 - name=$3 - - cat <> $path/config -lxc.tty = 4 -lxc.pts = 1024 -lxc.rootfs = $rootfs -lxc.cgroup.devices.deny = a -# /dev/null and zero -lxc.cgroup.devices.allow = c 1:3 rwm -lxc.cgroup.devices.allow = c 1:5 rwm -# consoles -lxc.cgroup.devices.allow = c 5:1 rwm -lxc.cgroup.devices.allow = c 5:0 rwm -lxc.cgroup.devices.allow = c 4:0 rwm -lxc.cgroup.devices.allow = c 4:1 rwm -# /dev/{,u}random -lxc.cgroup.devices.allow = c 1:9 rwm -lxc.cgroup.devices.allow = c 1:8 rwm -lxc.cgroup.devices.allow = c 136:* rwm -lxc.cgroup.devices.allow = c 5:2 rwm -# rtc -lxc.cgroup.devices.allow = c 254:0 rwm -#network -lxc.network.type = veth -lxc.network.flags = up -lxc.network.link = br0 - -# mounts point -lxc.mount.entry=proc $rootfs/proc proc nodev,noexec,nosuid 0 0 -lxc.mount.entry=devpts $rootfs/dev/pts devpts defaults 0 0 -lxc.mount.entry=sysfs $rootfs/sys sysfs defaults 0 0 -EOF - - if [ $? -ne 0 ]; then - echo "Failed to add configuration" - return 1 - fi - - return 0 -} - -clean() -{ - cache="/var/cache/lxc/debian-squeeze" - - if [ ! -e $cache ]; then - exit 0 - fi - - # lock, so we won't purge while someone is creating a repository - ( - flock -n -x 200 - if [ $? != 0 ]; then - echo "Cache repository is busy." - exit 1 - fi - - echo -n "Purging the download cache..." - rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 - exit 0 - - ) 200>/var/lock/subsys/lxc -} - -usage() -{ - cat < --clean -EOF - return 0 -} - -options=$(getopt -o hp:n:c -l help,path:,name:,clean -- "$@") -if [ $? -ne 0 ]; then - usage $(basename $0) - exit 1 -fi -eval set -- "$options" - -while true -do - case "$1" in - -h|--help) usage $0 && exit 0;; - -p|--path) path=$2; shift 2;; - -n|--name) name=$2; shift 2;; - -c|--clean) clean=$2; shift 2;; - --) shift 1; break ;; - *) break ;; - esac -done - -if [ ! -z "$clean" -a -z "$path" ]; then - clean || exit 1 - exit 0 -fi - -type debootstrap -if [ $? -ne 0 ]; then - echo "'debootstrap' command is missing" - exit 1 -fi - -if [ -z "$path" ]; then - echo "'path' parameter is required" - exit 1 -fi - -if [ "$(id -u)" != "0" ]; then - echo "This script should be run as 'root'" - exit 1 -fi - -rootfs=$path/rootfs - -install_debian $rootfs -if [ $? -ne 0 ]; then - echo "failed to install debian" - exit 1 -fi - -configure_debian $rootfs $name -if [ $? -ne 0 ]; then - echo "failed to configure debian for a container" - exit 1 -fi - -copy_configuration $path $rootfs -if [ $? -ne 0 ]; then - echo "failed write configuration file" - exit 1 -fi - -if [ ! -z $clean ]; then - clean || exit 1 - exit 0 -fi From 573d19c5fc53e1ee5ac6db475ebac006b8771b88 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 8 Nov 2011 18:17:16 -0500 Subject: [PATCH 08/12] CC-3024: airtime-check-system: Please add Web_server, OS, CPU information. --- utils/airtime-check-system.php | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/utils/airtime-check-system.php b/utils/airtime-check-system.php index d9bc445ab..562a87fc7 100644 --- a/utils/airtime-check-system.php +++ b/utils/airtime-check-system.php @@ -20,6 +20,7 @@ if (substr($sapi_type, 0, 3) == 'cli') { class AirtimeCheck { private static $AIRTIME_STATUS_OK = true; + CONST UNKNOWN = "UNKNOWN"; /** * Ensures that the user is running this PHP script with root @@ -39,11 +40,17 @@ class AirtimeCheck { public static function GetCpuInfo() { $command = "cat /proc/cpuinfo |grep -m 1 'model name' "; - exec($command, $output, $result); - + exec($command, $output, $rv); + + if ($rv != 0 || !isset($output[0])) + return self::UNKNOWN; + $choppedStr = explode(":", $output[0]); + + if (!isset($choppedStr[1])) + return self::UNKNOWN; + $status = trim($choppedStr[1]); - //output_status("CPU", $status); return $status; } @@ -62,8 +69,8 @@ class AirtimeCheck { public static function CheckOsTypeVersion(){ exec("lsb_release -ds", $output, $rv); - if ($rv != 0){ - $os_string = "Unknown"; + if ($rv != 0 || !isset($output[0])){ + $os_string = self::UNKNOWN; } else { $os_string = $output[0]; } @@ -72,8 +79,8 @@ class AirtimeCheck { // Figure out if 32 or 64 bit exec("uname -m", $output, $rv); - if ($rv != 0){ - $machine = "Unknown"; + if ($rv != 0 || !isset($output[0])){ + $machine = self::UNKNOWN; } else { $machine = $output[0]; } @@ -83,7 +90,11 @@ class AirtimeCheck { public static function GetServerType(){ $headerInfo = get_headers("http://localhost",1); - return $headerInfo['Server'][0]; + + if (!isset($headerInfo['Server'][0])) + return self::UNKNOWN; + else + return $headerInfo['Server'][0]; } public static function GetStatus($p_apiKey){ From 4b12b4e01e2ead8a22c75805747d45f1a27da9be Mon Sep 17 00:00:00 2001 From: James Date: Wed, 9 Nov 2011 10:15:44 -0500 Subject: [PATCH 09/12] SAAS-63: airtime-saas: Something is broken in Preference.php - fixed --- airtime_mvc/application/models/Preference.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index f7fca885e..0d417ccdb 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -7,7 +7,7 @@ class Application_Model_Preference global $CC_CONFIG, $CC_DBC; //called from a daemon process - if(!Zend_Auth::getInstance()->hasIdentity()) { + if(!class_exists("Zend_Auth", false) || !Zend_Auth::getInstance()->hasIdentity()) { $id = NULL; } else { From 6c740effde2229819a990f709c635ce006d22c94 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 9 Nov 2011 13:13:21 -0500 Subject: [PATCH 10/12] SAAS-52: New auto-feedback metrics: 1) Debian or manual install, 2) SaaS or Non-SaaS - done --- airtime_mvc/application/models/Preference.php | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 0d417ccdb..af7ea4924 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -369,11 +369,16 @@ class Application_Model_Preference $outputArray['NUM_OF_SCHEDULED_PLAYLISTS'] = Application_Model_Schedule::getSchduledPlaylistCount(); $outputArray['NUM_OF_PAST_SHOWS'] = Application_Model_ShowInstance::GetShowInstanceCount(date("Y-m-d H:i:s")); $outputArray['UNIQUE_ID'] = self::GetUniqueId(); + $outputArray['SAAS'] = self::GetPlanLevel(); + $outputArray['INSTALL_METHOD'] = self::GetInstallMethod(); $outputArray = array_merge($systemInfoArray, $outputArray); $outputString = "\n"; foreach($outputArray as $key => $out){ + if($key == 'SAAS' && ($out != '' || $out != 'disabled')){ + continue; + } if($out != ''){ $outputString .= $key.' : '.$out."\n"; } @@ -386,6 +391,20 @@ class Application_Model_Preference return $outputString; } } + + public static function GetInstallMethod(){ + $easy_install = file_exists('/usr/bin/airtime-easy-install'); + $debian_install = file_exists('/var/lib/dpkg/info/airtime.config'); + if($debian_install){ + if($easy_install){ + return "easy_install"; + }else{ + return "debian_install"; + } + }else{ + return "manual_install"; + } + } public static function SetRemindMeDate($now){ $weekAfter = mktime(0, 0, 0, date("m") , date("d")+7, date("Y")); @@ -446,7 +465,11 @@ class Application_Model_Preference } public static function GetPlanLevel(){ - return self::GetValue("plan_level"); + $plan = self::GetValue("plan_level"); + if(trim($plan) == ''){ + $plan = 'disabled'; + } + return $plan; } public static function SetTrialEndingDate($date){ From 32743ca780ace65442b5ba7af3e12a30715f0924 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 9 Nov 2011 13:35:22 -0500 Subject: [PATCH 11/12] CC-3016: Import files doesn't work on Debian(1.9.5, 2.0) - added extra comment --- .../media-monitor/airtimefilemonitor/airtimeprocessevent.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py index af8658c2a..cfd605cf2 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py @@ -274,7 +274,8 @@ class AirtimeProcessEvent(ProcessEvent): # check if file exist # When whole directory is copied to the organized dir, # inotify doesn't fire IN_CLOSE_WRITE, hench we need special way of - # handling those cases. + # handling those cases. We are manully calling handle_created_file + # function. if os.path.exists(k): # check if file is open command = "lsof "+k From c3d35df55cb9a7a90664d18cf726da001704d363 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 9 Nov 2011 14:29:52 -0500 Subject: [PATCH 12/12] CC-3026: Schedule Media: The show time displayed in this window is UTC time - fixed --- .../application/controllers/ScheduleController.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 6e8e445fa..cc4acd49e 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -310,13 +310,9 @@ class ScheduleController extends Zend_Controller_Action return; } - $start = explode(" ", $start_timestamp); - $end = explode(" ", $end_timestamp); - $startTime = explode(":", $start[1]); - $endTime = explode(":", $end[1]); - $dateInfo_s = getDate(strtotime($start_timestamp)); - $dateInfo_e = getDate(strtotime($end_timestamp)); - + $dateInfo_s = getDate(strtotime(Application_Model_DateHelper::ConvertToLocalDateTimeString($start_timestamp))); + $dateInfo_e = getDate(strtotime(Application_Model_DateHelper::ConvertToLocalDateTimeString($end_timestamp))); + $this->view->showContent = $show->getShowContent(); $this->view->timeFilled = $show->getTimeScheduled(); $this->view->showName = $show->getName(); @@ -329,8 +325,8 @@ class ScheduleController extends Zend_Controller_Action $this->view->e_wday = $dateInfo_e['weekday']; $this->view->e_month = $dateInfo_e['month']; $this->view->e_day = $dateInfo_e['mday']; - $this->view->startTime = sprintf("%d:%02d", $startTime[0], $startTime[1]); - $this->view->endTime = sprintf("%d:%02d", $endTime[0], $endTime[1]); + $this->view->startTime = sprintf("%02d:%02d", $dateInfo_s['hours'], $dateInfo_s['minutes']); + $this->view->endTime = sprintf("%02d:%02d", $dateInfo_e['hours'], $dateInfo_e['minutes']); $this->view->chosen = $this->view->render('schedule/scheduled-content.phtml'); $this->view->dialog = $this->view->render('schedule/schedule-show-dialog.phtml');