forked from syphyr/cm_build_scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate_web_cm14
executable file
·102 lines (83 loc) · 2.4 KB
/
update_web_cm14
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
#!/bin/bash
## LineageOS server directory
OTA_DIR=~/android/system/lineageos_updater
## Document Root
DOC_DIR=/var/www/html
## Root of Rom directory in Document Root
ROM_DIR=CyanogenModOTA/builds/full
## Root of CM project directory
PROJECT_DIR=~/android/system/cm-14.1
## Changelog location
CHANGE_FILE=~/android/changelog-cm14.html
## Device name
ANDROID_DEVICE=v500
## End Edit
OUTDIR=$PROJECT_DIR/out/target/product/$ANDROID_DEVICE
## Find file name of ROM and set variable
cd "$OUTDIR"
FILE=$(ls lineage-14.1-*.zip)
## Check if ROM exists before proceding
if [ ! -e "$FILE" ]; then
echo "Build Failed!"
if [ -e `which send_mail_cm14` ]; then
echo ""
echo "Automatic email notification sent for failed build!"
SUBJECT="Build Failed!"
send_mail_cm14 "$SUBJECT"
fi
exit
fi
echo "Build Successful!"
if [ -e `which send_mail_cm14` ]; then
echo ""
echo "Automatic email notification sent for successful build."
SUBJECT="Build Successful for $FILE"
send_mail_cm14 "$SUBJECT"
fi
## Remove extension of file name and set variable
NOEXT=${FILE%\.*}
CHANGELOG="$NOEXT".html
MD5=$(cat lineage-14.1-*.md5sum | cut -d " " -f 1)
ROM_VER=$(echo $FILE | cut -d "-" -f 2)
DATE=$(echo $FILE | cut -d "-" -f 3)
DATE=${DATE:0:4}-${DATE:4:2}-${DATE:6:2}
TIME=$(grep "ro.build.date=" system/build.prop | cut -d " " -f 4)
if [ ${#TIME} == 1 ]; then
TIME=$(grep "ro.build.date=" system/build.prop | cut -d " " -f 5)
fi
ROM_TYPE=$(echo $FILE | cut -d "-" -f 4 | tr A-Z a-z)
FILESIZE=$(stat -c%s "$FILE")
cd "$DOC_DIR"/"$ROM_DIR"
FILE_OLD=$(ls lineage-14.1-*.zip)
echo ""
echo "Removing previous builds on OTA REST Server."
echo ""
rm lineage-14.1-*
cd "$OTA_DIR"
echo "Removing $FILE_OLD from OTA Server"
echo ""
FLASK_APP=app.py flask delrom -f $FILE_OLD
echo ""
echo "Copying ROM ($FILE) to OTA REST Server."
echo ""
cd "$OUTDIR"
cp "$FILE" "$DOC_DIR"/"$ROM_DIR"/
if [ -e "$CHANGE_FILE" ]; then
echo "Copying changelog ($CHANGELOG) to OTA REST Server."
echo ""
cp "$CHANGE_FILE" "$DOC_DIR"/"$ROM_DIR"/"$CHANGELOG"
else
echo "Changelog not found!"
echo ""
exit
fi
cd "$OTA_DIR"
echo "Adding $FILE to OTA Server"
echo ""
FLASK_APP=app.py flask addrom -f $FILE -d $ANDROID_DEVICE -v $ROM_VER -t "$DATE $TIME" -r $ROM_TYPE -m $MD5 -s $FILESIZE -u http://192.168.1.5/$ROM_DIR/$FILE -c http://192.168.1.5/$ROM_DIR/$CHANGELOG
echo ""
echo "Done."
echo ""
#echo "Starting OTA Server"
#echo ""
#FLASK_APP=app.py flask run