-
Notifications
You must be signed in to change notification settings - Fork 1
/
sync-united
executable file
·444 lines (375 loc) · 14 KB
/
sync-united
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
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
#!/usr/bin/bash
#
# +-----------------------------------------------------------------------------------+
# | Copyright (C) 2022 David Vasquez |
# | MIT license |
# | Permission is hereby granted, free of charge, to any person obtaining a copy of |
# | this software and associated documentation files (the "Software"), to deal in the |
# | Software without restriction, including without limitation the rights to use, |
# | copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the |
# | Software, and to permit persons to whom the Software is furnished to do so, |
# | subject to the following conditions: |
#
# | The above copyright notice and this permission notice shall be included in all |
# | copies or substantial portions of the Software. |
#
# | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
# | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
# | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
# | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
# | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
# | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
# +-----------------------------------------------------------------------------------+
# | This code is designed, written and maintained by David Vasquez |
# | Any questions, comments or advice on this code |
# | should be addressed to: |
# | [email protected] |
# +-----------------------------------------------------------------------------------+
# The script is a shit because it doesn't has 60 lines ;)
# Requires: pinentry dnf-plugins-core createrepo_c repoview gnupg2 rsync wget openssl onedrive libappstream-glib-builder github-release openssh-clients xz unitedrpms rpm-sign findutils
usage() {
echo ""
echo -e '\e[33m -s sync\e[0m'
echo " synchronizes the cloud"
echo "Usage: $0 -s 35"
echo ""
exit 1
}
readargs() {
while [ "$#" -gt 0 ] ; do
case "$1" in
-s)
if [ "$2" ] ; then
task="$2"
shift ; shift
else
echo "Missing a value for $1."
echo
shift
usage
fi
;;
*)
echo "Unknown option or argument $1."
echo
shift
usage
exit
;;
esac
done
}
upd_hosts() {
cat /root/OneDrive/unitedrpms/conocidos_host >> /github/home/.ssh/known_hosts
}
sf_back() {
pushd ${motherpath}
#rsync -avP -e "ssh -o StrictHostKeyChecking=no" --backup "${user}@frs.sourceforge.net:/home/frs/project/unitedrpms/${task}/" ${motherpath}/
rsync -avP -e "ssh -o StrictHostKeyChecking=no" -P --delete --stats --backup "${user}@frs.sourceforge.net:/home/frs/project/unitedrpms/${task}/" ${motherpath}/
# rsync -avP --backup "${user}@frs.sourceforge.net:/home/frs/project/muchpack/${task}/" ${motherpath}/
popd
}
clean_old() {
echo -e "\e[31mDelete old versions...\e[0m"
[ -d ${motherpath}/x86_64/ ] && rm -f $(dnf repomanage --keep=1 --old ${motherpath}/x86_64/)
[ -d ${motherpath}/x86_64/debug/ ] && rm -f $(dnf repomanage --keep=1 --old ${motherpath}/x86_64/debug/)
[ -d ${motherpath}/srpm/ ] && rm -f $(dnf repomanage --keep=1 --old ${motherpath}/srpm/)
}
make_repo() {
rm -rf repodata/
#createrepo .
createrepo_c --database --compatibility ./
repoview .
}
prepare_sign() {
cp -f /root/.rpmmacros /github/home/.rpmmacros
/usr/bin/gpg2 --import --pinentry-mode=loopback --passphrase-file=/root/.outsign /root/.vitamin/my-public-key.asc
/usr/bin/gpg2 --import --pinentry-mode=loopback --passphrase-file=/root/.outsign /root/.vitamin/my-private-key.asc
}
sign_repo() {
echo -e "\e[31mSign repodata...\e[0m"
/usr/bin/gpg2 --pinentry-mode=loopback --passphrase-file=/root/.outsign --local-user 'unitedrpms' --yes --detach-sign --armor $PWD/repodata/repomd.xml
}
sign_rpm() {
echo -e "\e[31mSign rpms...\e[0m"
if ls -1qA ${motherpath}/x86_64/ | grep -q .
then ! echo "x86_64 directory is not empty"
pushd ${motherpath}/x86_64/
prepare_sign
rpm --addsign *.rpm
make_repo
sign_repo
repoview .
else echo "x86_64 directory is empty"
fi
if ls -1qA ${motherpath}/x86_64/debug/ | grep -q .
then ! echo "x86_64 debug directory is not empty"
pushd ${motherpath}/x86_64/debug/
rpm --addsign *.rpm
make_repo
sign_repo
repoview .
else echo "x86_64 debug directory is empty"
fi
if ls -1qA ${motherpath}/srpm/ | grep -q .
then ! echo "srpm directory is not empty"
pushd ${motherpath}/srpm/
rpm --addsign *.rpm
make_repo
sign_repo
repoview .
else "echo srpm directory is empty"
fi
#rpm --delsign *rpm
#rpm --define "_gpg_name unitedrpms" --addsign *.rpm
}
sfsync() {
echo -e "\e[31mSync with Sf...\e[0m"
pushd ${motherpath}
rsync -rav -e "ssh -o StrictHostKeyChecking=no" --delete x86_64/repoview/ ${user}@frs.sourceforge.net:/home/project-web/unitedrpms/htdocs/x86_64/repoview/
rsync -rav -e "ssh -o StrictHostKeyChecking=no" --delete x86_64/repoview/ ${user}@frs.sourceforge.net:/home/project-web/unitedrpms/htdocs/${task}/x86_64/repoview/
# rsync -rav -e "ssh -o StrictHostKeyChecking=no" --delete x86_64/debug/repoview/ ${user}@frs.sourceforge.net:/home/project-web/unitedrpms/htdocs/x86_64/debug/repoview/
# rsync -rav -e "ssh -o StrictHostKeyChecking=no" --delete x86_64/debug/repoview/ ${user}@frs.sourceforge.net:/home/project-web/unitedrpms/htdocs/${task}/x86_64/debug/
rsync -rav -e "ssh -o StrictHostKeyChecking=no" --delete srpm/repoview/ ${user}@frs.sourceforge.net:/home/project-web/unitedrpms/htdocs/srpm/repoview/
rsync -rav -e "ssh -o StrictHostKeyChecking=no" --delete srpm/repoview/ ${user}@frs.sourceforge.net:/home/project-web/unitedrpms/htdocs/${task}/srpm/
# rsync -av --ignore-existing x86_64/ ${user}@frs.sourceforge.net:/home/frs/project/unitedrpms/${task}/x86_64/
rsync -av -e "ssh -o StrictHostKeyChecking=no" --delete x86_64/repodata/ ${user}@frs.sourceforge.net:/home/frs/project/unitedrpms/${task}/x86_64/repodata/
rsync -av -e "ssh -o StrictHostKeyChecking=no" --delete x86_64/debug/repodata/ ${user}@frs.sourceforge.net:/home/frs/project/unitedrpms/${task}/x86_64/debug/repodata/
rsync -av -e "ssh -o StrictHostKeyChecking=no" --delete x86_64/repoview/ ${user}@frs.sourceforge.net:/home/frs/project/unitedrpms/${task}/x86_64/repoview/
rsync -rav -e "ssh -o StrictHostKeyChecking=no" --delete x86_64/ ${user}@frs.sourceforge.net:/home/frs/project/unitedrpms/${task}/x86_64/
rsync -rav -e "ssh -o StrictHostKeyChecking=no" --delete x86_64/debug/ ${user}@frs.sourceforge.net:/home/frs/project/unitedrpms/${task}/x86_64/debug/
rsync -rav -e "ssh -o StrictHostKeyChecking=no" --delete srpm/ ${user}@frs.sourceforge.net:/home/frs/project/unitedrpms/${task}/srpm/
rsync -rav -e "ssh -o StrictHostKeyChecking=no" --delete . ${user}@frs.sourceforge.net:/home/frs/project/unitedrpms/${task}/
if [[ $? -gt 0 ]]; then
echo 'ERROR rsymc failed'
exit 1
else
echo 'Done rsync succes'
fi
popd
}
osdnsync() {
echo -e "\e[31mSync with OSDN...\e[0m"
pushd ${motherpath}
rm -rf srpm/*
rm -rf x86_64/repoview/*
rm -rf x86_64/debug/*
#rsync -rav -e "ssh -o StrictHostKeyChecking=no" --delete . ${userB}@storage-in.osdn.net:/storage/groups/u/un/unitedrpms/${task}/
#[email protected]:/storage/groups/u/un/unitedrpms/
rsync -av -e "ssh -o StrictHostKeyChecking=no" --delete x86_64/repodata/ ${userB}@storage.osdn.net:/storage/groups/u/un/unitedrpms/${task}/x86_64/repodata/
rsync -rav -e "ssh -o StrictHostKeyChecking=no" --delete x86_64/ ${userB}@storage.osdn.net:/storage/groups/u/un/unitedrpms/${task}/x86_64/
popd
}
auth_mg() {
rm -f /root/mppass.tar.xz
rm -rf /root/.config/onedrive/
wget -c -P /root/ https://github.com/UnitedRPMS-devel/unibuild/releases/download/auth/mppass.tar.xz
pushd /root
mkdir -p /root/.config/onedrive/
mkdir -p /github/home/.config/onedrive/
tar xJf mppass.tar.xz -C /root/.config/onedrive/
tar xJf mppass.tar.xz -C /github/home/.config/onedrive/
pushd /root/.config/onedrive/
rm -f $PWD/config
rm -f $PWD/skip_file
openssl rsautl -decrypt -inkey ./clave.pem -in key.enc -out key.txt
openssl enc -aes-256-cbc -d -pass file:key.txt -in auth.enc -pbkdf2 -out refresh_token
#openssl enc -aes-256-cbc -d -pass file:key.txt -in item.enc -pbkdf2 -out items.sqlite3
sed -i "s|RELEASE|${task}|g" /root/.config/onedrive/sync_list
rm -f *.enc
rm -f *.pem
rm -f *.txt
rm -f /root/mppass.tar.xz
popd
pushd /github/home/.config/onedrive
rm -f $PWD/config
rm -f $PWD/skip_file
openssl rsautl -decrypt -inkey ./clave.pem -in key.enc -out key.txt
openssl enc -aes-256-cbc -d -pass file:key.txt -in auth.enc -pbkdf2 -out refresh_token
#openssl enc -aes-256-cbc -d -pass file:key.txt -in item.enc -pbkdf2 -out items.sqlite3
sed -i "s|RELEASE|${task}|g" /github/home/.config/onedrive/sync_list
rm -f *.enc
rm -f *.pem
rm -f *.txt
rm -f /root/mppass.tar.xz
popd
popd
}
mdow() {
rm -f ${raiz}/.megatmp.*
echo -e "\e[31mDownloading updates...\e[0m"
auth_mg
onedrive -v --synchronize
}
Cardow() {
echo -e "\e[31mDownloading updates of travis-rpm-builder...\e[0m"
curl -s https://api.github.com/repos/UnitedRPMs/travis-rpm-builder/releases | grep browser_download_url | cut -d '"' -f 4 > $HOME/urls_mock_travis
utra=$HOME/urls_mock_travis
while IFS= read -r urlst; do
wget -c -P ${raiz}/ $urlst
done <"$utra"
}
work_directory() {
rm -rf ${motherpath}
rm -rf $HOME/3{0..9}
rm -rf $HOME/f3{0..9}
rm -rf $HOME/4{0..9}
rm -rf $HOME/f4{0..9}
mkdir -p ${motherpath}
mkdir -p "${raiz}"
mkdir -p ${motherpath}/srpm/repoview/
mkdir -p ${motherpath}/srpm/repodata/
mkdir -p ${motherpath}/x86_64/debug/
mkdir -p ${motherpath}/x86_64/repodata/
}
m_mv() {
pushd "${raiz}"
[ ! -d ${motherpath}/x86_64/debug/ ] && mkdir -p ${motherpath}/x86_64/debug/
[ ! -d ${motherpath}/srpm/ ] && mkdir -p ${motherpath}/srpm/
mv -f *.src.rpm ${motherpath}/srpm/
mv -f *-debuginfo-*.rpm ${motherpath}/x86_64/debug/
mv -f *-debugsource-*.rpm ${motherpath}/x86_64/debug/
mv -f *.rpm ${motherpath}/x86_64/
# We don't need debug in base repo
mv -f ${motherpath}/x86_64/*-debuginfo-*.rpm ${motherpath}/x86_64/debug/
mv -f ${motherpath}/x86_64/*-debugsource-*.rpm ${motherpath}/x86_64/debug/
popd
mkdir -p /root/OneDrive/unitedrpms/updates/${task} && pushd /root/OneDrive/unitedrpms/updates/${task}
[ ! -d ${motherpath}/x86_64/debug/ ] && mkdir -p ${motherpath}/x86_64/debug/
[ ! -d ${motherpath}/srpm/ ] && mkdir -p ${motherpath}/srpm/
mv -f *.src.rpm ${motherpath}/srpm/
mv -f *-debuginfo-*.rpm ${motherpath}/x86_64/debug/
mv -f *-debugsource-*.rpm ${motherpath}/x86_64/debug/
mv -f *.rpm ${motherpath}/x86_64/
# We don't need debug in base repo
mv -f ${motherpath}/x86_64/*-debuginfo-*.rpm ${motherpath}/x86_64/debug/
mv -f ${motherpath}/x86_64/*-debugsource-*.rpm ${motherpath}/x86_64/debug/
popd
}
clean_trash() {
find $PWD/ -name "*~" -exec rm -f {} ${motherpath}/ \;
}
job() {
[ -d ${motherpath}/x86_64/ ] && pushd ${motherpath}/x86_64/
echo "x86_64 task"
clean_old
sign_rpm
clean_trash
make_repo
sign_repo
popd
[ -d ${motherpath}/x86_64/debug/ ] && pushd ${motherpath}/x86_64/debug/
echo "debug task"
clean_old
sign_rpm
clean_trash
make_repo
sign_repo
popd
[ -d ${motherpath}/srpm/ ] && pushd ${motherpath}/srpm/
echo "srpm task"
clean_old
sign_rpm
clean_trash
make_repo
sign_repo
popd
}
hosts_k() {
onedrive -v --synchronize
}
checkfiles() {
if [ "$(ls -A ${raiz})" ]; then
echo "Great ${raiz} is not Empty"
else
echo "${raiz} is Empty"
exit 0
fi
}
metadata_sync() {
pushd ${motherpath}/x86_64/
rm -rf $PWD/debug/
rm -rf $PWD/repoview/
rm -rf $PWD/repodata/
mkdir -p $PWD/tmp/
mkdir -p $PWD/appstream-data/
appstream-builder --max-threads=8 --log-dir=./logs/ --packages-dir=$PWD --temp-dir=$PWD/tmp/ --output-dir=$PWD/appstream-data/ --basename="unitedrpms" --origin="unitedrpms" --enable-hidpi
popd
}
metadata_tag_git() {
cp -f /root/.bashrc /github/home/.bashrc
pushd ${motherpath}/x86_64/
source ~/.bashrc
date_data=$(date "+%Y.%m.%d")
github-release delete \
--user UnitedRPMs \
--repo unitedrpms-appstream-data \
--tag ${date_data}
github-release release \
--user UnitedRPMs \
--repo unitedrpms-appstream-data \
--tag ${date_data} \
--name "unitedrpms-appdata" \
--description "Not a movie, contrary to popular opinion. The magic is here!"
ls $PWD/appstream-data/ > /tmp/file_metadata
echo 'files listed...'
cat /tmp/file_metadata
flm=/tmp/file_metadata
while IFS= read -r mcl; do
source ~/.bashrc
github-release upload \
--user UnitedRPMs \
--repo unitedrpms-appstream-data \
--tag ${date_data} \
--name $mcl \
--file $PWD/appstream-data/$mcl
done <"$flm"
popd
}
run_ping() {
status=$(curl -I "https://sourceforge.net/projects/unitedrpms/" 2> /dev/null | head -n 1 | cut -d ' ' -f 2)
if [ ${status} -eq 200 ]; then
echo 'PING OK'
else
echo 'SF or your conection is DOWN!'
exit 1
fi
}
#-----------------------
# BEGIN THE PROGRAM
readargs "$@"
user=kuboosoft
userB=davidva
#raiz="${/root/OneDrive/unitedrpms/updates/$task:-/github/OneDrive/unitedrpms/updates/$task}"
raiz="/github/home/OneDrive/unitedrpms/updates/${task}"
motherpath="/github/home/${task}"
#motherpath="${/root/$task:-/github/$task}"
if [ ${task} = 31 ] || [ ${task} = 32 ] || [ ${task} = 33 ] || [ ${task} = 34 ] || [ ${task} = 35 ] || [ ${task} = 36 ]; then
echo -e "\e[32msync limited to F31-F36...\e[0m"
echo -e "\e[32mCurrent sync with F${task} ...\e[0m"
else
echo 'ERROR'
echo -e "\e[32mSorry, check if exists the current release...\e[0m"
exit
fi
run_ping
work_directory
ssh-agent
eval `ssh-agent`
cp -f /root/.ssh/id_ecdsa /github/home/.ssh/id_ecdsa
ssh-add ~/.ssh/id_ecdsa
mdow
upd_hosts
sf_back
#Cardow
checkfiles
m_mv
job
sfsync
#osdnsync
#hosts_k
metadata_sync
metadata_tag_git
rm -rf "${motherpath}"
rm -rf "${raiz}"
echo 'DONE'