-
Notifications
You must be signed in to change notification settings - Fork 3
/
.alus-lfs
executable file
·41 lines (31 loc) · 993 Bytes
/
.alus-lfs
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
#!/bin/bash
# Created from the knowledge of https://www.cyberciti.biz/faq/unix-howto-read-line-by-line-from-file/
set -e
script_directory=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
resources_file="$script_directory/.alusresources"
mkdir -p "$script_directory/resources"
if [ "$1" == "--clean" ]; then
echo "cleaning"
for GOOD in "$script_directory/resources"/*;
do
resource=$(basename $GOOD)
if grep -q -R $resource $resources_file
then
echo "$resource is registered"
else
rm $GOOD
echo "$resource removed"
fi
done
else
while IFS=' ' read -r good destination comment
do
destination_path="$script_directory/$destination"
if [ -f "$destination_path" ]; then
echo "Alus LFS resource '$destination_path' exists, nothing to download"
else
echo "Alus LFS resource '$destination_path' will be downloaded"
wget -q "$good" -O "$destination_path"
fi
done <$resources_file
fi