-
Notifications
You must be signed in to change notification settings - Fork 108
/
juci-update
executable file
·96 lines (80 loc) · 2.68 KB
/
juci-update
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
#!/bin/sh
set -e
WWW="$1"
MODE="$2"
MODE=${MODE:="RELEASE"}
#if [ "$MODE" = "RELEASE" ]; then
# JS_WILDCARD="*.js.gz"
# CSS_WILDCARD="*.css.gz"
#else
#fi
JS_WILDCARD="*.js"
CSS_WILDCARD="*.css"
echo "Using mode: $MODE..."
if [ -n "$1" ]; then
WWW="$1"
elif [ -d /www ]; then
WWW="/www"
elif [ -d /var/www ]; then
WWW="/var/www"
fi
#rm -f $WWW/__all.js
#for file in $WWW/js/*.js; do
# cat $file >> $WWW/__all.js
#done
#rm -f $WWW/__all.css
#for file in $WWW/css/*.css; do
# cat $file >> $WWW/__all.css
#done
[ "$MODE" = "RELEASE" ] && {
for file in `find ${WWW} -type f | grep -v "\.gz" | grep -v cgi-bin`; do
echo "Compressing ${file}...";
#gzip -f ${file}
done
}
# now update the index file to include any extra files
INDEX=${WWW}/index.html
#gunzip -f ${INDEX}.gz
mkdir -p ${WWW}/js;
mkdir -p ${WWW}/css;
STYLES_HTML="" #"<link href='__all.css' rel='stylesheet' type='text/css' />"
SCRIPTS_HTML="" #"<script src='__all.js'></script>"
for file in `find ${WWW}/css -name "$CSS_WILDCARD" | sort`; do
style=${file#${WWW}/}
style=${style%.gz}
echo "Adding $style to index"
STYLES_HTML="${STYLES_HTML}<link href='${style}' rel='stylesheet' type='text/css' />"
done
#sed "/<!-- STYLES_BEGIN -->/,/<!-- STYLES_END -->/c<!-- STYLES_BEGIN -->${STYLES_HTML}<!-- STYLES_END -->" ${INDEX}
#cat ${INDEX} | tr -d '\n' | sed "s/<!-- STYLES_BEGIN -->.*<!-- STYLES_END -->/<!-- STYLES_BEGIN -->${STYLES_HTML}<!-- STYLES_END -->/"
#cat /www/index.html | tr -d '\n' | sed "s/<!-- STYLES_BEGIN -->.*<!-- STYLES_END -->/<!-- STYLES_BEGIN -->test<!-- STYLES_END -->/g"
for file in `find ${WWW}/js -name "$JS_WILDCARD" | sort`; do
echo "Adding $file to index"
JSFILE=${file#${WWW}/}
JSFILE=${JSFILE%.gz}
SCRIPTS_HTML="${SCRIPTS_HTML}<script src=\"${JSFILE}\"></script>"
done
#cat ${INDEX} | tr -d '\n' | sed "s/<!-- SCRIPTS_BEGIN -->.*<!-- SCRIPTS_END -->/<!-- SCRIPTS_BEGIN -->${SCRIPTS_HTML}<!-- SCRIPTS_END -->/"
# workaround because stupid f**ing sed is not working on busybox #@"#"!"¤¤"#!"¤!½!!!
echo "<!doctype html>
<html lang='en' >
<head>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>
<title>JUCI</title><!--ng-bind='title'-->
<link rel='shortcut icon' href='/favicon.ico' type='image/x-icon' />
${STYLES_HTML}
</head>
<body role='document'>
<div ng-hide='juci_loaded' class='juci-loadsplash'>
<div style='position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 1%; height: 1%;'>
<i class='fa fa-2x fa-spin fa-spinner text-success'></i>
</div>
</div>
<div ui-view='content' style='min-height: 1000px;'></div>
${SCRIPTS_HTML}
</body>
</html>" > ${INDEX}
#if [ "$MODE" = "RELEASE" ]; then
# gzip -f ${INDEX}
#fi