forked from hackndev/initrd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·62 lines (51 loc) · 1.29 KB
/
install.sh
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
#!/bin/sh
myname="`basename $0`"
mypath="`dirname $0`"
myfiles="scripts/linuxrc scripts/loader/dialog scripts/loader/timedkill"
die() {
echo "$1"
echo "Instalation failed!"
exit 1
}
checkforprg() {
echo -n "Checking for \"$1\"..."
if [ -z "`which "$1"`" ]; then
echo "failed"
die "Can't find \"$1\" which is essential."
else
echo "ok"
fi
}
checkfordta() {
echo -n "Checking file \"$1\"..."
if [ -r "$1" ]; then
echo "ok"
else
echo "failed"
die "Can't read file \"$1\" which is essential."
fi
}
if [ -z "$1" ] || [ "x$1" = "x-h" ] || [ "x$1" = "x--help" ]; then
echo "$myname usage:"
echo " $myname destination"
echo "Script will create ramdisk structure in directory provided as destination."
exit 0
fi
checkforprg cp
checkforprg mkdir
checkforprg bzip2
checkforprg tar
checkforprg basename
checkforprg dirname
for i in root.tar.bz2 $myfiles; do
checkfordta "$mypath/$i"
done
mkdir -p "$1" || die "Can't create destination directory"
echo "Installing content of ramdisk, please wait..."
( bzip2 -cd "$mypath/root.tar.bz2" | tar -xf - -C "$1" ) || die "Unpacking failed"
for i in $myfiles; do
tmp="$1/`dirname "$i"`"
mkdir -p "$tmp" || die "Can't create directory \"$tmp\"."
cp "$mypath/$i" "$tmp" || die "Can't copy \"$mypath/$i\" to \"$tmp\"."
done
echo "Instalation complete"