├── .gitignore
├── LICENSE
├── README.md
├── booleanFunctionTest.sh
├── functionCallsDiagram.dia
├── functionCallsDiagram.png
├── functionCallsDiagram.svg
├── holdall.sh
├── holdallTester.sh
├── truthTables.ods
├── usingLocationsListFile_MikeExample.png
└── usingLocationsListFile_MikeExample.svg
/.gitignore:
--------------------------------------------------------------------------------
1 | holdAllTesterSimulatedHost
2 | holdAllTesterSimulatedRmvbl
3 | holdAllTester SimulatedHost
4 | holdAllTester SimulatedRmvbl
5 | holdallTesterHoldallSavedOutput
6 | functionCallsDiagram_explanatoryText
7 | functionFlowDiagram.svg
8 | README.md.bak
9 | README.md~
10 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
341 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # holdall
2 | linux bash script to synchronise computers over an air-gap.
3 | Makes synchronising your computers easy, flexible and safe.
4 |
5 |
6 | QUICK START
7 | =======
8 | Holdall works in a simple way: run it on your computer to synchronise selected files/folders to your removable drive. Carry the drive to your other computer and run the program again to sync with that computer. Your two computers are now in sync. Repeat with other computers, and remember to sync before and after working.
9 |
10 | Holdall requires no install. Just run Holdall with one argument - the path to the syncing directory on the removable drive.
11 | On a new computer you should run holdall once to initialise some files. For example let's say you're using the folder mounted at /media/thumbdrive/holdallFolder. First run:
12 |
13 | $ bash holdall.sh /media/thumbdrive/holdallFolder
14 |
15 | Holdall will prompt you to create a template locations-list file and tell you where it is (default is e.g. at /media/thumbdrive/holdallFolder/syncLocationsOn_thisPC). There will be some instructions inside, but it's very simple, just type locations in, one per line. For example:
16 |
17 | /home/mike/work/expenseReports2016
18 |
19 | /home/mike/work/performanceReviews
20 |
21 | Now it's configured for this computer and in future you can sync all your files/folders simply by running:
22 |
23 | $ bash holdall.sh /media/thumbdrive/holdallFolder
24 |
25 | It will find the locations you gave it, ("/home/mike/work/performanceReviews" and "/home/mike/work/expenseReports2016") and synchronise them to the removable drive (default is to use the same names e.g. synchronises them to "/media/thumbdrive/holdallFolder/expenseReports2016" and "/media/thumbdrive/holdallFolder/performanceReviews").
26 |
27 | Carry to your other computers and repeat. By default it uses the basename as unique names (see the comments in the locations-list file for instructions on changing names), so if the locations-list file for your other computer contains e.g. "/media/storeMasterHDD/expenseReports2016" then this has the same basename as the removable-drive folder "/media/thumbdrive/holdallFolder/expenseReports2016" and synchronises them.
28 |
29 | Take a look at usingLocationsListFile_MikeExample.png for a diagram explaining locations-list files.
30 |
31 |
32 | INTRODUCTION
33 | =======
34 |
35 | Holdall is a smart bash script for synchronising computers over an air gap.
36 | You give a list of files/folders and it automates the process of synchronising them with a removable drive.
37 | Then you carry your removable drive to your other computer(s), synchronise with it, and continue working.
38 | It is designed to be more flexible than other syncing solutions.
39 |
40 | Advantages
41 | - It's robust. It detects forked versions and handles every mistake, error and edge case I found or I could think of.
42 | - It's flexible. It syncs any set of files/folders you like, instead of watching a single folder as some alternatives do.
43 | - You control it. You control and own both the removable drive "server" and the connection to it.
44 | - Very simple to use
45 | - No install
46 |
47 | If you're new to holdall, you may not feel you can trust it with your important data straight away. Try using these options:
48 | - with option -i it has an interactive mode. It gets permission with "y/n?" before every rsync or rm.
49 | - with option -p it has a pretend mode. Writes nothing to disk at all.
50 | - by default it keeps two backups to every sync, using rsync's -b --backup-dir options. Use -b X to keep X backups.
51 | - with option -v it has a verbose mode
52 |
53 | and of course you can check the code yourself.
54 | I always use the latest version of holdall to synchronise all my work, with no problems. I use it on Ubuntu and Debian. New users should take care when first trying holdall, especially if they have other hardware/distributions.
55 |
56 |
57 | USING HOLDALL
58 | =======
59 |
60 | Basics
61 | -----------
62 |
63 | Syncing with a removable drive works in the usual way. You modify your file/folder on a computer and when you're done you sync to the removable drive. It knows that you were working from the latest version, and it detects that you've made a change. It then copies the host version onto the removable drive. Then you move to another computer and sync again.
64 |
65 | Holdall checks that you haven't forked the file/folder between this computer and the previous one (let's say you haven't), and then copies the removable drive version onto the host. Then your two computers have identical versions of the data, and you resume working.
66 |
67 | Of course, you could just do this yourself, but if you have a lot of different things you want to sync then that could get cumbersome and error-prone. Holdall will help by automating things and by automatically detecting if you have conflicting changes, etc.
68 |
69 |
70 | Running holdall
71 | -----------
72 |
73 | Holdall takes one argument - the path to the syncing directory on the removable drive.
74 | For example let's say you're using the folder mounted at /media/thumbdrive/holdallFolder.
75 | $ bash holdall.sh /media/thumbdrive/holdallFolder
76 | If you're running for the first time, or a new host, it will initialise some files and print some simple instructions for editing your locations-list file.
77 |
78 | It has command-line options for showing the help
79 | - -h
80 | - --help
81 |
82 | and options for dealing with the location-list file
83 | - -l list mode: show what you're syncing and what's on the drive (does not synchronise)
84 | - -s (takes an argument) appends its argument to your locations-list file, e.g. "-s /home/docs" appends "/home/docs" to your locations-list file.
85 | - -f (takes an argument) specify a locations-list file to use other than the default one.
86 |
87 | and options for supervising the program if there's a problem or if you're being cautious
88 | - -i run in interactive mode - user approves or refuses each rsync and rm command individually with "y/n?" dialogs.
89 | - -p run in pretend mode - do not write to disk, only pretend to. Use to preview the program.
90 | - -v run in verbose mode - display extra messages.
91 | - -b (takes an argument) after copying with rsync keep a custom number of backups (default is 2). Accepts "0" as instruction to keep no backups (and delete existing backups).
92 |
93 | and an option to force it to run
94 | - -a run in automatic mode - no dialogs (interactive mode overrides this).
95 |
96 | When handling errors such as a forked file/folder, or missing data the default behaviour is always to ask/confirm with the user before acting. These dialogs should be rare, but you can use automatic mode to make sure execution isn't interrupted.
97 |
98 |
99 |
100 | Understanding the locations-list file(s) with an example
101 | -----------
102 |
103 | How does holdall know which files/folders on your computer you want to sync with the removable drive? It gets the list of files/folders you want synced from a "locations-list" file. You have to save your list of files/folders in this file so it can read them. Here's how it works: When you run the program for the first time on a new host it will create a blank locations-list file called "syncLocationsOn_HOSTNAME" (where HOSTNAME is the computer's name). Of course, the file starts off empty. You open it (with any text editor) and write in the locations of the files/folders you want synced. From then on your list is saved there.
104 |
105 | Now everything is set up, so when you run holdall on a host, it finds the appropriate locations-list file (the one with your hostname), and works its way down the list of locations. For each one it looks on your computer for the file/folder and in the removable drive's sync folder for a file/folder with the same name. Then it decides which one has the latest work (or if they have been forked, etc.), and then uses rsync to copy the recent version to the older version.
106 |
107 | Using locations-list files lets you sync folders to different locations, if your computers have different directory structures, and lets you choose what to sync, if you're sharing some things across some computers but not others. You can also sync files/folders to have the same data but have different names on each computer. As well as syncing work this makes it possible to sync e.g. internet bookmark files, or system config files where compatible.
108 |
109 | Inside a locations-list file are locations of folders/files, one per line.
110 | To copy a folder/file to a different name you can give the alternate name after a "|" delimiter.
111 |
112 | Look at the example below and its accompanying diagram, usingLocationsListFile_MikeExample.png.
113 |
114 | A user, Mike, synchronises his work computer (hostname employee297) with the removable drive.
115 | The locations-list file is "syncLocationsOn_employee297" and he has written and saved two lines in it:
116 | - /home/reports
117 | - /home/My Documents|docs
118 |
119 | First the program reads "/home/reports/" and synchronises "/home/reports" with "reports" on the removable drive.
120 | Next the program reads "/home/My Documents|docs" and synchronises "/home/My Documents" with "docs" on the removable drive.
121 |
122 | Mike also has a computer at home (hostname mikePC) and a laptop (hostname mikeLaptop).
123 | Mike now plugs his removable drive into his laptop and synchronises with it.
124 | For his laptop the locations-list file is syncLocationsOn_mikeLaptop and it contains
125 | - /home/work/reports
126 | - /home/work/docs
127 | - /home/personal/pictures
128 |
129 | First the program reads "/home/work/reports" and synchronises that folder with "reports" on the removable drive.
130 | Next the program reads "/home/work/docs" and synchronises that folder with "docs" on the removable drive.
131 | Now his laptop and work PC are synchronised, and between them he's free to use a different directory tree and a different name for his documents folder.
132 | Next the program reads "/home/personal/pictures" and synchronises that folder with "pictures" on the removable drive.
133 |
134 | Mike now synchronises with his home PC.
135 | The locations-list file is "syncLocationsOn_mikePC" and he put in it
136 | - /home/pictures
137 |
138 | Which ensures that "/home/pictures" is kept in sync with the folder "/home/personal/pictures" on his laptop.
139 |
140 |
141 |
142 | SOME TECHNICAL DETAILS
143 | =======
144 |
145 | Run with --help for a description of the option flags you can use.
146 |
147 | Don't be dismayed at the script's approximately 1000 lines. The core functionality spans a bit less than half of that. Much of that length is due to all the branching it needs to handle every possible case. As for the rest of the script, most of it is user dialogs. There are about 200 lines of comments, and about 150 are simply storing and echoing messages to the user. The --help is 50 lines. Ugly regex is split across multiple lines for readablity, etc.
148 |
149 | The program keeps two data/log files and a set of locations-list files. They go in the folder it uses on the removable drive.
150 |
151 | The locations-list files are called syncLocationsOn_[HOSTNAME]. It's meant to be edited by the user, so the function "cleanCommentsAndWhitespace" exists to clean it up. The program finds the locations-list file for the current host and it uses a "while read line" loop to deal with each path in the file. If two paths point to files/folders with the same name (e.g. /home/user/Documents/PDFs/ and /home/user/Downloads/PDFs/) then one must be given an alternate name (using a | in its entry in the locations-list file) to avoid clashing in the removable drive directory.
152 |
153 | The data to describe the state of syncs and updates is in syncStatus. It's definitely not meant to be edited by the user (though if needed the program can heal certain types of damage to this file). There are two types of line in syncStatus. One type has an entry for each item and each host, and records the times when each host most recently synced each item. It has the format:
154 |
155 | [item name] [hostname] LASTSYNCDATE [date in unix time]
156 |
157 | When an item is synced with a host this line is updated with the current time.
158 | The other type has an entry for each item and lists hosts with the latest changes. It has the format:
159 |
160 | [item name] UPTODATEHOSTS [hostname 1] [hostname 2] [(...etc.)]
161 |
162 | If the removable drive version was just copied to the host, the host is added to the list of hosts that have the latest version.
163 | If the host version was just copied to the removable drive, all other hosts are removed from the list and only the current host has the latest version.
164 | The dates of synchronisations, the list of hosts with the latest version, and the modification times of files, can be combined to determine if a mistake has been made including if a file/folder has been forked. I think this is the minimum information necessary.
165 |
166 | The log is kept in syncLog. The format is
167 |
168 | [date],[time], [HOSTNAME], [path to source of copy], copied to, [path to dest of copy], rsync exit status=[number]
169 |
170 | and it is capped at 5000 lines long.
171 | It's not ever consulted by the program, it just exists. I don't think it will ever be needed, but may be useful if there's confusion caused by an unwriteable file or something. Or just if someone gets in a real mess and wants to know the history of how an updated version of something was distributed to their computers.
172 |
173 | By default the rsync command sets the -b and --backup-dir options to keep two backups. The file/folder name is given a suffix "-removed-[date and time]~" (note the tilde at the end). These backups are not synchronised with anywhere else. There is no facility for restoring from a backup, it would have to be done manually. These are just a safety net; I've never used them.
174 |
175 | When syncing modification times are preserved. I find that if my computers use ext4 and my removable drive uses FAT32 there is some funny-looking behaviour because it will synchronise mod times of files even if their contents are identical. It's best to use the same filesystem on your disks.
176 |
177 |
178 | **Code overview**
179 |
180 | **This is an approximate layout of the code**
181 |
182 | *declare readonly variables esp. long messages*
183 |
184 | *getter functions*
185 |
186 | getPretend()
187 |
188 | getVerbose()
189 |
190 | getPermission()
191 |
192 | *utility functions*
193 |
194 | echoToLog()
195 |
196 | echoTitle()
197 |
198 | readableDate()
199 |
200 | appendLineToSummary()
201 |
202 | diffItems()
203 |
204 | noRsync()
205 |
206 | modTimeOf()
207 |
208 | *functions for displaying help*
209 |
210 | showHelp()
211 |
212 | usage()
213 |
214 | *functions for dealing with the locs-list*
215 |
216 | cleanCommentsAndWhitespace()
217 |
218 | addLocation()
219 |
220 | listLocsListContents()
221 |
222 | scanLocsList()
223 |
224 | createLocsListTemplateDialog()
225 |
226 | createLocsListTemplate()
227 |
228 | *functions for dealing with various errors*
229 |
230 | noSyncStatusFileDialog()
231 |
232 | eraseItemFromStatusFileDialog()
233 |
234 | eraseItemFromStatusFile()
235 |
236 | chooseVersionDialog()
237 |
238 | unexpectedAbsenceDialog()
239 |
240 | *functions for performing the actual copying*
241 |
242 | synchronise()
243 |
244 | syncSourceToDest()
245 |
246 | removeOldBackups()
247 |
248 | writeToStatus()
249 |
250 | merge()
251 |
252 | mergeSourceToDest()
253 |
254 | *core program and logic*
255 |
256 | readOptions()
257 |
258 | main(){
259 |
260 | *basic checking that files are ready*
261 |
262 | *"while read line" loop over locations in locations-list file*
263 |
264 | *read the line from the file*
265 |
266 | *retrieve data from syncStatus file*
267 |
268 | *retrieve data from disk*
269 |
270 | *logic based on non/existence of files/folders, their relative mod times, and their recorded sync status*
271 |
272 | *done*
273 |
274 | }
275 |
276 |
--------------------------------------------------------------------------------
/booleanFunctionTest.sh:
--------------------------------------------------------------------------------
1 | readonly TRUE="TRUE" # can be any unique string
2 | readonly FALSE="FALSE" # can be any unique string
3 |
4 | isTrue(){
5 | [[ "$1" == "$TRUE" ]]
6 | }
7 | isNotTrue(){
8 | if isTrue "$1"
9 | then
10 | return 1
11 | else
12 | return 0
13 | fi
14 | }
15 |
16 | # to check boolean functions, assert the following:
17 |
18 | if isTrue "$TRUE"; then echo "OK"; else echo "not OK"; fi
19 | if isTrue "$FALSE"; then echo "not OK"; else echo "OK"; fi
20 | if isTrue "another string"; then echo "not OK"; else echo "OK"; fi
21 |
22 | if isNotTrue "$TRUE"; then echo "not OK"; else echo "OK"; fi
23 | if isNotTrue "$FALSE"; then echo "OK"; else echo "not OK"; fi
24 | if isNotTrue "another string"; then echo "OK"; else echo "not OK"; fi
25 | if isTrue "$TRUE" && isNotTrue "$FALSE"; then echo "OK"; else echo "not OK"; fi
26 |
27 | if isTrue "$TRUE" && isNotTrue "$FALSE"; then echo "OK"; else echo "not OK"; fi
28 | if isTrue "$TRUE" && isNotTrue "$TRUE"; then echo "not OK"; else echo "OK"; fi
29 | if isTrue "$FALSE" && isNotTrue "$FALSE"; then echo "not OK"; else echo "OK"; fi
30 | if isTrue "$FALSE" && isNotTrue "$TRUE"; then echo "not OK"; else echo "OK"; fi
31 |
32 | if isTrue "$TRUE" || isNotTrue "$FALSE"; then echo "OK"; else echo "not OK"; fi
33 | if isTrue "$TRUE" || isNotTrue "$TRUE"; then echo "OK"; else echo "not OK"; fi
34 | if isTrue "$FALSE" || isNotTrue "$FALSE"; then echo "OK"; else echo "not OK"; fi
35 | if isTrue "$FALSE" || isNotTrue "$TRUE"; then echo "not OK"; else echo "OK"; fi
36 |
--------------------------------------------------------------------------------
/functionCallsDiagram.dia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alunperkins/holdall/1dc4d32575eda8eaa363e4299423219c3105c1f8/functionCallsDiagram.dia
--------------------------------------------------------------------------------
/functionCallsDiagram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alunperkins/holdall/1dc4d32575eda8eaa363e4299423219c3105c1f8/functionCallsDiagram.png
--------------------------------------------------------------------------------
/functionCallsDiagram.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
478 |
--------------------------------------------------------------------------------
/holdallTester.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # the "unofficial bash strict mode" convention, recommended by Aaron Maxwell http://redsymbol.net/articles/unofficial-bash-strict-mode/
4 | set -e
5 | set -u
6 | set -o pipefail
7 |
8 | readonly PROGNAME=$(basename $0)
9 |
10 | # this tests the logic of holdall for different mod time/history configurations, to see if it does the sync in the correct direction
11 |
12 | readonly HOST="holdAllTester SimulatedHost"
13 | readonly RMVBL="holdAllTester SimulatedRmvbl"
14 | readonly LOCSLIST=$RMVBL/syncLocationsOn_$HOSTNAME
15 | readonly STATUSFILE=$RMVBL/syncStatus
16 |
17 | # some dates in seconds since epoch
18 | readonly MON=1388966400 # Mon 06 Jan 2014
19 | readonly TUE=1389052800
20 | readonly WED=1389139200
21 | readonly THU=1389225600
22 | readonly FRI=1389312000 # Fri 10 Jan 2014
23 | # a time between those days and the current time
24 | readonly SAT=1483197947
25 |
26 | report="UNIT@RESULT@DESCRIPTION" # global, but not readonly!
27 |
28 | # the warning messages of the program
29 | readonly WARNINGSyncStatusForNonexistentItems="Warning: This item does not exist on this host or the removable drive but the status file says it should."
30 | readonly WARNINGNonexistentItems="Warning: This item does not exist on this host or the removable drive. "
31 | readonly WARNINGStatusInconsistent="Warning: The sync status for this item is invalid: This host is stated as being up-to-date with changes but there is no synchronisation date. "
32 | readonly WARNINGSyncedButRmvblAbsent="Warning: There is a record of synchronising this item but it is not present on the removable drive. "
33 | readonly WARNINGSyncedButHostAbsent="Warning: There is a record of synchronising this item but it is not present on the local host. "
34 | readonly WARNINGMismatchedItems="Warning: The items on disk have conflicting types - one is a folder but one is a file. "
35 | readonly WARNINGUnexpectedSyncStatusAbsence="Warning: The items both exist but there is no record of a synchronisation date. "
36 | readonly WARNINGFork="Warning: The item has been forked - the removable drive and host version have independent changes. "
37 | readonly WARNINGUnexpectedlyNotOnUpToDateList="Warning: The item is showing no changes since last recorded sync but this host is not listed as having the latest changes. "
38 | readonly WARNINGUnexpectedDifference="Warning: The items differ even though the items' last modifications are dated before their last sync"
39 | readonly WARNINGUnreachableState="Warning: The items' states and sync record are in a state that should be unreachable."
40 |
41 | appendLineToReport(){
42 | report="$report\n$1"
43 | }
44 |
45 | setRmvblFileTime(){
46 | local itemName="$1"
47 | local time="$2"
48 | touch -m -d "$(date --date=@$time +%c)" "$RMVBL/$itemName"
49 | }
50 | setRmvblDirTime(){
51 | local itemName="$1"
52 | local time="$2"
53 | touch -m -d "$(date --date=@$time +%c)" "$RMVBL/$itemName/file01"
54 | touch -m -d "$(date --date=@$time +%c)" "$RMVBL/$itemName"
55 | }
56 | setHostFileTime(){
57 | local itemName="$1"
58 | local time="$2"
59 | touch -m -d "$(date --date=@$time +%c)" "$HOST/$itemName"
60 | }
61 | setHostDirTime(){
62 | local itemName="$1"
63 | local time="$2"
64 | touch -m -d "$(date --date=@$time +%c)" "$HOST/$itemName/file01"
65 | touch -m -d "$(date --date=@$time +%c)" "$HOST/$itemName"
66 | }
67 | getRmvblFileTime(){
68 | set -euo pipefail
69 | local itemName="$1"
70 | echo $(date -r "$RMVBL/$itemName" +%s)
71 | }
72 | getRmvblDirContentsTime(){
73 | set -euo pipefail
74 | local itemName="$1"
75 | echo $(date -r "$RMVBL/$itemName/file01" +%s)
76 | }
77 | getHostFileTime(){
78 | set -euo pipefail
79 | local itemName="$1"
80 | echo $(date -r "$HOST/$itemName" +%s)
81 | }
82 | getHostDirContentsTime(){
83 | set -euo pipefail
84 | local itemName="$1"
85 | echo $(date -r "$HOST/$itemName/file01" +%s)
86 | }
87 |
88 | writeToRmvblFile(){
89 | local itemName="$1"
90 | local message="$2"
91 | echo "$message" >> "$RMVBL/$itemName"
92 | }
93 | writeToRmvblDir(){
94 | local itemName="$1"
95 | local message="$2"
96 | mkdir "$RMVBL/$itemName"
97 | echo "$message" >> "$RMVBL/$itemName/file01"
98 | }
99 |
100 | writeToHostFile(){
101 | local itemName="$1"
102 | local message="$2"
103 | echo "$message" >> "$HOST/$itemName"
104 | }
105 | writeToHostDir(){
106 | local itemName="$1"
107 | local message="$2"
108 | mkdir "$HOST/$itemName"
109 | echo "$message" >> "$HOST/$itemName/file01"
110 | }
111 |
112 | setSyncTime(){
113 | local itemName="$1"
114 | local time="$2"
115 | echo "$itemName $HOSTNAME LASTSYNCDATE $time" >> "$STATUSFILE"
116 | }
117 | getSyncTime(){
118 | set -euo pipefail
119 | local itemName="$1"
120 | local lastSyncTime=$(sed -n "s/$itemName $HOSTNAME LASTSYNCDATE \([0-9]*\)/\1/p" "$STATUSFILE")
121 | echo $lastSyncTime
122 | }
123 | setUTDTrue(){
124 | local itemName="$1"
125 | echo "$itemName UPTODATEHOSTS someOtherHost, $HOSTNAME," >> "$STATUSFILE"
126 | }
127 | setUTDFalse(){
128 | local itemName="$1"
129 | echo "$itemName UPTODATEHOSTS someOtherHost," >> "$STATUSFILE"
130 | }
131 | addToLocsList(){
132 | local itemName="$1"
133 | echo "$HOST/$itemName" >> "$LOCSLIST"
134 | }
135 |
136 | checkRmvblTopLevelDirTimeIsNotRecent(){
137 | local itemName="$1"
138 | local rmvblDirTime=$(date -r "$RMVBL/$itemName" +%s)
139 | [[ $rmvblDirTime -lt $SAT ]] && return 0 || return 1
140 | }
141 | checkRmvblTopLevelDirTimeIsRecent(){
142 | local itemName="$1"
143 | local rmvblDirTime=$(date -r "$RMVBL/$itemName" +%s)
144 | [[ $rmvblDirTime -gt $SAT ]] && return 0 || return 1
145 | }
146 | checkHostTopLevelDirTimeIsNotRecent(){
147 | local itemName="$1"
148 | local hostDirTime=$(date -r "$HOST/$itemName" +%s)
149 | [[ $hostDirTime -lt $SAT ]] && return 0 || return 1
150 | }
151 | checkHostTopLevelDirTimeIsRecent(){
152 | local itemName="$1"
153 | local hostDirTime=$(date -r "$HOST/$itemName" +%s)
154 | [[ $hostDirTime -gt $SAT ]] && return 0 || return 1
155 | }
156 |
157 | checkLastSyncTimeIsNotRecent(){
158 | local itemName="$1"
159 | local lastSyncTime=$(sed -n "s/$itemName $HOSTNAME LASTSYNCDATE \([0-9]*\)/\1/p" "$STATUSFILE")
160 | [[ $lastSyncTime -lt $SAT ]] && return 0 || return 1
161 | }
162 | checkLastSyncTimeIsRecent(){
163 | local itemName="$1"
164 | local lastSyncTime=$(sed -n "s/$itemName $HOSTNAME LASTSYNCDATE \([0-9]*\)/\1/p" "$STATUSFILE")
165 | [[ $lastSyncTime -gt $SAT ]] && return 0 || return 1
166 | }
167 | checkLastSyncTimeAbsent(){
168 | local itemName="$1"
169 | grep "$itemName $HOSTNAME LASTSYNCDATE" "$STATUSFILE" && return 1 || return 0
170 | }
171 | checkUTDisJustThisHost(){
172 | local itemName="$1"
173 | grep -q "^$itemName UPTODATEHOSTS $HOSTNAME," "$STATUSFILE" && local hostUTD="true" || local hostUTD="false"
174 | grep -q "^$itemName UPTODATEHOSTS.* someOtherHost,.*$" "$STATUSFILE" && local someOtherHostUTD="true" || local someOtherHostUTD="false"
175 | [[ $hostUTD == true && $someOtherHostUTD == false ]] && return 0 || return 1
176 | }
177 | checkUTDisJustSomeOtherHost(){
178 | local itemName="$1"
179 | grep -q "^$itemName UPTODATEHOSTS someOtherHost," "$STATUSFILE" && local someOtherHostUTD="true" || local someOtherHostUTD="false"
180 | grep -q "^$itemName UPTODATEHOSTS.* $HOSTNAME,.*$" "$STATUSFILE" && local hostUTD="true" || local hostUTD="false"
181 | [[ $hostUTD == false && $someOtherHostUTD == true ]] && return 0 || return 1
182 | }
183 | checkUTDisThisHostAndSomeOtherHost(){
184 | local itemName="$1"
185 | grep -q "^$itemName UPTODATEHOSTS.* $HOSTNAME,.*$" "$STATUSFILE" && local hostUTD="true" || local hostUTD="false"
186 | grep -q "^$itemName UPTODATEHOSTS.* someOtherHost,.*$" "$STATUSFILE" && local someOtherHostUTD="true" || local someOtherHostUTD="false"
187 | [[ $hostUTD == true && $someOtherHostUTD == true ]] && return 0 || return 1
188 | }
189 | checkUTDisNoHosts(){
190 | local itemName="$1"
191 | grep -q "^$itemName UPTODATEHOSTS.* $HOSTNAME,.*$" "$STATUSFILE" && local hostUTD="true" || local hostUTD="false"
192 | grep -q "^$itemName UPTODATEHOSTS.* someOtherHost,.*$" "$STATUSFILE" && local someOtherHostUTD="true" || local someOtherHostUTD="false"
193 | [[ $hostUTD == false && $someOtherHostUTD == false ]] && return 0 || return 1
194 | }
195 |
196 |
197 |
198 | # NOTATION
199 | # HE = item exists on host
200 | # NHE = item doesn't exist on host
201 | # RE = item exists on rmvbl
202 | # NRE = item doesn't exist on rmvbl
203 | # SP = items have been synced previously (i.e. a LASTSYNCDATE line exists in the syncRecord)
204 | # NSP = items have not been sync previously
205 | # RT = removable drive modification time
206 | # HT = host modification time
207 | # ST = last sync time
208 | # < = is older than, e.g. ST < HT means ST is older than HT
209 | # UTD = this host is on the up-to-date hosts list
210 | # NUTD = this host is not on the up-to-date hosts list
211 | # DMD = drive modified directly, as opposed to the usual situation of a modification being pushed to it from a host
212 |
213 | # units with sync time inbetween host time and rmvbl time
214 | # unit001 DESCRIPTION: RT < ST < HT, UTD, should sync host>rmvbl
215 | unit001Initialise(){
216 | local itemName="unit 001"
217 | addToLocsList "$itemName"
218 |
219 | writeToRmvblFile "$itemName" "old"
220 | writeToHostFile "$itemName" "new"
221 |
222 | setRmvblFileTime "$itemName" $MON
223 | setSyncTime "$itemName" $WED
224 | setHostFileTime "$itemName" $FRI
225 | setUTDTrue "$itemName"
226 | }
227 | unit001Check(){
228 | local itemName="unit 001"
229 | [[ $(cat "$HOST/$itemName") == "new" ]] || return 1
230 | [[ $(cat "$RMVBL/$itemName") == "new" ]] || return 2
231 | [[ $(cat "$RMVBL/$itemName"-removed*/*) == "old" ]] || return 3
232 | [[ $(getHostFileTime "$itemName") -eq $FRI ]] || return 4
233 | [[ $(getRmvblFileTime "$itemName") -eq $FRI ]] || return 5
234 | checkLastSyncTimeIsRecent "$itemName" || return 10
235 | checkUTDisJustThisHost "$itemName" || return 11
236 | return 0
237 | }
238 | # unit002 DESCRIPTION: RT < ST < HT, NUTD, should say fork and do nothing, item is file
239 | unit002Initialise(){
240 | local itemName="unit 002"
241 | addToLocsList "$itemName"
242 |
243 | writeToRmvblFile "$itemName" "old"
244 | writeToHostFile "$itemName" "new"
245 |
246 | setRmvblFileTime "$itemName" $MON
247 | setSyncTime "$itemName" $WED
248 | setHostFileTime "$itemName" $FRI
249 | setUTDFalse "$itemName"
250 | }
251 | unit002Check(){
252 | local itemName="unit 002"
253 | [[ $(cat "$HOST/$itemName") == "new" ]] || return 1
254 | [[ $(cat "$RMVBL/$itemName") == "old" ]] || return 2
255 | [[ $(getHostFileTime "$itemName") -eq $FRI ]] || return 4
256 | [[ $(getRmvblFileTime "$itemName") -eq $MON ]] || return 5
257 | grep "$itemName: $WARNINGFork"<<<"$holdallOutput" >/dev/null || return 6
258 | checkUTDisJustSomeOtherHost "$itemName" || return 11
259 | return 0
260 | }
261 | # unit003 DESCRIPTION: RT < ST < HT, NUTD, should say fork and merge host>rmvbl, item is directory
262 | unit003Initialise(){
263 | local itemName="unit 003"
264 | addToLocsList "$itemName"
265 |
266 | writeToRmvblDir "$itemName" "old"
267 | writeToHostDir "$itemName" "new"
268 |
269 | setRmvblDirTime "$itemName" $MON
270 | setSyncTime "$itemName" $WED
271 | setHostDirTime "$itemName" $FRI
272 | setUTDFalse "$itemName"
273 | }
274 | unit003Check(){
275 | local itemName="unit 003"
276 | [[ $(cat "$HOST/$itemName/file01") == "new" ]] || return 1
277 | [[ $(cat "$RMVBL/$itemName/file01") == "new" ]] || return 2
278 | [[ $(cat "$RMVBL/$itemName/"*-removed*) == "old" ]] || return 3
279 | [[ $(getHostDirContentsTime "$itemName") -eq $FRI ]] || return 4
280 | [[ $(getRmvblDirContentsTime "$itemName") -eq $FRI ]] || return 5
281 | checkRmvblTopLevelDirTimeIsRecent "$itemName" || return 12
282 | grep "$itemName: $WARNINGFork"<<<"$holdallOutput" >/dev/null || return 6
283 | checkLastSyncTimeIsNotRecent "$itemName" || return 10
284 | checkUTDisNoHosts "$itemName" || return 11
285 | return 0
286 | }
287 | # unit007 DESCRIPTION: HT < ST < RT, UTD, should say DMD and sync rmvbl>host
288 | unit007Initialise(){
289 | local itemName="unit 007"
290 | addToLocsList "$itemName"
291 |
292 | writeToRmvblFile "$itemName" "new"
293 | writeToHostFile "$itemName" "old"
294 |
295 | setHostFileTime "$itemName" $MON
296 | setSyncTime "$itemName" $WED
297 | setRmvblFileTime "$itemName" $FRI
298 | setUTDTrue "$itemName"
299 | }
300 | unit007Check(){
301 | local itemName="unit 007"
302 | [[ $(cat "$HOST/$itemName") == "new" ]] || return 1
303 | [[ $(cat "$RMVBL/$itemName") == "new" ]] || return 2
304 | [[ $(cat "$HOST/$itemName"-removed*/*) == "old" ]] || return 3
305 | [[ $(getHostFileTime "$itemName") -eq $FRI ]] || return 4
306 | [[ $(getRmvblFileTime "$itemName") -eq $FRI ]] || return 5
307 | grep "$itemName.*removable drive.*modified directly"<<<"$holdallOutput" >/dev/null || return 6
308 | checkLastSyncTimeIsRecent "$itemName" || return 10
309 | checkUTDisJustThisHost "$itemName" || return 11
310 | return 0
311 | }
312 | # unit008 DESCRIPTION: HT < ST < RT, NUTD, should sync rmvbl>host
313 | unit008Initialise(){
314 | local itemName="unit 008"
315 | addToLocsList "$itemName"
316 |
317 | writeToRmvblFile "$itemName" "new"
318 | writeToHostFile "$itemName" "old"
319 |
320 | setHostFileTime "$itemName" $MON
321 | setSyncTime "$itemName" $WED
322 | setRmvblFileTime "$itemName" $FRI
323 | setUTDFalse "$itemName"
324 | }
325 | unit008Check(){
326 | local itemName="unit 008"
327 | [[ $(cat "$HOST/$itemName") == "new" ]] || return 1
328 | [[ $(cat "$RMVBL/$itemName") == "new" ]] || return 2
329 | [[ $(cat "$HOST/$itemName"-removed*/*) == "old" ]] || return 3
330 | [[ $(getHostFileTime "$itemName") -eq $FRI ]] || return 4
331 | [[ $(getRmvblFileTime "$itemName") -eq $FRI ]] || return 5
332 | checkLastSyncTimeIsRecent "$itemName" || return 10
333 | checkUTDisThisHostAndSomeOtherHost "$itemName" || return 11
334 | return 0
335 | }
336 |
337 | # units with sync time before both host time and mod time
338 | # unit020 DESCRIPTION: ST < HT < RT, UTD, should say fork and do nothing, item is file
339 | unit020Initialise(){
340 | local itemName="unit 020"
341 | addToLocsList "$itemName"
342 |
343 | writeToRmvblFile "$itemName" "new"
344 | writeToHostFile "$itemName" "old"
345 |
346 | setSyncTime "$itemName" $MON
347 | setHostFileTime "$itemName" $WED
348 | setRmvblFileTime "$itemName" $FRI
349 | setUTDTrue "$itemName"
350 | }
351 | unit020Check(){
352 | local itemName="unit 020"
353 | [[ $(cat "$HOST/$itemName") == "old" ]] || return 1
354 | [[ $(cat "$RMVBL/$itemName") == "new" ]] || return 2
355 | [[ $(getHostFileTime "$itemName") -eq $WED ]] || return 4
356 | [[ $(getRmvblFileTime "$itemName") -eq $FRI ]] || return 5
357 | grep "$itemName: $WARNINGFork"<<<"$holdallOutput" >/dev/null || return 6
358 | checkLastSyncTimeIsNotRecent "$itemName" || return 10
359 | checkUTDisThisHostAndSomeOtherHost "$itemName" || return 11
360 | return 0
361 | }
362 | # unit021 DESCRIPTION: ST < HT < RT, UTD, should say fork and merge rmvbl>host, item is directory
363 | unit021Initialise(){
364 | local itemName="unit 021"
365 | addToLocsList "$itemName"
366 |
367 | writeToRmvblDir "$itemName" "new"
368 | writeToHostDir "$itemName" "old"
369 |
370 | setSyncTime "$itemName" $MON
371 | setHostDirTime "$itemName" $WED
372 | setRmvblDirTime "$itemName" $FRI
373 | setUTDTrue "$itemName"
374 | }
375 | unit021Check(){
376 | local itemName="unit 021"
377 | [[ $(cat "$HOST/$itemName/file01") == "new" ]] || return 1
378 | [[ $(cat "$RMVBL/$itemName/file01") == "new" ]] || return 2
379 | [[ $(cat "$HOST/$itemName/"*-removed*) == "old" ]] || return 3
380 | [[ $(getHostDirContentsTime "$itemName") -eq $FRI ]] || return 4
381 | checkHostTopLevelDirTimeIsRecent "$itemName" || return 12
382 | [[ $(getRmvblDirContentsTime "$itemName") -eq $FRI ]] || return 5
383 | grep "$itemName: $WARNINGFork"<<<"$holdallOutput" >/dev/null || return 6
384 | checkLastSyncTimeIsNotRecent "$itemName" || return 10
385 | checkUTDisJustThisHost "$itemName" || return 11
386 | return 0
387 | }
388 | # unit022 DESCRIPTION: ST < HT < RT, NUTD, should say fork and do nothing, item is file
389 | unit022Initialise(){
390 | local itemName="unit 022"
391 | addToLocsList "$itemName"
392 |
393 | writeToRmvblFile "$itemName" "new"
394 | writeToHostFile "$itemName" "old"
395 |
396 | setSyncTime "$itemName" $MON
397 | setHostFileTime "$itemName" $WED
398 | setRmvblFileTime "$itemName" $FRI
399 | setUTDFalse "$itemName"
400 | }
401 | unit022Check(){
402 | local itemName="unit 022"
403 | [[ $(cat "$HOST/$itemName") == "old" ]] || return 1
404 | [[ $(cat "$RMVBL/$itemName") == "new" ]] || return 2
405 | [[ $(getHostFileTime "$itemName") -eq $WED ]] || return 4
406 | [[ $(getRmvblFileTime "$itemName") -eq $FRI ]] || return 5
407 | grep "$itemName: $WARNINGFork"<<<"$holdallOutput" >/dev/null || return 6
408 | checkLastSyncTimeIsNotRecent "$itemName" || return 10
409 | checkUTDisJustSomeOtherHost "$itemName" || return 11
410 | return 0
411 | }
412 | # unit023 DESCRIPTION: ST < HT < RT, NUTD, should say fork and merge rmvbl>host, item is directory
413 | unit023Initialise(){
414 | local itemName="unit 023"
415 | addToLocsList "$itemName"
416 |
417 | writeToRmvblDir "$itemName" "new"
418 | writeToHostDir "$itemName" "old"
419 |
420 | setSyncTime "$itemName" $MON
421 | setHostDirTime "$itemName" $WED
422 | setRmvblDirTime "$itemName" $FRI
423 | setUTDFalse "$itemName"
424 | }
425 | unit023Check(){
426 | local itemName="unit 023"
427 | [[ $(cat "$HOST/$itemName/file01") == "new" ]] || return 1
428 | [[ $(cat "$RMVBL/$itemName/file01") == "new" ]] || return 2
429 | [[ $(cat "$HOST/$itemName/"*-removed*) == "old" ]] || return 3
430 | [[ $(getHostDirContentsTime "$itemName") -eq $FRI ]] || return 4
431 | checkHostTopLevelDirTimeIsRecent "$itemName" || return 12
432 | [[ $(getRmvblDirContentsTime "$itemName") -eq $FRI ]] || return 5
433 | grep "$itemName: $WARNINGFork"<<<"$holdallOutput" >/dev/null || return 6
434 | checkLastSyncTimeIsNotRecent "$itemName" || return 10
435 | checkUTDisJustThisHost "$itemName" || return 11
436 | return 0
437 | }
438 | # unit024 DESCRIPTION: ST < RT < HT, UTD, should say fork and do nothing, item is file
439 | unit024Initialise(){
440 | local itemName="unit 024"
441 | addToLocsList "$itemName"
442 |
443 | writeToRmvblFile "$itemName" "old"
444 | writeToHostFile "$itemName" "new"
445 |
446 | setSyncTime "$itemName" $MON
447 | setRmvblFileTime "$itemName" $WED
448 | setHostFileTime "$itemName" $FRI
449 | setUTDTrue "$itemName"
450 | }
451 | unit024Check(){
452 | local itemName="unit 024"
453 | [[ $(cat "$HOST/$itemName") == "new" ]] || return 1
454 | [[ $(cat "$RMVBL/$itemName") == "old" ]] || return 2
455 | [[ $(getHostFileTime "$itemName") -eq $FRI ]] || return 4
456 | [[ $(getRmvblFileTime "$itemName") -eq $WED ]] || return 5
457 | grep "$itemName: $WARNINGFork"<<<"$holdallOutput" >/dev/null || return 6
458 | checkLastSyncTimeIsNotRecent "$itemName" || return 10
459 | checkUTDisThisHostAndSomeOtherHost "$itemName" || return 11
460 | return 0
461 | }
462 | # unit025 DESCRIPTION: ST < RT < HT, UTD, should say fork and merge host>rmvbl, item is directory
463 | unit025Initialise(){
464 | local itemName="unit 025"
465 | addToLocsList "$itemName"
466 |
467 | writeToRmvblDir "$itemName" "old"
468 | writeToHostDir "$itemName" "new"
469 |
470 | setSyncTime "$itemName" $MON
471 | setRmvblDirTime "$itemName" $WED
472 | setHostDirTime "$itemName" $FRI
473 | setUTDTrue "$itemName"
474 | }
475 | unit025Check(){
476 | local itemName="unit 025"
477 | [[ $(cat "$HOST/$itemName/file01") == "new" ]] || return 1
478 | [[ $(cat "$RMVBL/$itemName/file01") == "new" ]] || return 2
479 | [[ $(cat "$RMVBL/$itemName/"*-removed*) == "old" ]] || return 3
480 | [[ $(getHostDirContentsTime "$itemName") -eq $FRI ]] || return 4
481 | [[ $(getRmvblDirContentsTime "$itemName") -eq $FRI ]] || return 5
482 | checkRmvblTopLevelDirTimeIsRecent "$itemName" || return 12
483 | grep "$itemName: $WARNINGFork"<<<"$holdallOutput" >/dev/null || return 6
484 | checkLastSyncTimeIsNotRecent "$itemName" || return 10
485 | checkUTDisNoHosts "$itemName" || return 11
486 | return 0
487 | }
488 | # unit026 DESCRIPTION: ST < RT < HT, NUTD, should say fork and do nothing, item is file
489 | unit026Initialise(){
490 | local itemName="unit 026"
491 | addToLocsList "$itemName"
492 |
493 | writeToRmvblFile "$itemName" "old"
494 | writeToHostFile "$itemName" "new"
495 |
496 | setSyncTime "$itemName" $MON
497 | setRmvblFileTime "$itemName" $WED
498 | setHostFileTime "$itemName" $FRI
499 | setUTDFalse "$itemName"
500 | }
501 | unit026Check(){
502 | local itemName="unit 026"
503 | [[ $(cat "$HOST/$itemName") == "new" ]] || return 1
504 | [[ $(cat "$RMVBL/$itemName") == "old" ]] || return 2
505 | [[ $(getHostFileTime "$itemName") -eq $FRI ]] || return 4
506 | [[ $(getRmvblFileTime "$itemName") -eq $WED ]] || return 5
507 | grep "$itemName: $WARNINGFork"<<<"$holdallOutput" >/dev/null || return 6
508 | checkLastSyncTimeIsNotRecent "$itemName" || return 10
509 | checkUTDisJustSomeOtherHost "$itemName" || return 11
510 | return 0
511 | }
512 | # unit027 DESCRIPTION: ST < RT < HT, NUTD, should say fork and merge host>rmvbl, item is directory
513 | unit027Initialise(){
514 | local itemName="unit 027"
515 | addToLocsList "$itemName"
516 |
517 | writeToRmvblDir "$itemName" "old"
518 | writeToHostDir "$itemName" "new"
519 |
520 | setSyncTime "$itemName" $MON
521 | setRmvblDirTime "$itemName" $WED
522 | setHostDirTime "$itemName" $FRI
523 | setUTDFalse "$itemName"
524 | }
525 | unit027Check(){
526 | local itemName="unit 027"
527 | [[ $(cat "$HOST/$itemName/file01") == "new" ]] || return 1
528 | [[ $(cat "$RMVBL/$itemName/file01") == "new" ]] || return 2
529 | [[ $(cat "$RMVBL/$itemName/"*-removed*) == "old" ]] || return 3
530 | [[ $(getHostDirContentsTime "$itemName") -eq $FRI ]] || return 4
531 | [[ $(getRmvblDirContentsTime "$itemName") -eq $FRI ]] || return 5
532 | checkRmvblTopLevelDirTimeIsRecent "$itemName" || return 12
533 | grep "$itemName: $WARNINGFork"<<<"$holdallOutput" >/dev/null || return 6
534 | checkLastSyncTimeIsNotRecent "$itemName" || return 10
535 | checkUTDisNoHosts "$itemName" || return 11
536 | return 0
537 | }
538 | # unit028 DESCRIPTION: ST < RT = HT, UTD, should say fork and do nothing
539 | unit028Initialise(){
540 | local itemName="unit 028"
541 | addToLocsList "$itemName"
542 |
543 | writeToRmvblFile "$itemName" "new"
544 | writeToHostFile "$itemName" "also new"
545 |
546 | setSyncTime "$itemName" $MON
547 | setRmvblFileTime "$itemName" $FRI
548 | setHostFileTime "$itemName" $FRI
549 | setUTDTrue "$itemName"
550 | }
551 | unit028Check(){
552 | local itemName="unit 028"
553 | [[ $(cat "$HOST/$itemName") == "also new" ]] || return 1
554 | [[ $(cat "$RMVBL/$itemName") == "new" ]] || return 2
555 | [[ $(getHostFileTime "$itemName") -eq $FRI ]] || return 4
556 | [[ $(getRmvblFileTime "$itemName") -eq $FRI ]] || return 5
557 | grep "$itemName: $WARNINGFork"<<<"$holdallOutput" >/dev/null || return 6
558 | [[ $(getSyncTime "$itemName") -eq $MON ]] || return 10
559 | checkUTDisThisHostAndSomeOtherHost "$itemName" || return 11
560 | return 0
561 | }
562 | # unit029 DESCRIPTION: ST < RT = HT, NUTD, should say fork and do nothing
563 | unit029Initialise(){
564 | local itemName="unit 029"
565 | addToLocsList "$itemName"
566 |
567 | writeToRmvblFile "$itemName" "new"
568 | writeToHostFile "$itemName" "also new"
569 |
570 | setSyncTime "$itemName" $MON
571 | setRmvblFileTime "$itemName" $FRI
572 | setHostFileTime "$itemName" $FRI
573 | setUTDFalse "$itemName"
574 | }
575 | unit029Check(){
576 | local itemName="unit 029"
577 | [[ $(cat "$HOST/$itemName") == "also new" ]] || return 1
578 | [[ $(cat "$RMVBL/$itemName") == "new" ]] || return 2
579 | [[ $(getHostFileTime "$itemName") -eq $FRI ]] || return 4
580 | [[ $(getRmvblFileTime "$itemName") -eq $FRI ]] || return 5
581 | grep "$itemName: $WARNINGFork"<<<"$holdallOutput" >/dev/null || return 6
582 | [[ $(getSyncTime "$itemName") -eq $MON ]] || return 10
583 | checkUTDisJustSomeOtherHost "$itemName" || return 11
584 | return 0
585 | }
586 |
587 | # units with sync time after both host time and rmvbl time
588 | # unit030 DESCRIPTION: HT < RT < ST, UTD, should say error and do nothing
589 | unit030Initialise(){
590 | local itemName="unit 030"
591 | addToLocsList "$itemName"
592 |
593 | writeToRmvblFile "$itemName" "new"
594 | writeToHostFile "$itemName" "old"
595 |
596 | setHostFileTime "$itemName" $MON
597 | setRmvblFileTime "$itemName" $WED
598 | setSyncTime "$itemName" $FRI
599 | setUTDTrue "$itemName"
600 | }
601 | unit030Check(){
602 | local itemName="unit 030"
603 | [[ $(cat "$HOST/$itemName") == "old" ]] || return 1
604 | [[ $(cat "$RMVBL/$itemName") == "new" ]] || return 2
605 | [[ $(getHostFileTime "$itemName") -eq $MON ]] || return 4
606 | [[ $(getRmvblFileTime "$itemName") -eq $WED ]] || return 5
607 | grep "$itemName: $WARNINGUnreachableState"<<<"$holdallOutput" >/dev/null || return 6
608 | [[ $(getSyncTime "$itemName") -eq $FRI ]] || return 10
609 | checkUTDisThisHostAndSomeOtherHost "$itemName" || return 11
610 | return 0
611 | }
612 | # unit031 DESCRIPTION: HT < RT < ST, NUTD, should sync rmvbl>host
613 | unit031Initialise(){
614 | local itemName="unit 031"
615 | addToLocsList "$itemName"
616 |
617 | writeToRmvblFile "$itemName" "new"
618 | writeToHostFile "$itemName" "old"
619 |
620 | setHostFileTime "$itemName" $MON
621 | setRmvblFileTime "$itemName" $WED
622 | setSyncTime "$itemName" $FRI
623 | setUTDFalse "$itemName"
624 | }
625 | unit031Check(){
626 | local itemName="unit 031"
627 | [[ $(cat "$HOST/$itemName") == "new" ]] || return 1
628 | [[ $(cat "$RMVBL/$itemName") == "new" ]] || return 2
629 | [[ $(cat "$HOST/$itemName"-removed*/*) == "old" ]] || return 3
630 | [[ $(getHostFileTime "$itemName") -eq $WED ]] || return 4
631 | [[ $(getRmvblFileTime "$itemName") -eq $WED ]] || return 5
632 | checkLastSyncTimeIsRecent "$itemName" || return 10
633 | checkUTDisThisHostAndSomeOtherHost "$itemName" || return 11
634 | return 0
635 | }
636 | # unit032 DESCRIPTION: RT < HT < ST, UTD, should say error and do nothing
637 | unit032Initialise(){
638 | local itemName="unit 032"
639 | addToLocsList "$itemName"
640 |
641 | writeToRmvblFile "$itemName" "old"
642 | writeToHostFile "$itemName" "new"
643 |
644 | setRmvblFileTime "$itemName" $MON
645 | setHostFileTime "$itemName" $WED
646 | setSyncTime "$itemName" $FRI
647 | setUTDTrue "$itemName"
648 | }
649 | unit032Check(){
650 | local itemName="unit 032"
651 | [[ $(cat "$HOST/$itemName") == "new" ]] || return 1
652 | [[ $(cat "$RMVBL/$itemName") == "old" ]] || return 2
653 | [[ $(getHostFileTime "$itemName") -eq $WED ]] || return 4
654 | [[ $(getRmvblFileTime "$itemName") -eq $MON ]] || return 5
655 | grep "$itemName: $WARNINGUnreachableState"<<<"$holdallOutput" >/dev/null || return 6
656 | [[ $(getSyncTime "$itemName") -eq $FRI ]] || return 10
657 | checkUTDisThisHostAndSomeOtherHost "$itemName" || return 11
658 | return 0
659 | }
660 | # unit033 DESCRIPTION: RT < HT < ST, NUTD, should say error and do nothing
661 | unit033Initialise(){
662 | local itemName="unit 033"
663 | addToLocsList "$itemName"
664 |
665 | writeToRmvblFile "$itemName" "old"
666 | writeToHostFile "$itemName" "new"
667 |
668 | setRmvblFileTime "$itemName" $MON
669 | setHostFileTime "$itemName" $WED
670 | setSyncTime "$itemName" $FRI
671 | setUTDFalse "$itemName"
672 | }
673 | unit033Check(){
674 | local itemName="unit 033"
675 | [[ $(cat "$HOST/$itemName") == "new" ]] || return 1
676 | [[ $(cat "$RMVBL/$itemName") == "old" ]] || return 2
677 | [[ $(getHostFileTime "$itemName") -eq $WED ]] || return 4
678 | [[ $(getRmvblFileTime "$itemName") -eq $MON ]] || return 5
679 | grep "$itemName: $WARNINGUnreachableState"<<<"$holdallOutput" >/dev/null || return 6
680 | [[ $(getSyncTime "$itemName") -eq $FRI ]] || return 10
681 | checkUTDisJustSomeOtherHost "$itemName" || return 11
682 | return 0
683 | }
684 | # unit034 DESCRIPTION: RT = HT < ST, UTD, this is the "no changes" state, should do nothing
685 | unit034Initialise(){
686 | local itemName="unit 034"
687 | addToLocsList "$itemName"
688 |
689 | writeToRmvblFile "$itemName" "old"
690 | writeToHostFile "$itemName" "also old"
691 |
692 | setRmvblFileTime "$itemName" $MON
693 | setHostFileTime "$itemName" $MON
694 | setSyncTime "$itemName" $FRI
695 | setUTDTrue "$itemName"
696 | }
697 | unit034Check(){
698 | local itemName="unit 034"
699 | [[ $(cat "$HOST/$itemName") == "also old" ]] || return 1
700 | [[ $(cat "$RMVBL/$itemName") == "old" ]] || return 2
701 | [[ $(getHostFileTime "$itemName") -eq $MON ]] || return 4
702 | [[ $(getRmvblFileTime "$itemName") -eq $MON ]] || return 5
703 | [[ $(getSyncTime "$itemName") -eq $FRI ]] || return 10
704 | checkUTDisThisHostAndSomeOtherHost "$itemName" || return 11
705 | return 0
706 | }
707 | # unit035 DESCRIPTION: RT = HT < ST, NUTD, should say error and do nothing
708 | unit035Initialise(){
709 | local itemName="unit 035"
710 | addToLocsList "$itemName"
711 |
712 | writeToRmvblFile "$itemName" "old"
713 | writeToHostFile "$itemName" "also old"
714 |
715 | setRmvblFileTime "$itemName" $MON
716 | setHostFileTime "$itemName" $MON
717 | setSyncTime "$itemName" $FRI
718 | setUTDFalse "$itemName"
719 | }
720 | unit035Check(){
721 | local itemName="unit 035"
722 | [[ $(cat "$HOST/$itemName") == "also old" ]] || return 1
723 | [[ $(cat "$RMVBL/$itemName") == "old" ]] || return 2
724 | [[ $(getHostFileTime "$itemName") -eq $MON ]] || return 4
725 | [[ $(getRmvblFileTime "$itemName") -eq $MON ]] || return 5
726 | grep "$itemName: $WARNINGUnreachableState"<<<"$holdallOutput" >/dev/null || return 6
727 | [[ $(getSyncTime "$itemName") -eq $FRI ]] || return 10
728 | checkUTDisJustSomeOtherHost "$itemName" || return 11
729 | return 0
730 | }
731 |
732 | # units with sync time simulataneous with either host time or rmvbl time
733 | # unit040 DESCRIPTION: RT < HT = ST, UTD, should say error and do nothing
734 | unit040Initialise(){
735 | local itemName="unit 040"
736 | addToLocsList "$itemName"
737 |
738 | writeToRmvblFile "$itemName" "old"
739 | writeToHostFile "$itemName" "also old"
740 |
741 | setRmvblFileTime "$itemName" $MON
742 | setHostFileTime "$itemName" $FRI
743 | setSyncTime "$itemName" $FRI
744 | setUTDTrue "$itemName"
745 | }
746 | unit040Check(){
747 | local itemName="unit 040"
748 | [[ $(cat "$HOST/$itemName") == "also old" ]] || return 1
749 | [[ $(cat "$RMVBL/$itemName") == "old" ]] || return 2
750 | [[ $(getHostFileTime "$itemName") -eq $FRI ]] || return 4
751 | [[ $(getRmvblFileTime "$itemName") -eq $MON ]] || return 5
752 | grep "$itemName: $WARNINGUnreachableState"<<<"$holdallOutput" >/dev/null || return 6
753 | [[ $(getSyncTime "$itemName") -eq $FRI ]] || return 10
754 | checkUTDisThisHostAndSomeOtherHost "$itemName" || return 11
755 | return 0
756 | }
757 | # unit041 DESCRIPTION: RT < HT = ST, NUTD, should say error and do nothing
758 | unit041Initialise(){
759 | local itemName="unit 041"
760 | addToLocsList "$itemName"
761 |
762 | writeToRmvblFile "$itemName" "old"
763 | writeToHostFile "$itemName" "also old"
764 |
765 | setRmvblFileTime "$itemName" $MON
766 | setHostFileTime "$itemName" $FRI
767 | setSyncTime "$itemName" $FRI
768 | setUTDFalse "$itemName"
769 | }
770 | unit041Check(){
771 | local itemName="unit 041"
772 | [[ $(cat "$HOST/$itemName") == "also old" ]] || return 1
773 | [[ $(cat "$RMVBL/$itemName") == "old" ]] || return 2
774 | [[ $(getHostFileTime "$itemName") -eq $FRI ]] || return 4
775 | [[ $(getRmvblFileTime "$itemName") -eq $MON ]] || return 5
776 | grep "$itemName: $WARNINGUnreachableState"<<<"$holdallOutput" >/dev/null || return 6
777 | [[ $(getSyncTime "$itemName") -eq $FRI ]] || return 10
778 | checkUTDisJustSomeOtherHost "$itemName" || return 11
779 | return 0
780 | }
781 | # unit042 DESCRIPTION: HT = ST < RT, UTD, should say error and do nothing
782 | unit042Initialise(){
783 | local itemName="unit 042"
784 | addToLocsList "$itemName"
785 |
786 | writeToRmvblFile "$itemName" "new"
787 | writeToHostFile "$itemName" "old"
788 |
789 | setHostFileTime "$itemName" $MON
790 | setSyncTime "$itemName" $MON
791 | setRmvblFileTime "$itemName" $FRI
792 | setUTDTrue "$itemName"
793 | }
794 | unit042Check(){
795 | local itemName="unit 042"
796 | [[ $(cat "$HOST/$itemName") == "old" ]] || return 1
797 | [[ $(cat "$RMVBL/$itemName") == "new" ]] || return 2
798 | [[ $(getHostFileTime "$itemName") -eq $MON ]] || return 4
799 | [[ $(getRmvblFileTime "$itemName") -eq $FRI ]] || return 5
800 | grep "$itemName: $WARNINGUnreachableState"<<<"$holdallOutput" >/dev/null || return 6
801 | [[ $(getSyncTime "$itemName") -eq $MON ]] || return 10
802 | checkUTDisThisHostAndSomeOtherHost "$itemName" || return 11
803 | return 0
804 | }
805 | # unit043 DESCRIPTION: HT = ST < RT, NUTD, should say error and do nothing
806 | unit043Initialise(){
807 | local itemName="unit 043"
808 | addToLocsList "$itemName"
809 |
810 | writeToRmvblFile "$itemName" "new"
811 | writeToHostFile "$itemName" "old"
812 |
813 | setHostFileTime "$itemName" $MON
814 | setSyncTime "$itemName" $MON
815 | setRmvblFileTime "$itemName" $FRI
816 | setUTDFalse "$itemName"
817 | }
818 | unit043Check(){
819 | local itemName="unit 043"
820 | [[ $(cat "$HOST/$itemName") == "old" ]] || return 1
821 | [[ $(cat "$RMVBL/$itemName") == "new" ]] || return 2
822 | [[ $(getHostFileTime "$itemName") -eq $MON ]] || return 4
823 | [[ $(getRmvblFileTime "$itemName") -eq $FRI ]] || return 5
824 | grep "$itemName: $WARNINGUnreachableState"<<<"$holdallOutput" >/dev/null || return 6
825 | [[ $(getSyncTime "$itemName") -eq $MON ]] || return 10
826 | checkUTDisJustSomeOtherHost "$itemName" || return 11
827 | return 0
828 | }
829 | # unit044 DESCRIPTION: HT < ST = RT, UTD, should say error and do nothing
830 | unit044Initialise(){
831 | local itemName="unit 044"
832 | addToLocsList "$itemName"
833 |
834 | writeToRmvblFile "$itemName" "new"
835 | writeToHostFile "$itemName" "old"
836 |
837 | setHostFileTime "$itemName" $MON
838 | setSyncTime "$itemName" $FRI
839 | setRmvblFileTime "$itemName" $FRI
840 | setUTDTrue "$itemName"
841 | }
842 | unit044Check(){
843 | local itemName="unit 044"
844 | [[ $(cat "$HOST/$itemName") == "old" ]] || return 1
845 | [[ $(cat "$RMVBL/$itemName") == "new" ]] || return 2
846 | [[ $(getHostFileTime "$itemName") -eq $MON ]] || return 4
847 | [[ $(getRmvblFileTime "$itemName") -eq $FRI ]] || return 5
848 | grep "$itemName: $WARNINGUnreachableState"<<<"$holdallOutput" >/dev/null || return 6
849 | [[ $(getSyncTime "$itemName") -eq $FRI ]] || return 10
850 | checkUTDisThisHostAndSomeOtherHost "$itemName" || return 11
851 | return 0
852 | }
853 | # unit045 DESCRIPTION: HT < ST = RT, NUTD, should say error and do nothing
854 | unit045Initialise(){
855 | local itemName="unit 045"
856 | addToLocsList "$itemName"
857 |
858 | writeToRmvblFile "$itemName" "new"
859 | writeToHostFile "$itemName" "old"
860 |
861 | setHostFileTime "$itemName" $MON
862 | setSyncTime "$itemName" $FRI
863 | setRmvblFileTime "$itemName" $FRI
864 | setUTDFalse "$itemName"
865 | }
866 | unit045Check(){
867 | local itemName="unit 045"
868 | [[ $(cat "$HOST/$itemName") == "old" ]] || return 1
869 | [[ $(cat "$RMVBL/$itemName") == "new" ]] || return 2
870 | [[ $(getHostFileTime "$itemName") -eq $MON ]] || return 4
871 | [[ $(getRmvblFileTime "$itemName") -eq $FRI ]] || return 5
872 | grep "$itemName: $WARNINGUnreachableState"<<<"$holdallOutput" >/dev/null || return 6
873 | [[ $(getSyncTime "$itemName") -eq $FRI ]] || return 10
874 | checkUTDisJustSomeOtherHost "$itemName" || return 11
875 | return 0
876 | }
877 | # unit046 DESCRIPTION: RT = ST < HT, UTD, should say error and do nothing
878 | unit046Initialise(){
879 | local itemName="unit 046"
880 | addToLocsList "$itemName"
881 |
882 | writeToRmvblFile "$itemName" "old"
883 | writeToHostFile "$itemName" "new"
884 |
885 | setSyncTime "$itemName" $MON
886 | setRmvblFileTime "$itemName" $MON
887 | setHostFileTime "$itemName" $FRI
888 | setUTDTrue "$itemName"
889 | }
890 | unit046Check(){
891 | local itemName="unit 046"
892 | [[ $(cat "$HOST/$itemName") == "new" ]] || return 1
893 | [[ $(cat "$RMVBL/$itemName") == "old" ]] || return 2
894 | [[ $(getHostFileTime "$itemName") -eq $FRI ]] || return 4
895 | [[ $(getRmvblFileTime "$itemName") -eq $MON ]] || return 5
896 | grep "$itemName: $WARNINGUnreachableState"<<<"$holdallOutput" >/dev/null || return 6
897 | [[ $(getSyncTime "$itemName") -eq $MON ]] || return 10
898 | checkUTDisThisHostAndSomeOtherHost "$itemName" || return 11
899 | return 0
900 | }
901 | # unit047 DESCRIPTION: RT = ST < HT, NUTD, should say error and do nothing
902 | unit047Initialise(){
903 | local itemName="unit 047"
904 | addToLocsList "$itemName"
905 |
906 | writeToRmvblFile "$itemName" "old"
907 | writeToHostFile "$itemName" "new"
908 |
909 | setSyncTime "$itemName" $MON
910 | setRmvblFileTime "$itemName" $MON
911 | setHostFileTime "$itemName" $FRI
912 | setUTDFalse "$itemName"
913 | }
914 | unit047Check(){
915 | local itemName="unit 047"
916 | [[ $(cat "$HOST/$itemName") == "new" ]] || return 1
917 | [[ $(cat "$RMVBL/$itemName") == "old" ]] || return 2
918 | [[ $(getHostFileTime "$itemName") -eq $FRI ]] || return 4
919 | [[ $(getRmvblFileTime "$itemName") -eq $MON ]] || return 5
920 | grep "$itemName: $WARNINGUnreachableState"<<<"$holdallOutput" >/dev/null || return 6
921 | [[ $(getSyncTime "$itemName") -eq $MON ]] || return 10
922 | checkUTDisJustSomeOtherHost "$itemName" || return 11
923 | return 0
924 | }
925 | # unit048 DESCRIPTION: RT = ST = HT, UTD, should say error and do nothing
926 | unit048Initialise(){
927 | local itemName="unit 048"
928 | addToLocsList "$itemName"
929 |
930 | writeToRmvblFile "$itemName" "old"
931 | writeToHostFile "$itemName" "also old"
932 |
933 | setSyncTime "$itemName" $WED
934 | setRmvblFileTime "$itemName" $WED
935 | setHostFileTime "$itemName" $WED
936 | setUTDTrue "$itemName"
937 | }
938 | unit048Check(){
939 | local itemName="unit 048"
940 | [[ $(cat "$HOST/$itemName") == "also old" ]] || return 1
941 | [[ $(cat "$RMVBL/$itemName") == "old" ]] || return 2
942 | [[ $(getHostFileTime "$itemName") -eq $WED ]] || return 4
943 | [[ $(getRmvblFileTime "$itemName") -eq $WED ]] || return 5
944 | grep "$itemName: $WARNINGUnreachableState"<<<"$holdallOutput" >/dev/null || return 6
945 | [[ $(getSyncTime "$itemName") -eq $WED ]] || return 10
946 | checkUTDisThisHostAndSomeOtherHost "$itemName" || return 11
947 | return 0
948 | }
949 | # unit049 DESCRIPTION: RT = ST = HT, NUTD, should say error and do nothing
950 | unit049Initialise(){
951 | local itemName="unit 049"
952 | addToLocsList "$itemName"
953 |
954 | writeToRmvblFile "$itemName" "old"
955 | writeToHostFile "$itemName" "also old"
956 |
957 | setSyncTime "$itemName" $WED
958 | setRmvblFileTime "$itemName" $WED
959 | setHostFileTime "$itemName" $WED
960 | setUTDFalse "$itemName"
961 | }
962 | unit049Check(){
963 | local itemName="unit 049"
964 | [[ $(cat "$HOST/$itemName") == "also old" ]] || return 1
965 | [[ $(cat "$RMVBL/$itemName") == "old" ]] || return 2
966 | [[ $(getHostFileTime "$itemName") -eq $WED ]] || return 4
967 | [[ $(getRmvblFileTime "$itemName") -eq $WED ]] || return 5
968 | grep "$itemName: $WARNINGUnreachableState"<<<"$holdallOutput" >/dev/null || return 6
969 | [[ $(getSyncTime "$itemName") -eq $WED ]] || return 10
970 | checkUTDisJustSomeOtherHost "$itemName" || return 11
971 | return 0
972 | }
973 |
974 | # units 50-99 deal with cases of incomplete sync record and/or missing files/folders
975 |
976 | # units where there is no record of a previous sync time, but the host is listed as up to date (this is unreachable)
977 | # unit050 DESCRIPTION: NSP, UTD, HE, RE, should say sync status is inconsistent, erase record
978 | unit050Initialise(){
979 | local itemName="unit 050"
980 | addToLocsList "$itemName"
981 | writeToRmvblFile "$itemName" "rmvbl content"
982 | setRmvblFileTime "$itemName" $WED
983 | writeToHostFile "$itemName" "host content"
984 | setHostFileTime "$itemName" $TUE
985 | setUTDTrue "$itemName"
986 | }
987 | unit050Check(){
988 | local itemName="unit 050"
989 | [[ $(cat "$RMVBL/$itemName") == "rmvbl content" ]] || return 2
990 | [[ $(getRmvblFileTime "$itemName") -eq $WED ]] || return 5
991 | [[ $(cat "$HOST/$itemName") == "host content" ]] || return 1
992 | [[ $(getHostFileTime "$itemName") -eq $TUE ]] || return 4
993 | grep "$itemName: $WARNINGStatusInconsistent"<<<"$holdallOutput" >/dev/null || return 6
994 | checkLastSyncTimeAbsent "$itemName" || return 10
995 | checkUTDisJustSomeOtherHost "$itemName" || return 11
996 | return 0
997 | }
998 | # unit051 DESCRIPTION: NSP, UTD, HE, NRE, should say sync record is missing, erase record
999 | unit051Initialise(){
1000 | local itemName="unit 051"
1001 | addToLocsList "$itemName"
1002 | writeToHostFile "$itemName" "host content"
1003 | setHostFileTime "$itemName" $TUE
1004 | setUTDTrue "$itemName"
1005 | }
1006 | unit051Check(){
1007 | local itemName="unit 051"
1008 | [[ $(cat "$HOST/$itemName") == "host content" ]] || return 1
1009 | [[ $(getHostFileTime "$itemName") -eq $TUE ]] || return 4
1010 | grep "$itemName: $WARNINGStatusInconsistent"<<<"$holdallOutput" >/dev/null || return 6
1011 | [[ -e "$RMVBL/$itemName" ]] && return 7
1012 | checkLastSyncTimeAbsent "$itemName" || return 10
1013 | checkUTDisJustSomeOtherHost "$itemName" || return 11
1014 | return 0
1015 | }
1016 | # unit052 DESCRIPTION: NSP, UTD, NHE, RE, should say sync record is missing, erase record
1017 | unit052Initialise(){
1018 | local itemName="unit 052"
1019 | addToLocsList "$itemName"
1020 | writeToRmvblFile "$itemName" "rmvbl content"
1021 | setRmvblFileTime "$itemName" $WED
1022 | setUTDTrue "$itemName"
1023 | }
1024 | unit052Check(){
1025 | local itemName="unit 052"
1026 | [[ $(cat "$RMVBL/$itemName") == "rmvbl content" ]] || return 2
1027 | [[ $(getRmvblFileTime "$itemName") -eq $WED ]] || return 5
1028 | grep "$itemName: $WARNINGStatusInconsistent"<<<"$holdallOutput" >/dev/null || return 6
1029 | [[ -e "$HOST/$itemName" ]] && return 7
1030 | checkLastSyncTimeAbsent "$itemName" || return 10
1031 | checkUTDisJustSomeOtherHost "$itemName" || return 11
1032 | return 0
1033 | }
1034 | # unit053 DESCRIPTION: NSP, UTD, NHE, NRE, should say sync record is missing, erase record
1035 | unit053Initialise(){
1036 | local itemName="unit 053"
1037 | addToLocsList "$itemName"
1038 | setUTDTrue "$itemName"
1039 | }
1040 | unit053Check(){
1041 | local itemName="unit 053"
1042 | grep "$itemName: $WARNINGStatusInconsistent"<<<"$holdallOutput" >/dev/null || return 6
1043 | checkLastSyncTimeAbsent "$itemName" || return 10
1044 | checkUTDisJustSomeOtherHost "$itemName" || return 11
1045 | return 0
1046 | }
1047 |
1048 | # units where neither item is not on host nor removable
1049 | # unit060 DESCRIPTION: SP, UTD, NHE, NRE, should say sync record for missing items, erase record
1050 | unit060Initialise(){
1051 | local itemName="unit 060"
1052 | addToLocsList "$itemName"
1053 | setSyncTime "$itemName" $THU
1054 | setUTDTrue "$itemName"
1055 | }
1056 | unit060Check(){
1057 | local itemName="unit 060"
1058 | grep "$itemName: $WARNINGSyncStatusForNonexistentItems"<<<"$holdallOutput" >/dev/null || return 6
1059 | checkLastSyncTimeAbsent "$itemName" || return 10
1060 | checkUTDisJustSomeOtherHost "$itemName" || return 11
1061 | return 0
1062 | }
1063 | # unit061 DESCRIPTION: SP, NUTD, NHE, NRE, should say sync record for missing items, erase record
1064 | unit061Initialise(){
1065 | local itemName="unit 061"
1066 | addToLocsList "$itemName"
1067 | setSyncTime "$itemName" $THU
1068 | setUTDFalse "$itemName"
1069 | }
1070 | unit061Check(){
1071 | local itemName="unit 061"
1072 | grep "$itemName: $WARNINGSyncStatusForNonexistentItems"<<<"$holdallOutput" >/dev/null || return 6
1073 | checkLastSyncTimeAbsent "$itemName" || return 10
1074 | checkUTDisJustSomeOtherHost "$itemName" || return 11
1075 | return 0
1076 | }
1077 | # unit062 DESCRIPTION: NSP, NUTD, NHE, NRE, should say nonexistent items
1078 | unit062Initialise(){
1079 | local itemName="unit 062"
1080 | addToLocsList "$itemName"
1081 | setUTDFalse "$itemName"
1082 | }
1083 | unit062Check(){
1084 | local itemName="unit 062"
1085 | grep "$itemName: $WARNINGNonexistentItems"<<<"$holdallOutput" >/dev/null || return 6
1086 | checkLastSyncTimeAbsent "$itemName" || return 10
1087 | checkUTDisJustSomeOtherHost "$itemName" || return 11
1088 | return 0
1089 | }
1090 |
1091 | # units where the item is on the host but not the removable drive
1092 | # unit070 DESCRIPTION: SP, UTD, HE, NRE, should say rmvbl is missing
1093 | unit070Initialise(){
1094 | local itemName="unit 070"
1095 | addToLocsList "$itemName"
1096 | writeToHostFile "$itemName" "host content"
1097 | setHostFileTime "$itemName" $TUE
1098 | setSyncTime "$itemName" $THU
1099 | setUTDTrue "$itemName"
1100 | }
1101 | unit070Check(){
1102 | local itemName="unit 070"
1103 | [[ $(cat "$HOST/$itemName") == "host content" ]] || return 1
1104 | [[ $(getHostFileTime "$itemName") -eq $TUE ]] || return 4
1105 | grep "$itemName: $WARNINGSyncedButRmvblAbsent"<<<"$holdallOutput" >/dev/null || return 6
1106 | [[ -e "$RMVBL/$itemName" ]] && return 7
1107 | [[ $(getSyncTime "$itemName") -eq $THU ]] || return 10
1108 | checkUTDisThisHostAndSomeOtherHost "$itemName" || return 11
1109 | return 0
1110 | }
1111 | # unit071 DESCRIPTION: SP, NUTD, HE, NRE, should say rmvbl is missing
1112 | unit071Initialise(){
1113 | local itemName="unit 071"
1114 | addToLocsList "$itemName"
1115 | writeToHostFile "$itemName" "host content"
1116 | setHostFileTime "$itemName" $TUE
1117 | setSyncTime "$itemName" $THU
1118 | setUTDFalse "$itemName"
1119 | }
1120 | unit071Check(){
1121 | local itemName="unit 071"
1122 | [[ $(cat "$HOST/$itemName") == "host content" ]] || return 1
1123 | [[ $(getHostFileTime "$itemName") -eq $TUE ]] || return 4
1124 | grep "$itemName: $WARNINGSyncedButRmvblAbsent"<<<"$holdallOutput" >/dev/null || return 6
1125 | [[ -e "$RMVBL/$itemName" ]] && return 7
1126 | [[ $(getSyncTime "$itemName") -eq $THU ]] || return 10
1127 | checkUTDisJustSomeOtherHost "$itemName" || return 11
1128 | return 0
1129 | }
1130 | # unit072 DESCRIPTION: NSP, NUTD, HE, NRE, should sync host>rmvbl
1131 | unit072Initialise(){
1132 | local itemName="unit 072"
1133 | addToLocsList "$itemName"
1134 | writeToHostFile "$itemName" "host content"
1135 | setHostFileTime "$itemName" $TUE
1136 | setUTDFalse "$itemName"
1137 | }
1138 | unit072Check(){
1139 | local itemName="unit 072"
1140 | [[ $(cat "$HOST/$itemName") == "host content" ]] || return 1
1141 | [[ $(getHostFileTime "$itemName") -eq $TUE ]] || return 4
1142 | [[ $(cat "$RMVBL/$itemName") == "host content" ]] || return 2
1143 | [[ $(getRmvblFileTime "$itemName") -eq $TUE ]] || return 5
1144 | grep "$itemName: first time syncing from host to removable drive"<<<"$holdallOutput" >/dev/null || return 6
1145 | checkLastSyncTimeIsRecent "$itemName" || return 10
1146 | checkUTDisJustThisHost "$itemName" || return 11
1147 | return 0
1148 | }
1149 |
1150 | # units where the item is on the removable drive but not the host
1151 | # unit080 DESCRIPTION: SP, UTD, NHE, RE, should say host is missing
1152 | unit080Initialise(){
1153 | local itemName="unit 080"
1154 | addToLocsList "$itemName"
1155 | writeToRmvblFile "$itemName" "rmvbl content"
1156 | setRmvblFileTime "$itemName" $WED
1157 | setSyncTime "$itemName" $THU
1158 | setUTDTrue "$itemName"
1159 | }
1160 | unit080Check(){
1161 | local itemName="unit 080"
1162 | [[ $(cat "$RMVBL/$itemName") == "rmvbl content" ]] || return 2
1163 | [[ $(getRmvblFileTime "$itemName") -eq $WED ]] || return 5
1164 | grep "$itemName: $WARNINGSyncedButHostAbsent"<<<"$holdallOutput" >/dev/null || return 6
1165 | [[ -e "$HOST/$itemName" ]] && return 7
1166 | [[ $(getSyncTime "$itemName") -eq $THU ]] || return 10
1167 | checkUTDisThisHostAndSomeOtherHost "$itemName" || return 11
1168 | return 0
1169 | }
1170 | # unit081 DESCRIPTION: SP, NUTD, NHE, RE, should say host is missing
1171 | unit081Initialise(){
1172 | local itemName="unit 081"
1173 | addToLocsList "$itemName"
1174 | writeToRmvblFile "$itemName" "rmvbl content"
1175 | setRmvblFileTime "$itemName" $WED
1176 | setSyncTime "$itemName" $THU
1177 | setUTDFalse "$itemName"
1178 | }
1179 | unit081Check(){
1180 | local itemName="unit 081"
1181 | [[ $(cat "$RMVBL/$itemName") == "rmvbl content" ]] || return 2
1182 | [[ $(getRmvblFileTime "$itemName") -eq $WED ]] || return 5
1183 | grep "$itemName: $WARNINGSyncedButHostAbsent"<<<"$holdallOutput" >/dev/null || return 6
1184 | [[ -e "$HOST/$itemName" ]] && return 7
1185 | [[ $(getSyncTime "$itemName") -eq $THU ]] || return 10
1186 | checkUTDisJustSomeOtherHost "$itemName" || return 11
1187 | return 0
1188 | }
1189 | # unit082 DESCRIPTION: NSP, NUTD, NHE, RE, should sync rmvbl>host
1190 | unit082Initialise(){
1191 | local itemName="unit 082"
1192 | addToLocsList "$itemName"
1193 | writeToRmvblFile "$itemName" "rmvbl content"
1194 | setRmvblFileTime "$itemName" $WED
1195 | setUTDFalse "$itemName"
1196 | }
1197 | unit082Check(){
1198 | local itemName="unit 082"
1199 | [[ $(cat "$HOST/$itemName") == "rmvbl content" ]] || return 1
1200 | [[ $(getHostFileTime "$itemName") -eq $WED ]] || return 4
1201 | [[ $(cat "$RMVBL/$itemName") == "rmvbl content" ]] || return 2
1202 | [[ $(getRmvblFileTime "$itemName") -eq $WED ]] || return 5
1203 | grep "$itemName: first time syncing from removable drive to host"<<<"$holdallOutput" >/dev/null || return 6
1204 | checkLastSyncTimeIsRecent "$itemName" || return 10
1205 | checkUTDisThisHostAndSomeOtherHost "$itemName" || return 11
1206 | return 0
1207 | }
1208 |
1209 | # unit where the host and rvmbl are both present, but there is no sync record
1210 | # unit090 DESCRIPTION: NSP, NUTD, HE, RE, HT < RT, should say sync record is missing, do nothing, item is file
1211 | unit090Initialise(){
1212 | local itemName="unit 090"
1213 | addToLocsList "$itemName"
1214 | writeToRmvblFile "$itemName" "rmvbl content"
1215 | setRmvblFileTime "$itemName" $WED
1216 | writeToHostFile "$itemName" "host content"
1217 | setHostFileTime "$itemName" $TUE
1218 | setUTDFalse "$itemName"
1219 | }
1220 | unit090Check(){
1221 | local itemName="unit 090"
1222 | [[ $(cat "$HOST/$itemName") == "host content" ]] || return 1
1223 | [[ $(getHostFileTime "$itemName") -eq $TUE ]] || return 4
1224 | [[ $(cat "$RMVBL/$itemName") == "rmvbl content" ]] || return 2
1225 | [[ $(getRmvblFileTime "$itemName") -eq $WED ]] || return 5
1226 | grep "$itemName: $WARNINGUnexpectedSyncStatusAbsence"<<<"$holdallOutput" >/dev/null || return 6
1227 | checkLastSyncTimeIsNotRecent "$itemName" || return 10
1228 | checkUTDisJustSomeOtherHost "$itemName" || return 11
1229 | return 0
1230 | }
1231 | # unit091 DESCRIPTION: NSP, NUTD, HE, RE, HT < RT, should say sync record is missing, merge rmvbl>host, item is directory
1232 | unit091Initialise(){
1233 | local itemName="unit 091"
1234 | addToLocsList "$itemName"
1235 | writeToRmvblDir "$itemName" "rmvbl content"
1236 | setRmvblDirTime "$itemName" $WED
1237 | writeToHostDir "$itemName" "host content"
1238 | setHostDirTime "$itemName" $TUE
1239 | setUTDFalse "$itemName"
1240 | }
1241 | unit091Check(){
1242 | local itemName="unit 091"
1243 | [[ $(cat "$HOST/$itemName/file01") == "rmvbl content" ]] || return 1
1244 | [[ $(getHostDirContentsTime "$itemName") -eq $WED ]] || return 4
1245 | checkHostTopLevelDirTimeIsRecent "$itemName" || return 12
1246 | [[ $(cat "$HOST/$itemName/"*-removed*) == "host content" ]] || return 3
1247 | [[ $(cat "$RMVBL/$itemName/file01") == "rmvbl content" ]] || return 2
1248 | [[ $(getRmvblDirContentsTime "$itemName") -eq $WED ]] || return 5
1249 | grep "$itemName: $WARNINGUnexpectedSyncStatusAbsence"<<<"$holdallOutput" >/dev/null || return 6
1250 | checkLastSyncTimeIsNotRecent "$itemName" || return 10
1251 | checkUTDisJustThisHost "$itemName" || return 11
1252 | }
1253 | # unit093 DESCRIPTION: NSP, NUTD, HE, RE, RT < HT, should say sync record is missing, do nothing, item is file
1254 | unit093Initialise(){
1255 | local itemName="unit 093"
1256 | addToLocsList "$itemName"
1257 | writeToRmvblFile "$itemName" "rmvbl content"
1258 | setRmvblFileTime "$itemName" $TUE
1259 | writeToHostFile "$itemName" "host content"
1260 | setHostFileTime "$itemName" $WED
1261 | setUTDFalse "$itemName"
1262 | }
1263 | unit093Check(){
1264 | local itemName="unit 093"
1265 | [[ $(cat "$HOST/$itemName") == "host content" ]] || return 1
1266 | [[ $(getHostFileTime "$itemName") -eq $WED ]] || return 4
1267 | [[ $(cat "$RMVBL/$itemName") == "rmvbl content" ]] || return 2
1268 | [[ $(getRmvblFileTime "$itemName") -eq $TUE ]] || return 5
1269 | grep "$itemName: $WARNINGUnexpectedSyncStatusAbsence"<<<"$holdallOutput" >/dev/null || return 6
1270 | checkLastSyncTimeIsNotRecent "$itemName" || return 10
1271 | checkUTDisJustSomeOtherHost "$itemName" || return 11
1272 | return 0
1273 | }
1274 | # unit094 DESCRIPTION: NSP, NUTD, HE, RE, RT < HT, should say sync record is missing, merge host>rmvbl, item is directory
1275 | unit094Initialise(){
1276 | local itemName="unit 094"
1277 | addToLocsList "$itemName"
1278 | writeToRmvblDir "$itemName" "rmvbl content"
1279 | setRmvblDirTime "$itemName" $TUE
1280 | writeToHostDir "$itemName" "host content"
1281 | setHostDirTime "$itemName" $WED
1282 | setUTDFalse "$itemName"
1283 | }
1284 | unit094Check(){
1285 | local itemName="unit 094"
1286 | [[ $(cat "$HOST/$itemName/file01") == "host content" ]] || return 1
1287 | [[ $(getHostDirContentsTime "$itemName") -eq $WED ]] || return 4
1288 | [[ $(cat "$RMVBL/$itemName/"*-removed*) == "rmvbl content" ]] || return 3
1289 | [[ $(cat "$RMVBL/$itemName/file01") == "host content" ]] || return 2
1290 | [[ $(getRmvblDirContentsTime "$itemName") -eq $WED ]] || return 5
1291 | checkRmvblTopLevelDirTimeIsRecent "$itemName" || return 12
1292 | grep "$itemName: $WARNINGUnexpectedSyncStatusAbsence"<<<"$holdallOutput" >/dev/null || return 6
1293 | checkLastSyncTimeIsNotRecent "$itemName" || return 10
1294 | checkUTDisNoHosts "$itemName" || return 11
1295 | return 0
1296 | }
1297 | # unit095 DESCRIPTION: NSP, NUTD, HE, RE, HT = RT, should say sync record is missing, do no merge
1298 | unit095Initialise(){
1299 | local itemName="unit 095"
1300 | addToLocsList "$itemName"
1301 | writeToRmvblFile "$itemName" "rmvbl content"
1302 | setRmvblFileTime "$itemName" $TUE
1303 | writeToHostFile "$itemName" "host content"
1304 | setHostFileTime "$itemName" $TUE
1305 | setUTDFalse "$itemName"
1306 | }
1307 | unit095Check(){
1308 | local itemName="unit 095"
1309 | [[ $(cat "$HOST/$itemName") == "host content" ]] || return 1
1310 | [[ $(getHostFileTime "$itemName") -eq $TUE ]] || return 4
1311 | [[ $(cat "$RMVBL/$itemName") == "rmvbl content" ]] || return 2
1312 | [[ $(getRmvblFileTime "$itemName") -eq $TUE ]] || return 5
1313 | grep "$itemName: $WARNINGUnexpectedSyncStatusAbsence"<<<"$holdallOutput" >/dev/null || return 6
1314 | checkLastSyncTimeAbsent "$itemName" || return 10
1315 | checkUTDisJustSomeOtherHost "$itemName" || return 11
1316 | return 0
1317 | }
1318 |
1319 |
1320 |
1321 |
1322 | main(){
1323 | [[ -f $HOST ]] && (echo "there is a file with the name $HOST that I wanted to use as a folder name"; exit 1)
1324 | [[ -f $RMVBL ]] && (echo "there is a file with the name $RMVBL that I wanted to use as a folder name"; exit 2)
1325 |
1326 | local holdallCustomOptions="$@"
1327 | if [[ ! -z $holdallCustomOptions ]]; then echo "custom options are being used - the tests are not designed for any custom options!"; fi
1328 |
1329 | echo
1330 | [[ -d "$HOST" ]] && (echo "deleting $HOST"; rm -Ir "$HOST")
1331 | mkdir "$HOST"
1332 | [[ -d "$RMVBL" ]] && (echo "deleting $RMVBL"; rm -Ir "$RMVBL")
1333 | mkdir "$RMVBL"
1334 | echo
1335 |
1336 | # get a list of all the unit functions that have been declared above by self-grepping (!)
1337 | listOfUnits="$(grep -o '^unit[0-9][0-9][0-9][a-zA-Z0-9]*(){\s*$' $PROGNAME | grep -o '^unit[0-9]*' | sort | uniq)"
1338 |
1339 | # run all the initialisers
1340 | echo "initialising..."
1341 | for unit in $listOfUnits
1342 | do
1343 | ${unit}Initialise
1344 | done
1345 | echo "initialised"
1346 |
1347 | echo
1348 | echo "running holdall"
1349 | # run holdall
1350 | #readonly holdallOutput="$(bash holdall.sh $holdallCustomOptions -b 1 -a holdAllTesterSimulatedRmvbl)" # store output in GLOBAL VARIABLE!
1351 | echo "_________________________________________________________________________________"
1352 | bash holdall.sh $holdallCustomOptions -b 1 -a "$RMVBL" | tee holdallTesterHoldallSavedOutput
1353 | echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
1354 | readonly holdallOutput="$(cat holdallTesterHoldallSavedOutput)" # global variable!
1355 |
1356 | # run all the checkers
1357 | echo
1358 | echo "evaluating tests..."
1359 | for unit in $listOfUnits
1360 | do
1361 | echo "evaluating test $unit"
1362 | local unitDesc="$(sed -n "s/# $unit DESCRIPTION: \(.*\)/\1/p" $PROGNAME )" # save the description comment for this unit
1363 | set +e
1364 | ${unit}Check # run this unit's checker
1365 | unitExitVal=$?
1366 | set -e
1367 | [[ $unitExitVal -eq 0 ]] && appendLineToReport "$unit@Pass@$unitDesc" || appendLineToReport "$unit@fail state $unitExitVal@$unitDesc"
1368 | done
1369 |
1370 | echo -e "$report" | column -t -s "@"
1371 |
1372 | echo
1373 | if [[ ! -z $holdallCustomOptions ]]; then echo "BUT custom options were used that the tests were not designed for"; fi
1374 | echo
1375 | echo "end of script"
1376 | }
1377 |
1378 | main $@
1379 |
1380 |
1381 |
1382 |
1383 |
1384 |
1385 |
--------------------------------------------------------------------------------
/truthTables.ods:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alunperkins/holdall/1dc4d32575eda8eaa363e4299423219c3105c1f8/truthTables.ods
--------------------------------------------------------------------------------
/usingLocationsListFile_MikeExample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alunperkins/holdall/1dc4d32575eda8eaa363e4299423219c3105c1f8/usingLocationsListFile_MikeExample.png
--------------------------------------------------------------------------------
/usingLocationsListFile_MikeExample.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
714 |
--------------------------------------------------------------------------------