-
Notifications
You must be signed in to change notification settings - Fork 1
/
profilebckp
425 lines (328 loc) · 11.1 KB
/
profilebckp
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
cd /data/data/com.termux/files/usr/share/apache2/default-site/htdocs
alias ll="ls -ahtr"
alias grep="grep --color"
alias scr="cd /storage/emulated/0/Dhamma/scripts"
alias fdg="cd /data/data/com.termux/files/home/fdg"
alias apa="cd /data/data/com.termux/files/usr/share/apache2/default-site/htdocs"
alias cdsutta="cd /data/data/com.termux/files/usr/share/apache2/default-site/htdocs/assets/texts/sutta/sn/sn45"
alias roottxt="cd /storage/emulated/0/Dhamma/suttacentral.net/sc-data/sc_bilara_data/root/pli/ms/sutta"
alias trntxt="cd /storage/emulated/0/Dhamma/suttacentral.net/sc-data/sc_bilara_data/translation/en/sujato/sutta"
alias out="cd /storage/emulated/0/Dhamma/output"
alias res="cd /storage/emulated/0/Dhamma/fdg/result"
alias all="cd /storage/emulated/0/Dhamma/output/allwords"
alias ssssh="ssh -tt [email protected]"
alias asssh="ssh -i /data/data/com.termux/files/home/.ssh/Fdg2.pem [email protected]"
alias rsssh="ssh -tt -p1000 [email protected]"
alias ksssh="ssh -tt -p1000 [email protected]"
alias aksa="cd /data/data/com.termux/files/home/aksamukha ; source bin/activate"
alias dwnl="echo /storage/emulated/0/Download/"
alias sutta="cd /data/data/com.termux/files/usr/share/apache2/default-site/htdocs/suttacentral.net/sc-data/sc_bilara_data/root/pli/ms/sutta"
alias asset="cd /data/data/com.termux/files/usr/share/apache2/default-site/htdocs/assets/texts/sutta/"
function md5checkwrite {
var="$(cat)"
functionname=`echo $var | awk '{print $1}'`
functionfile=~/.shortcuts/${functionname}.sh
content=`echo "$var" | awk 'NR!=1'`
#echo $functionfile $functionname
md5_stdin=$(echo "$content" | md5sum | cut -d" " -f 1)
md5_file=$(md5sum ${functionfile} | cut -d" " -f1)
[[ "$md5_stdin" != "$md5_file" ]] && echo "$content" > $functionfile
}
functionname=grepallwords
finddhamma-nohup () {
cd /storage/emulated/0/Dhamma/fdg/result
nohup bash /storage/emulated/0/Dhamma/fdg/scripts/finddhamma.sh "$@" &
};
echo "${functionname}
#!/data/data/com.termux/files/usr/bin/bash
#cd /storage/emulated/0/Dhamma/fdg/result
#bash /storage/emulated/0/Dhamma/fdg/scripts/finddhamma.sh \"\$@\"
#" | md5checkwrite
functionname=apaswitch
function apaswitch {
bash ~/.shortcuts/apaswitch.sh
}
echo "${functionname}
#!/data/data/com.termux/files/usr/bin/bash
curip=`ifconfig 2>/dev/null | grep inet | grep -v 127.0.0 | awk '{print $2}' | xargs`
echo \$curip
for ip in \$curip
do
echo \$ip
grep \$ip /data/data/com.termux/files/usr/etc/apache2/httpd.conf | grep ServerName
if [[ \$? == \"0\" ]]
then
echo \"\$ip added already\"
else
echo -n
#add ip to httpd conf as a ServerName
#echo \"ServerName \$ip:8080
#added by script\" >> /data/data/com.termux/files/usr/etc/apache2/httpd.conf
fi
done
curl localhost:8080 > /dev/null 2>&1
if [[ \$? == \"0\" ]]
then
#echo stopping
#apachectl stop
echo already running
else
echo starting
apachectl start
#am start --user 0 -n com.android.chrome/com.google.android.apps.chrome.Main
fi
termux-open-url http://localhost:8080/ru
sleep 2
" | md5checkwrite
#
functionname=findallSuttas-th
function find_in_all_Suttas-th.sh {
bash ~/.shortcuts/find_in_all_Suttas-th.sh
}
echo "${functionname}
#!/data/data/com.termux/files/usr/bin/bash
cd /storage/emulated/0/Dhamma/output
bash /storage/emulated/0/Dhamma/scripts/find_in_all_Suttas-th.sh \$@
" | md5checkwrite
functionname=grepallwords
grepallwords-nohup () {
cd /storage/emulated/0/Dhamma/output/
nohup bash /storage/emulated/0/Dhamma/scripts/grepallwords.sh $@ &
}
echo "${functionname}
#!/data/data/com.termux/files/usr/bin/bash
cd /storage/emulated/0/Dhamma/output
bash /storage/emulated/0/Dhamma/scripts/grepallwords.sh \$@
" | md5checkwrite
result.sh()
{
cd /storage/emulated/0/Dhamma/output/
bash ./result.sh $@
}
functionname=sshgrepallwords
function sshgrepallwords.sh {
ssh [email protected] "( cd /home/a0092061/scripts ; bash /home/a0092061/scripts/grepallwords.sh $@ ) &>/dev/null & "
}
echo "${functionname}
#!/data/data/com.termux/files/usr/bin/bash
if [ $# -ne 0 ]
then
pattern=\"\$@\"
else
echo \"enter pattern\"
read \"pattern\"
fi
ssh [email protected] \"( cd /home/a0092061/scripts ; bash /home/a0092061/scripts/grepallwords.sh \$pattern ) &>/dev/null & \"
" | md5checkwrite
functionname=sshresult
function sshresult.sh {
ssh -tt [email protected] "cd /home/a0092061/output/ ; bash -i ./result.sh $@"
}
echo "${functionname}
#!/data/data/com.termux/files/usr/bin/bash
ssh -tt [email protected] \"cd /home/a0092061/output/ ; bash -i ./result.sh \$@\"
" | md5checkwrite
functionname=sshfindallsuttas
function sshfindallsuttas.sh {
ssh [email protected] "( cd /home/a0092061/scripts ; bash /home/a0092061/scripts/find_in_all_Suttas-th.sh $@ ) &>/dev/null &"
}
echo "${functionname}
#!/data/data/com.termux/files/usr/bin/bash
if [ \$# -ne 0 ]
then
pattern=\"\$@\"
else
echo \"enter pattern\"
read \"pattern\"
fi
ssh [email protected] \"(cd /home/a0092061/scripts/ ; bash ./find_in_all_Suttas-th.sh \$pattern ) &>/dev/null &\"
" | md5checkwrite
function sshpsls {
ssh [email protected] " cd /home/a0092061/output; ls -atr |tail -n15 ; echo ; ps -ef| grep '.sh' "
}
#git commit and push
functionname=z_commit_and_push
function commit_and_push {
#cd /storage/emulated/0/Dhamma/scripts
git status
read
git add . && git commit -a -m updates && git push
}
echo "${functionname}
cd /storage/emulated/0/Dhamma/scripts
git add . && git commit -a -m updates && git push
sleep 2
" | md5checkwrite
#rsync-lite
functionname=rsync-lite
echo "$functionname
#!/bin/bash
source /storage/emulated/0/Dhamma/scripts/script_config-termux.sh
#backup
#rsync -azP --include="*.sh" --include="*backup*" --exclude="*" \$user@\$host:\$sourcedir \$scriptdir
#outputs
rsync -azP --exclude="nohup.out" --include="*" \$user@\$host:\$serveroutputdir \$outputdir
" | md5checkwrite
#rsync
functionname=rsync
echo "$functionname
#!/bin/bash
source /storage/emulated/0/Dhamma/scripts/script_config-termux.sh
#backup
#rsync -azP --include="*.sh" --include="*backup*" --exclude="*" \$user@\$host:\$sourcedir \$scriptdir
#outputs
rsync -azP --exclude="nohup.out" \$user@\$host:\$serveroutputdir \$outputdir
" | md5checkwrite
functionname=wordfind
function wordfind.sh {
cd /storage/emulated/0/Dhamma/output/allwords
grep --color=always $@ /storage/emulated/0/Dhamma/output/allwords/sutta_words.txt
}
echo "$functionname
#!/data/data/com.termux/files/usr/bin/bash
cd /storage/emulated/0/Dhamma/output/allwords
grep \$@ /storage/emulated/0/Dhamma/output/allwords/sutta_words.txt
" | md5checkwrite
functionname=backup
function backup.sh {
bash ~/.shortcuts/backup.sh
}
echo "$functionname
#!/data/data/com.termux/files/usr/bin/bash
source /storage/emulated/0/Dhamma/scripts/script_config-termux.sh
backupdir=/storage/emulated/0/Dhamma/scripts/
shortcutdir=/data/data/com.termux/files/home/.shortcuts
backupfile=/storage/emulated/0/Dhamma/scripts/profile_termux_backup
sorcefile=~/.profile
echo -n backup
md5_stdin=\$( md5sum \$backupfile | cut -d\" \" -f 1)
md5_file=\$(md5sum \${sorcefile} | cut -d\" \" -f1)
if [[ \"\$md5_stdin\" != \"\$md5_file\" ]]
then
cp ~/.profile /storage/emulated/0/Dhamma/scripts/profile_termux_backup
#backup
rsync -azP --include=\"/storage/emulated/0/Dhamma/scripts/profile_termux_backup\" --exclude=\"*\" \$scriptdir \$user@\$host:\$sourcedir
fi
ssh [email protected] \"cat ~/.bash_profile\" > /storage/emulated/0/Dhamma/scripts/profile_server_backup
echo ' done'
sleep 2
" | md5checkwrite
functionname=restore
function restore.sh {
bash ~/.shortcuts/restore.sh
}
echo "$functionname
#!/data/data/com.termux/files/usr/bin/bash
backupdir=/storage/emulated/0/Dhamma/scripts/
shortcutdir=/data/data/com.termux/files/home/.shortcuts
# cd $backupdir
# for file in \`ls *_shortcut_backup\`
# do
# echo $file
# name=` echo $file | sed 's@_shortcut_backup@@g' `
# cp ${file} $shortcutdir/$name
# done
echo -n $functionname
backupfile=/storage/emulated/0/Dhamma/scripts/profile_termux_backup
restorefile=~/.profile
md5_stdin=\$( md5sum \${backupfile} | cut -d\" \" -f 1)
md5_file=\$(md5sum \${restorefile} | cut -d\" \" -f1)
[[ \"\$md5_stdin\" != \"\$md5_file\" ]] && cp /storage/emulated/0/Dhamma/scripts/profile_termux_backup ~/.profile
echo ' done'
sleep 2
exit 0
" | md5checkwrite
#git pull
functionname=pull
function pull {
cd /storage/emulated/0/Dhamma/scripts
git pull
restore.sh
}
echo "${functionname}
cd /storage/emulated/0/Dhamma/scripts
git pull
bash ~/.shortcuts/restore.sh
sleep 2
" | md5checkwrite
functionname=sshcommit
function sshcommit {
ssh -p1000 [email protected] "cd /var/www/html
git status
read
git add --all
git commit -a -m "message $@"
git push"
}
echo "${functionname}
ssh -p1000 [email protected] \"cd /var/www/html
git status
read
git add --all
git commit -a -m \\\"message \$@\\\"
git push
read\"
" | md5checkwrite
functionname=sshpull
function sshpull {
echo "server kz"
ssh -p1000 [email protected] "cd /var/www/html
git pull
echo
echo audio
echo
cd assets/audio
git pull"
}
echo "${functionname}
echo 'server kz'
ssh -p1000 [email protected] \"cd /var/www/html
git pull
echo echo audio
echo
cd assets/audio
git pull
" | md5checkwrite
alias comsshpull="commit_and_push && sshpull"
alias sclpull="sshcommit && git pull"
function awkit {
echo awk -F'/' '{print $'$1' }' \| sed 's@_@@g'
}
alias gitall="git pull ; yes '' | commit_and_push ; sshpull ; ssh -p1000 [email protected] 'cd /var/www/html ; bash scripts/checknewlinebylineinscrepo.sh' ; yes '' | sshcommit ; git pull"
export PATH=$PATH:/data/data/com.termux/files/usr/share/apache2/default-site/htdocs/scripts
#alias miss='apa 2>&1 >/dev/null ; bash scripts/mvNewTextsFromDownloads.sh; bash ./scripts/missingtranslations.sh an5; git pull; cd - 2>&1 >/dev/null'
function miss() {
if [[ "$@" == "" ]]
then
args="sn45 -o"
else
args="$@"
fi
apa 2>&1>/dev/null
bash scripts/mvNewTextsFromDownloads.sh
bash ./scripts/missingtranslations.sh $args
git pull
cd - 2>&1>/dev/null
}
function catjq() {
cat $1 | jq -r '.[]'
}
apachectl start
function replacer() {
sed -i 's/осознанности/памятования/g' *
sed -i 's/осознанный/памятующий/g' *
sed -i '/Достопочтенный!/!s/Достопочтенный/почтенный/g' *
sed -i 's/созерцан/наблюден/g' *
sed -i '/друг друга/!s/друг\b/товарищ/g' *
sed -i 's/друзья/товарищи/g' *
sed -i 's/осознанны/памятующи/g' *
sed -i 's/бдитель/сознатель/g' *
sed -i "s/основы\b/установления/g" *
sed -i "s/основах/установлениях/g" *
sed -i "s/основами/установлениями/g" *
sed -i "s/основ\b/установлений/g" *
sed -i "s/неправильн/ошибочн/g" *
}
function checker() {
apa; bash scripts/checknewlinebylineinscrepo.sh | grep -v done ; cd - >/dev/null
}