Mageia 4 Xen Server

mageia logo

A quick guide for a working Xen hypervisor (Dom0) on a Mageia 4 host.

Minimal installation for a server

Fetch a network install iso (64 bit!)

http://www.mageia.org/en/downloads/

I chose a Text installer, but do a graphical install if you prefer. We are doing a minimal install.

  • Install from HTTP (choose your favorite mirror)
  • Desktop : custom
  • uncheck everything
  • next screen (“Type of install”), use default choices
  • bootloader : I prefer GRUB2

Installation finished, reboot, login as root.

Continue reading

xorg.conf snippet for Samsung SyncMaster 2253LW monitor

xorg.conf snippet for a Samsung SyncMaster 2253LW monitor.

Full specs here : http://downloadcenter.samsung.com/content/UM/200801/20080105125513265_BN59-00671A-Eng.pdf

Section "Monitor"
        Identifier "Monitor0"
        VendorName "Samsung"
        ModelName "SyncMaster 2253LW"
        Option  "DPMS"
        HorizSync       30-81
        VertRefresh     56-75

  # 1680x1050 @ 60.00 Hz (GTF) hsync: 65.22 kHz; pclk: 147.14 MHz
  Modeline "1680x1050_60.00"  147.14  1680 1784 1968 2256  1050 1051 1054 1087  -HSync +Vsync

  # 1280x1024 @ 60.00 Hz (GTF) hsync: 63.60 kHz; pclk: 108.88 MHz
  Modeline "1280x1024_60.00"  108.88  1280 1360 1496 1712  1024 1025 1028 1060  -HSync +Vsync
EndSection

Section "Screen"
        Identifier "Screen0"
        Device  "Card0"
        Monitor "Monitor0"
        DefaultDepth    24
        Subsection      "Display"
                ViewPort        0 0
                Depth   24
                Modes   "1680x1050_60.00" "1280x1024_60.00" "1024x768"
        EndSubSection
EndSection

Wifi repeater/range extender script

Updated June, 17 2013 : bad copy/paste, script did not work! Arghhh. Now fixed!


#!/bin/bash
#
# Wifi Repeater/Range extender script
#
# last modified 12/Apr/2013
# - adapted for Debian (tested under 7.0 Wheezy)
#
# http://agentoss.wordpress.com / fredo696@gmail.com
#
# thanks to : http://www.aerospacesoftware.com/howtos/Laptop-NAT-Howto.html
#
# hardware requirements : 2 wireless NICs
# software requirements : iptables, wpa_supplicant, hostapd, dnsmasq, dhcpcd (or equivalent)
#
# This is a standalone script, it will not use your existing configuration files
# (wpa_supplicant/hostapd)
#
# Both wireless interfaces will use WPA/WPA2 encryption.
#
# BEFORE STARTING THIS SCRIPT :
# - you must have root rights
# - stop your wireless connection manager (networkmanager, wicd, etc...)
# - disable your firewall
# - disable power management (prevent the computer to go into suspend mode when unused)
#
# This script has been tested on OpenSUSE 12.2, Debian 7.0
# but should work on other Linux systems with minor adaptations.

# this is the wireless interface we use to connect to our main AP
WLAN_STA="wlan0"
# enter here your SSID and WPA passphrase
WLAN_STA_SSID="YOUR_EXISTING_SSID"
WLAN_STA_PASSPHRASE="your$existing$passphrase"

# this is the wireless interface we use to create our new AP (the "repeater" AP)
WLAN_AP="wlan1"
# your new AP's SSID
WLAN_AP_SSID="REPEAT_$WLAN_STA_SSID"
# Be sure to use different channels for the 2 AP's for best performance
WLAN_AP_CHANNEL=6
WLAN_AP_IP="192.168.7.1"
WLAN_AP_DHCP_RANGE="192.168.7.10,192.168.7.20"
# we can use the same passphrase (or not)
WLAN_AP_PASSPHRASE=$WLAN_STA_PASSPHRASE

# temp files (will contain clear passphrases!)
HOSTAP_TEMP_CONF="/root/hostap_temp.conf"
WPASUPPLICANT_TEMP_CONF="/root/wpasupplicant_temp.conf"

# Path for used commands (adapt to your system)
#DHCPCD="/sbin/dhcpcd"
#for Debian we use dhclient (installed by default)
DHCPCD=$(which dhclient)
HOSTAPD=$(which hostapd)
WPASUPPLICANT=$(which wpa_supplicant)
DNSMASQ=$(which dnsmasq)
IPTABLES=$(which iptables)

