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
#
# https://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

Arch Linux on the HP Pavilion DM1-3xxx notebook (AMD E-350 “Zacate” based series)


Computer specs

Specs will vary, my model is the 3130.

Goal of this tutorial

To quickly setup a functional, lightweight Arch Linux system, optimized for our portable computer.
This guide may evolve during time as I try to improve my Linux experience 🙂

SONY VAIO PCG-Z600TEK (aka PCG-5316) – Debian GNU/Linux install notes

A friend gave me this old laptop from the early 2000’s.
Here are my personal notes about installing an optimized and lightweight Debian GNU/Linux system on this machine, mainly for internet browsing / music playing (with external speakers!)

Official support pages

Computer specs

PIII 700MHz
128 Mb SDRAM on the motherboard, 1 SODIMM slot available for RAM upgrade (Specs says this computer can be upgraded upto 256 Mb at max!)
8 Mb Video RAM (ATI Rage Mobility M1)
20 Gb HDD (a Win2000 system was installed)
No CD / No floppy drive
No booting from USB! / No PXE boot!
No Wifi
Dead battery!

HP DM1 3130 and some Linux distributions

(Sorry this is a messy post!)

 

Update 01/08/2012

Wake On Lan seems to be active by default, and no option in the BIOS to disable it.

This will cause your battery to discharge when the computer if off…

Solution : disable Wake On Lan

Edit your distro’s rc.local and put this line in it :

ethtool -s eth0 wol d

 

Update 08/16/2011 for french readers : Article en français de Carmelo sur le paramĂ©trage d’Ubuntu sur ce netbook : http://c.ingrao.free.fr/blog/?p=450 )

I recently purchased an HP DM1 3130 netbook (AMD Zacate E-350 based) and quickly felt the need to install Linux on it.  (before that I did backup the whole hard disk containing the pre-installed windows 7 and stuff. For this task, I used a Clonezilla Live USB drive to save the whole disk to a Samba share – 32Gb free storage needed!)

Update 22/07/2011 : when using Clonezilla for restoring a disk image, you might encounter problems with GRUB not being properly rebuilt.  I have noticed such problems using the standard Debian-based Clonezilla Live, but found that the “alternate” (Ubuntu-based) version solved the problem!

First, I chose to install Mageia 1 Linux 64 bits, the KDE edition  (Note: the AMD Zacate platform is supported since Linux kernel 2.6.38).

As I don’t have an external DVD drive, I installed Mageia using a PXE boot environment. You’ll need to use the network boot iso, right here.

Continue reading

Recycling an IBM ThinkPad 365X as a MP3 Player with SliTaz GNU/Linux 1.0

Maybe you’ve got one of these laptops and wonder what to do with it?
I’m proposing here to use it into a basic MP3 music player (a Linux system of course!)

Let’s see what we’ve got here :

IBM ThinkPad 365X, model from 1997

Pentium 133MHz, no MMX!
16Mb RAM
2.1Gb 2.5″ HDD (initially running Win95)
Floppy drive
No cdrom drive!
No network interface!
No USB!

Continue reading