-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch.sh
executable file
·106 lines (85 loc) · 2.25 KB
/
fetch.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
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
#!/bin/bash
# Script written by Ashfame (Ashish Kumar) https://ashfame.com
# Repository to download from
ADDR="http://repo.tinycorelinux.net"
# Tinycore version
TC="11.x"
# Processor architecture, current options are x86 x86_64 armv6 armv7
ARCH="armv7"
# Kernel version to download the appropriate extensions for it. Run "uname -r" on your piCore based linux OS to see kernel version
KERNEL="4.19.81-piCore-v7"
function download {
# ext name
ext="$1"
# ensure extension is non-empty
if [[ -z $ext ]]
then
return
fi
# ensure extension has a suffix .tcz
if [[ $ext != *.tcz ]]
then
echo "adding suffix to $ext"
ext=$ext".tcz"
fi
# replace KERNEL placeholder in extension name, if present
if [[ $ext == *KERNEL* ]]
then
ext=${ext/KERNEL/$KERNEL}
fi
echo "[$ext] Downloading.."
URL="$ADDR/$TC/$ARCH/tcz/$ext"
# bail if we already have this extension downloaded
if [[ -f $ext ]]
then
echo "Already exists, going to check dependencies tree now."
else
# download the extension
wget -q $URL > /dev/null 2>&1
# @TODO: show message if we couldn't download the extension or some error happened
if [ "$?" != "0" ]
then
echo "Err: Could not download $ext"
fi
# download md5 of extension
wget -q $URL".md5.txt" > /dev/null 2>&1
# verify md5sum of extension
md5sum -c $ext".md5.txt"
if [ "$?" != "0" ]
then
echo "Err: MD5 checksum failed"
fi
fi
# download dependencies
wget -q -O dep.txt "$URL.dep" 2>&1
if [ "$?" == 0 ]
then
echo "Downloading dependencies.."
cp dep.txt $ext".dep"
for ext in `cat dep.txt`
do
echo "Attempting to download $ext"
download $ext
done
fi
}
if [[ -z $1 ]]
then
echo "Err: No extension name given."
exit 1
fi
# first invocation
download $1
# set file permissions, numeric values for tc:staff used here, since these users may not exist on the host system where this script is executed
echo ""
echo "Warning:"
echo "Script will now attempt to set file permissions on the downloaded files."
echo "If you are not running this as root user or with sudo, this will fail."
echo "Simply run the following command as root user or with sudo to do it yourself:"
echo "sudo chown 1001:50 *.tcz*"
read -p "Press any key to continue.."
chown 1001:50 *.tcz*
# cleanup
rm dep.txt
# clean exit
exit 0