Browse code

Ramize-Physave version 1.0.

Apollia authored on06/21/2017 10:18:07
Showing19 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,4 @@
1
+.hg/
2
+.hgignore
3
+.hgtimestamp
4
+0000-Config/
0 5
\ No newline at end of file
1 6
new file mode 120000
... ...
@@ -0,0 +1 @@
1
+/root/apbin/Ramize-Physave/In Use/Physave/Physave
0 2
\ No newline at end of file
1 3
new file mode 120000
... ...
@@ -0,0 +1 @@
1
+../../../In Use/Ramize Any Physaved Folder/Ramize Any Physaved Folder
0 2
\ No newline at end of file
1 3
new file mode 120000
... ...
@@ -0,0 +1 @@
1
+/root/apbin/Ramize-Physave/In Use/Ramize/Ramize
0 2
\ No newline at end of file
1 3
new file mode 120000
... ...
@@ -0,0 +1 @@
1
+/root/apbin/Ramize-Physave/In Use/Shortcuts/Go to Physave Path
0 2
\ No newline at end of file
1 3
new file mode 120000
... ...
@@ -0,0 +1 @@
1
+/root/apbin/Ramize-Physave/In Use/Shortcuts/Go to Ramize Path
0 2
\ No newline at end of file
1 3
new file mode 100644
... ...
@@ -0,0 +1,14 @@
1
+#!/bin/bash
2
+
3
+#pwd ; echo "from_path_for_rsync: $from_path_for_rsync" ; echo "to_path_for_rsync: $to_path_for_rsync" ; exit
4
+
5
+[ -z "$from_path_for_rsync" ] && exit 1
6
+[ -z "$to_path_for_rsync" ] && exit 2
7
+
8
+rsync --archive --verbose --update --recursive --itemize-changes \
9
+--exclude "0000-Unmirrored Minimal Ramize-Physave*" \
10
+--exclude "*/0000-Config/Physave Path" \
11
+--exclude "*/0000-Config/Datetime of Last Physave" \
12
+--exclude "*/0000-Config/Datetime of Last Ramize" \
13
+"$from_path_for_rsync" \
14
+"$to_path_for_rsync"
0 15
\ No newline at end of file
1 16
new file mode 100644
2 17
new file mode 100644
... ...
@@ -0,0 +1,10 @@
1
+#!/bin/bash
2
+
3
+#pwd ; echo "from_path_for_rsync: $from_path_for_rsync" ; echo "to_path_for_rsync: $to_path_for_rsync" ; exit
4
+
5
+[ -z "$from_path_for_rsync" ] && exit 1
6
+[ -z "$to_path_for_rsync" ] && exit 2
7
+
8
+rsync --archive --verbose --update --recursive --itemize-changes \
9
+"$from_path_for_rsync" \
10
+"$to_path_for_rsync"
0 11
\ No newline at end of file
1 12
new file mode 100644
... ...
@@ -0,0 +1,655 @@
1
+#!/bin/bash
2
+
3
+first_char_of_uncanon_folpath=$(echo "${Full_Uncanon_Unreal_Folpath____This_Script:0:1}")
4
+
5
+
6
+if [ "$first_char_of_uncanon_folpath" != "/" ]
7
+then
8
+	readonly Full_Canon_Unreal_Folpath____This_Script=$(readlink -m "$Original_Working_Dir/$Full_Uncanon_Unreal_Folpath____This_Script")
9
+else
10
+	readonly Full_Canon_Unreal_Folpath____This_Script=$(readlink -m "$Full_Uncanon_Unreal_Folpath____This_Script")
11
+fi
12
+
13
+
14
+
15
+if [ "$Full_Canon_Unreal_Folpath____This_Script" != "$Follpath____This_Script" ]
16
+then
17
+	readonly Follpath____Config=$(readlink -m "$Full_Canon_Unreal_Folpath____This_Script/../0000-Config")
18
+else
19
+	readonly Follpath____Config=$(readlink -m "$Follpath____This_Script/../0000-Config")
20
+fi
21
+
22
+
23
+
24
+if [ ! -d "$Follpath____Config" ]
25
+then
26
+	echo "Error: No Ramize-Physave config folder was found at:
27
+
28
+	$Follpath____Config
29
+
30
+Aborting."
31
+
32
+	echo
33
+	echo
34
+	if [ "$Follpath____This_Script" != "$Full_Canon_Unreal_Folpath____This_Script" ]
35
+	then
36
+		echo "By the way, it appears $Script_Name might have been launched via a symlink, because
37
+
38
+Follpath____This_Script:
39
+	$Follpath____This_Script
40
+
41
+...differs from...
42
+
43
+Full_Uncanon_Unreal_Folpath____This_Script:
44
+	$Full_Uncanon_Unreal_Folpath____This_Script
45
+	
46
+and
47
+
48
+Full_Canon_Unreal_Folpath____This_Script:
49
+	$Full_Canon_Unreal_Folpath____This_Script
50
+
51
+To make a shortcut to $Script_Name, it's best to use a shell script rather than a symlink, because the location from which $Script_Name is launched from actually makes a difference in what it does.
52
+
53
+That's to make it so you only need one installed copy of Ramize-Physave, instead of many duplicate full copies of Ramize-Physave inside every repo you want to use Ramize-Physave in."
54
+		exit 10
55
+	else
56
+		echo "Since it looks like you might not have launched $Script_Name via a symlink, it's possible your Ramize-Physave installation is missing its 0000-Config folder."
57
+		exit 11
58
+	fi
59
+	
60
+	exit 12
61
+	
62
+	
63
+fi
64
+
65
+
66
+
67
+readonly Follpath____Ramize_Physave=$(dirname "$Follpath____Config")
68
+readonly Foldername____Ramize_Physave="${Follpath____Ramize_Physave##*/}"
69
+
70
+
71
+if [ -z "$Follpath____Helpers" ]
72
+then
73
+	echo "Error: Follpath____Helpers must be set to something!
74
+
75
+Aborting."
76
+	exit 7
77
+fi
78
+
79
+
80
+readonly Fillepath____is_this_fiol_in_the_puppy_linux_ramdisk="$Follpath____Helpers/is-this-fiol-in-the-puppy-linux-ramdisk"
81
+
82
+
83
+if [ ! -f "$Fillepath____is_this_fiol_in_the_puppy_linux_ramdisk" ]
84
+then
85
+	echo "Error: Aborting, because this script requires $Fillepath____is_this_fiol_in_the_puppy_linux_ramdisk, and it was not found!"
86
+	
87
+	exit 8
88
+fi
89
+	
90
+	
91
+should_maybe_update_physave_path=false
92
+
93
+
94
+if [ "$Script_Name" = "Physave" ]
95
+then
96
+	should_get_datetime_of_last_physave=true
97
+fi
98
+
99
+
100
+if [ "$Script_Name" = "Ramize" ]
101
+then
102
+	
103
+	should_get_datetime_of_last_ramize=true
104
+
105
+
106
+	cd "$Follpath____Helpers"
107
+	
108
+	result=$(bash "$Fillepath____is_this_fiol_in_the_puppy_linux_ramdisk" "$Full_Canon_Unreal_Folpath____This_Script" 2>&1 )
109
+	
110
+	retcode="$?"
111
+	
112
+	
113
+	if [ "$retcode" != 0 ]
114
+	then
115
+		# 02:41:16 05/04/2017.  If the Ramize script is NOT in the RAM disk,
116
+		# we possibly should update the physave path.
117
+		
118
+		should_maybe_update_physave_path=true
119
+		
120
+	fi
121
+fi
122
+
123
+readonly Fillepath____Ramize_Path="$Follpath____Config/Ramize Path"
124
+
125
+readonly Fillepath____Ramize_Rsync="$Follpath____Config/Ramize Rsync"
126
+readonly Fillepath____Physave_Rsync="$Follpath____Config/Physave Rsync"
127
+
128
+
129
+
130
+
131
+
132
+############
133
+# Function
134
+Retrieve_Config()
135
+{
136
+	local what_to_retrieve="$1"
137
+	local filepath_to_retrieve_from="$2"
138
+	
139
+	
140
+	##############################
141
+		
142
+	retrieved_text=$(cat "$filepath_to_retrieve_from")
143
+	retcode="$?"
144
+}
145
+readonly -f Retrieve_Config
146
+
147
+# End of
148
+# Function
149
+############
150
+
151
+
152
+
153
+############
154
+# Function
155
+Abort_if_Retrieve_Failed()
156
+{
157
+	local retcode="$1"
158
+	local what_to_retrieve="$2"
159
+	local filepath_to_retrieve_from="$3"
160
+	
161
+	
162
+	##############################
163
+		
164
+	if [ "$retcode" != 0 ]
165
+	then 
166
+		echo "$Script_Name error: Somehow couldn't retrieve $what_to_retrieve from config file:
167
+
168
+$filepath_to_retrieve_from
169
+
170
+Aborting."
171
+
172
+
173
+		#!!!!
174
+		exit 1
175
+	fi
176
+}
177
+readonly -f Abort_if_Retrieve_Failed
178
+
179
+# End of
180
+# Function
181
+############
182
+
183
+
184
+
185
+############
186
+# Function
187
+Retrieve_Config_and_Abort_if_Failed()
188
+{
189
+	local what_to_retrieve="$1"
190
+	local filepath_to_retrieve_from="$2"
191
+	
192
+	
193
+	##############################
194
+		
195
+	Retrieve_Config "$what_to_retrieve" "$filepath_to_retrieve_from"
196
+	Abort_if_Retrieve_Failed "$retcode" "$what_to_retrieve" "$filepath_to_retrieve_from"
197
+}
198
+readonly -f Retrieve_Config_and_Abort_if_Failed
199
+
200
+# End of
201
+# Function
202
+############
203
+
204
+
205
+Retrieve_Config_and_Abort_if_Failed "Ramize Path" "$Fillepath____Ramize_Path"
206
+
207
+readonly Retrieved____Ramize_Path="$retrieved_text"
208
+
209
+
210
+readonly Actual_Physave_Folder=$(realpath "$Full_Canon_Unreal_Folpath____This_Script/../..")
211
+
212
+
213
+
214
+############
215
+# Function
216
+Standardize_Path_with_readlink()
217
+{
218
+	local path="$1"
219
+	
220
+	
221
+	##############################
222
+
223
+	retval=$(readlink -m "$1" 2>&1)
224
+
225
+	retcode="$?"
226
+
227
+}
228
+readonly -f Standardize_Path_with_readlink
229
+
230
+# End of
231
+# Function
232
+############
233
+
234
+
235
+
236
+############
237
+# Function
238
+Run_Realpath_on()
239
+{
240
+	local path="$1"
241
+	
242
+	
243
+	##############################
244
+
245
+	retval=$(realpath "$1" 2>&1)
246
+
247
+	retcode="$?"
248
+}
249
+readonly -f Run_Realpath_on
250
+
251
+# End of
252
+# Function
253
+############
254
+
255
+
256
+
257
+############
258
+# Function
259
+Standardize_Path_and_Abort_if_Failed()
260
+{
261
+	local desc_of_path_to_standardize="$1"
262
+	local path_to_standardize="$2"
263
+
264
+
265
+	##############################
266
+	
267
+	
268
+	Standardize_Path_with_readlink "$path_to_standardize"
269
+	
270
+	if [ "$retcode" != 0 ]
271
+	then
272
+		echo "$Script_Name error: Couldn't standardize $desc_of_path_to_standardize, which was:
273
+
274
+	$path_to_standardize
275
+
276
+Result:
277
+
278
+	$retval
279
+
280
+Aborting."
281
+
282
+
283
+		#!!!!
284
+		exit 2
285
+	fi
286
+	
287
+	standardized_path="$retval"
288
+	retcode=0
289
+}
290
+readonly -f Standardize_Path_and_Abort_if_Failed
291
+
292
+# End of
293
+# Function
294
+############
295
+
296
+
297
+
298
+Standardize_Path_and_Abort_if_Failed "Ramize Path" "$Retrieved____Ramize_Path"
299
+
300
+readonly Standardized____Ramize_Path="$standardized_path"
301
+
302
+
303
+
304
+readonly Ramized_Follpath____Config="$Standardized____Ramize_Path/$Foldername____Ramize_Physave/0000-Config"
305
+
306
+if [ ! -e "$Ramized_Follpath____Config" ]
307
+then
308
+	mkdir --parents "$Ramized_Follpath____Config"
309
+fi
310
+
311
+readonly Ramized_Fillepath____Physave_Path="$Ramized_Follpath____Config/Physave Path"
312
+
313
+
314
+if [ "$should_get_datetime_of_last_physave" = true ]
315
+then
316
+	readonly Ramized_Fillepath____Datetime_of_Last_Physave="$Ramized_Follpath____Config/Datetime of Last Physave"
317
+
318
+	if [ -e "$Ramized_Fillepath____Datetime_of_Last_Physave" ]
319
+	then
320
+		Retrieve_Config_and_Abort_if_Failed "Datetime of Last Physave" "$Ramized_Fillepath____Datetime_of_Last_Physave"
321
+		
322
+		Retrieved____Datetime_of_Last_Physave="$retrieved_text"
323
+	fi
324
+fi
325
+
326
+
327
+if [ "$should_get_datetime_of_last_ramize" = true ]
328
+then
329
+	readonly Ramized_Fillepath____Datetime_of_Last_Ramize="$Ramized_Follpath____Config/Datetime of Last Ramize"
330
+	if [ -e "$Ramized_Fillepath____Datetime_of_Last_Ramize" ]
331
+	then
332
+		Retrieve_Config_and_Abort_if_Failed "Datetime of Last Ramize" "$Ramized_Fillepath____Datetime_of_Last_Ramize"
333
+		
334
+		Retrieved____Datetime_of_Last_Ramize="$retrieved_text"
335
+	fi
336
+fi
337
+
338
+
339
+if [ -e "$Ramized_Fillepath____Physave_Path" ]
340
+then
341
+	Retrieve_Config_and_Abort_if_Failed "Physave Path" "$Ramized_Fillepath____Physave_Path"
342
+
343
+	Retrieved____Physave_Path="$retrieved_text"
344
+else
345
+	should_definitely_update_physave_path=true
346
+fi
347
+
348
+
349
+if [ "$should_maybe_update_physave_path" = true ]
350
+then
351
+if [ "$Actual_Physave_Folder" != "$Retrieved____Physave_Path" ]
352
+	then
353
+		should_definitely_update_physave_path=true
354
+		
355
+		Retrieved____Physave_Path="$Actual_Physave_Folder"
356
+	fi		
357
+fi
358
+
359
+
360
+Standardize_Path_and_Abort_if_Failed "Physave Path" "$Retrieved____Physave_Path"
361
+
362
+readonly Standardized____Physave_Path="$standardized_path"
363
+		
364
+
365
+cd "$Follpath____Helpers"
366
+
367
+if [ ! -d "$Standardized____Physave_Path" ]
368
+then
369
+	echo "$Script_Name error: No folder exists at the intended physave path:
370
+
371
+	$Standardized____Physave_Path
372
+	
373
+Must abort."
374
+	
375
+	
376
+	#!!!!
377
+	exit 15
378
+	
379
+fi
380
+
381
+
382
+result=$(bash "$Fillepath____is_this_fiol_in_the_puppy_linux_ramdisk" "$Standardized____Physave_Path" 2>&1 )
383
+
384
+result_code="$?"
385
+
386
+
387
+if [ "$result_code" = 0 ]
388
+then
389
+	echo "
390
+*******************************************************************************
391
+WARNING: The physave path appears to be located in the Puppy Linux RAM disk!
392
+
393
+	$Standardized____Physave_Path
394
+
395
+That might mean the disk you wish to physave to unexpectedly got dismounted
396
+at some point.
397
+
398
+Aborting.
399
+*******************************************************************************
400
+"
401
+	exit 14
402
+
403
+fi
404
+
405
+
406
+
407
+############
408
+# Function
409
+If_Necessary__Update_Physave_Path()
410
+{
411
+
412
+	if [ "$should_definitely_update_physave_path" = true ]
413
+	then
414
+		echo "Actual physave path differs from the physave path in the config file!  Updating config to reflect the change."
415
+		echo
416
+	
417
+		# 11:06:44 05/16/2017.  Decided I'd rather have it just update the ramized Config rather than the physaved Config.
418
+		#echo -n "$Standardized____Physave_Path" > "$Full_Filepath____Physave_Path"
419
+	
420
+		echo -n "$Standardized____Physave_Path" > "$Ramized_Fillepath____Physave_Path"
421
+	
422
+	fi
423
+
424
+	
425
+}
426
+readonly -f If_Necessary__Update_Physave_Path
427
+
428
+# End of
429
+# Function
430
+############
431
+
432
+
433
+If_Necessary__Update_Physave_Path
434
+
435
+
436
+
437
+############
438
+# Function
439
+Count_Things_in_String()
440
+{
441
+	local thing="$1"
442
+	local string="$2"
443
+
444
+
445
+	##############################
446
+	
447
+	retval=$(echo "$string" | awk -F"$thing" '{print NF-1}')
448
+	
449
+
450
+	if [ "$retval" == "-1" ]
451
+	then
452
+		retval=0
453
+	fi
454
+}
455
+readonly -f Count_Things_in_String
456
+
457
+# End of
458
+# Function
459
+############
460
+
461
+
462
+
463
+############
464
+# Function
465
+Count_Newlines_in_String()
466
+{
467
+	local string="$1"
468
+
469
+
470
+	##############################
471
+	
472
+	retval=$(echo -n "$string" | wc -l)
473
+	
474
+}
475
+readonly -f Count_Newlines_in_String
476
+
477
+# End of
478
+# Function
479
+############
480
+
481
+
482
+
483
+############
484
+# Function
485
+Abort_if_Path_Contains_Any_Newlines()
486
+{
487
+	local desc_of_path_to_check="$1"
488
+	local path_to_check="$2"
489
+	
490
+
491
+	##############################
492
+
493
+	
494
+	Count_Newlines_in_String "$path_to_check"
495
+
496
+	
497
+	if [ "$retval" -gt 0 ]
498
+	then
499
+		echo "$Script_Name error: $desc_of_path_to_check must not contain any newlines!
500
+
501
+But it contained $retval newline:
502
+
503
+	$path_to_check
504
+
505
+Aborting."
506
+		
507
+		
508
+		#!!!!
509
+		exit 3
510
+	fi
511
+}
512
+readonly -f Count_Newlines_in_String
513
+
514
+# End of
515
+# Function
516
+############
517
+
518
+
519
+
520
+Abort_if_Path_Contains_Any_Newlines "Physave Path" "$Standardized____Physave_Path"
521
+Abort_if_Path_Contains_Any_Newlines "Ramize Path" "$Standardized____Ramize_Path"
522
+
523
+
524
+
525
+############
526
+# Function
527
+Abort_if_Path_Contains_Less_Than_x_Slashes()
528
+{
529
+	local desc_of_path_to_check="$1"
530
+	local path_to_check="$2"
531
+	local minimum_num_of_slashes="$3"
532
+
533
+
534
+	##############################
535
+	
536
+	Count_Things_in_String "/" "$path_to_check"
537
+	
538
+	
539
+	if [ "$retval" -lt "$minimum_num_of_slashes" ]
540
+	then
541
+		echo "$Script_Name error: $desc_of_path_to_check must contain at least $minimum_num_of_slashes slashes!
542
+
543
+But it contained $retval slashes:
544
+
545
+	$path_to_check
546
+
547
+Aborting."
548
+		
549
+		
550
+		#!!!!
551
+		exit 4
552
+	fi
553
+	
554
+}
555
+readonly -f Abort_if_Path_Contains_Less_Than_x_Slashes
556
+
557
+# End of
558
+# Function
559
+############
560
+
561
+
562
+Abort_if_Path_Contains_Less_Than_x_Slashes "Physave Path" "$Standardized____Physave_Path" 3
563
+
564
+Abort_if_Path_Contains_Less_Than_x_Slashes "Ramize Path" "$Standardized____Ramize_Path" 2
565
+
566
+
567
+
568
+############
569
+# Function
570
+Abort_if_Path_Does_Not_Exist()
571
+{
572
+	local desc_of_path_to_check="$1"
573
+	local path_to_check="$2"
574
+
575
+
576
+	##############################
577
+	
578
+	if [ ! -e "$path_to_check" ]
579
+	then
580
+		echo "$Script_Name error: $desc_of_path_to_check must exist, but nothing was found there:
581
+
582
+	$path_to_check
583
+
584
+Aborting."
585
+		
586
+		
587
+		#!!!!
588
+		exit 5
589
+	fi
590
+	
591
+}
592
+readonly -f Abort_if_Path_Does_Not_Exist
593
+
594
+# End of
595
+# Function
596
+############
597
+
598
+
599
+if [ "$Script_Name" = "Ramize" ]
600
+then
601
+	Abort_if_Path_Does_Not_Exist "Physave Path" "$Standardized____Physave_Path"
602
+fi
603
+
604
+
605
+
606
+
607
+############
608
+# Function
609
+Update_Datetime_of_Last_Ramize_to_Now()
610
+{
611
+
612
+
613
+	##############################
614
+	
615
+	if [ "$should_get_datetime_of_last_ramize" = true ]
616
+	then
617
+		now_datetime=$(date +"%c")
618
+
619
+		echo -n "$now_datetime" > "$Ramized_Fillepath____Datetime_of_Last_Ramize"
620
+		
621
+		result_code="$?"
622
+		return "$result_code"
623
+	fi
624
+}
625
+readonly -f Update_Datetime_of_Last_Ramize_to_Now
626
+
627
+# End of
628
+# Function
629
+############
630
+
631
+
632
+
633
+############
634
+# Function
635
+Update_Datetime_of_Last_Physave_to_Now()
636
+{
637
+
638
+
639
+	##############################
640
+	
641
+	if [ "$should_get_datetime_of_last_physave" = true ]
642
+	then
643
+		now_datetime=$(date +"%c")
644
+
645
+		echo -n "$now_datetime" > "$Ramized_Fillepath____Datetime_of_Last_Physave"
646
+		
647
+		result_code="$?"
648
+		return "$result_code"
649
+	fi
650
+}
651
+readonly -f Update_Datetime_of_Last_Physave_to_Now
652
+
653
+# End of
654
+# Function
655
+############
0 656
\ No newline at end of file
1 657
new file mode 100644
... ...
@@ -0,0 +1,230 @@
1
+#!/bin/sh
2
+
3
+# Script:              Is This Fiol in the Puppy Linux RAM Disk?
4
+#
5
+#                       is-this-fiol-in-the-puppy-linux-ramdisk
6
+#
7
+# 
8
+# by Apollia - http://apollia.com/ 
9
+#
10
+# License: GNU Affero GPL 3.0
11
+# http://www.gnu.org/licenses/
12
+#
13
+#
14
+# Version 1 completed Jan. 17, 2017 at 5:38 PM EST.
15
+#
16
+# Version 2 completed June 21, 2017 at 4:18 AM EDT.  No longer mistakenly
17
+# assumes mountpoint folders are in the Puppy Linux RAM disk.
18
+#
19
+#
20
+# The word "fiol" refers to something that is either a file or a folder.
21
+#
22
+# The purpose of this script is to quickly tell you whether or not a fiol
23
+# you're inquiring about resides somewhere inside the Puppy Linux RAM disk.
24
+# (The fiol may also be a symlink, and/or its fiolpath may contain one or 
25
+# more symlinks.)
26
+#
27
+#
28
+# Works in Lucid Puppy Linux 5.2.8 version 004:
29
+# http://www.murga-linux.com/puppy/viewtopic.php?t=70855
30
+#
31
+# And Lighthouse 64 Puppy Linux 6.02 Beta 2:
32
+# http://lhpup.org/
33
+#
34
+# Haven't yet tried it in any other Puppy Linux.
35
+#
36
+#
37
+# --------
38
+# Argument
39
+# --------
40
+#
41
+# Accepts only one argument - a fiolpath (filepath or folderpath) or fiolname
42
+# (filename or foldername).
43
+#
44
+#
45
+# -------
46
+# Results
47
+# -------
48
+#
49
+# If the fiol is found in the Puppy Linux RAM disk:
50
+#
51
+#    The script returns exit code 0, and prints to STDOUT either of the
52
+#    following, depending on where the fiol was found:
53
+#
54
+#            /initrd/pup_rw/
55
+#            /initrd/pup_ro2/
56
+#
57
+#
58
+# If Argument 1 is empty:
59
+# If the "realpath" command doesn't work on the fiolpath:
60
+# If the fiol is not found in the Puppy Linux RAM disk:
61
+#
62
+#     The script returns an exit code other than 0, and prints to STDERR
63
+#     whatever went wrong.
64
+#
65
+#
66
+# ------------------
67
+# Exit Code Meanings
68
+# ------------------
69
+#
70
+# 0 - The fiol was found in the Puppy Linux RAM disk.
71
+#
72
+# 1 - Argument 1 was empty.
73
+#
74
+# 2 - The "realpath" command somehow didn't work on the fiolpath (which might
75
+# mean no fiol exists at that fiolpath).
76
+#
77
+# 3 - The fiol definitely exists, but wasn't found in the Puppy Linux RAM disk.
78
+#
79
+# 4 - The fiol is a mountpoint folder, so isn't in the Puppy Linux RAM disk.
80
+#
81
+#
82
+# -------------------------------------
83
+# More details on how this script works
84
+# -------------------------------------
85
+#
86
+# The precise location Argument 1 refers to will (hopefully) be discovered by 
87
+# running "realpath" on Argument 1, which should result in a canonicalized,
88
+# symlinks-dereferenced, absolute fiolpathstring (known below as
89
+# REAL_FIOLPATHSTRING or REAL_FIOLPATH).
90
+#
91
+# Then, two more new fiolpathstrings are made by prefixing the
92
+# REAL_FIOLPATHSTRING with these folderpaths:
93
+#
94
+#      /initrd/pup_ro2/
95
+#           Contains the original, unmodified versions of the
96
+#           files in the Puppy Linux RAM disk.
97
+#
98
+#      /initrd/pup_rw/
99
+#           Contains any new additions to (or modified version of) the
100
+#           files in the Puppy Linux RAM disk.
101
+#
102
+# If something exists at either /initrd/pup_ro2/[REAL_FIOLPATH] or
103
+# /initrd/pup_rw/[REAL_FIOLPATH], and that fiolpath isn't found to be a
104
+# mountpoint folder, the answer to the question
105
+#
106
+# "Is This Fiol in the Puppy Linux RAM Disk?"
107
+#
108
+# ...is assumed to be yes.  So, this script returns exit code 0, and announces
109
+# via STDOUT which of the above folders the fiol was found in first.
110
+# (pup_rw is checked first, then if nothing's there, pup_ro2 is checked).
111
+#
112
+#
113
+# If nothing is found in either pup_ro2 or pup_rw, the answer is assumed to be
114
+# no, so the script returns exit code 3 and announces the results via STDERR.
115
+#
116
+# If the fiol is a mountpoint folder, the script returns exit code 4
117
+# announces the results via STDERR.
118
+#
119
+#------------------------------------------------------------------------------
120
+#
121
+#
122
+# Under the GNU Affero General Public License v3.0.
123
+#
124
+# Copyright (C) 2017  Apollia
125
+#
126
+#    This program is free software: you can redistribute it and/or modify
127
+#    it under the terms of the GNU Affero General Public License as
128
+#    published by the Free Software Foundation, either version 3 of the
129
+#    License, or (at your option) any later version.
130
+#
131
+#    This program is distributed in the hope that it will be useful,
132
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
133
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
134
+#    GNU Affero General Public License for more details.
135
+#
136
+#    You should have received a copy of the GNU Affero General Public License
137
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
138
+#
139
+#
140
+# Contact info:     http://astroblahhh.com/contact-apollia.shtml
141
+#
142
+#-----
143
+
144
+
145
+if [ -z "$1" ]
146
+then
147
+	# 14:08 01/17/2017.  Argument 1 is empty.
148
+	echo
149
+	echo "$0: Aborted, because Argument 1 was not provided.
150
+
151
+Please provide a fiolpath (a filepath or folderpath), or a fiolname (a filename or foldername)." 1>&2
152
+		# 07:15 01/17/2017.  Echoed to STDERR.
153
+	exit 1
154
+fi
155
+
156
+
157
+real_fiolpath=$(realpath "$1")
158
+
159
+exit_code="$?"
160
+
161
+if [ "$exit_code" != 0 ]
162
+then 
163
+	echo
164
+	echo "$0: Aborted, because realpath command somehow didn't work on Argument 1: $1" 1>&2
165
+		# 14:01 01/17/2017.  Echoed to STDERR.
166
+	exit 2
167
+fi
168
+
169
+
170
+
171
+# 04:12:29 06/21/2017.  Function from:
172
+#
173
+# https://stackoverflow.com/questions/11856054/bash-easy-way-to-pass-a-raw-string-to-grep
174
+
175
+ere_quote() {
176
+    sed 's/[]\.|$(){}?+*^]/\\&/g' <<< "$*"
177
+}
178
+
179
+
180
+
181
+grepescaped_real_fiolpath=$(ere_quote "$real_fiolpath")
182
+
183
+result_of_check_for_mountpoint=$(df -h "$real_fiolpath" | grep -E "$grepescaped_real_fiolpath\$" | wc -l )
184
+
185
+if [ "$result_of_check_for_mountpoint" != 0 ]
186
+then
187
+	echo "Mountpoint - not in Puppy Linux RAM disk"
188
+	
189
+	exit 4
190
+fi
191
+
192
+
193
+
194
+Folder____Original_RAM_Disk_Files="/initrd/pup_ro2/"
195
+Folder____Modified_RAM_Disk_Files="/initrd/pup_rw/"
196
+
197
+real_fiolpath_in_Original_RAM_Disk_Files="$Folder____Original_RAM_Disk_Files$real_fiolpath"
198
+real_fiolpath_in_Modified_RAM_Disk_Files="$Folder____Modified_RAM_Disk_Files$real_fiolpath"
199
+
200
+
201
+if [ -e "$real_fiolpath_in_Modified_RAM_Disk_Files" ]
202
+then
203
+	# 14:13 01/17/2017.  Then the path is a later addition to (or modified version of)
204
+	# stuff in the Puppy Linux RAM disk.
205
+	echo "$Folder____Modified_RAM_Disk_Files"
206
+	
207
+	exit 0
208
+fi
209
+
210
+if [ -e "$real_fiolpath_in_Original_RAM_Disk_Files"  ]
211
+then
212
+	# 18:39 01/17/2017.  Then the path is one of the original, unmodified
213
+	# items in the Puppy Linux RAM disk.
214
+	echo "$real_fiolpath_in_Original_RAM_Disk_Files"
215
+	exit 0
216
+fi
217
+
218
+
219
+echo
220
+echo "Could not find in Puppy Linux RAM disk:
221
+
222
+$1
223
+
224
+...whose canonical, symlinks-dereferenced location is:
225
+
226
+$real_fiolpath" 1>&2
227
+
228
+exit 3
229
+
230
+# 14:46 01/17/2017.  End of script.
0 231
new file mode 100644
... ...
@@ -0,0 +1,96 @@
1
+#!/bin/bash
2
+
3
+readonly Script_Name="Physave"
4
+
5
+readonly Fillepath____This_Script=$(realpath "${BASH_SOURCE[0]}")
6
+readonly Follpath____This_Script=$(dirname "$Fillepath____This_Script")
7
+
8
+# 05:54:15 06/21/2017.
9
+#
10
+#	Fillepath	=	Full Filepath
11
+#	Follpath	=	Full Folderpath
12
+
13
+
14
+readonly Full_Uncanon_Unreal_Folpath____This_Script=$(dirname "${BASH_SOURCE[0]}")
15
+
16
+
17
+readonly Original_Working_Dir=$(pwd)
18
+
19
+
20
+readonly Follpath____Helpers=$(readlink -m "$Follpath____This_Script/../Helpers")
21
+
22
+cd "$Follpath____Helpers"
23
+
24
+source "Initialize Ramize or Physave"
25
+
26
+
27
+
28
+##############################
29
+
30
+
31
+cd "$Follpath____Config"
32
+
33
+echo "Datetime of last physave: $Retrieved____Datetime_of_Last_Physave"
34
+echo
35
+echo "Standardized____Physave_Path: $Standardized____Physave_Path"
36
+echo " Standardized____Ramize_Path: $Standardized____Ramize_Path"
37
+
38
+
39
+from_path_for_rsync="$Standardized____Ramize_Path/"
40
+to_path_for_rsync="$Standardized____Physave_Path"
41
+
42
+echo
43
+echo "from_path_for_rsync: $from_path_for_rsync"
44
+echo "  to_path_for_rsync: $to_path_for_rsync"
45
+
46
+echo
47
+echo
48
+source "$Fillepath____Physave_Rsync"
49
+result_code="$?"
50
+
51
+echo
52
+echo
53
+if [ "$result_code" != 0 ]
54
+then
55
+	echo "Physave rsync somehow failed!  Result code: $result_code"
56
+	exit $result_code
57
+fi
58
+
59
+
60
+echo "Physave rsync succeeded.  Now syncing..."
61
+	
62
+sync
63
+	
64
+result_code="$?"
65
+	
66
+echo
67
+	
68
+if [ "$result_code" != 0 ]
69
+then
70
+	echo "Sync (not rsync) somehow failed!  Result code: $result_code"
71
+	exit $result_code
72
+fi
73
+
74
+echo "Sync succeeded.  Now noting date/time of this physave..."
75
+
76
+
77
+
78
+Update_Datetime_of_Last_Physave_to_Now
79
+
80
+result_code="$?"
81
+
82
+
83
+
84
+if [ "$result_code" != 0 ]
85
+then
86
+	echo
87
+	echo "Somehow failed to note the date/time of this physave!  Result code: $result_code"
88
+	exit $result_code
89
+fi
90
+
91
+echo "$now_datetime"
92
+echo
93
+
94
+echo "All done!"
95
+
96
+exit 0
0 97
\ No newline at end of file
1 98
new file mode 100644
... ...
@@ -0,0 +1,155 @@
1
+#!/bin/bash
2
+
3
+readonly Script_Name="Ramize Any Physaved Folder"
4
+
5
+readonly Fillepath____This_Script=$(realpath "${BASH_SOURCE[0]}")
6
+readonly Follpath____This_Script=$(dirname "$Fillepath____This_Script")
7
+
8
+# 05:54:15 06/21/2017.
9
+#
10
+#	Fillepath	=	Full Filepath
11
+#	Follpath	=	Full Folderpath
12
+
13
+
14
+readonly Follpath____Minimal_Ramize_Physave="/root/apbin/Minimal Ramize-Physave/In Use"
15
+
16
+if [ ! -d "$Follpath____Minimal_Ramize_Physave" ]
17
+then
18
+	echo "Error: Couldn't find the copy of Minimal Ramize-Physave intended for installation into the ramized folder!
19
+
20
+It should have been here:
21
+
22
+	$Follpath____Minimal_Ramize_Physave"
23
+	
24
+	exit 7
25
+	
26
+fi
27
+
28
+
29
+
30
+if [ -z "$1" ]
31
+then
32
+	echo "Error: Arg #1 was empty, but it must be a physaved folderpath you want to ramize!"
33
+	exit 1
34
+fi
35
+
36
+if [ -z "$2" ]
37
+then
38
+	echo "Error: Arg #2 was empty, but it must be the destination folder in the RAM disk where you want to ramize the physaved folderpath in Arg #1!"
39
+	
40
+	exit 2
41
+fi
42
+
43
+
44
+possible_folder_to_ramize="$1"
45
+possible_dest_folder="$2"
46
+
47
+if [ ! -d "$possible_folder_to_ramize" ]
48
+then
49
+	echo "Error: Arg #1 (the physaved folderpath you want to ramize) does not lead to a folder!
50
+		
51
+	$possible_folder_to_ramize"
52
+	
53
+	exit 3
54
+fi
55
+
56
+
57
+
58
+if [ ! -d "$possible_dest_folder" ]
59
+then
60
+	echo "Error: Arg #2 (the destination folder in the RAM disk) does not lead to a folder!
61
+	
62
+	$possible_dest_folder"
63
+	exit 4
64
+fi
65
+
66
+
67
+
68
+readonly Original_Working_Dir=$(pwd)
69
+
70
+readonly Follpath____Helpers=$(readlink -m "$Follpath____This_Script/../Helpers")
71
+
72
+cd "$Follpath____Helpers"
73
+
74
+
75
+readonly Fillepath____is_this_fiol_in_the_puppy_linux_ramdisk="$Follpath____Helpers/is-this-fiol-in-the-puppy-linux-ramdisk"
76
+
77
+if [ ! -f "$Fillepath____is_this_fiol_in_the_puppy_linux_ramdisk" ]
78
+then
79
+	echo "Error: Aborting, because this script requires $Fillepath____is_this_fiol_in_the_puppy_linux_ramdisk, and it was not found!"
80
+	
81
+	exit 5
82
+fi
83
+
84
+
85
+result=$(bash "$Fillepath____is_this_fiol_in_the_puppy_linux_ramdisk" "$possible_dest_folder" 2>&1 )
86
+result_code="$?"
87
+
88
+
89
+if [ "$result_code" != 0 ]
90
+then
91
+	echo "Error: Aborting, because the destination folder in Arg #2 isn't actually in the Puppy Linux RAM disk!
92
+	
93
+	$possible_dest_folder"
94
+	
95
+	exit 6
96
+fi
97
+
98
+
99
+
100
+result=$(bash "$Fillepath____is_this_fiol_in_the_puppy_linux_ramdisk" "$possible_folder_to_ramize" 2>&1 )
101
+
102
+result_code="$?"
103
+
104
+
105
+
106
+if [ "$result_code" = 0 ]
107
+then
108
+	echo "Error: Aborting, because the folder to minimal-ramize in Arg #1 was found in the Puppy Linux RAM disk!
109
+	
110
+	$possible_folder_to_ramize"
111
+	
112
+	exit 6
113
+fi
114
+
115
+
116
+folder_to_ramize=$(readlink -m "$possible_folder_to_ramize" )
117
+dest_folder=$(readlink -m "$possible_dest_folder")
118
+
119
+
120
+cd "$Original_Working_Dir"
121
+
122
+
123
+Follpath____Dest_Unmirrored_Minimal_Ramize_Physave="$dest_folder/0000-Unmirrored Minimal Ramize-Physave"
124
+Follpath____Dest_Ramize_Physave="$dest_folder/Ramize-Physave"
125
+Follpath____Dest_Minimal_Ramize_Physave="$dest_folder/Minimal Ramize-Physave"
126
+
127
+
128
+if [ -e "$Follpath____Dest_Unmirrored_Minimal_Ramize_Physave" ] || [ -e "$Follpath____Dest_Minimal_Ramize_Physave" ] || [ -e "$Follpath____Dest_Ramize_Physave" ]
129
+then
130
+	echo "Error: It seems something was already ramized to this folder:
131
+
132
+	$dest_folder
133
+
134
+Aborting."
135
+
136
+	exit 8
137
+fi
138
+
139
+Follpath____Dest_for_Whatever_Ramize_Physave="$Follpath____Dest_Unmirrored_Minimal_Ramize_Physave"
140
+
141
+
142
+rsync --archive --verbose --update --recursive --exclude ".hg*" "$Follpath____Minimal_Ramize_Physave/" "$Follpath____Dest_for_Whatever_Ramize_Physave"
143
+
144
+Follpath____Dest_Config="$Follpath____Dest_for_Whatever_Ramize_Physave/0000-Config"
145
+
146
+Fillepath____Dest_Config____Ramize_Path="$Follpath____Dest_Config/Ramize Path"
147
+Fillepath____Dest_Config____Physave_Path="$Follpath____Dest_Config/Physave Path"
148
+
149
+echo -n "$dest_folder" > "$Fillepath____Dest_Config____Ramize_Path"
150
+echo -n "$folder_to_ramize" > "$Fillepath____Dest_Config____Physave_Path"
151
+
152
+
153
+Fillepath____Dest_Script____Ramize="$Follpath____Dest_for_Whatever_Ramize_Physave/Ramize/Ramize"
154
+
155
+bash "$Fillepath____Dest_Script____Ramize"
0 156
\ No newline at end of file
1 157
new file mode 100644
... ...
@@ -0,0 +1,82 @@
1
+#!/bin/bash
2
+
3
+readonly Script_Name="Ramize"
4
+
5
+readonly Fillepath____This_Script=$(realpath "${BASH_SOURCE[0]}")
6
+readonly Follpath____This_Script=$(dirname "$Fillepath____This_Script")
7
+
8
+# 05:54:15 06/21/2017.
9
+#
10
+#	Fillepath	=	Full Filepath
11
+#	Follpath	=	Full Folderpath
12
+
13
+
14
+readonly Full_Uncanon_Unreal_Folpath____This_Script=$(dirname "${BASH_SOURCE[0]}")
15
+
16
+
17
+readonly Original_Working_Dir=$(pwd)
18
+
19
+
20
+readonly Follpath____Helpers=$(readlink -m "$Follpath____This_Script/../Helpers")
21
+
22
+cd "$Follpath____Helpers"
23
+
24
+source "Initialize Ramize or Physave"
25
+
26
+
27
+
28
+##############################
29
+
30
+
31
+cd "$Full_Folpath____Config"
32
+
33
+echo "Datetime of last ramize: $Retrieved____Datetime_of_Last_Ramize"
34
+echo
35
+echo " Standardized____Ramize_Path: $Standardized____Ramize_Path"
36
+echo "Standardized____Physave_Path: $Standardized____Physave_Path"
37
+
38
+
39
+from_path_for_rsync="$Standardized____Physave_Path/"
40
+to_path_for_rsync="$Standardized____Ramize_Path/"
41
+
42
+echo
43
+echo "from_path_for_rsync: $from_path_for_rsync"
44
+echo "  to_path_for_rsync: $to_path_for_rsync"
45
+
46
+echo
47
+echo
48
+source "$Fillepath____Ramize_Rsync"
49
+result_code="$?"
50
+
51
+echo
52
+echo
53
+if [ "$result_code" != 0 ]
54
+then
55
+	echo "Ramize rsync somehow failed!  Result code: $result_code"
56
+	exit $result_code
57
+fi
58
+
59
+
60
+echo "Ramize rsync succeeded.  Now noting date/time of this ramize..."
61
+
62
+
63
+Update_Datetime_of_Last_Ramize_to_Now
64
+
65
+result_code="$?"
66
+
67
+
68
+
69
+if [ "$result_code" != 0 ]
70
+then
71
+	echo
72
+	echo "Somehow failed to note the date/time of this ramize!  Result code: $result_code"
73
+	exit $result_code
74
+fi
75
+
76
+echo "$now_datetime"
77
+echo
78
+
79
+echo "All done!"
80
+
81
+
82
+exit 0
0 83
new file mode 100755
... ...
@@ -0,0 +1,30 @@
1
+#!/bin/bash
2
+
3
+readonly Script_Name="Physave"
4
+
5
+readonly Fillepath____This_Script=$(realpath "${BASH_SOURCE[0]}")
6
+readonly Follpath____This_Script=$(dirname "$Fillepath____This_Script")
7
+
8
+# 05:54:15 06/21/2017.
9
+#
10
+#	Fillepath	=	Full Filepath
11
+#	Follpath	=	Full Folderpath
12
+
13
+
14
+readonly Full_Uncanon_Unreal_Folpath____This_Script=$(dirname "${BASH_SOURCE[0]}")
15
+
16
+readonly Original_Working_Dir=$(pwd)
17
+
18
+readonly Follpath____Helpers=$(readlink -m "$Follpath____This_Script/../Helpers")
19
+
20
+cd "$Follpath____Helpers"
21
+
22
+
23
+source "Initialize Ramize or Physave"
24
+
25
+
26
+
27
+##############################
28
+
29
+
30
+rox "$Standardized____Physave_Path"
0 31
\ No newline at end of file
1 32
new file mode 100755
... ...
@@ -0,0 +1,30 @@
1
+#!/bin/bash
2
+
3
+readonly Script_Name="Physave"
4
+
5
+readonly Fillepath____This_Script=$(realpath "${BASH_SOURCE[0]}")
6
+readonly Follpath____This_Script=$(dirname "$Fillepath____This_Script")
7
+
8
+# 05:54:15 06/21/2017.
9
+#
10
+#	Fillepath	=	Full Filepath
11
+#	Follpath	=	Full Folderpath
12
+
13
+
14
+readonly Full_Uncanon_Unreal_Folpath____This_Script=$(dirname "${BASH_SOURCE[0]}")
15
+
16
+readonly Original_Working_Dir=$(pwd)
17
+
18
+readonly Follpath____Helpers=$(readlink -m "$Follpath____This_Script/../Helpers")
19
+
20
+cd "$Follpath____Helpers"
21
+
22
+
23
+source "Initialize Ramize or Physave"
24
+
25
+
26
+
27
+##############################
28
+
29
+
30
+rox "$Standardized____Ramize_Path"
0 31
\ No newline at end of file
1 32
new file mode 100644
... ...
@@ -0,0 +1,14 @@
1
+#!/bin/bash
2
+
3
+#pwd ; echo "from_path_for_rsync: $from_path_for_rsync" ; echo "to_path_for_rsync: $to_path_for_rsync" ; exit
4
+
5
+[ -z "$from_path_for_rsync" ] && exit 1
6
+[ -z "$to_path_for_rsync" ] && exit 2
7
+
8
+rsync --archive --verbose --update --recursive --itemize-changes \
9
+--exclude "0000-Unmirrored Minimal Ramize-Physave*" \
10
+--exclude "*/0000-Config/Physave Path" \
11
+--exclude "*/0000-Config/Datetime of Last Physave" \
12
+--exclude "*/0000-Config/Datetime of Last Ramize" \
13
+"$from_path_for_rsync" \
14
+"$to_path_for_rsync"
0 15
\ No newline at end of file
1 16
new file mode 100644
2 17
new file mode 100644
... ...
@@ -0,0 +1,10 @@
1
+#!/bin/bash
2
+
3
+#pwd ; echo "from_path_for_rsync: $from_path_for_rsync" ; echo "to_path_for_rsync: $to_path_for_rsync" ; exit
4
+
5
+[ -z "$from_path_for_rsync" ] && exit 1
6
+[ -z "$to_path_for_rsync" ] && exit 2
7
+
8
+rsync --archive --verbose --update --recursive --itemize-changes \
9
+"$from_path_for_rsync" \
10
+"$to_path_for_rsync"
0 11
\ No newline at end of file