DHCPD

Add static DHCP entry
# create new entry
uci add dhcp host
uci set dhcp.@host[-1].name='srv1'
uci set dhcp.@host[-1].mac='00:01:02:25:96:99'
uci set dhcp.@host[-1].ip='192.168.2.55'
uci commit dhcp

# restart dhcpd server
/etc/init.d/dnsmasq restart

Create Debian Wheezy DomU

wget https://raw.githubusercontent.com/panticz/xen/master/domains/debian.wheezy.sh -O - | bash -

#!/bin/bash

# configure domU
DOMAIN_NAME=wheezy
DOMAIN_MAC=00:10:01:01:aa:bb
DOMAIN_RAM=2Gb
DOMAIN_HDD=8Gb
 
# create domU on LVM (for image file use --dir=/root, --pygrub)
xen-create-image \
 --hostname=${DOMAIN_NAME} \
 --dist=wheezy \
 --lvm=vg0 \
 --size=${DOMAIN_HDD} \
 --fs=ext4 \
 --role=udev \
 --memory=${DOMAIN_RAM} \
 --swap=${DOMAIN_RAM} \
 --dhcp \
 --mac=${DOMAIN_MAC} \
 --genpass=0 \
 --password=t00r \
 --apt_proxy=http://apt-cacher:3142/ \
 --vcpus $(cat /proc/cpuinfo | grep processor | wc -l)
 
# rename vm config
mv /etc/xen/${DOMAIN_NAME}.cfg /etc/xen/${DOMAIN_NAME}
 
# OPTIONAL: add to autostart
ln -s /etc/xen/${DOMAIN_NAME} /etc/xen/auto
 
# start domU
xm create -c ${DOMAIN_NAME}

# disable pc speaker
echo 'blacklist snd-pcsp' >> /etc/modprobe.d/blacklist.conf

# check for updates
touch /etc/apt/apt.conf.d/10periodic
if [ $(cat /etc/apt/apt.conf.d/10periodic | grep -c Update-Package-Lists) -eq 0 ]; then
 echo 'APT::Periodic::Update-Package-Lists "1";' >> /etc/apt/apt.conf.d/10periodic
fi

# fix FQDN
sed -i "s|$(hostname) $(hostname)|$(hostname -A)$(hostname)|g" /etc/hosts
 
user: root
password: t00r

OPTIONAL: enable auto updates
http://www.panticz.de/debian-ubuntu-automatic-upgrades

Magento: Update custom core config data and refresh cache to view the changes

#!/usr/bin/php
<?php
require '/var/www/app/Mage.php';
Mage::app(0);

if(count($_SERVER['argv']) == 2) {
  $value = $_SERVER['argv'][1];

  # update magento core config data
  $config = new Mage_Core_Model_Config();
  $config->saveConfig('stocklist/number', $value, 'default', 0);

  # refresh magento configuration cache
  Mage::app()->getCacheInstance()->cleanType('config');
} else {
  echo "Usage: " . $_SERVER['argv'][0] . " LIST_ID\n";
}
?>

Links
http://inchoo.net/ecommerce/magento/how-to-programmatically-change-magentos-core-config-data/
http://makandracards.com/magento/8277-cache-clearing-and-general-information

Ubuntu / Debian: Install and configure lm-sensors

wget -q https://raw.githubusercontent.com/panticz/installit/master/install.lm-sensors.sh -O - | bash -

#!/bin/bash

# ensure that this script is run by root
if [ $(id -u) -ne 0 ]; then
  sudo $0
  exit
fi

# install lm-sensors
apt-get install -y lm-sensors

# install the latest version
if [ "$1" == "-n" ]; then
  wget http://mirrors.kernel.org/ubuntu/pool/universe/l/lm-sensors/lm-sensors_3.3.3-1ubuntu1_amd64.deb -P /tmp/
  dpkg -i /tmp/lm-sensors_*.deb
  rm /tmp/lm-sensors_*.deb
fi

# auto configure
yes | /usr/sbin/sensors-detect

Search for motherboard configuration
sudo dmidecode -t baseboard | grep "Product Name"
http://www.lm-sensors.org/wiki/Configurations/

Motherboard configurations
# MSI X58 Pro-E (MS-7522) / Fintek f71882fg
echo "f71882fg" >> /etc/modules
echo "#coretemp" >> /etc/modules
modprobe f71882fg
wget http://dl.panticz.de/lm-sensors/ms-7522.conf -O /etc/sensors.d/f71882fg.conf
sensors -s

# ASUS M2N32 WS Professional
cat /etc/sensors.d/asus_m2n.conf
wget http://dl.panticz.de/lm-sensors/m2n32_ws_professional.conf -O /etc/sensors.d/m2n32_ws_professional.conf

