-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync-to-server
More file actions
executable file
·68 lines (50 loc) · 1.39 KB
/
Copy pathsync-to-server
File metadata and controls
executable file
·68 lines (50 loc) · 1.39 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
#!/usr/bin/env bash
shopt -s globstar dotglob
set -e
MODNAME=pf2
FASTDL_DOWNLOAD=https://play.oaktown.cc/files/?zip=fastdl/$MODNAME
if ! command -v unzip &>/dev/null; then
echo 'could not find unzip. do you have it installed?' >&2
exit 1
fi
if ! command -v bzip2 &>/dev/null; then
echo 'could not find bzip2. do you have it installed?' >&2
exit 1
fi
if ! command -v wget &>/dev/null; then
echo 'could not find wget. do you have it installed?' >&2
exit 1
fi
if [[ ! -d $MODNAME ]]; then
echo "could not find the mod folder $MODNAME. are you in the server folder?"
exit 1
fi
TEMP_D=$(mktemp -d)
FASTDL_D=$TEMP_D/fastdl
handle_sigint() {
rm -rf "$TEMP_D"
}
trap handle_sigint SIGINT
echo "temp dir: $TEMP_D"
# unzip
wget -O "$TEMP_D/fastdl.zip" "$FASTDL_DOWNLOAD"
#cp fastdl.zip "$TEMP_D"
unzip -d "$FASTDL_D" "$TEMP_D/fastdl.zip"
## recreate fastdl dir
#[[ -d $MODNAME/custom/fastdl ]] && rm -rf "$MODNAME/custom/fastdl"
#mkdir -p "$MODNAME/custom/fastdl"
for file in $FASTDL_D/**/*; do
if [[ -d $file ]]; then
continue
fi
newname=$(basename "$file" .bz2)
reldir=$(dirname "$(realpath -s --relative-to "$FASTDL_D" "$file")")
relpath=$reldir/$newname
echo "$relpath"
if [[ $file =~ \.bz2$ ]]; then
bzip2 -df "$file"
fi
mkdir -p "$MODNAME/$reldir"
mv "$FASTDL_D/$relpath" "$MODNAME/$relpath"
done
rm -rf "$TEMP_D"