Iccaros-Linux » Source Code

Source Code

Scripts and Code


Welcome to the Scripts page. This page is to post, for all to see, the scripts that are being used with Iccaros-Linux and to allow people to give their 2 cents worth. Please if you know of a better way of doing things.. Let me know (see email link below).
As stated on the home page, all scripts are copywrite under the GPL.

Here is the Main install Script for Iccaros-linux.

#!/bin/bash
#this is the start to a installation program for my linux distro
#Author: William Huskey
# OS Install functions come from Tomas Matejicek slax install script as noted above function.
# copywrite 2004 under the GPL www.gnu.org for a copy

#create temp variable
TMPFILE=/tmp/steve-installer-tmp
rm -f $TMPFILE
DISK=”hda”
#begin with header information
clear
echo “This Program will assist you in installing Icaros Linux to your hard drive.”
echo “Please answer the questions and this will be a simple process.”
echo “are you ready Y/n”
read a #this is just a pause to let the user read the output above
if [ “$a” = “n” ]; then
echo quit installer
exit
fi

#this will start the main part of the install program
function menu()
{
clear
echo “There are several things need to be done to install an Operating system.”
echo “the following will allow you to do so”
echo “1. Un-Mount any mounted parttions needed if you are going to create partitons”
echo “2. Partition Hardrive/Format”
echo “3. Mount partitions”
echo “4. choose install partition/install OS”
echo “5. exit program”
read Menu_choice
}

# this function will umount disk partitions under /mnt/ and will remove the disk* folders for mntall to work
function umnt()
{
umount /mnt/disc*
rmdir /mnt/disc* –ignore-fail-on-non-empty
ls -l /mnt/
echo “disk are unmounted if they were not in use press enter to continue”
read b
menu
}

#This is the function to partition your harddrive
function partition()
{
sudo /usr/sbin/qtparted
menu
}

#this function will make the install folder and mount it
function mnt()
{
/usr/bin/mntall
ls -la /mnt/
echo ” partitons are mounted press enter to continue”
read c
menu
}

# This function will allow you to choose what partition and install the os
# this function is derived from the Slax-install script
function install()
{
sudo /usr/bin/osinstall
menu
}

menu
x=5
while [ $x -gt 1 ]
do
case $Menu_choice in
1) umnt
;;
2) partition
;;
3) mnt
;;
4) install
;;
5) x=0
;;
esac
done

exit

Here is the osinstall scripts called from the InstallMe scripts.. as this is a Mix of a Slax script I wanted to keep it as its own script.. and modify as needed. This script contains fixes for installing large images with OVFS

#!/bin/bash
#
# SLAX installer
#
# Modified by: Sean Donahoe
#
# License: GNU General Public License
# Author: Tomas Matejicek
#

TMPFILE=/tmp/slax-installer-tmp
rm -f $TMPFILE

function error()
{
echo “$@” >&2
read e
exit 1
}

if [ “$1″ = “” -o ! -d “$1″ ]; then

