This repository was archived by the owner on Jan 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathsfx2sh
More file actions
110 lines (100 loc) · 2.21 KB
/
sfx2sh
File metadata and controls
110 lines (100 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/sh
#
# @(#)sfx2sh 1.2 97/11/16 Tom Rodriguez
#
# Convert a self-extracting zip file into a shell script that requires
# the LICENSE be read.
#
#
# Usage:
# % sfx2sh <SFX_FILE> <LICENSE_FILE> <OUTPUT_FILE>
#
PATH=/usr/bin
data_file=$1
license_file=$2
out_file=$3
tmp_file=install.bin.$$
# emit the beginning of the script
cat - > $tmp_file <<'EOF'
#!/bin/sh
PATH=/usr/bin
EOF
if [ x$license_file != "x" ] ; then
# emit the code the show the license file
echo 'more <<"EOF"' >> $tmp_file
cat $license_file >> $tmp_file
echo EOF >> $tmp_file
# emit the script to ask if they agree to the license
cat - >> $tmp_file <<'EOF'
agreed=
while [ x$agreed = x ]; do
echo
echo "Do you agree to the above license terms? [yes or no] "
read reply leftover
case $reply in
y* | Y*)
agreed=1;;
n* | n*)
echo "If you don't agree to the license you can't install this sofware";
exit 1;;
esac
done
EOF
fi
cat - >> $tmp_file <<'EOF'
outname=install.sfx.$$
echo "Unpacking..."
tail +_LINES_TO_STRIP_ $0 > $outname
if [ -x /usr/bin/sum ] ; then
echo "Checksumming..."
sum=`/usr/bin/sum $outname`
index=1
for s in $sum
do
case $index in
1) sum1=$s;
index=2;
;;
2) sum2=$s;
index=3;
;;
esac
done
if expr $sum1 != _SUM_1_ || expr $sum2 != _SUM_2_ ; then
echo "The download file appears to be corrupted. Please refer"
echo "to the Troubleshooting section of the Installation"
echo "Instructions on the download page for more information."
echo "Please do not attempt to install this archive file."
exit 1
fi
else
echo "Can't find /usr/bin/sum to do checksum. Continuing anyway."
fi
chmod +x $outname
echo "Extracting..."
./$outname
echo "Done."
rm -f $outname
exit 0
EOF
# count the number of lines in the file and rewrite it so that tail
# strips the right amount off
lines=`wc -l $tmp_file | awk '{ print $1 + 1; }'`
sum=`/usr/bin/sum $data_file`
index=1
for s in $sum
do
case $index in
1) sum1=$s;
index=2;
;;
2) sum2=$s;
index=3;
;;
esac
done
sed -e "s/_LINES_TO_STRIP_/$lines/" -e "s/_SUM_1_/$sum1/" \
-e "s/_SUM_2_/$sum2/" $tmp_file > $out_file
cat $data_file >> $out_file
chmod +x $out_file
rm -f $tmp_file