-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
70 lines (48 loc) · 1.99 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
62
63
64
65
66
67
68
69
70
#!/bin/bash
DIR="pma"
GET="$(wget -help &> /dev/null && echo "wget" || echo "curl -LOk")";
T="$(date +%Y-%m-%d-%H-%M-%S)"
VER="0.0.2"
# przekazać listę np 'jeden dwa trzy'
# funkcja zamieni sobie spacje na entery i z tego zrobi listę iterowalną przez for
function replace {
for file in $( echo $@ | perl -pe 's/ /\n/g' )
do
if [ "$(sed -nr "s/(\]\])/\1\n/p" $file | sed -nr "s/.*?\[\[(.*)\]\].*/\1/p" | uniq | wc -l)" != "0" ] ; then
echo -e "\e[32mconfig: \e[96m${file}";
for match in $(sed -nr "s/(\]\])/\1\n/gp" $file | sed -nr "s/.*?\[\[(.*)\]\].*/\1/p" | sort | perl -pe 's/^(?:\d+_)?(.*)$/\1/g' | uniq)
do
printf "\e[32m${match} \e[33m:\e[0m";
read VAL </dev/tty
perl -i -p -e "s/\[\[(\d*_)?${match}\]\]/${VAL}/g" $file
done
else
echo -e "\e[32mconfig: \e[96m${file}\e[0m";
fi
done
}
if [ -e $DIR ]; then
echo -e "\e[31mDirectory '$DIR' already exist\e[m"
exit 1
fi
mkdir -p $DIR
if [ -e $DIR ]; then
echo -e "\e[32mDownload pma ...\e[0m";
$GET https://github.com/stopsopa/pma/archive/v${VER}.tar.gz?$T && mv v${VER}.tar.gz* v${VER}.tar.gz
tar -zxvf v${VER}.tar.gz
mv pma-${VER}/pma/ . && rm -rf pma-${VER} && rm v${VER}.tar.gz
LIST="$(for i in $(find pma -maxdepth 1 -type f -name "*.php" -not -path "pma/basic_auth.php"); do if [ $(perl -ne 'print if /\[\[.*\]\]/' $i | wc -l) != 0 ] ; then echo $i; fi ; done | perl -pe 's/\n/ /g')"
replace $LIST
for file in $( echo $LIST | perl -pe 's/ /\n/g' )
do
for i in $(perl -ne 'while(/\[md5\[(.+?)\]md5\]/g){print "$1\n";}' $file); do
MD5="$(echo -n "$i" | md5sum | awk '{ print $1 }')"
perl -i -p -e "s/\[md5\[$i\]md5\]/$MD5/g" $file
done
done
echo -e "*\n"'!'".gitignore" > pma/.gitignore
exit 0
else
echo -e "\e[31mNie można utworzyć katalogu '$DIR' brak uprawnień\e[m";
exit 1
fi