ls -aA1bd /mnt/* | while read LINE;
do
MOUNT=`mount | egrep -v “\(.*bind.*\)” | egrep -v “\(.*loop.*\)” | grep -F “$LINE” | cut -d ” ” -f 1`
if [ ! “$MOUNT” = “” ]; then
echo -n “$LINE $MOUNT ” >>$TMPFILE
fi
done

if [ “`cat $TMPFILE 2>/dev/null`” = “” ]; then error “You have to mount your partition to /mnt/something first. Try ‘mntall’ script. press enter to go to menu “;fi

dialog –title “SLAX Installer” –menu \
“BEFORE YOU START:\n\
Prepare your disk partition for example by using cfdisk\n\
and make ext2 or ext3 or reiserfs or xfs filesystem on it.\n\
Then mount it somewhere in /mnt/ or reboot SLAX\n\
to mount it automatically.\n\n\
All partitions available right now are listed below.\n\
Choose your target partition:\n” 0 0 0 `cat $TMPFILE` 2>$TMPFILE

if [ ! “$?” = 0 ]; then exit; fi
$0 `cat $TMPFILE`
rm -f $TMPFILE
exit
fi
# INSTALL SLAX TO DISK (mounted to $1) NOW

DEST=$1

dialog –infobox “Preparing files to $DEST …” 3 40
mkdir -p $DEST/{dev,proc,boot,tmp,sys,mnt} 2>/dev/null
if [ “$?” -ne 0 ]; then echo “Can’t create directories in $DEST”; fi

dialog –infobox “copying files to $DEST …” 3 40
cp -pR /{etc,home,root,var} $DEST/
if [ “$?” -ne 0 ]; then error “error copying files to $DEST”; fi

mkdir $DEST/tmp/base

## Copy and install main imgs
IMGLIST=( bin lib opt usr sbin bin stuff stuff2 stuff3)
for img in ${IMGLIST[@]}
do
dialog –infobox “Installing $img.img to Disk …” 3 40
img2dir $LIVECD_PATH/base/$img.img $DEST/tmp/base
done

## Copy and install modules
ls $LIVECD_PATH/modules/*.img > /tmp/list
for i in `cat /tmp/list`
do
dialog –infobox “Installing Module $i to Disk …” 3 40
img2dir $LIVECD_PATH/modules/$i $DEST/tmp/base
done
rm /tmp/list

## Copy and install optional imgs
ls $LIVECD_PATH/optional/*.img > /tmp/list
for i in `cat /tmp/list`
do
dialog –infobox “Installing Optional IMG $i to Disk …” 3 40
img2dir $LIVECD_PATH/optional/$i $DEST/tmp/base
done
rm /tmp/list

mv -f $DEST/tmp/base/data/* $DEST
rm -rf $DEST/tmp/base

dialog –infobox “creating new mountpoints in /mnt…” 3 40
ls -aA1b /mnt | while read LINE; do
if [ “$LINE” != “ramdisk” -a “$LINE” != “livecd” ]; then
mkdir -p $DEST/mnt/$LINE
fi
done

dialog –infobox “copying kernel image (vmlinuz)…” 3 40
cp $LIVECD_PATH/vmlinuz $DEST/boot/vmlinuz
if [ “$?” -ne 0 ]; then error “error copying kernel image from $LIVECD_PATH”; fi

# fix fstab
dialog –infobox “modifying /etc/fstab entries…” 3 40
FSTABTMP=/tmp/fstab$$
echo -ne “” >$FSTABTMP
cat $DEST/etc/fstab | while read LINE; do
if [ “0$FIRST” -ne 0 ]; then # Skip first line
echo $LINE >>$FSTABTMP
fi
FIRST=1
done
echo “`mount | grep -w $DEST | cut -f 1 -d \” \”` / auto defaults 1 1″ >$DEST/etc/fstab
cat $FSTABTMP >>/$DEST/etc/fstab

# disable guest account
chroot $DESC /usr/sbin/usermod -L guest

# setup lilo
dialog –infobox “Installing LILO boot loader …” 3 40
slax-liloconfig “$DEST/boot/vmlinuz” >/tmp/lilo.conf.slax
lilo -C /tmp/lilo.conf.slax -S /dev/null -m $DEST/boot/map
if [ “$?” -ne 0 ]; then error “error installing LILO boot loader”; fi

dialog –msgbox “Installation successfull” 5 28

Here is the mntall script.. this is a Slax Script but I also use it for USB plugins..

#!/bin/bash
# Started as a daemon only if “daemon” parameter is present as $1
# Will analyze /dev/discs each second and if new disc is found then it’s
# mounted to /mnt/…
#
# example of usage: mntall # will mount all discs and exit
# example of usage: mntall daemon # will try to mount all discs each second
#
# Author: Tomas Matejicek
#
# Note: I believe that there is a better way how to mount new discs
# automatically, but to be honest I’m very lazy to learn it.
# It works great this way with devfs.
#

DDIR=/dev/discs
if [ ! -d $DDIR ]; then exit; fi
ls -aAb1 $DDIR | while read DISC ; # list all files in directory
do
ls -aAb1 “$DDIR/$DISC” | grep part | while read PART;
do
MYMOUNT=”/mnt/$DISC$PART”
if [ ! -d “$MYMOUNT” ]; then
mkdir -p “$MYMOUNT”
mount -t auto “$DDIR/$DISC/$PART” “$MYMOUNT” >/dev/null 2>/dev/null
if [ “$?” != 0 ]; then rmdir “$MYMOUNT”; fi
fi
done
done

if [ “$1″ = “daemon” ]; then
sleep 2
$0 daemon &
fi

No Software Patents