WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Scripts for preparing Tiny Core Linux for PXE boot  (Read 4462 times)

Offline SvOlli

  • Full Member
  • ***
  • Posts: 193
  • Linux Developer
Scripts for preparing Tiny Core Linux for PXE boot
« on: August 02, 2010, 12:28:07 PM »
Hello,

I've written a script that does all the steps necessary for downloading all the components needed for a PXE setup of tinycore:
- download updated bzImage, tinycore.gz, etc.
- download extensions including dependencies
- create a file that can be passed with the "tftplist="-parameter

I'm using pxelinux right now and the Tiny Core Linux entry looks like this:
Code: [Select]
LABEL tinycore
  KERNEL /tinycore/bzImage
  APPEND initrd=/tinycore/tinycore.gz quiet tftplist=server:/tinycore/tcz/.tftp.lst

The script at the moment of writing looks like this:
Code: [Select]
#!/bin/sh

TCMIRROR="http://distro.ibiblio.org/pub/linux/distributions/tinycorelinux/3.x"
BASEFILES="bzImage tinycore.gz"
TCZLIST="setproxy dropbear most gparted ntfsprogs jfsutils xfsprogs ntfs-3g grub4dos partimage scite"
PXEPATH="/tinycore"

MD5SUM="md5sum --quiet"
WGET="wget -q"

tczdep1()
{
  echo ${1}
  rm -f "${1}.tcz.dep"
  ${WGET} "${TCMIRROR}/tcz/${1}.tcz.dep"
  if [ -s "${1}.tcz.dep" ]; then
    cat "${1}.tcz.dep" | while read tcz ; do
      if [ -n "${tcz}" ]; then
        tczdep1 ${tcz%.tcz}
      fi
    done
  fi
}

tczdep()
{
  for pkg; do
    tczdep1 ${pkg}
  done | sort -u | tr '\n' ' '
  echo
}

download_tcz()
{
  : > .tftp.lst
  for pkg; do
    rm -f "${pkg}.tcz.md5.txt"
    ${WGET} "${TCMIRROR}/tcz/${pkg}.tcz.md5.txt"
    if ${MD5SUM} -c "${pkg}.tcz.md5.txt"; then
      echo "${pkg} already downloaded and up to date"
    else
      echo "${pkg} is now updated"
      rm -f "${pkg}.tcz"
      ${WGET} "${TCMIRROR}/tcz/${pkg}.tcz"
    fi
    echo "${PXEPATH}/tcz/${pkg}.tcz" >> .tftp.lst
  done
}

mydir="${0%/*}"
if [ -n "${mydir}" -a "${mydir}" != "${0}" ];then
  cd "${mydir}"
fi

for file in ${BASEFILES}; do
  rm -f "${file}.md5.txt"
  wget -q "${TCMIRROR}/release/distribution_files/${file}.md5.txt"
  if ${MD5SUM} -c "${file}.md5.txt"; then
    echo "${file} already downloaded and up to date"
  else
    echo "${file} is now downloading"
    mv -f "${file}" "${file%.gz}-old.gz"
    ${WGET} "${TCMIRROR}/release/distribution_files/${file}"
  fi
done

mkdir -p tcz
cd tcz

echo "resolving dependencies"
alltcz="$(tczdep ${TCZLIST})"

echo "updating tczs"
download_tcz ${alltcz}
« Last Edit: August 02, 2010, 03:30:18 PM by SvOlli »