-
Notifications
You must be signed in to change notification settings - Fork 0
/
travis-plesk-builder.sh
127 lines (100 loc) · 3.57 KB
/
travis-plesk-builder.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/bash
# external config variables:
# PRODUCT_NAME
# PLESK_PRODUCT_TITLE
# PLESK_PRODUCT_FULLTITLE
# PLESK_PRODUCT_WEBSITE
# PLESK_PRODUCT_DOWNLOAD
# FTP_USER
# FTP_PASSWORD
# dev
# PRODUCT_NAME="webmail-lite"
# PLESK_PRODUCT_TITLE="WebMail Lite"
# PLESK_PRODUCT_FULLTITLE="Afterlogic WebMail Lite 8"
# PLESK_PRODUCT_WEBSITE=https://afterlogic.org/webmail-lite
# PLESK_PRODUCT_DOWNLOAD=https://afterlogic.org/download/webmail-lite-php
TASK="build"
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-t|--task)
TASK="$2"
shift # past argument
shift # past value
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
if [ "$TASK" = "build" ]; then
echo DOWNLOAD PLESK TEMPLATE
# wget http://github.com/afterlogic/plesk-package-template/archive/latest.zip -nv --no-check-certificate
wget http://codeload.github.com/afterlogic/plesk-package-template/zip/latest -O plesk-package-template.zip -nv --no-check-certificate
echo POPULATE TEMPLATE
PRODUCT_VERSION=`cat VERSION`
mkdir ./template
# unzip -q ./plesk-package-template.zip -d ./template
unzip -q ./plesk-package-template.zip
cp -r ./plesk-package-template-latest/* ./template
unzip -q ./${PRODUCT_NAME}_${PRODUCT_VERSION}.zip -d ./template/htdocs
echo POPULATE APP-META.XML
PRODUCT_RELEASE="1"
PRODUCT_VERSION_TRIMMED=$(echo $PRODUCT_VERSION | grep '^[\d|\.]*' -o -P)
DOT_COUNT=$(echo $PRODUCT_VERSION_TRIMMED | grep -o '\.' | wc -l)
while [ $DOT_COUNT -lt 2 ]
do
PRODUCT_VERSION_TRIMMED=$PRODUCT_VERSION_TRIMMED".0"
DOT_COUNT=$[$DOT_COUNT+1]
done
INSTALL_SIZE=$(du -sb ./template/htdocs | cut -f 1)
sed -i "s/%PRODUCT_FULLNAME%/$PLESK_PRODUCT_FULLTITLE/g" ./template/APP-META.xml
sed -i "s/%PRODUCT_NAME%/${PLESK_PRODUCT_TITLE}/g" ./template/APP-META.xml
sed -i "s/%PRODUCT_VERSION%/$PRODUCT_VERSION_TRIMMED/g" ./template/APP-META.xml
sed -i "s/%PRODUCT_RELEASE%/$PRODUCT_RELEASE/g" ./template/APP-META.xml
sed -i "s/%INSTALL_SIZE%/$INSTALL_SIZE/g" ./template/APP-META.xml
sed -i "s|%PRODUCT_WEBSITE%|${PLESK_PRODUCT_WEBSITE}|g" ./template/APP-META.xml
sed -i "s|%PRODUCT_DOWNLOAD%|${PLESK_PRODUCT_DOWNLOAD}|g" ./template/APP-META.xml
fi
if [ "$TASK" = "xmllog" ]; then
first_seen=1
while read line ; do
line=`echo $line | tr -d '\015'`
token=`echo "$line" | awk '{print $1}' | sed "s/\[//;s/\]//"`
[ ${#token} -gt 1 ] && {
[ $first_seen -gt 0 ] || echo " </version>"
first_seen=0
echo " <version version=\"$token\" release=\"1\">"
continue ;
}
[ ${#token} -gt 0 ] && {
line=`echo "$line" | tr -d '<>&'`
echo " <entry>${line}</entry>";
}
done
[ $first_seen -gt 0 ] || echo " </version>"
fi
if [ "$TASK" = "log" ]; then
echo GENERATE CHANGELOG
cat ./CHANGELOG.txt | ./travis-plesk-builder.sh -t xmllog > ./changelog.xml
sed -i -e "/%PRODUCT_CHANGELOG%/ {r ./changelog.xml
d}" ./template/APP-META.xml
echo GENERATE CHANGELOG DONE
fi
if [ "$TASK" = "zip" ]; then
PRODUCT_VERSION=`cat VERSION`
echo BUILD ARCHIVE
cd ./template
zip -rq ../${PRODUCT_NAME}-plesk_${PRODUCT_VERSION}.zip .
echo BUILD ARCHIVE DONE
fi
if [ "$TASK" = "upload" ]; then
PRODUCT_VERSION=`cat VERSION`
echo UPLOAD ZIP FILE: "${PRODUCT_NAME}-plesk_${PRODUCT_VERSION}.zip"
curl --ftp-create-dirs --retry 6 -T ${PRODUCT_NAME}-plesk_${PRODUCT_VERSION}.zip -u ${FTP_USER}:${FTP_PASSWORD} ftp://afterlogic.com/
echo UPLOAD DONE
fi