-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgit-adder
executable file
·59 lines (44 loc) · 959 Bytes
/
git-adder
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
#! /bin/bash
# All the useful stuff
#find . -maxdepth 2 -type f -name "*.md"
for dir in $(find . -maxdepth 1 -type d)
do
if [[ $dir == "." ]]
then
continue
fi
cd $dir
echo "DIR: $dir"
name=$(find . -maxdepth 1 -name "*.md" | cut -d "/" -f 2 |cut -d "." -f 1)
if [[ $name == "" ]]
then
cd ..
continue
fi
alreadyzipped=$(find . -maxdepth 1 -name "${name}-writeup.zip")
if [[ ${#alreadyzipped} -ge 1 ]]
then
cd ..
continue
fi
#scanning file
for file in $(find . -maxdepth 1 -not -type d)
do
file=$(echo $file | cut -d "/" -f 2)
dim=$(ls -l $file | nawk '{print $5}')
#file sgreather that 2 MB are discarded
if [[ $dim -ge 2000000 ]]
then
continue
fi
echo $file >> tozip
done
passwd=$(openssl rand -base64 32)
echo $passwd > archive_password
#removing if exists an old one
rm $name-writeup.zip
zip --password $passwd $name-writeup.zip $(cat tozip)
rm tozip
git add ${name}-writeup.zip
cd ..
done