# Main program

# check if we are root
if [ $EUID -ne 0 ]; then
echo `basename $0` ": this script must be run as root!" 1>&2
exit 1
fi
# check for software we need
if [ ! -x $DHCPCD ]; then
echo "FATAL: $DHCPCD not found!"; exit 1
fi
if [ ! -x $HOSTAPD ]; then
echo "FATAL: $HOSTAPD not found!"; exit 1
fi
if [ ! -x $WPASUPPLICANT ]; then
echo "FATAL: $WPASUPPLICANT not found!"; exit 1
fi
if [ ! -x $DNSMASQ ]; then
echo "FATAL: $DNSMASQ not found!"; exit 1
fi
if [ ! -x $IPTABLES ]; then
echo "FATAL: $IPTABLES not found!"; exit 1
fi
# check for wireless interfaces
ifconfig $WLAN_STA 1>&2>/dev/null
if [[ $? -ne 0 ]]; then
echo "FATAL: Wireless interface $WLAN_STA unavailable!"; exit 1
fi
ifconfig $WLAN_AP 1>&2>/dev/null
if [[ $? -ne 0 ]]; then
echo "FATAL: Wireless interface $WLAN_AP unavailable!"; exit 1
fi

# some cleanup
# stop network-manager or wicd daemons if running
service network-manager stop 2>/dev/null
service wicd stop 2>/dev/null

# kill existing wireless connections from previous execution of this script
$DHCPCD -x $WLAN_STA 2>/dev/null
$DHCPCD -x $WLAN_AP 2>/dev/null
killall wpa_supplicant 2>/dev/null

# kill running hostapd daemon if it exists
killall hostapd 2>/dev/null

# kill dnsmasq dhcp
killall dnsmasq 2>/dev/null

# empty existing temp.conf files, for security
>$HOSTAP_TEMP_CONF
>$WPASUPPLICANT_TEMP_CONF

# stop the repeater? then just exit, we have already cleaned up!
if [ "$1" == "stop" ]; then
echo "Repeater has been stopped."
exit 0;
fi

# else, continue and create our repeater AP
echo "Please wait, starting up... "

# create temp wpa_supplicant.conf file for our STA interface
cat >$WPASUPPLICANT_TEMP_CONF <$HOSTAP_TEMP_CONF <<EOF
interface=$WLAN_AP
country_code=FR
ieee80211d=1
ssid=$WLAN_AP_SSID
hw_mode=g
channel=$WLAN_AP_CHANNEL
wme_enabled=0
macaddr_acl=0
auth_algs=1
wpa=2
wpa_passphrase=$WLAN_AP_PASSPHRASE
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
EOF

# start the STA interface (my router has a DHCP server)
$DHCPCD $WLAN_STA
if [ $? -ne 0 ]; then
echo "FATAL: unable to start $WLAN_STA interface! ($DHCPCD)"; exit 1
fi

# start hostapd daemon to create the "repeater" AP
$HOSTAPD -B $HOSTAP_TEMP_CONF
if [ $? -ne 0 ]; then
echo "FATAL: unable to start $WLAN_AP interface ($HOSTAPD)!"; exit 1
fi

# assign an IP address to the AP, and start a new DHCP server
ifconfig $WLAN_AP $WLAN_AP_IP netmask 255.255.255.0
$DNSMASQ --dhcp-range=$WLAN_AP_DHCP_RANGE --interface=$WLAN_AP
if [ $? -ne 0 ]; then
echo "FATAL: unable to start dhcp server! ($DNSMASQ)"; exit 1
fi

# enable packet forwarding and add firewall rules to allow forwarding packets
# between our 2 network interfaces.
IF_IN=$WLAN_STA
IF_OUT=$WLAN_AP

sysctl -w net.ipv4.ip_forward=1
$IPTABLES -F
$IPTABLES -X
$IPTABLES -P INPUT ACCEPT
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT
$IPTABLES -t nat -A POSTROUTING -o $IF_IN -j MASQUERADE
$IPTABLES -A FORWARD -i $IF_IN -o $IF_OUT -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $IF_OUT -o $IF_IN -j ACCEPT

