source: MondoRescue/trunk/mindi/rootfs/sbin/untar-and-softlink@ 322

Last change on this file since 322 was 30, checked in by bcornec, 19 years ago

Id property added on files to allow for better conf. management

  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1#!/bin/sh
2
3Die() {
4 echo "Fatal error! $1" >> /dev/stderr
5 exit 1
6}
7
8
9# ---------------------- main ----------------------
10
11mountpoint=/mnt/floppy
12[ -e "/tmp/CDROM-LIVES-HERE" ] && mountpoint=/mnt/cdrom/images
13[ "$#" -eq "3" ] || Die "untar-and-softlink <tarball> <untar_to> <softlink_to>"
14diskno=$1
15untar_path=$2
16softlink_path=$3
17tarball=$mountpoint/$diskno.tar.gz
18if [ -e "/tmp/CDROM-LIVES-HERE" ] ; then
19 [ -e "$tarball" ] || LogIt "Can't find CD's $tarball" 1
20else
21 while [ ! -f "$tarball" ] ; do
22 echo -e -n "Please insert data (floppy) disk #$diskno and press ENTER."
23 read line
24 mount /dev/fd0 -t ext2 -o ro $mountpoint
25 [ -f "$tarball" ] || umount $mountpoint ; # unmount if tarball not on disk
26 echo -en "Working..."
27 done
28fi
29
30[ -e "$mountpoint/LAST-DISK" ] && cp -f $mountpoint/LAST-DISK /
31old_pwd=`pwd`
32cd $untar_path
33counter=0
34for fname in `tar -zxvf $tarball` ; do
35 [ -e "$softlink_path/$fname" ] && continue
36 mkdir -p $softlink_path/$fname 2> /dev/null
37 if [ ! -d "$untar_path/$fname" ] ; then
38 rmdir $softlink_path/$fname 2> /dev/null
39 ln -sf $untar_path/$fname $softlink_path/$fname
40 sync;sync;sync
41 fi
42 counter=$(($counter+1))
43 [ "$(($counter % 4))" -eq "0" ] && echo -en "\r\t\t\t\t\t\t\t\\"
44 [ "$(($counter % 4))" -eq "1" ] && echo -en "\r\t\t\t\t\t\t\t|"
45 [ "$(($counter % 4))" -eq "2" ] && echo -en "\r\t\t\t\t\t\t\t/"
46 [ "$(($counter % 4))" -eq "3" ] && echo -en "\r\t\t\t\t\t\t\t-"
47done
48cd $old_pwd
49echo -e -n "\r"
50[ ! -e "/tmp/CDROM-LIVES-HERE" ] && umount $mountpoint
51sleep 1
52if [ ! -e "/tmp/CDROM-LIVES-HERE" -a -f "/LAST-DISK" ] ; then
53 echo -en "Please remove the last data disk and press ENTER."
54 read line
55fi
56exit 0
Note: See TracBrowser for help on using the repository browser.