IceWalkers.com - Linux Software downloads and news
Name : Password :
Linux SoftwareLinux RPMLinux HowtosLink UsAboutAdvertise

HOWTOs

Search Howtos :Match :

B. Clone script

#!/bin/bash

set -e

export PATH=/sbin:/bin

tftp_server=10.0.0.1
nic_module=3c59x.o
major_a=(2 3 22)
family_a=(fd hda hdc)
image_a=(img0001 img0002 img0003 img0004)

operation_a=(	"Copy from network to device" \
		"Copy from device to network" \
		"Run fdisk")

mount -t proc proc /proc
insmod /lib/${nic_module}
/sbin/dhcpcd

while true; do \
	[ ! -z "${image}" ] && unset image
	echo
	echo "Clone Menu"
	echo
	echo "Operation"
	echo
	PS3="Choose operation (1-${#operation_a[*]}): "
	select operation in "${operation_a[ at ]}"; do \
		[ -z "${operation}" ] && continue
		echo
		echo $REPLY - $operation
		echo
		break
	done

	echo "Device Family"
	echo
	PS3="Choose device family (1-${#family_a[*]}): "
	select family in "${family_a[ at ]}"; do \
		[ -z "${family}" ] && continue
		echo
		echo $REPLY - $family
		echo
		break
	done

	major_i=$[REPLY-1]
	major=${major_a[$major_i]}

	echo "Minor Number"
	echo
	PS3="Choose minor number (0-255): "
	echo -n "$PS3" >&2
	read minor
	minor=$[minor%256]
	echo
	echo $minor
	echo

	if [ "${operation}" != "${operation_a[2]}" ]; then \
		echo "Image"
		echo
		PS3="Choose image (1-${#image_a[*]}): "
		select image in "${image_a[ at ]}"; do \
			[ -z "${image}" ] && continue
			echo
			echo $REPLY - $image
			echo
			break
		done
		image_i=$[REPLY-1]
		image=${image_a[${image_i}]}
	fi

	echo
	echo -e "Operation:\t$operation"
	device_name=/dev/${family_a[${major_i}]}${minor}
	echo -e "Device:\t\t${device_name} ($major, $minor)"
	[ ! -z "${image}" ] && echo -e "Image:\t\t${image}"
	echo

	echo "Confirmation"
	echo
	PS3="Ok/Cancel (1-2): "
	select ok in Ok Cancel; do \
		[ -z "${ok}" ] && continue
		echo
		echo $REPLY - $ok
		echo
		break
	done
	if [ "${ok}" = "Ok" ]; then \
		if [ ! -b ${device_name} ]; then \
			echo "Creating ${device_name}"
			mknod ${device_name} b ${major} ${minor}
		fi
		if [ ! -z "${image}" ]; then \
			if [ ! -p ${image} ]; then \
				echo "Creating pipe"
				mknod ${image} p
			fi
		fi
		if [ "${operation}" = "${operation_a[0]}" ]; then \
			tftp ${tftp_server} <<-EOT &
			binary
			get ${image}
			EOT
			gzip -c -d < ${image} | dd of=${device_name}
		elif [ "${operation}" = "${operation_a[1]}" ]; then \
			tftp ${tftp_server} <<-EOT &
			binary
			put ${image}
			EOT
			dd if=${device_name} | gzip -c > ${image}
		elif [ "${operation}" = "${operation_a[2]}" ]; then \
			fdisk ${device_name}
		fi
		echo
	fi

	echo "Continuation"
	echo
	PS3="Continue/Exit (1-2): "
	select new in Continue Exit; do \
		[ -z "${new}" ] && continue
		echo
		echo $REPLY - $new
		echo
		break
	done
	[ "${new}" = "Exit" ] && break
done
exit 0
		
Search Howtos :Match :
Linux Kernel 2.6 2.6.27.7
Linux Kernel
Battle for Wesnoth 1.4.6
Fantasy Turn-Based Strategy Game
DeleGate 9.9.0-pre8
Proxy server which runs on multiple platforms
Safesquid proxy server 4.2.2.RC8.14B
Antivirus and content filtering proxy server
Thunderbird 2.0.0.18
An email and newsgroup client with powerful, new junk mail controls
JEdit 4.3pre16
Programmers text editor
Wine 1.1.9
Free implementation of Windows on Unix
WebGUI 7.5.34
A fully featured content management system.
KOffice 2.0 beta3
Integrated office suite for KDE
LimeWire 4.18.8
Gnutella Client
Free IT Magazines, White Papers, eBooks, and more !
Oracle Magazine

Contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more.

eWeek

The essential technology information source for builders of e-business.

BusinessWeek (Digital Edition)

Provides readers a deeper understanding of the trends that drive growth, and what best practices keep them ahead of the competition.

Linux Software Map
Find Linux RPM
Best Rated Linux Software
Most Rated Linux Software
Linux Distributions
Linux Howtos
Quick Survey

Please take our survey and help us improve our website to serve you better.

Thank you.
Linux Software
Linux / IT Resources
Site Resources
Google
Privacy Policy
Contact Us
Submit Software
Advertising info