echo -e "\nWireless repeater access point \"$WLAN_AP_SSID\" is *up* and running!\n"
echo -e "To kill it : `basename $0` stop"

exit 0

Debian 6.0 (Squeeze) on the Xplore iX104C3 rugged Tablet PC

productid-1444-sku-IX104C3

System specs

A nice review here : http://www.ruggedpcreview.com/3_slates_xplore_ix104c3.html

Users handbook : ftp://Support:Xplore@ftp.xploretech.com/Reports%20and%20Handbooks/iX104C3%20USERS%20HANDBOOK.pdf

Note: my model only has a digitizer (tablet PC model), no touchscreen (dual mode version)

Debian stable to the rescue

First I wanted to install Arch Linux on this system, but soon I encountered a severe setback : the Wacom stylus would not work. Then I tried Ubuntu 12.04 (Precise), everything worked out of the box, except the stylus!
Explanation : it seems the support for this older, serial Wacom tablet has been removed from the X.Org Wacom input drivers, since the 0.10.6 version and up.
(more info can be found here : http://ubuntuforums.org/showthread.php?t=1780154 )

Fortunately Debian Squeeze still uses a working 0.10.5 driver version!

Continue reading

Home mail server with Postfix + Dovecot (IMAP) + Squirrelmail/Roundcube on NetBSD 6.0.1

NetBSD-smaller-tb

NetBSD 6.0.1

Goals

  • lightweight (no mysql server, no antivirus)
  • simple (no virtual domains/users)
  • secure

Requirements

  • a valid internet domain name if you want to be able to send/receive email to/from the internet (buy a domain or take a free one at http://freedns.afraid.org )
  • valid DNS records for your domain
  • we assume your mail server is behind a properly configured router/gateway/firewall

Hardware/Virtual machine requirements

  • 512M RAM
  • 3G of disk space minimum, 8G recommended

Continue reading

Wireless Ad-hoc server script

Today, a quick and dirty Bash script which will allow you, for instance, to quickly serve files from your laptop to other wireless devices (Warning here, we use WEP encryption which is not secure).


#!/bin/bash
#
# Wireless Ad-hoc script
#
# http://agentoss.wordpress.com / fredo696@gmail.com
#
# This script will setup your wireless adapter in Ad-Hoc mode
# and start a DHCP server so that other peers (eg. an Android device)
# can receive an IP address and connect to your computer.
#
# After that, you can start a minimal webserver (darkhttpd for example)
# so that you can quickly share some files with minimal effort!
#
# This script must be run as root.
# Tested on Arch Linux.
# Some adaptations may be needed for other Linux systems.
#
# Requirements: iw, ifconfig commands, and dnsmasq.
#
# WARNING : WEP encryption is weak security :)

# User variables
mywlan="wlan0"
myessid="fredo"
mychan="4"
mywepkey="dead-beef-00"
myip="192.168.7.100"
mydhcprange="192.168.7.101,192.168.7.110"

# Main program
echo -n "Stopping wireless connections (if any)... "
# adapt to your system; I use wicd
systemctl stop wicd && echo "OK"
# for networkmanager
#systemctl stop NetworkManager

echo -n "Starting wireless Ad-hoc mode... "
ifconfig $mywlan down || exit 1
iwconfig $mywlan mode ad-hoc || exit 1
iwconfig $mywlan essid $myessid
iwconfig $mywlan channel $mychan
[ "$mywepkey" ] && iwconfig $mywlan key $mywepkey

ifconfig $mywlan $myip
ifconfig $mywlan up && echo "OK"
echo -n "Starting DHCP server ... "
dnsmasq --dhcp-range="$mydhcprange" && echo "OK"

echo "--------------------------------------"
echo "ESSID : $myessid"
[ "$mywepkey" ] && echo "WEP KEY : $mywepkey"
echo "This computer's IP : $myip"
echo "--------------------------------------"

# debug
#iwconfig $mywlan

while true; do
echo -n "Enter 'q' to quit. "
read value
if [ "$value" == "q" ]; then
break
fi
done

echo -n "Killing DHCP server... "
killall dnsmasq && echo "OK"
echo -n "Killing wireless... "
# restoring the wlan interface to "default" mode
ifconfig $mywlan down
iwconfig $mywlan mode managed
iwconfig $mywlan essid off
iwconfig $mywlan key off
echo "OK"
echo "Wireless Ad-hoc mode terminated."
# now you can restart your network manager

exit 0