# SuperMicro PDSMi-LN4+
wget http://dl.panticz.de/lm-sensors/pdsmi-ln4.conf -O /etc/sensors.d/pdsmi-ln4.conf

View raw sensor data
sensors -u

# default config file
/etc/sensors3.conf

# view hardwired? fan alarm value
cat /sys/class/hwmon/hwmon8/device/fan1_alarm

OPTIONAL: check with icinga
/usr/lib/nagios/plugins/check_sensors

Links
http://www.lm-sensors.org/wiki/Configurations/MSI/X58-Pro-E
http://www.lm-sensors.org/wiki/FAQ/Chapter3#HowdoIsetnewlimits

hostgroup.cfg

wget -q https://raw.githubusercontent.com/panticz/icinga/master/objects/hostgroup.cfg -O /etc/icinga/objects/hostgroup.cfg

define hostgroup {
    hostgroup_name host
    alias Physical machine
}

define hostgroup {
    hostgroup_name raid1
    alias RAID1 check
}

define hostgroup {
    hostgroup_name raid5
    alias RAID5 check
}

define hostgroup {
    hostgroup_name debian
    alias Debian server
}

define hostgroup {
    hostgroup_name snom
    alias Snom VoIP phones 
}

define hostgroup {
    hostgroup_name mx
    alias Mailserver
}

define hostgroup {
    hostgroup_name printer 
    alias Printer
}

Install Obnam

Installation
wget https://raw.githubusercontent.com/panticz/installit/master/install.obnam.sh -O - | bash -

#!/bin/bash

# ensure that this script is run by root
if [ $(id -u) -ne 0 ]; then
  sudo $0
  exit
fi

# install the latest version 
if [ "$1" == "-n" ]; then
  # add repository
  echo "deb http://code.liw.fi/debian wheezy main" > /etc/apt/sources.list.d/obnam.list
  wget -q http://code.liw.fi/apt.asc -O - | apt-key add -
  apt-get update
fi

# install obnam
apt-get install -y obnam

# config
cat < /root/.obnam.conf
[config]
repository = sftp://root@itdev/backup/
root = /var/www
log = /var/log/obnam.log
EOF

# add ssh keys
ssh-keygen
ssh-copy-id root@itdev

# backup
obnam backup

# commands
obnam ls
obnam ls --generation=2
obnam diff 2 5

# mount
apt-get install python-fuse #fuse

obnam mount --to /mnt/

Links
http://www.heise.de/artikel-archiv/ct/2013/23/170_Gut-gesichert - Gut gesichert: Verschlüsselte Datensicherung unter Linux mit Obnam

Magento: Add upload field to contact form

wget -q http://dl.panticz.de/magento/contact_attachment/form.phtml.diff -O - | patch -p2 \
/var/www/app/design/frontend/default/default/template/contacts/form.phtml

--- /var/www/app/design/frontend/default/default/template/contacts/form.phtml.org	2013-11-11 17:35:28.000000000 +0100
+++ /var/www/app/design/frontend/default/default/template/contacts/form.phtml	2013-11-12 16:20:06.000000000 +0100
@@ -28,7 +28,7 @@
 <div class="page-title">
     <h1><?php echo Mage::helper('contacts')->__('Contact Us Form') ?></h1>
 </div>
-<form action="<?php echo $this->getFormAction(); ?>" id="contactForm" method="post">
+<form action="<?php echo $this->getFormAction(); ?>" id="contactForm" method="post" enctype="multipart/form-data"> 
     <div class="fieldset">
         <h2 class="legend"><?php echo Mage::helper('contacts')->__('Contact Information') ?></h2>
         <ul class="form-list">
@@ -68,6 +68,13 @@
                     <textarea name="comment" id="comment" title="<?php echo Mage::helper('contacts')->__('Comment') ?>" class="required-entry input-text" cols="5" rows="3"><?php echo $this->getRequest()->getParam('message');?></textarea>
                 </div>
             </li>
+            <li>
+                <label for="attachment"><?php echo Mage::helper('contacts')->__('Attachment') ?></label>
+                <div class="input-box">
+                    <input name="MAX_FILE_SIZE" type="hidden" value="2000000" />
+                    <input name="attachment" id="attachment" class="input-text" type="file" />
+                </div>
+            </li>
         </ul>
     </div>
     <div class="buttons-set">

wget -q http://dl.panticz.de/magento/contact_attachment/IndexController.php.diff -O - | patch -p2 \
/var/www/app/code/core/Mage/Contacts/controllers/IndexController.php

