1 | #!/bin/sh
|
---|
2 |
|
---|
3 | Die() {
|
---|
4 | echo "Fatal error! $1" >> /dev/stderr
|
---|
5 | exit 1
|
---|
6 | }
|
---|
7 |
|
---|
8 |
|
---|
9 | # ---------------------- main ----------------------
|
---|
10 |
|
---|
11 | mountpoint=/mnt/floppy
|
---|
12 | [ -e "/tmp/CDROM-LIVES-HERE" ] && mountpoint=/mnt/cdrom/images
|
---|
13 | [ "$#" -eq "3" ] || Die "untar-and-softlink <tarball> <untar_to> <softlink_to>"
|
---|
14 | diskno=$1
|
---|
15 | untar_path=$2
|
---|
16 | softlink_path=$3
|
---|
17 | tarball=$mountpoint/$diskno.tar.gz
|
---|
18 | if [ -e "/tmp/CDROM-LIVES-HERE" ] ; then
|
---|
19 | [ -e "$tarball" ] || LogIt "Can't find CD's $tarball" 1
|
---|
20 | else
|
---|
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
|
---|
28 | fi
|
---|
29 |
|
---|
30 | [ -e "$mountpoint/LAST-DISK" ] && cp -f $mountpoint/LAST-DISK /
|
---|
31 | old_pwd=`pwd`
|
---|
32 | cd $untar_path
|
---|
33 | counter=0
|
---|
34 | for 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-"
|
---|
47 | done
|
---|
48 | cd $old_pwd
|
---|
49 | echo -e -n "\r"
|
---|
50 | [ ! -e "/tmp/CDROM-LIVES-HERE" ] && umount $mountpoint
|
---|
51 | sleep 1
|
---|
52 | if [ ! -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
|
---|
55 | fi
|
---|
56 | exit 0
|
---|