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