-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
otdm2yssSiteDebian_postinst
71 lines (54 loc) · 1.74 KB
/
otdm2yssSiteDebian_postinst
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
# dpkgDir is added on auto build directory for the site in ./otdm2yssSites.sh
echo "installing ... "${dpkgDir}
otdmHome="/data/data/com.termux/files/home/.otdm"
yssSs=`cat ${otdmHome}/config.json | jq '.otdm.prefix' -r `"/yss/sites/sites.json"
nrHost=`cat ${otdmHome}/config.json | jq '.["node-red"].host' -r`
nrPort=`cat ${otdmHome}/config.json | jq '.["node-red"].port' -r`
yssUrl="http://"$nrHost":"$nrPort"/yss/index.html"
cp ${yssSs} ${yssSs}"_"`date +%y%m%d%H%M%S`
echo "yss/sites/sites.json .... "${yssSs}
jAdd=`cat $yssSs | jq '. .dirs+=["'${dpkgDir}'"]'`
echo "jAdd"
echo ${jAdd} | jq '.'
echo ${jAdd} | jq '.' > ${yssSs}
echo "wget for "$yssUrl
wget "$yssUrl" -O `tempfile`
if [ $? = "0" ];then
echo "OK"
else
echo "no ok :("
fi
# old path ---------------
if [ "0" = "1" ]; then
echo "update sites.json for yss ...."
otdmH=`cat /data/data/com.termux/files/home/.otdm/config.json | jq '.otdm.prefix' -r`
echo "otdm home: "${otdmH}
sPath=${otdmH}"/yss/sites/sites.json"
jBase=`cat ${sPath} | jq '.'`
echo "jBase"
echo ${jBase}
jBase='{"dirs":'`cat ${sPath} | jq '.dirs'`"}"
echo "jBase after sites ..."
echo ${jBase} | jq '.'
ds=""
for d in `ls /data/data/com.termux/files/home/.otdm/ | grep yss-`; do
#echo $d
if [ "$ds" == "" ]
then
ds='"'${otdmH}'/'$d'"'
else
ds='"'${otdmH}"/"$d'",'${ds}
fi
done
dsTrim=${ds}
echo "j ext trim:["${dsTrim}"]"
jBase=`echo ${jBase} | jq '. |= . + {"externals":['${dsTrim}']}'`
#echo "ds: "${ds}
echo "new jBase ..."
echo ${jBase} | jq '.'
echo "making backup of current .sites.json...."
cp ${sPath} ${sPath}"_"`date +%y%m%d%H%M%S`
echo "flush it ...."
echo ${jBase} | jq '.' > ${sPath}
cowsay -f moose " ok yss/sites/sites.json REBUILD !"
fi