--- /var/www/app/code/core/Mage/Contacts/controllers/IndexController.php.org	2013-11-11 17:44:06.000000000 +0100
+++ /var/www/app/code/core/Mage/Contacts/controllers/IndexController.php	2013-11-13 11:34:56.000000000 +0100
@@ -91,7 +91,40 @@
                 if ($error) {
                     throw new Exception();
                 }
+
+                $fileName = '';
+                if (isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') {
+                    try {
+                        $fileName       = $_FILES['attachment']['name'];
+                        $fileExt        = strtolower(substr(strrchr($fileName, "."), 1));
+                        $fileNamewoe    = rtrim($fileName, $fileExt);
+                        $fileName       = preg_replace('/\s+', '', $fileNamewoe) . time() . '.' . $fileExt;
+ 
+                        $uploader       = new Varien_File_Uploader('attachment');
+                        $uploader->setAllowedExtensions(array('jpg', 'png', 'bmp', 'gif', 'pdf', 'zip', 'rar'));
+                        $uploader->setAllowRenameFiles(false);
+                        $uploader->setFilesDispersion(false);
+                        $path = Mage::getBaseDir('media') . DS . 'contacts';
+                        if(!is_dir($path)){
+                            mkdir($path, 0777, true);
+                        }
+                        $uploader->save($path . DS, $fileName);
+ 
+                    } catch (Exception $e) {
+                        $error = true;
+                    }
+                }
+
                 $mailTemplate = Mage::getModel('core/email_template');
+                if($fileName != '') {
+                    $attachmentFilePath = Mage::getBaseDir('media'). DS . 'contacts' . DS . $fileName;
+                    if(file_exists($attachmentFilePath)){
+                        $fileContents = file_get_contents($attachmentFilePath);
+                        $attachment   = $mailTemplate->getMail()->createAttachment($fileContents);
+                        $attachment->filename = $fileName;
+                    }
+                }
+
                 /* @var $mailTemplate Mage_Core_Model_Email_Template */
                 $mailTemplate->setDesignConfig(array('area' => 'frontend'))
                     ->setReplyTo($post['email'])

wget -q http://dl.panticz.de/magento/contact_attachment/Mage_Contacts.csv.diff -O - | patch -p2 \
/var/www/app/locale/de_DE/Mage_Contacts.csv

--- /var/www/app/locale/de_DE/Mage_Contacts.csv.org	2013-11-13 15:57:34.000000000 +0100
+++ /var/www/app/locale/de_DE/Mage_Contacts.csv	2013-11-13 11:40:11.000000000 +0100
@@ -15,5 +15,6 @@
 "Send Emails To","Sende E-Mails an"
 "Submit","Absenden"
 "Telephone","Telefon"
+"Attachment","Anhang"
 "Unable to submit your request. Please, try again later","Fehler beim Übertragen der Anfrage. Bitte versuchen Sie es später noch einmal."
 "Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.","Ihre Anfrage wurde übertragen. Wir werden diese umgehend bearbeiten und uns gegebenenfalls mit Ihnen in Verbindung setzen. Vielen Dank!"

Links
http://www.blog.magepsycho.com/adding-upload-field-in-contact-form-and-send-as-attachment/
http://www.magentocommerce.com/boards/viewthread/440759/

makemkv

## Install required packages on Ubuntu
sudo apt-get install -y build-essential libc6-dev libssl-dev libgl1-mesa-dev libqt4-dev
 
## Download Files
wget http://www.makemkv.com/download/makemkv_v1.6.10_bin.tar.gz -O /tmp/makemkv_oss.tar.gz
# http://www.makemkv.com/download/makemkv-bin-1.8.14.tar.gz
wget http://www.makemkv.com/download/makemkv_v1.6.10_oss.tar.gz -O /tmp/makemkv_bin.tar.gz
# http://www.makemkv.com/download/makemkv-oss-1.8.14.tar.gz
 
## Unzip Files and Remove tarballs
tar -xzf /tmp/makemkv_oss.tar.gz -C /tmp
tar -xzf /tmp/makemkv_bin.tar.gz -C /tmp
 
## Build OSS
cd /tm

Install pipelight (watch Watchever under Linux / Ubuntu)

wget https://raw.githubusercontent.com/panticz/installit/master/install.pipelight.sh -O - | bash -

#!/bin/bash

# add repository
sudo add-apt-repository -y ppa:pipelight/stable

# update repository
sudo apt-get update

# install pipelight
sudo apt-get install -y pipelight-multi

sudo pipelight-plugin --update
sudo pipelight-plugin --accept --enable silverlight
sudo pipelight-plugin --accept --enable flash
sudo pipelight-plugin --create-mozilla-plugins

Start Watchever
chromium-browser https://www.watchever.de/login

Links
https://wiki.ubuntuusers.de/Pipelight/
http://fds-team.de/cms/pipelight-installation.html

Syndicate content