This repository has been archived by the owner on Nov 13, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
install.sh
executable file
·605 lines (505 loc) · 24.2 KB
/
install.sh
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
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
#!/bin/bash
#: Title : Pepper&Carrot Installer and Updater ; install.sh
#: Author : David REVOY < [email protected] >, Mjtalkiewicz (aka Player_2)
#: License : GPL
scriptversion="1.0b"
# a Bash script to install all the source of Pepper&Carrot inside a folder
# Usage : Launch the script on a terminal, and follow the instructions.
# Dependencies needed:
# bash
# git
# wget
# unzip
# Utils
export scriptpath="`dirname \"$0\"`"
export projectname="${PWD##*/}"
export workingpath="${PWD}"
export isodate=$(date +%Y-%m-%d)
export version=$(date +%Y-%m-%d_%Hh%M)
export versiondaily=$(date +%Y%m%d)
export svgcount=0
export Off=$'\e[0m'
export Purple=$'\e[1;35m'
export Blue=$'\e[1;34m'
export Green=$'\e[1;32m'
export Red=$'\e[1;31m'
export Yellow=$'\e[1;33m'
export White=$'\e[1;37m'
export BlueBG=$'\e[1;44m'
export RedBG=$'\e[1;41m'
export PurpleBG=$'\e[1;45m'
export Black=$'\e[1;30m'
clear
echo ""
echo " ${Yellow}${PurpleBG} ${Off}"
echo " ${Yellow}${PurpleBG} -= Pepper&Carrot Installer =- ${Off}"
echo " ${Yellow}${PurpleBG} ${Off}"
echo " ${Yellow}${PurpleBG} /|_____|\ ${Off}"
echo " ${Yellow}${PurpleBG} / ' ' ' \ ${Off}"
echo " ${Yellow}${PurpleBG} < ( . . ) > ${Off}"
echo " ${Yellow}${PurpleBG} < '◡ > ${Off}"
echo " ${Yellow}${PurpleBG} '''| \ ${Off}"
echo " ${Yellow}${PurpleBG} ${Off}"
echo " ${Yellow}${PurpleBG} ${Off}"
echo ""
echo ""
echo "${Yellow} * version: $scriptversion ${Off}"
echo ""
# Config.sh external file
# (a configuration file ignored by git)
# it store: path + ftp login and password
if [ -f "$scriptpath"/config.sh ]; then
source "$scriptpath"/config.sh
echo "* config.sh found"
echo ""
echo "${Green} FTP user: $configuser ${Off}"
else
echo "${Red} * config.sh not found, creating it${Off}"
# Write file
echo '#!/bin/bash' > "$scriptpath"/config.sh
echo '' >> "$scriptpath"/config.sh
echo '# Global config' >> "$scriptpath"/config.sh
echo 'export projectroot="/home/username/peppercarrot"' >> "$scriptpath"/config.sh
echo '' >> "$scriptpath"/config.sh
echo '# Uploaders' >> "$scriptpath"/config.sh
echo 'confighost="ftp.yourhostname.net"' >> "$scriptpath"/config.sh
echo 'configuser="username"' >> "$scriptpath"/config.sh
echo 'configpass="password"' >> "$scriptpath"/config.sh
# Verbose
echo "${Yellow} ==> done${Off}"
echo " * please configure your config.sh file now"
echo " * and launch this script again"
exit
fi
# Define absolute path to folders in usage
export folder_webcomics="$projectroot"/webcomics
export folder_scripts="$projectroot"/scripts
export libpath="$projectroot"/scripts/lib
# Runtime counter: start
script_runtime_start=$(date +"%s")
cd "$projectroot"
echo "${Green} Install path: $projectroot ${Off}"
echo ""
echo " Is everything correct? "
echo ""
echo -n " [Enter] to continue, [Ctrl+C] to cancel."
read end
echo ""
# Start with install
# ==================
echo ""
echo "${Blue} [ INSTALL ] ${Off}"
echo "${Blue} ########################################################################## ${Off}"
echo ""
echo "${Yellow} [ REPOSITORIES ] ${Off}"
echo "${Yellow} =-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ${Off}"
# Install a pretty launcher, for the OS menu.
if [ -f $HOME/.local/share/applications/peppercarrot-menu.desktop ]; then
echo " * $HOME/.local/share/applications/peppercarrot-menu.desktop found"
else
echo "${Green} * Pepper&Carrot launcher not found, creating it in $HOME/.local/share/applications/peppercarrot-menu.desktop. ${Off}"
# icon creation
echo '[Desktop Entry]' > $HOME/.local/share/applications/peppercarrot-menu.desktop
echo 'Comment=All services, uploading, rendering and more for managing Pepper&Carrot project' >> $HOME/.local/share/applications/peppercarrot-menu.desktop
echo 'Terminal=false' >> $HOME/.local/share/applications/peppercarrot-menu.desktop
echo 'Categories=Development' >> $HOME/.local/share/applications/peppercarrot-menu.desktop
echo 'Name=Peppercarrot Main Menu' >> $HOME/.local/share/applications/peppercarrot-menu.desktop
echo 'Exec='$projectroot'/scripts/peppercarrot-main-menu.sh' >> $HOME/.local/share/applications/peppercarrot-menu.desktop
echo 'Type=Application' >> $HOME/.local/share/applications/peppercarrot-menu.desktop
echo 'Icon='$projectroot'/scripts/lib/peppercarrot_icon.png' >> $HOME/.local/share/applications/peppercarrot-menu.desktop
# permission right: execute
chmod +x $HOME/.local/share/applications/peppercarrot-menu.desktop
fi
# Check and install repository for scripts
if [ -d "$projectroot"/scripts ]; then
echo " * "$projectroot"/scripts found"
else
echo "${Green} * "$projectroot"/scripts not found, cloning git repository. ${Off}"
git clone https://github.com/Deevad/peppercarrot.git scripts
fi
if [ -f "$projectroot"/config.sh ]; then
echo "${Green} * "$projectroot"/config.sh found, moving it to "$projectroot"/scripts/config.sh ${Off}"
cp "$projectroot"/config.sh "$projectroot"/scripts/config.sh
fi
# Check and install repository for fonts
if [ -d "$projectroot"/fonts ]; then
echo " * "$projectroot"/fonts found"
else
echo "${Green} * "$projectroot"/fonts not found, cloning git repository. ${Off}"
git clone https://github.com/Deevad/peppercarrot_fonts.git fonts
fi
# Check and install repository for wiki
if [ -d "$projectroot"/wiki ]; then
echo " * "$projectroot"/wiki found"
else
echo "${Green} * "$projectroot"/wiki not found, cloning git repository. ${Off}"
git clone https://github.com/Deevad/peppercarrot.wiki.git wiki
fi
# Check and install repository for www-lang
if [ -d "$projectroot"/www-lang ]; then
echo " * "$projectroot"/www-lang found"
else
echo "${Green} * "$projectroot"/www-lang not found, cloning git repository. ${Off}"
git clone https://github.com/Deevad/peppercarrot_website_translation.git www-lang
fi
# Check and install repository for webcomic
if [ -d "$projectroot"/webcomics ]; then
echo " * "$projectroot"/webcomics found"
else
echo "${Green} * "$projectroot"/webcomics not found, building... ${Off}"
mkdir webcomics
fi
echo ""
echo "${Yellow} [ DATABASE ] ${Off}"
echo "${Yellow} =-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ${Off}"
# Retrieve a fresh list of episode from server
echo "* Downloading http://www.peppercarrot.com/0_sources/.episodes-list.md"
wget http://www.peppercarrot.com/0_sources/.episodes-list.md -O "$projectroot"/webcomics/.episodes-list.md
# parse it as an array
cd "$projectroot"/webcomics/
readarray input < .episodes-list.md
# Big loop on episode published so far
# Creating and updating episodes
echo ""
echo "${Yellow} [ EPISODES ] ${Off}"
echo "${Yellow} =-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ${Off}"
for episodes in "${input[@]}"; do
episodecleanstring=$(echo $episodes | sed -e 's/\r//g')
if [ -d "$projectroot"/webcomics/"$episodecleanstring" ]; then
echo "* $episodecleanstring found"
# folder basic sanity check
if [ ! -d "$projectroot"/webcomics/"$episodecleanstring"/lang/.git ]; then
echo "${Green} lang is missing ${Off}"
fi
if [ ! -d "$projectroot"/webcomics/"$episodecleanstring"/zip ]; then
echo "${Green} zip is missing ${Off}"
fi
else
echo "${Green}* $episodecleanstring is missing ${Off}"
echo "Downloading and setting up. Please wait while downloading."
mkdir -p "$projectroot"/webcomics/"$episodecleanstring"
# trim folder name to keep only the episode number
episode_number=${episodecleanstring:2:2}
# GIT: clone the lang folder
echo "[GIT] cloning https://github.com/Deevad/peppercarrot_ep"$episode_number"_translation.git"
git clone https://github.com/Deevad/peppercarrot_ep"$episode_number"_translation.git "$projectroot"/webcomics/"$episodecleanstring"/lang
# WGET: get *.kra artwork big zip of sources
echo "[WGET] Downloading http://www.peppercarrot.com/0_sources/"$episodecleanstring"/zip/"$episodecleanstring".zip"
# wget needs URL string compatible
episode_url=$(echo "$episodecleanstring" | sed -e 's/%/%25/g' -e 's/ /%20/g' -e 's/!/%21/g' -e 's/"/%22/g' -e 's/#/%23/g' -e 's/\$/%24/g' -e 's/\&/%26/g' -e 's/'\''/%27/g' -e 's/(/%28/g' -e 's/)/%29/g' -e 's/\*/%2a/g' -e 's/+/%2b/g' -e 's/,/%2c/g' -e 's/-/%2d/g' -e 's/\./%2e/g' -e 's/\//%2f/g' -e 's/:/%3a/g' -e 's/;/%3b/g' -e 's//%3e/g' -e 's/?/%3f/g' -e 's/@/%40/g' -e 's/\[/%5b/g' -e 's/\\/%5c/g' -e 's/\]/%5d/g' -e 's/\^/%5e/g' -e 's/_/%5f/g' -e 's/`/%60/g' -e 's/{/%7b/g' -e 's/|/%7c/g' -e 's/}/%7d/g' -e 's/~/%7e/g')
mkdir -p "$projectroot"/webcomics/"$episodecleanstring"/zip
wget http://www.peppercarrot.com/0_sources/"$episode_url"/zip/"$episode_url".zip -O "$projectroot"/webcomics/"$episodecleanstring"/zip/"$episodecleanstring".zip
if [ -f "$projectroot"/webcomics/"$episodecleanstring"/zip/"$episodecleanstring".zip ]; then
echo " * zip file downloaded"
echo "[UNZIP] Extract zipped *.kra artworks"
unzip "$projectroot"/webcomics/"$episodecleanstring"/zip/"$episodecleanstring".zip -d "$projectroot"/webcomics/"$episodecleanstring"
echo "${Green}[DONE] ${Off}"
else
echo "${Red}[ERROR] file couldn't be downloaded${Off}"
fi
echo ""
echo ""
fi
done
## Symlink everything to finish the instalation:
echo ""
echo "${Yellow} [ SYMLINKS ] ${Off}"
echo "${Yellow} =-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ${Off}"
# 0_sources: symlink all webcomics to the root of the local website
if [ -d "$projectroot"/www/peppercarrot/0_sources ]; then
echo "* $projectroot/www/peppercarrot/0_sources found"
else
echo "${Green}* $projectroot/www/peppercarrot/0_sources not found${Off}"
echo "${Yellow} => creating symlink ${Off}"
mkdir -p "$projectroot"/www/peppercarrot
ln -s "$projectroot"/webcomics/ $projectroot/www/peppercarrot/0_sources
fi
# Artworks: symlink artwork at root inside the webcomic/0ther folder to get sync via FTP on the fly.
if [ -d "$projectroot"/webcomics/0ther/artworks ]; then
echo "* $projectroot/webcomics/0ther/artworks found"
else
echo "${Green}* $projectroot/webcomics/0ther/artworks not found${Off}"
echo "${Yellow} => creating symlink ${Off}"
ln -s "$projectroot"/webcomics/0ther/artworks/ "$projectroot"/artworks
fi
# Wiki: symlink root wiki folder inside the local website
if [ -d "$projectroot"/www/peppercarrot/data/wiki ]; then
echo "* $projectroot/www/peppercarrot/data/wiki found"
else
echo "${Green}* $projectroot/www/peppercarrot/data/wiki not found${Off}"
echo "${Yellow} => creating symlink ${Off}"
mkdir -p "$projectroot"/www/peppercarrot/data
ln -s "$projectroot"/wiki "$projectroot"/www/peppercarrot/data/wiki
fi
# Fonts: symlink git folder to a subfolder into local/share of active user. So the fonts are in use.
if [ -d $HOME/.local/share/fonts/peppercarrot-fonts ]; then
echo "* $HOME/.local/share/fonts/peppercarrot-fonts found"
else
echo "${Green}* $HOME/.local/share/fonts/peppercarrot-fonts not found${Off}"
echo "${Yellow} => creating symlink ${Off}"
mkdir -p $HOME/.local/share/fonts
ln -s "$projectroot"/fonts $HOME/.local/share/fonts/peppercarrot-fonts
fi
# Www-lang: symlink git website-translation located at root of the project folder to the local website code.
if [ -d "$projectroot"/www/peppercarrot/themes/peppercarrot-theme_v2/lang ]; then
echo "* $projectroot/www/peppercarrot/themes/peppercarrot-theme_v2/lang found"
else
echo "${Green}* $projectroot/www/peppercarrot/themes/peppercarrot-theme_v2/lang not found${Off}"
echo "${Yellow} => creating symlink ${Off}"
mkdir -p "$projectroot"/www/peppercarrot/themes/peppercarrot-theme_v2
ln -s "$projectroot"/www-lang "$projectroot"/www/peppercarrot/themes/peppercarrot-theme_v2/lang
fi
# Second part: Update
# ====================
echo ""
echo "${Blue} [ UPDATE ] ${Off}"
echo "${Blue} ########################################################################## ${Off}"
echo ""
echo "${Yellow} [UPDATE WEBCOMICS]${Off}"
echo "${Yellow} =-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ${Off}"
cd "$projectroot"/webcomics
# Batch entry door to all episodes
for directories in */ ; do
gitdirectories=$directories"lang/"
# Does the folder got a sub lang folder existing ?
if [ -d "$projectroot"/webcomics/"$gitdirectories" ]; then
#yes
# is it a git repository ?
if [ -d "$projectroot"/webcomics/"$gitdirectories"/.git ]; then
# BATCH ENTRY DOOR : good place to batch action to do for each webcomic directories, look at the comment under for template.
cd "$projectroot"/webcomics/"$directories"
# # Eg. Auto-commit changes to all README.md files
# # A. Do your changes on all the README.md
# # B. Uncomment the paragraph under and customise it.
# # enter every lang dir
# cd "$projectroot"/webcomics/"$gitdirectories"
# git add README.md
# git commit -m "Fix, clean and correct contributors name for consistency"
# git push
# # Eg. Reset the change and clean the repositories and do a clean re-render:
# # enter every lang dir
#cd "$projectroot"/webcomics/"$gitdirectories"
# # napalm changes
#git checkout -- .
# # enter the episode dir
#cd "$projectroot"/webcomics/"$directories"
# # Call renderfarm
#gnome-terminal --command="$folder_scripts"/renderfarm.sh
# # wait 30s before showing another windows.
#sleep 30
# Eg. Entering in hires subfolder, and cleaning all PNG to JPG :
#cd hi-res
#for pngfile in $(find . -name '*.png')
#do
#jpgfile=$(echo $pngfile|sed 's/\(.*\)\..\+/\1/')".jpg"
#echo " * converting $pngfile => $jpgfile"
#convert -strip -interlace Plane -quality 95% "$pngfile" "$jpgfile"
#echo " * done"
#echo ""
#done
# Eg. Entering in hires/gfx-only and transforming all PNG to JPG, then delete PNG.
# cd hi-res/gfx-only
# for pngfile in $(find . -name '*.png'); do
# jpgfile=$(echo $pngfile|sed 's/\(.*\)\..\+/\1/')".jpg"
# echo " ${Blue}* Converting $pngfile ${Off}"
# convert -strip -interlace Plane -units PixelsPerInch -density 300 -colorspace sRGB -background white -alpha remove -quality 95% "$pngfile" "$jpgfile"
# if [ -f "$jpgfile" ]; then
# echo "${Green}* Done.${Off}."
# # cleaning:
# rm -f "$pngfile"
# else
# echo " ${Red}* Error:${Off} jpg non generated."
# fi
# echo ""
# done
# execute a command on all SVG
# Eg. Entering in lang
# cd "$projectroot"/webcomics/"$gitdirectories"
# Pretty title
# echo "${Blue}* Command on all SVGs ${Off}"
#for svgfile in $(find . -name '*.svg'); do
# svgcount=$((svgcount+1))
# echo "[ ""$svgcount"" ]"
# svgfullpath=$(readlink -m $svgfile)
# "$projectroot"/scripts/utils/svg-sanifier.sh $svgfullpath
#done
# execute a command on SVGs selected with a string
# Eg. Entering in lang
#cd "$projectroot"/webcomics/"$gitdirectories"
# Pretty title
#echo "${Blue}* Command on all SVGs ${Off}"
#for svgfile in $(find . -name '*.svg'); do
#svgfullpath=$(readlink -m $svgfile)
# if grep -q 'radius="0.59999999999999998"' "$svgfullpath"; then
# echo "[ ""$svgcount"" ] ""$svgfullpath"
# svgcount=$((svgcount+1))
# echo "${Red}"
# grep 'radius="0.59999999999999998"' "$svgfullpath"
# echo "${Off}"
# fi
#done
# execute a command for white-transparency-background on all 5800 TXT-only PNGs
# Entering Txt-only :
#if [ -d "$projectroot"/webcomics/"$directories"/hi-res/txt-only ]; then
# cd "$projectroot"/webcomics/"$directories"/hi-res/txt-only
# # Pretty title
# echo "${Blue}* Command on all TXT-ONLY ${Off}"
# for pngfile in $(find . -name '*.png'); do
# pngfullpath=$(readlink -m $pngfile)
# convert $pngfullpath -background White -alpha Background $pngfullpath
# echo " * ""$pngfile"" Converted"
# done
#fi
echo "${Blue} =-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ${Off}"
# ask user to press a key before process next episode:
#echo -n "${Blue} Press Enter to continue. ${Off}"
#read end
# Batch Git update them
cd "$projectroot"/webcomics/"$gitdirectories"
# refresh repo to get remote informations
git remote update
# git tools
gitlocal=$(git rev-parse @)
gitremote=$(git rev-parse @{u})
gitbase=$(git merge-base @ @{u})
# start git update smart decisions
if [ $gitlocal = $gitremote ]; then
echo "* $directories is up-to-date"
elif [ $gitlocal = $gitbase ]; then
echo "${Blue} * $directories is outdated${Off}"
# echo "${Green} ==> [git] Batch fix all to remote tree HEAD: git reset hard master ${Off}"
# cd "$projectroot"/webcomics/"$gitdirectories"
# git reset --hard master
cd "$projectroot"/webcomics/"$directories"
gnome-terminal --command="$projectroot"/scripts/renderfarm.sh &
read -t 150 -p "* Hit ENTER or wait 2 minute and 30s"
elif [ $gitremote = $gitbase ]; then
echo "${Purple} * $directories contains commit non pushed${Off}"
else
echo "${Red} * $directories error: diverging repositories${Off}"
fi
else
echo " * $directories doesn't have a Git repository ${Off}"
fi
fi
done
echo "${Blue} * TOTAL SVGs : $svgcount${Off}"
echo ""
echo "${Yellow} [UPDATE FONTS]${Off}"
echo "${Yellow} =-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ${Off}"
directories="fonts"
cd "$projectroot"/"$directories"
# refresh repo to get remote informations
git remote update
if [ -d "$projectroot"/"$directories"/.git ]; then
# git tools
gitlocal=$(git rev-parse @)
gitremote=$(git rev-parse @{u})
gitbase=$(git merge-base @ @{u})
# start git update smart decisions
if [ $gitlocal = $gitremote ]; then
echo " * $directories is up-to-date"
elif [ $gitlocal = $gitbase ]; then
echo "${Blue} * $directories is outdated${Off}"
echo "${Green} ==> [git] git pull ${Off}"
git pull
elif [ $gitremote = $gitbase ]; then
echo "${Purple} * $directories contains commit non pushed${Off}"
else
echo "${Red} * $directories error: diverging repositories${Off}"
fi
else
echo " * $directories isn't a Git repository ${Off}"
fi
echo ""
echo "${Yellow} [UPDATE WIKI]${Off}"
echo "${Yellow} =-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ${Off}"
directories="wiki"
cd "$projectroot"/"$directories"
# refresh repo to get remote informations
git remote update
if [ -d "$projectroot"/"$directories"/.git ]; then
# git tools
gitlocal=$(git rev-parse @)
gitremote=$(git rev-parse @{u})
gitbase=$(git merge-base @ @{u})
# start git update smart decisions
if [ $gitlocal = $gitremote ]; then
echo " * $directories is up-to-date"
elif [ $gitlocal = $gitbase ]; then
echo "${Blue} * $directories is outdated${Off}"
echo "${Green} ==> [git] git pull ${Off}"
git pull
elif [ $gitremote = $gitbase ]; then
echo "${Purple} * $directories contains commit non pushed${Off}"
else
echo "${Red} * $directories error: diverging repositories${Off}"
fi
else
echo " * $directories doesn't have a Git repository ${Off}"
fi
echo ""
echo "${Yellow} [UPDATE WWW-LANG]${Off}"
echo "${Yellow} =-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ${Off}"
directories="www-lang"
cd "$projectroot"/"$directories"
# refresh repo to get remote informations
git remote update
if [ -d "$projectroot"/"$directories"/.git ]; then
# git tools
gitlocal=$(git rev-parse @)
gitremote=$(git rev-parse @{u})
gitbase=$(git merge-base @ @{u})
# start git update smart decisions
if [ $gitlocal = $gitremote ]; then
echo " * $directories is up-to-date"
elif [ $gitlocal = $gitbase ]; then
echo "${Blue} * $directories is outdated${Off}"
echo "${Green} ==> [git] git pull ${Off}"
git pull
elif [ $gitremote = $gitbase ]; then
echo "${Purple} * $directories contains commit non pushed${Off}"
else
echo "${Red} * $directories error: diverging repositories${Off}"
fi
else
echo " * $directories doesn't have a Git repository ${Off}"
fi
echo ""
echo "${Yellow} [UPDATE SCRIPT]${Off}"
echo "${Yellow} =-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ${Off}"
directories="scripts"
cd "$projectroot"/"$directories"
# refresh repo to get remote informations
git remote update
if [ -d "$projectroot"/"$directories"/.git ]; then
# git tools
gitlocal=$(git rev-parse @)
gitremote=$(git rev-parse @{u})
gitbase=$(git merge-base @ @{u})
# start git update smart decisions
if [ $gitlocal = $gitremote ]; then
echo " * $directories is up-to-date"
elif [ $gitlocal = $gitbase ]; then
echo "${Blue} * $directories is outdated${Off}"
echo "${Green} ==> [git] git pull ${Off}"
git pull
elif [ $gitremote = $gitbase ]; then
echo "${Purple} * $directories contains commit non pushed${Off}"
else
echo "${Red} * $directories error: diverging repositories${Off}"
fi
else
echo " * $directories doesn't have a Git repository ${Off}"
fi
# Script ending. Debriefing.
# Runtime counter: end and math
script_runtime_end=$(date +"%s")
diff_runtime=$(($script_runtime_end-$script_runtime_start))
# End User Interface messages
echo ""
echo " * Script did the job in $(($diff_runtime / 60))min $(($diff_runtime % 60))sec."
# Notification for system when out-of-focus
notify-send "Install.sh" "all task done in $(($diff_runtime / 60))min $(($diff_runtime % 60))sec."
echo -n " Press [Enter] to exit"
read end