mirror of
https://github.com/FPGArtktic/GnuRAMage.git
synced 2025-07-24 19:57:50 +00:00
feat: hello from my homelab repo
This commit is contained in:
commit
154ad75a0c
9 changed files with 2281 additions and 0 deletions
29
GnuRAMage.ini
Normal file
29
GnuRAMage.ini
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
# GnuRAMage Configuration File
|
||||||
|
# This file configures the behavior of the GnuRAMage synchronization tool.
|
||||||
|
|
||||||
|
[SETTINGS]
|
||||||
|
# Interval between synchronizations in seconds (default: 180 seconds = 3 minutes)
|
||||||
|
sync_interval = 10
|
||||||
|
|
||||||
|
# Log level: ERROR, WARN, INFO, DEBUG
|
||||||
|
log_level = INFO
|
||||||
|
|
||||||
|
# Verify checksums during sync (slower but more accurate)
|
||||||
|
verify_checksums = false
|
||||||
|
|
||||||
|
[DIRECTORIES]
|
||||||
|
# Source directory on hard disk
|
||||||
|
source_dir = /home/.../HARD-DRIVE/
|
||||||
|
|
||||||
|
# Target directory on RAM disk
|
||||||
|
ramdisk_dir = /home/.../RAMDISC/test
|
||||||
|
|
||||||
|
[EXCLUDE]
|
||||||
|
# Patterns to exclude from synchronization
|
||||||
|
# Each line is a pattern in rsync format
|
||||||
|
*.bak
|
||||||
|
*.tmp
|
||||||
|
temp_*
|
||||||
|
test_ignore_dir/
|
||||||
|
|
||||||
|
|
675
LICENSE
Normal file
675
LICENSE
Normal file
|
@ -0,0 +1,675 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
GnuRAMage
|
||||||
|
Copyright (C) 2025 Mateusz Okulanis
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
Email: FPGArtktic@outlook.com
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
GnuRAMage Copyright (C) 2025 Mateusz Okulanis
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
377
README.md
Normal file
377
README.md
Normal file
|
@ -0,0 +1,377 @@
|
||||||
|
# GnuRAMage - The GNU RAM Disk Synchronization Tool
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<img src="docs/logo.png" alt="GnuRAMage Logo" width="500"/>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
## What is GnuRAMage?
|
||||||
|
|
||||||
|
GnuRAMage is a sophisticated yet humble Bash tool that bridges the gap between your sluggish rotating rust (hard drives) and the blazing fast silicon heaven (RAM disks). It's like having a very diligent intern who never sleeps, constantly ensuring your files are where they should be, when they should be there.
|
||||||
|
|
||||||
|
This tool was born out of the necessity to manage multi-terabyte RAM disks without losing one's sanity or data. Because let's face it, having terabytes of RAM without proper synchronization is like having a Ferrari without brakes - exciting, but ultimately catastrophic.
|
||||||
|
|
||||||
|
## Table of Contents
|
||||||
|
|
||||||
|
- [What is GnuRAMage?](#what-is-gnuramage)
|
||||||
|
- [Features](#features)
|
||||||
|
- [Why Would You Want This?](#why-would-you-want-this)
|
||||||
|
- [Requirements](#requirements)
|
||||||
|
- [Installation](#installation)
|
||||||
|
- [Configuration](#configuration)
|
||||||
|
- [Usage](#usage)
|
||||||
|
- [Examples](#examples)
|
||||||
|
- [Testing](#testing)
|
||||||
|
- [Contributing](#contributing)
|
||||||
|
- [License](#license)
|
||||||
|
- [Author](#author)
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
GnuRAMage comes packed with features that would make even the most demanding sysadmin shed a tear of joy:
|
||||||
|
|
||||||
|
- **Automatic File Copying**: Intelligently copies files from hard disk to RAM disk (because manual copying is for peasants)
|
||||||
|
- **Periodic Synchronization**: Regular sync-back to hard disk (because RAM is volatile, unlike our commitment to data integrity)
|
||||||
|
- **Exclusion Patterns**: Support for excluding files and directories (because not everything deserves the RAM treatment)
|
||||||
|
- **INI Configuration**: Human-readable configuration format (unlike some tools that use hieroglyphics)
|
||||||
|
- **Comprehensive Logging**: Multiple log levels and optional error-only logs (for when you want to pretend everything is fine)
|
||||||
|
- **Dry Run Mode**: Test operations without actually doing anything (for the cautious and the paranoid)
|
||||||
|
- **One-time Mode**: Single synchronization cycle (for those commitment-phobic moments)
|
||||||
|
- **Signal Handling**: Graceful shutdown on interruption (because even tools need manners)
|
||||||
|
- **Checksum Verification**: Optional data integrity checks (for the truly paranoid)
|
||||||
|
- **Script Generation**: Creates standalone scripts for automation (delegation at its finest)
|
||||||
|
|
||||||
|
## Why Would You Want This?
|
||||||
|
|
||||||
|
### The Problem
|
||||||
|
You have a massive RAM disk - perhaps several terabytes of the finest DDR5 money can buy. You want to use it for frequently accessed files to achieve ludicrous speed improvements. But you also don't want to lose your data when the power goes out, the cat trips over the power cord, or the universe decides to have a cosmic ray event.
|
||||||
|
|
||||||
|
### The Solution
|
||||||
|
GnuRAMage acts as your faithful guardian, ensuring that:
|
||||||
|
1. Your files get copied to the RAM disk for blazing fast access
|
||||||
|
2. Changes are periodically synchronized back to persistent storage
|
||||||
|
3. Your data survives power outages, system crashes, and acts of feline interference
|
||||||
|
4. You can sleep peacefully knowing your multi-thousand-dollar RAM investment is properly protected
|
||||||
|
|
||||||
|
### The GNU Way
|
||||||
|
In true GNU tradition, GnuRAMage is:
|
||||||
|
- **Free** (as in freedom, not as in "free puppy that costs $500/month in food")
|
||||||
|
- **Extensible** (modify it to your heart's content)
|
||||||
|
- **Well-documented** (this README is proof of our commitment to verbosity)
|
||||||
|
- **Standards-compliant** (follows POSIX where possible, and good sense everywhere else)
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- **Bash**: Version 4.0 or later (because life's too short for ancient shells)
|
||||||
|
- **rsync**: The Swiss Army knife of file synchronization
|
||||||
|
- **GNU/Linux**: Any reasonably modern distribution (we're not picky, but we have standards)
|
||||||
|
- **Sufficient RAM**: Ideally measured in terabytes, but we won't judge your modest gigabytes
|
||||||
|
- **Coffee**: Optional but highly recommended for optimal performance (applies to both you and the system)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
### The Traditional Way
|
||||||
|
|
||||||
|
1. Clone this repository (or download it like it's 1999):
|
||||||
|
```bash
|
||||||
|
git clone <repository-url>
|
||||||
|
cd priv_ram_disk
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Make the script executable (because files don't execute themselves):
|
||||||
|
```bash
|
||||||
|
chmod +x gramage.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Edit the configuration file to match your setup:
|
||||||
|
```bash
|
||||||
|
cp GnuRAMage.ini.example GnuRAMage.ini
|
||||||
|
$EDITOR GnuRAMage.ini
|
||||||
|
```
|
||||||
|
|
||||||
|
### The Lazy Way
|
||||||
|
|
||||||
|
```bash
|
||||||
|
wget <direct-link-to-script>
|
||||||
|
chmod +x gramage.sh
|
||||||
|
# Edit configuration as needed
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
GnuRAMage uses an INI-style configuration file that's so simple, even a Windows user could understand it. The file is divided into logical sections:
|
||||||
|
|
||||||
|
### [SETTINGS] Section
|
||||||
|
|
||||||
|
```ini
|
||||||
|
# How often to sync (in seconds). 180 = 3 minutes of procrastination
|
||||||
|
sync_interval = 180
|
||||||
|
|
||||||
|
# Log verbosity: ERROR (silent treatment), WARN (passive aggressive),
|
||||||
|
# INFO (chatty), DEBUG (verbose to the point of annoyance)
|
||||||
|
log_level = INFO
|
||||||
|
|
||||||
|
# Verify checksums? true = paranoid but safe, false = living dangerously
|
||||||
|
verify_checksums = false
|
||||||
|
```
|
||||||
|
|
||||||
|
### [DIRECTORIES] Section
|
||||||
|
|
||||||
|
```ini
|
||||||
|
# Where your precious files currently live (the slow storage)
|
||||||
|
source_dir = /path/to/your/slow/storage
|
||||||
|
|
||||||
|
# Where your files will achieve enlightenment (the fast storage)
|
||||||
|
ramdisk_dir = /path/to/your/blazing/fast/ramdisk
|
||||||
|
```
|
||||||
|
|
||||||
|
### [EXCLUDE] Section
|
||||||
|
|
||||||
|
Patterns for files you don't want cluttering your precious RAM:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
# Backup files (because backup-of-backups is just hoarding)
|
||||||
|
*.bak
|
||||||
|
*.tmp
|
||||||
|
|
||||||
|
# Temporary files (the digital equivalent of junk mail)
|
||||||
|
temp_*
|
||||||
|
|
||||||
|
# That one directory you created and forgot about
|
||||||
|
forgotten_project_from_2019/
|
||||||
|
```
|
||||||
|
|
||||||
|
### [CRON] Section
|
||||||
|
|
||||||
|
```ini
|
||||||
|
# When to run automatic syncs (cron format)
|
||||||
|
# Default: every 5 minutes (because patience is overrated)
|
||||||
|
schedule = */5 * * * *
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Basic Syntax
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./gramage.sh [OPTIONS]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Command Line Options
|
||||||
|
|
||||||
|
| Option | Description | Example |
|
||||||
|
|--------|-------------|---------|
|
||||||
|
| `--config <file>` | Use custom config file | `--config my_setup.ini` |
|
||||||
|
| `--dry-run` | Simulate without actual changes | Perfect for the commitment-phobic |
|
||||||
|
| `--verbose` or `-v` | Detailed output | For when you want to know everything |
|
||||||
|
| `--logs <file>` | Write logs to file | `--logs sync.log` |
|
||||||
|
| `--errors-log <file>` | Separate error log | `--errors-log errors.log` |
|
||||||
|
| `--script-gen-only` | Generate scripts and exit | For the delegation enthusiasts |
|
||||||
|
| `--one-time` | Single sync cycle | One and done |
|
||||||
|
| `--help` | Display help | When all else fails |
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Basic Operation
|
||||||
|
|
||||||
|
Start GnuRAMage with default settings:
|
||||||
|
```bash
|
||||||
|
./gramage.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
This will:
|
||||||
|
1. Read `GnuRAMage.ini`
|
||||||
|
2. Copy files to RAM disk
|
||||||
|
3. Start periodic synchronization
|
||||||
|
4. Run until interrupted (Ctrl+C like a civilized person)
|
||||||
|
|
||||||
|
### Paranoid Mode
|
||||||
|
|
||||||
|
Run with verbose output and comprehensive logging:
|
||||||
|
```bash
|
||||||
|
./gramage.sh --verbose --logs detailed.log --errors-log problems.log
|
||||||
|
```
|
||||||
|
|
||||||
|
### Test Drive
|
||||||
|
|
||||||
|
Try before you buy with dry-run mode:
|
||||||
|
```bash
|
||||||
|
./gramage.sh --dry-run --verbose
|
||||||
|
```
|
||||||
|
|
||||||
|
This shows you what would happen without actually doing it - like a preview of your life choices.
|
||||||
|
|
||||||
|
### One-Shot Sync
|
||||||
|
|
||||||
|
For those commitment-averse moments:
|
||||||
|
```bash
|
||||||
|
./gramage.sh --one-time --verbose
|
||||||
|
```
|
||||||
|
|
||||||
|
### Script Generation Only
|
||||||
|
|
||||||
|
Generate automation scripts without starting the sync:
|
||||||
|
```bash
|
||||||
|
./gramage.sh --script-gen-only
|
||||||
|
```
|
||||||
|
|
||||||
|
This creates:
|
||||||
|
- `gramage_copy_to_ram.sh` - Initial copy script
|
||||||
|
- `gramage_sync_to_disk.sh` - Periodic sync script
|
||||||
|
|
||||||
|
Perfect for integrating with your existing automation or cron jobs.
|
||||||
|
|
||||||
|
### Custom Configuration
|
||||||
|
|
||||||
|
Use a different configuration file:
|
||||||
|
```bash
|
||||||
|
./gramage.sh --config production.ini --logs production.log
|
||||||
|
```
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
We've included a comprehensive test suite because untested code is like unverified file transfers - a recipe for disaster.
|
||||||
|
|
||||||
|
### Running Tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd test
|
||||||
|
./run_test.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
The test suite verifies:
|
||||||
|
- Script existence and permissions (basic sanity checks)
|
||||||
|
- Configuration parsing (because INI files can be tricky)
|
||||||
|
- Script generation (delegation functionality)
|
||||||
|
- File operations (the core purpose of our existence)
|
||||||
|
- Exclusion patterns (making sure ignored files stay ignored)
|
||||||
|
- Logging functionality (documenting our achievements and failures)
|
||||||
|
|
||||||
|
### Test Environment Generator
|
||||||
|
|
||||||
|
Create a test environment with sample files:
|
||||||
|
```bash
|
||||||
|
cd test
|
||||||
|
./test_generator.sh --files 100 --dirs 10 --size 1M
|
||||||
|
```
|
||||||
|
|
||||||
|
This creates a realistic test environment with:
|
||||||
|
- Multiple directories with nested structures
|
||||||
|
- Various file types and sizes
|
||||||
|
- Files that should be excluded (to test our exclusion logic)
|
||||||
|
|
||||||
|
## How It Works
|
||||||
|
|
||||||
|
### The Philosophy
|
||||||
|
|
||||||
|
GnuRAMage follows the UNIX philosophy: do one thing and do it well. That one thing happens to be "make your files faster while keeping them safe," which admittedly is more like two things, but who's counting?
|
||||||
|
|
||||||
|
### The Process
|
||||||
|
|
||||||
|
1. **Initialization**: Parse configuration, check dependencies, validate paths
|
||||||
|
2. **Initial Copy**: Copy files from slow storage to fast storage
|
||||||
|
3. **Monitoring Loop**: Periodically sync changes back to persistent storage
|
||||||
|
4. **Graceful Shutdown**: On interruption, perform final sync and cleanup
|
||||||
|
|
||||||
|
### The Magic
|
||||||
|
|
||||||
|
- Uses `rsync` for efficient synchronization (because reinventing the wheel is overrated)
|
||||||
|
- Employs intelligent exclusion patterns (your `.tmp` files don't deserve RAM)
|
||||||
|
- Provides comprehensive logging (for debugging and bragging rights)
|
||||||
|
- Handles signals gracefully (manners matter, even in code)
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Common Issues
|
||||||
|
|
||||||
|
**"rsync not found"**
|
||||||
|
- Install rsync: `sudo apt-get install rsync` (Debian/Ubuntu) or equivalent
|
||||||
|
|
||||||
|
**"Permission denied"**
|
||||||
|
- Check file permissions: `chmod +x gramage.sh`
|
||||||
|
- Verify directory access rights
|
||||||
|
|
||||||
|
**"Configuration file not found"**
|
||||||
|
- Ensure `GnuRAMage.ini` exists in the script directory
|
||||||
|
- Use `--config` to specify a different location
|
||||||
|
|
||||||
|
**"RAM disk not mounted"**
|
||||||
|
- Verify your RAM disk is properly mounted
|
||||||
|
- Check mount points with `mount | grep tmpfs`
|
||||||
|
|
||||||
|
### Getting Help
|
||||||
|
|
||||||
|
1. Read this README (you're already doing great!)
|
||||||
|
2. Check the logs (they're surprisingly informative)
|
||||||
|
3. Use `--dry-run --verbose` to see what's happening
|
||||||
|
4. File an issue (we're surprisingly responsive)
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Contributions are welcome! This is free software, after all. Whether you want to:
|
||||||
|
|
||||||
|
- Fix bugs (our favorite kind of contribution)
|
||||||
|
- Add features (preferably ones that make sense)
|
||||||
|
- Improve documentation (because more words are always better)
|
||||||
|
- Write tests (the unsung heroes of software development)
|
||||||
|
|
||||||
|
Please follow these guidelines:
|
||||||
|
|
||||||
|
1. **Follow GNU coding standards** (or at least pretend to)
|
||||||
|
2. **Write tests** (your future self will thank you)
|
||||||
|
3. **Update documentation** (this README won't update itself)
|
||||||
|
4. **Use meaningful commit messages** ("fix stuff" is not meaningful)
|
||||||
|
|
||||||
|
### Code Style
|
||||||
|
|
||||||
|
- Use 4 spaces for indentation (not tabs, we're not barbarians)
|
||||||
|
- Comment your code (future you is practically a different person)
|
||||||
|
- Follow existing conventions (consistency is key)
|
||||||
|
- Keep functions focused (do one thing well)
|
||||||
|
|
||||||
|
## Reporting Bugs
|
||||||
|
|
||||||
|
Found a bug? Congratulations! You've contributed to the improvement of this software. Please report it with:
|
||||||
|
|
||||||
|
1. **Clear description** of the problem
|
||||||
|
2. **Steps to reproduce** (be specific)
|
||||||
|
3. **Expected vs actual behavior**
|
||||||
|
4. **Log files** if available
|
||||||
|
5. **System information** (OS, RAM size, phase of moon)
|
||||||
|
|
||||||
|
## Future Enhancements
|
||||||
|
|
||||||
|
Ideas for future versions (contributions welcome):
|
||||||
|
|
||||||
|
- **Web interface** (because everything needs a web interface these days)
|
||||||
|
- **Real-time monitoring** (for the dashboard enthusiasts)
|
||||||
|
- **Multiple RAM disk support** (because more is always better)
|
||||||
|
- **Compression support** (squeeze more files into that precious RAM)
|
||||||
|
- **Network synchronization** (for the distributed storage aficionados)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
### In Plain English
|
||||||
|
|
||||||
|
- **Use it** for whatever you want (commercial, personal, world domination)
|
||||||
|
- **Modify it** to your heart's content
|
||||||
|
- **Share it** with friends, enemies, and random strangers
|
||||||
|
- **Don't blame us** if it breaks something (though we tried really hard to make it not break things)
|
||||||
|
|
||||||
|
## Author
|
||||||
|
|
||||||
|
**Mateusz Okulanis**
|
||||||
|
Email: FPGArtktic@outlook.com
|
||||||
|
|
||||||
|
Creator, maintainer, and chief RAM disk enthusiast. Available for consulting, debugging sessions, and philosophical discussions about the nature of persistent vs. volatile storage.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*"In a world full of slow storage, be the RAM disk synchronization tool."* - Ancient GNU Proverb (probably)
|
||||||
|
|
||||||
|
**Note**: This software was developed with love, caffeine, and an unhealthy obsession with making things faster. Use responsibly.
|
BIN
docs/logo.png
Normal file
BIN
docs/logo.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 1.3 MiB |
625
gramage.sh
Executable file
625
gramage.sh
Executable file
|
@ -0,0 +1,625 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# GnuRAMage: Advanced RAM Disk Synchronization Tool
|
||||||
|
# Version: 1.0.0
|
||||||
|
#
|
||||||
|
# Copyright (C) 2025 Mateusz Okulanis
|
||||||
|
# Email: FPGArtktic@outlook.com
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# Default values
|
||||||
|
CONFIG_FILE="GnuRAMage.ini"
|
||||||
|
DRY_RUN=false
|
||||||
|
VERBOSE=false
|
||||||
|
LOGS_FILE=""
|
||||||
|
ERRORS_LOG_FILE=""
|
||||||
|
SCRIPT_GEN_ONLY=false
|
||||||
|
ONE_TIME_MODE=false
|
||||||
|
SYNC_INTERVAL=180 # Default sync interval in seconds (3 minutes)
|
||||||
|
LOG_LEVEL="INFO" # Default log level: ERROR, WARN, INFO, DEBUG
|
||||||
|
VERIFY_CHECKSUMS=false
|
||||||
|
DEFAULT_SOURCE_DIR=""
|
||||||
|
DEFAULT_RAMDISK_DIR=""
|
||||||
|
|
||||||
|
# Get script directory
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# File paths for generated scripts
|
||||||
|
RSYNC_SCRIPT="${SCRIPT_DIR}/gramage_sync_to_disk.sh"
|
||||||
|
CP_SCRIPT="${SCRIPT_DIR}/gramage_copy_to_ram.sh"
|
||||||
|
|
||||||
|
# Statistics for report
|
||||||
|
TOTAL_FILES_COPIED=0
|
||||||
|
TOTAL_FILES_SYNCED=0
|
||||||
|
START_TIME=$(date +%s)
|
||||||
|
|
||||||
|
# Variables for cleanup
|
||||||
|
CLEANUP_NEEDED=false
|
||||||
|
TRAP_REGISTERED=false
|
||||||
|
|
||||||
|
# Print usage information
|
||||||
|
print_usage() {
|
||||||
|
echo "Usage: $0 [OPTIONS]"
|
||||||
|
echo "GnuRAMage: Advanced RAM Disk Synchronization Tool"
|
||||||
|
echo ""
|
||||||
|
echo "Options:"
|
||||||
|
echo " --config <file> Path to the configuration file (default: GnuRAMage.ini)"
|
||||||
|
echo " --dry-run Simulate operations without actually copying/syncing files"
|
||||||
|
echo " --verbose, -v Display more detailed information about operations"
|
||||||
|
echo " --logs <file> Write logs to the specified file (TXT or JSON)"
|
||||||
|
echo " --errors-log <file> Write error logs to the specified file (TXT or JSON)"
|
||||||
|
echo " --script-gen-only Generate scripts only, don't start synchronization"
|
||||||
|
echo " --one-time Run only one synchronization cycle (no loop)"
|
||||||
|
echo " --help Display this help message and exit"
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
# Log levels
|
||||||
|
LOG_LEVEL_ERROR=0
|
||||||
|
LOG_LEVEL_WARN=1
|
||||||
|
LOG_LEVEL_INFO=2
|
||||||
|
LOG_LEVEL_DEBUG=3
|
||||||
|
|
||||||
|
# Function to convert log level string to numeric value
|
||||||
|
get_log_level_value() {
|
||||||
|
case "$1" in
|
||||||
|
"ERROR") echo $LOG_LEVEL_ERROR ;;
|
||||||
|
"WARN") echo $LOG_LEVEL_WARN ;;
|
||||||
|
"INFO") echo $LOG_LEVEL_INFO ;;
|
||||||
|
"DEBUG") echo $LOG_LEVEL_DEBUG ;;
|
||||||
|
*) echo $LOG_LEVEL_INFO ;; # Default to INFO
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# Parse command line arguments
|
||||||
|
parse_arguments() {
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
--config)
|
||||||
|
CONFIG_FILE="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--dry-run)
|
||||||
|
DRY_RUN=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--verbose|-v)
|
||||||
|
VERBOSE=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--logs)
|
||||||
|
LOGS_FILE="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--errors-log)
|
||||||
|
ERRORS_LOG_FILE="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--script-gen-only)
|
||||||
|
SCRIPT_GEN_ONLY=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--one-time)
|
||||||
|
ONE_TIME_MODE=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--help)
|
||||||
|
print_usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
log_error "Unknown option: $1"
|
||||||
|
print_usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get current timestamp
|
||||||
|
get_timestamp() {
|
||||||
|
date "+%Y-%m-%d %H:%M:%S"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Log function with levels
|
||||||
|
log() {
|
||||||
|
local level="$1"
|
||||||
|
local message="$2"
|
||||||
|
local timestamp=$(get_timestamp)
|
||||||
|
local numeric_level=$(get_log_level_value "$level")
|
||||||
|
local current_level=$(get_log_level_value "$LOG_LEVEL")
|
||||||
|
|
||||||
|
# Only log if the message level is less than or equal to the current log level
|
||||||
|
if [ $numeric_level -le $current_level ]; then
|
||||||
|
local log_message="[$timestamp] [$level] $message"
|
||||||
|
|
||||||
|
# If not in dry-run mode or if it's an error, show on console
|
||||||
|
if ! $DRY_RUN || [ "$level" = "ERROR" ]; then
|
||||||
|
echo "$log_message"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Log to file if specified
|
||||||
|
if [ -n "$LOGS_FILE" ]; then
|
||||||
|
echo "$log_message" >> "$LOGS_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Log errors to error log file if specified
|
||||||
|
if [ "$level" = "ERROR" ] && [ -n "$ERRORS_LOG_FILE" ]; then
|
||||||
|
echo "$log_message" >> "$ERRORS_LOG_FILE"
|
||||||
|
elif [ "$level" = "WARN" ] && [ -n "$ERRORS_LOG_FILE" ]; then
|
||||||
|
echo "$log_message" >> "$ERRORS_LOG_FILE"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Shorthand logging functions
|
||||||
|
log_error() {
|
||||||
|
log "ERROR" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
log_warn() {
|
||||||
|
log "WARN" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
log_info() {
|
||||||
|
log "INFO" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
log_debug() {
|
||||||
|
log "DEBUG" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if rsync is installed
|
||||||
|
check_rsync() {
|
||||||
|
if ! command -v rsync &> /dev/null; then
|
||||||
|
log_error "rsync is not installed. Please install it and try again."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
log_debug "rsync is installed."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Read and parse INI file
|
||||||
|
parse_config_file() {
|
||||||
|
if [ ! -f "$CONFIG_FILE" ]; then
|
||||||
|
# Check if config file exists in script directory
|
||||||
|
if [ -f "$SCRIPT_DIR/$CONFIG_FILE" ]; then
|
||||||
|
CONFIG_FILE="$SCRIPT_DIR/$CONFIG_FILE"
|
||||||
|
log_debug "Using configuration file from script directory: $CONFIG_FILE"
|
||||||
|
else
|
||||||
|
log_error "Configuration file '$CONFIG_FILE' not found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
log_info "Reading configuration from: $CONFIG_FILE"
|
||||||
|
|
||||||
|
# Read general settings
|
||||||
|
if grep -q "^\[SETTINGS\]" "$CONFIG_FILE"; then
|
||||||
|
# Read sync interval
|
||||||
|
if grep -q "^sync_interval" "$CONFIG_FILE"; then
|
||||||
|
SYNC_INTERVAL=$(grep "^sync_interval" "$CONFIG_FILE" | cut -d= -f2 | tr -d ' ')
|
||||||
|
log_debug "Set sync interval to $SYNC_INTERVAL seconds"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Read log level
|
||||||
|
if grep -q "^log_level" "$CONFIG_FILE"; then
|
||||||
|
LOG_LEVEL=$(grep "^log_level" "$CONFIG_FILE" | cut -d= -f2 | tr -d ' ' | tr '[:lower:]' '[:upper:]')
|
||||||
|
log_debug "Set log level to $LOG_LEVEL"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Read verify checksums setting
|
||||||
|
if grep -q "^verify_checksums" "$CONFIG_FILE"; then
|
||||||
|
verify_checksums_val=$(grep "^verify_checksums" "$CONFIG_FILE" | cut -d= -f2 | tr -d ' ' | tr '[:upper:]' '[:lower:]')
|
||||||
|
if [ "$verify_checksums_val" = "true" ] || [ "$verify_checksums_val" = "1" ] || [ "$verify_checksums_val" = "yes" ]; then
|
||||||
|
VERIFY_CHECKSUMS=true
|
||||||
|
log_debug "Checksum verification enabled"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Read source and destination directories
|
||||||
|
if grep -q "^\[DIRECTORIES\]" "$CONFIG_FILE"; then
|
||||||
|
# Read source directory
|
||||||
|
if grep -q "^source_dir" "$CONFIG_FILE"; then
|
||||||
|
DEFAULT_SOURCE_DIR=$(grep "^source_dir" "$CONFIG_FILE" | cut -d= -f2 | tr -d ' ')
|
||||||
|
log_debug "Source directory: $DEFAULT_SOURCE_DIR"
|
||||||
|
else
|
||||||
|
log_error "Source directory not specified in config file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Read ramdisk directory
|
||||||
|
if grep -q "^ramdisk_dir" "$CONFIG_FILE"; then
|
||||||
|
DEFAULT_RAMDISK_DIR=$(grep "^ramdisk_dir" "$CONFIG_FILE" | cut -d= -f2 | tr -d ' ')
|
||||||
|
log_debug "RAM disk directory: $DEFAULT_RAMDISK_DIR"
|
||||||
|
else
|
||||||
|
log_error "RAM disk directory not specified in config file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log_error "DIRECTORIES section not found in config file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check and create target directories if they don't exist
|
||||||
|
check_directories() {
|
||||||
|
log_info "Checking target directories"
|
||||||
|
|
||||||
|
if [ ! -d "$DEFAULT_SOURCE_DIR" ]; then
|
||||||
|
log_error "Source directory '$DEFAULT_SOURCE_DIR' does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "$DEFAULT_RAMDISK_DIR" ]; then
|
||||||
|
log_info "Creating RAM disk directory: $DEFAULT_RAMDISK_DIR"
|
||||||
|
if ! $DRY_RUN; then
|
||||||
|
mkdir -p "$DEFAULT_RAMDISK_DIR"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
log_error "Failed to create RAM disk directory: $DEFAULT_RAMDISK_DIR"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Generate the rsync script (from RAM disk to hard disk)
|
||||||
|
generate_rsync_script() {
|
||||||
|
log_info "Generating rsync script: $RSYNC_SCRIPT"
|
||||||
|
|
||||||
|
if ! $DRY_RUN; then
|
||||||
|
cat > "$RSYNC_SCRIPT" << EOF
|
||||||
|
#!/bin/bash
|
||||||
|
# Auto-generated rsync script for RAM disk synchronization
|
||||||
|
# Created by GnuRAMage: Advanced RAM Disk Synchronization Tool on $(date)
|
||||||
|
|
||||||
|
# Options explanation:
|
||||||
|
# -a: archive mode (recursive, preserves permissions, timestamps, etc.)
|
||||||
|
# -v: verbose (if --verbose is specified)
|
||||||
|
# --delete: remove files in destination that don't exist in source
|
||||||
|
# --exclude: exclude patterns from config
|
||||||
|
# Check if required variables are set and directories exist
|
||||||
|
if [ -z "$DEFAULT_RAMDISK_DIR" ]; then
|
||||||
|
echo "[ERROR] Source or RAM disk directory variable is empty! Aborting."
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
if [ ! -d "$DEFAULT_RAMDISK_DIR" ]; then
|
||||||
|
echo "[ERROR] Source or RAM disk directory does not exist! Aborting."
|
||||||
|
exit 4
|
||||||
|
fi
|
||||||
|
if [ ! "\$(ls -A "$DEFAULT_RAMDISK_DIR" 2>/dev/null)" ]; then
|
||||||
|
echo "[WARNING] RAM disk directory is empty!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create directories if they don't exist
|
||||||
|
mkdir -p "$DEFAULT_SOURCE_DIR"
|
||||||
|
|
||||||
|
# Build rsync command as array
|
||||||
|
RSYNC_CMD=(rsync -a)
|
||||||
|
|
||||||
|
# Add options based on settings
|
||||||
|
if [ "$1" = "--verbose" ]; then
|
||||||
|
RSYNC_CMD+=( -v )
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" = "--dry-run" ]; then
|
||||||
|
RSYNC_CMD+=( --dry-run )
|
||||||
|
fi
|
||||||
|
|
||||||
|
EOF
|
||||||
|
# Add exclude patterns from INI if they exist, all in one line
|
||||||
|
if grep -q "^\[EXCLUDE\]" "$CONFIG_FILE"; then
|
||||||
|
exclude_patterns=$(sed -n '/^\[EXCLUDE\]/,/^\[/p' "$CONFIG_FILE" | grep -v "^\[" | grep -v "^;" | grep -v "^$" | grep -v '^#' | grep -v -i 'pattern' | grep -v -i 'exclude' | grep -v -i 'synchronization' | grep -v -i 'line' | grep -v -i 'format')
|
||||||
|
for pattern in $exclude_patterns; do
|
||||||
|
echo "RSYNC_CMD+=( --exclude='$pattern' )" >> "$RSYNC_SCRIPT"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
echo "RSYNC_CMD+=( --delete \"$DEFAULT_RAMDISK_DIR/\" \"$DEFAULT_SOURCE_DIR/\" )" >> "$RSYNC_SCRIPT"
|
||||||
|
echo '' >> "$RSYNC_SCRIPT"
|
||||||
|
echo '#echo "[INFO] Rsync command: ${RSYNC_CMD[*]}"' >> "$RSYNC_SCRIPT"
|
||||||
|
echo '# Execute rsync command' >> "$RSYNC_SCRIPT"
|
||||||
|
echo '"${RSYNC_CMD[@]}"' >> "$RSYNC_SCRIPT"
|
||||||
|
|
||||||
|
# Make the script executable
|
||||||
|
chmod +x "$RSYNC_SCRIPT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log_debug "Rsync script generated successfully"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Generate the cp script (from hard disk to RAM disk)
|
||||||
|
generate_cp_script() {
|
||||||
|
log_info "Generating cp script: $CP_SCRIPT"
|
||||||
|
|
||||||
|
if ! $DRY_RUN; then
|
||||||
|
cat > "$CP_SCRIPT" << EOF
|
||||||
|
#!/bin/bash
|
||||||
|
# Auto-generated cp script for RAM disk synchronization
|
||||||
|
# Created by GnuRAMage: Advanced RAM Disk Synchronization Tool on $(date)
|
||||||
|
|
||||||
|
# Create directories if they don't exist
|
||||||
|
mkdir -p "$DEFAULT_RAMDISK_DIR"
|
||||||
|
|
||||||
|
# If verbose flag is set, add -v option to cp
|
||||||
|
CP_CMD="cp -a"
|
||||||
|
if [ "\$1" = "--verbose" ]; then
|
||||||
|
CP_CMD="cp -av"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If dry-run flag is set, just echo what would be done
|
||||||
|
if [ "\$1" = "--dry-run" ]; then
|
||||||
|
echo "Would copy files from $DEFAULT_SOURCE_DIR to $DEFAULT_RAMDISK_DIR"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copy files from source to RAM disk
|
||||||
|
\$CP_CMD "$DEFAULT_SOURCE_DIR"* "$DEFAULT_RAMDISK_DIR" 2>/dev/null
|
||||||
|
|
||||||
|
# Handle case where source directory is empty or no files match
|
||||||
|
if [ \$? -ne 0 ]; then
|
||||||
|
# Check if source directory exists and is not empty
|
||||||
|
if [ -d "$DEFAULT_SOURCE_DIR" ] && [ "\$(ls -A "$DEFAULT_SOURCE_DIR" 2>/dev/null)" ]; then
|
||||||
|
echo "Error: Failed to copy files to RAM disk"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
# Create an empty file to mark successful execution even if no files were copied
|
||||||
|
touch "$DEFAULT_RAMDISK_DIR/.rsyncignore"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Make the script executable
|
||||||
|
chmod +x "$CP_SCRIPT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log_debug "Copy script generated successfully"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execute cp script to copy from hard disk to RAM disk
|
||||||
|
execute_cp_script() {
|
||||||
|
log_info "Executing copy to RAM disk script"
|
||||||
|
|
||||||
|
local verbose_flag=""
|
||||||
|
if $VERBOSE; then
|
||||||
|
verbose_flag="--verbose"
|
||||||
|
fi
|
||||||
|
|
||||||
|
local dry_run_flag=""
|
||||||
|
if $DRY_RUN; then
|
||||||
|
dry_run_flag="--dry-run"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! $DRY_RUN; then
|
||||||
|
if $VERBOSE; then
|
||||||
|
"$CP_SCRIPT" "$verbose_flag"
|
||||||
|
else
|
||||||
|
"$CP_SCRIPT" > /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
log_error "Failed to copy files to RAM disk"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
log_info "Files copied to RAM disk successfully"
|
||||||
|
TOTAL_FILES_COPIED=$(find "$DEFAULT_RAMDISK_DIR" -type f | wc -l)
|
||||||
|
log_debug "Total files copied: $TOTAL_FILES_COPIED"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log_info "Dry run: Would execute copy script"
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execute rsync script to sync from RAM disk to hard disk
|
||||||
|
execute_rsync_script() {
|
||||||
|
log_info "Executing rsync to hard disk script"
|
||||||
|
|
||||||
|
local verbose_flag=""
|
||||||
|
if $VERBOSE; then
|
||||||
|
verbose_flag="--verbose"
|
||||||
|
fi
|
||||||
|
|
||||||
|
local dry_run_flag=""
|
||||||
|
if $DRY_RUN; then
|
||||||
|
dry_run_flag="--dry-run"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! $DRY_RUN; then
|
||||||
|
if $VERBOSE; then
|
||||||
|
"$RSYNC_SCRIPT" "$verbose_flag" 2> /tmp/rsync_error.log
|
||||||
|
else
|
||||||
|
"$RSYNC_SCRIPT" > /dev/null 2> /tmp/rsync_error.log
|
||||||
|
fi
|
||||||
|
|
||||||
|
local rsync_status=$?
|
||||||
|
if [ $rsync_status -ne 0 ]; then
|
||||||
|
local error_msg=$(cat /tmp/rsync_error.log)
|
||||||
|
log_error "Failed to sync files to hard disk: Error code $rsync_status"
|
||||||
|
log_error "Rsync error: $error_msg"
|
||||||
|
# Add rsync errors to the error log as well
|
||||||
|
if [ -n "$ERRORS_LOG_FILE" ]; then
|
||||||
|
echo "[$(get_timestamp)] [ERROR] Rsync error: $error_msg" >> "$ERRORS_LOG_FILE"
|
||||||
|
fi
|
||||||
|
rm -f /tmp/rsync_error.log
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
log_info "Files synced to hard disk successfully"
|
||||||
|
TOTAL_FILES_SYNCED=$((TOTAL_FILES_SYNCED + 1))
|
||||||
|
log_debug "Total sync operations: $TOTAL_FILES_SYNCED"
|
||||||
|
rm -f /tmp/rsync_error.log
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log_info "Dry run: Would execute rsync script"
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Wait for key press with timeout
|
||||||
|
wait_for_key() {
|
||||||
|
local interval=$1
|
||||||
|
log_info "Syncing every $interval seconds. Press any key to stop..."
|
||||||
|
|
||||||
|
# Use read with timeout
|
||||||
|
if read -t "$interval" -n 1 key; then
|
||||||
|
log_info "Key pressed. Stopping synchronization..."
|
||||||
|
return 1 # Key was pressed
|
||||||
|
else
|
||||||
|
return 0 # Timeout occurred
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Initialize log files
|
||||||
|
initialize_log_files() {
|
||||||
|
# Create log file if specified and doesn't exist
|
||||||
|
if [ -n "$LOGS_FILE" ]; then
|
||||||
|
touch "$LOGS_FILE"
|
||||||
|
log_info "Log file initialized: $LOGS_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create error log file if specified and doesn't exist
|
||||||
|
if [ -n "$ERRORS_LOG_FILE" ]; then
|
||||||
|
touch "$ERRORS_LOG_FILE"
|
||||||
|
# Add a header to the error log file
|
||||||
|
echo "[$(get_timestamp)] [INFO] Error log file initialized" > "$ERRORS_LOG_FILE"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Clean up function for proper termination
|
||||||
|
cleanup() {
|
||||||
|
# Skip if cleanup has already been done
|
||||||
|
if $CLEANUP_NEEDED; then
|
||||||
|
log_info "Starting cleanup process..."
|
||||||
|
|
||||||
|
# Final sync before exiting
|
||||||
|
log_info "Performing final sync to disk..."
|
||||||
|
execute_rsync_script
|
||||||
|
|
||||||
|
# Run sync command to ensure data is written to disk
|
||||||
|
if ! $DRY_RUN; then
|
||||||
|
log_info "Running sync command..."
|
||||||
|
sync
|
||||||
|
sync
|
||||||
|
else
|
||||||
|
log_info "Dry run: Would run sync command"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Generate report
|
||||||
|
generate_report
|
||||||
|
|
||||||
|
# Reset cleanup flag
|
||||||
|
CLEANUP_NEEDED=false
|
||||||
|
|
||||||
|
log_info "Cleanup completed. Exiting."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Generate report
|
||||||
|
generate_report() {
|
||||||
|
local end_time=$(date +%s)
|
||||||
|
local duration=$((end_time - START_TIME))
|
||||||
|
local hours=$((duration / 3600))
|
||||||
|
local minutes=$(( (duration % 3600) / 60 ))
|
||||||
|
local seconds=$((duration % 60))
|
||||||
|
|
||||||
|
log_info "===== RAM Disk Sync Report ====="
|
||||||
|
log_info "Start time: $(date -d @$START_TIME)"
|
||||||
|
log_info "End time: $(date -d @$end_time)"
|
||||||
|
log_info "Duration: ${hours}h ${minutes}m ${seconds}s"
|
||||||
|
log_info "Files copied to RAM disk: $TOTAL_FILES_COPIED"
|
||||||
|
log_info "Sync operations performed: $TOTAL_FILES_SYNCED"
|
||||||
|
log_info "============================"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main synchronization loop
|
||||||
|
run_sync_loop() {
|
||||||
|
# Register trap for cleanup
|
||||||
|
if ! $TRAP_REGISTERED; then
|
||||||
|
trap cleanup EXIT INT TERM
|
||||||
|
TRAP_REGISTERED=true
|
||||||
|
CLEANUP_NEEDED=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start report timer
|
||||||
|
START_TIME=$(date +%s)
|
||||||
|
|
||||||
|
# Execute copy script once at start
|
||||||
|
execute_cp_script
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
log_error "Initial copy failed. Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If one-time mode, run rsync once and exit
|
||||||
|
if $ONE_TIME_MODE; then
|
||||||
|
log_info "Running in one-time mode"
|
||||||
|
execute_rsync_script
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Main sync loop
|
||||||
|
log_info "Starting synchronization loop"
|
||||||
|
while true; do
|
||||||
|
# Wait for key press or timeout
|
||||||
|
if ! wait_for_key "$SYNC_INTERVAL"; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Execute rsync script
|
||||||
|
execute_rsync_script
|
||||||
|
done
|
||||||
|
execute_rsync_script
|
||||||
|
log_info "Synchronization loop ended"
|
||||||
|
sync
|
||||||
|
sync
|
||||||
|
log_info "Final sync command executed"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main function
|
||||||
|
main() {
|
||||||
|
# Parse command line arguments
|
||||||
|
parse_arguments "$@"
|
||||||
|
|
||||||
|
# Check if rsync is installed
|
||||||
|
check_rsync
|
||||||
|
|
||||||
|
# Parse configuration file
|
||||||
|
parse_config_file
|
||||||
|
|
||||||
|
# Check and create directories
|
||||||
|
check_directories
|
||||||
|
|
||||||
|
# Generate scripts
|
||||||
|
generate_rsync_script
|
||||||
|
generate_cp_script
|
||||||
|
|
||||||
|
# Initialize log files
|
||||||
|
initialize_log_files
|
||||||
|
|
||||||
|
# Exit if only script generation is requested
|
||||||
|
if $SCRIPT_GEN_ONLY; then
|
||||||
|
log_info "Scripts generated. Exiting as requested."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run synchronization loop
|
||||||
|
run_sync_loop
|
||||||
|
}
|
||||||
|
|
||||||
|
# Start the program
|
||||||
|
main "$@"
|
26
test/gnuramage_test.ini
Normal file
26
test/gnuramage_test.ini
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# GnuRAMage Test Configuration File
|
||||||
|
|
||||||
|
[SETTINGS]
|
||||||
|
# Interval between synchronizations in seconds (short for testing)
|
||||||
|
sync_interval = 10
|
||||||
|
|
||||||
|
# Log level: ERROR, WARN, INFO, DEBUG
|
||||||
|
log_level = DEBUG
|
||||||
|
|
||||||
|
# Verify checksums during sync (test both true and false)
|
||||||
|
verify_checksums = true
|
||||||
|
|
||||||
|
[DIRECTORIES]
|
||||||
|
# Source directory on hard disk
|
||||||
|
source_dir = /tmp/ram_disk_test_source
|
||||||
|
|
||||||
|
# Target directory on RAM disk
|
||||||
|
ramdisk_dir = /tmp/ram_disk_test_ramdisk
|
||||||
|
|
||||||
|
[EXCLUDE]
|
||||||
|
# Patterns to exclude from synchronization
|
||||||
|
# Each line is a pattern in rsync format
|
||||||
|
*.bak
|
||||||
|
*.tmp
|
||||||
|
temp_*
|
||||||
|
test_ignore_dir/
|
26
test/gramage_test.ini
Normal file
26
test/gramage_test.ini
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# GnuRAMage Test Configuration File
|
||||||
|
|
||||||
|
[SETTINGS]
|
||||||
|
# Interval between synchronizations in seconds (short for testing)
|
||||||
|
sync_interval = 10
|
||||||
|
|
||||||
|
# Log level: ERROR, WARN, INFO, DEBUG
|
||||||
|
log_level = DEBUG
|
||||||
|
|
||||||
|
# Verify checksums during sync (test both true and false)
|
||||||
|
verify_checksums = true
|
||||||
|
|
||||||
|
[DIRECTORIES]
|
||||||
|
# Source directory on hard disk
|
||||||
|
source_dir = /tmp/ram_disk_test_source
|
||||||
|
|
||||||
|
# Target directory on RAM disk
|
||||||
|
ramdisk_dir = /tmp/ram_disk_test_ramdisk
|
||||||
|
|
||||||
|
[EXCLUDE]
|
||||||
|
# Patterns to exclude from synchronization
|
||||||
|
# Each line is a pattern in rsync format
|
||||||
|
*.bak
|
||||||
|
*.tmp
|
||||||
|
temp_*
|
||||||
|
test_ignore_dir/
|
351
test/run_test.sh
Executable file
351
test/run_test.sh
Executable file
|
@ -0,0 +1,351 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Test script for GnuRAMage.sh
|
||||||
|
# Automatically verifies the correct operation of the program
|
||||||
|
|
||||||
|
# Colors for console display
|
||||||
|
GREEN="\033[0;32m"
|
||||||
|
RED="\033[0;31m"
|
||||||
|
YELLOW="\033[0;33m"
|
||||||
|
RESET="\033[0m"
|
||||||
|
|
||||||
|
# Test counters
|
||||||
|
TESTS_TOTAL=0
|
||||||
|
TESTS_PASSED=0
|
||||||
|
TESTS_FAILED=0
|
||||||
|
|
||||||
|
# Function to display test headers
|
||||||
|
print_header() {
|
||||||
|
echo -e "\n${YELLOW}=====================================${RESET}"
|
||||||
|
echo -e "${YELLOW}$1${RESET}"
|
||||||
|
echo -e "${YELLOW}=====================================${RESET}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to report test results
|
||||||
|
report_test() {
|
||||||
|
local test_name="$1"
|
||||||
|
local result="$2"
|
||||||
|
local message="$3"
|
||||||
|
|
||||||
|
TESTS_TOTAL=$((TESTS_TOTAL + 1))
|
||||||
|
|
||||||
|
if [ "$result" = "PASS" ]; then
|
||||||
|
TESTS_PASSED=$((TESTS_PASSED + 1))
|
||||||
|
echo -e "${GREEN}✓ PASS:${RESET} $test_name - $message"
|
||||||
|
else
|
||||||
|
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||||
|
echo -e "${RED}✗ FAIL:${RESET} $test_name - $message"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to display summary
|
||||||
|
print_summary() {
|
||||||
|
echo -e "\n${YELLOW}===== TEST SUMMARY =====${RESET}"
|
||||||
|
echo -e "Tests executed: $TESTS_TOTAL"
|
||||||
|
echo -e "${GREEN}Tests passed: $TESTS_PASSED${RESET}"
|
||||||
|
echo -e "${RED}Tests failed: $TESTS_FAILED${RESET}"
|
||||||
|
|
||||||
|
if [ $TESTS_FAILED -eq 0 ]; then
|
||||||
|
echo -e "\n${GREEN}ALL TESTS PASSED SUCCESSFULLY!${RESET}"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo -e "\n${RED}SOME TESTS FAILED!${RESET}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to clean up the test environment
|
||||||
|
cleanup() {
|
||||||
|
echo "Cleaning up test environment..."
|
||||||
|
rm -rf /tmp/ram_disk_test_source /tmp/ram_disk_test_ramdisk
|
||||||
|
rm -f ../gramage_sync_to_disk.sh ../gramage_copy_to_ram.sh
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if the program exists
|
||||||
|
check_program_exists() {
|
||||||
|
print_header "TEST 1: Checking program existence"
|
||||||
|
|
||||||
|
if [ -f "../gramage.sh" ]; then
|
||||||
|
report_test "Program existence" "PASS" "gramage.sh file exists"
|
||||||
|
else
|
||||||
|
report_test "Program existence" "FAIL" "gramage.sh file does not exist"
|
||||||
|
print_summary
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -x "../gramage.sh" ]; then
|
||||||
|
report_test "Program permissions" "PASS" "gramage.sh has execution permissions"
|
||||||
|
else
|
||||||
|
report_test "Program permissions" "FAIL" "gramage.sh does not have execution permissions"
|
||||||
|
chmod +x ../gramage.sh
|
||||||
|
report_test "Fix permissions" "PASS" "Added execution permissions"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check script generation
|
||||||
|
check_script_generation() {
|
||||||
|
print_header "TEST 2: Checking script generation"
|
||||||
|
|
||||||
|
# Remove existing scripts
|
||||||
|
rm -f ../gramage_sync_to_disk.sh ../gramage_copy_to_ram.sh
|
||||||
|
|
||||||
|
# Create source directory first to ensure script generation works
|
||||||
|
mkdir -p /tmp/ram_disk_test_source
|
||||||
|
|
||||||
|
# Generate scripts only
|
||||||
|
../gramage.sh --config gramage_test.ini --script-gen-only
|
||||||
|
|
||||||
|
if [ -f "../gramage_sync_to_disk.sh" ]; then
|
||||||
|
report_test "Generating gramage_sync_to_disk.sh" "PASS" "gramage_sync_to_disk.sh script was generated"
|
||||||
|
else
|
||||||
|
report_test "Generating gramage_sync_to_disk.sh" "FAIL" "gramage_sync_to_disk.sh script was not generated"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "../gramage_copy_to_ram.sh" ]; then
|
||||||
|
report_test "Generating gramage_copy_to_ram.sh" "PASS" "gramage_copy_to_ram.sh script was generated"
|
||||||
|
else
|
||||||
|
report_test "Generating gramage_copy_to_ram.sh" "FAIL" "gramage_copy_to_ram.sh script was not generated"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -x "../gramage_sync_to_disk.sh" ] && [ -x "../gramage_copy_to_ram.sh" ]; then
|
||||||
|
report_test "Script permissions" "PASS" "Both scripts have execution permissions"
|
||||||
|
else
|
||||||
|
report_test "Script permissions" "FAIL" "Scripts do not have execution permissions"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Test environment and directories
|
||||||
|
test_environment() {
|
||||||
|
print_header "TEST 3: Testing environment and directories"
|
||||||
|
|
||||||
|
# Generate test environment
|
||||||
|
./test_generator.sh
|
||||||
|
|
||||||
|
if [ -d "/tmp/ram_disk_test_source" ]; then
|
||||||
|
report_test "Source directory" "PASS" "Directory /tmp/ram_disk_test_source exists"
|
||||||
|
else
|
||||||
|
report_test "Source directory" "FAIL" "Directory /tmp/ram_disk_test_source does not exist"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if there are files in the source directory
|
||||||
|
SOURCE_FILES=$(find /tmp/ram_disk_test_source -type f | wc -l)
|
||||||
|
if [ "$SOURCE_FILES" -gt 0 ]; then
|
||||||
|
report_test "Source files" "PASS" "Found $SOURCE_FILES files in source directory"
|
||||||
|
else
|
||||||
|
report_test "Source files" "FAIL" "No files in source directory"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Test copying from hard disk to RAM disk
|
||||||
|
test_copy_to_ramdisk() {
|
||||||
|
print_header "TEST 4: Testing copying from hard disk to RAM disk"
|
||||||
|
|
||||||
|
# Run the copy script
|
||||||
|
if [ ! -f "../gramage_copy_to_ram.sh" ]; then
|
||||||
|
# Run the main script to generate the scripts
|
||||||
|
../gramage.sh --config gramage_test.ini --script-gen-only
|
||||||
|
fi
|
||||||
|
|
||||||
|
../gramage_copy_to_ram.sh --verbose
|
||||||
|
|
||||||
|
if [ -d "/tmp/ram_disk_test_ramdisk" ]; then
|
||||||
|
report_test "RAM disk directory" "PASS" "Directory /tmp/ram_disk_test_ramdisk exists"
|
||||||
|
else
|
||||||
|
report_test "RAM disk directory" "FAIL" "Directory /tmp/ram_disk_test_ramdisk does not exist"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if there are files in the RAM disk directory
|
||||||
|
RAMDISK_FILES=$(find /tmp/ram_disk_test_ramdisk -type f | wc -l)
|
||||||
|
if [ "$RAMDISK_FILES" -gt 0 ]; then
|
||||||
|
report_test "Files on RAM disk" "PASS" "Found $RAMDISK_FILES files on RAM disk"
|
||||||
|
else
|
||||||
|
report_test "Files on RAM disk" "FAIL" "No files on RAM disk"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Test synchronization from RAM disk to hard disk
|
||||||
|
test_sync_to_disk() {
|
||||||
|
print_header "TEST 5: Testing synchronization from RAM disk to hard disk"
|
||||||
|
|
||||||
|
# Create an additional file on RAM disk to check synchronization
|
||||||
|
echo "Test synchronization" > "/tmp/ram_disk_test_ramdisk/test_sync_file.txt"
|
||||||
|
|
||||||
|
# Run the synchronization script
|
||||||
|
if [ ! -f "../gramage_sync_to_disk.sh" ]; then
|
||||||
|
# Run the main script to generate the scripts
|
||||||
|
../gramage.sh --config gramage_test.ini --script-gen-only
|
||||||
|
fi
|
||||||
|
|
||||||
|
../gramage_sync_to_disk.sh --verbose
|
||||||
|
|
||||||
|
# Check if the test file was synchronized to the hard disk
|
||||||
|
if [ -f "/tmp/ram_disk_test_source/test_sync_file.txt" ]; then
|
||||||
|
report_test "File synchronization" "PASS" "Test file was synchronized to the hard disk"
|
||||||
|
else
|
||||||
|
report_test "File synchronization" "FAIL" "Test file was not synchronized to the hard disk"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Test file exclusion patterns
|
||||||
|
test_exclude_patterns() {
|
||||||
|
print_header "TEST 6: Testing file exclusion patterns"
|
||||||
|
|
||||||
|
# Create files that should be excluded
|
||||||
|
touch "/tmp/ram_disk_test_ramdisk/excluded_file.bak"
|
||||||
|
touch "/tmp/ram_disk_test_ramdisk/excluded_file.tmp"
|
||||||
|
touch "/tmp/ram_disk_test_ramdisk/temp_excluded_file.txt"
|
||||||
|
mkdir -p "/tmp/ram_disk_test_ramdisk/test_ignore_dir"
|
||||||
|
touch "/tmp/ram_disk_test_ramdisk/test_ignore_dir/file_in_ignored_dir.txt"
|
||||||
|
|
||||||
|
# Run the synchronization script
|
||||||
|
if [ ! -f "../gramage_sync_to_disk.sh" ]; then
|
||||||
|
# Run the main script to generate the scripts
|
||||||
|
../gramage.sh --config gramage_test.ini --script-gen-only
|
||||||
|
fi
|
||||||
|
|
||||||
|
../gramage_sync_to_disk.sh --verbose
|
||||||
|
|
||||||
|
# Check if files that should be excluded were not synchronized
|
||||||
|
EXCLUDED_FILES=0
|
||||||
|
[ ! -f "/tmp/ram_disk_test_source/excluded_file.bak" ] && EXCLUDED_FILES=$((EXCLUDED_FILES + 1))
|
||||||
|
[ ! -f "/tmp/ram_disk_test_source/excluded_file.tmp" ] && EXCLUDED_FILES=$((EXCLUDED_FILES + 1))
|
||||||
|
[ ! -f "/tmp/ram_disk_test_source/temp_excluded_file.txt" ] && EXCLUDED_FILES=$((EXCLUDED_FILES + 1))
|
||||||
|
[ ! -f "/tmp/ram_disk_test_source/test_ignore_dir/file_in_ignored_dir.txt" ] && EXCLUDED_FILES=$((EXCLUDED_FILES + 1))
|
||||||
|
|
||||||
|
if [ "$EXCLUDED_FILES" -eq 4 ]; then
|
||||||
|
report_test "File exclusion" "PASS" "All files were correctly excluded from synchronization"
|
||||||
|
else
|
||||||
|
report_test "File exclusion" "FAIL" "Not all files were excluded from synchronization ($EXCLUDED_FILES/4)"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Test main script in one-time mode
|
||||||
|
test_main_script() {
|
||||||
|
print_header "TEST 7: Testing main script in one-time mode"
|
||||||
|
|
||||||
|
# Clean directories
|
||||||
|
rm -rf /tmp/ram_disk_test_ramdisk/*
|
||||||
|
|
||||||
|
# Run the main script in one-time mode
|
||||||
|
../gramage.sh --config gramage_test.ini --one-time
|
||||||
|
|
||||||
|
# Check if files were copied to RAM disk
|
||||||
|
RAMDISK_FILES=$(find /tmp/ram_disk_test_ramdisk -type f | wc -l)
|
||||||
|
if [ "$RAMDISK_FILES" -gt 0 ]; then
|
||||||
|
report_test "File copying by main script" "PASS" "Found $RAMDISK_FILES files on RAM disk"
|
||||||
|
else
|
||||||
|
report_test "File copying by main script" "FAIL" "No files on RAM disk"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create an additional file on RAM disk to check synchronization
|
||||||
|
echo "Testing main script" > "/tmp/ram_disk_test_ramdisk/test_main_script.txt"
|
||||||
|
|
||||||
|
# Run the main script again
|
||||||
|
../gramage.sh --config gramage_test.ini --one-time
|
||||||
|
|
||||||
|
# Check if the test file was synchronized to the hard disk
|
||||||
|
if [ -f "/tmp/ram_disk_test_source/test_main_script.txt" ]; then
|
||||||
|
report_test "Synchronization by main script" "PASS" "Test file was synchronized to the hard disk"
|
||||||
|
else
|
||||||
|
report_test "Synchronization by main script" "FAIL" "Test file was not synchronized to the hard disk"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Test log generation
|
||||||
|
test_logging() {
|
||||||
|
print_header "TEST 8: Testing log generation"
|
||||||
|
|
||||||
|
# Temporary log files for testing
|
||||||
|
LOG_FILE="/tmp/ram_disk_test_logs.txt"
|
||||||
|
ERROR_LOG_FILE="/tmp/ram_disk_test_errors.txt"
|
||||||
|
|
||||||
|
# Remove log files if they exist
|
||||||
|
rm -f "$LOG_FILE" "$ERROR_LOG_FILE"
|
||||||
|
|
||||||
|
# Run the script with logging options
|
||||||
|
../gramage.sh --config gramage_test.ini --one-time --logs "$LOG_FILE" --errors-log "$ERROR_LOG_FILE"
|
||||||
|
|
||||||
|
# Check if the log file was created
|
||||||
|
if [ -f "$LOG_FILE" ]; then
|
||||||
|
LOG_SIZE=$(wc -c < "$LOG_FILE")
|
||||||
|
if [ "$LOG_SIZE" -gt 0 ]; then
|
||||||
|
report_test "Log file creation" "PASS" "Log file was created and contains data (size: $LOG_SIZE bytes)"
|
||||||
|
else
|
||||||
|
report_test "Log file creation" "FAIL" "Log file was created but is empty"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
report_test "Log file creation" "FAIL" "Log file was not created"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if the error log file was created
|
||||||
|
if [ -f "$ERROR_LOG_FILE" ]; then
|
||||||
|
ERROR_LOG_SIZE=$(wc -c < "$ERROR_LOG_FILE")
|
||||||
|
report_test "Error log file creation" "PASS" "Error log file was created (size: $ERROR_LOG_SIZE bytes)"
|
||||||
|
else
|
||||||
|
report_test "Error log file creation" "FAIL" "Error log file was not created"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if logs contain expected information
|
||||||
|
if [ -f "$LOG_FILE" ]; then
|
||||||
|
if grep -q "INFO" "$LOG_FILE"; then
|
||||||
|
report_test "INFO log content" "PASS" "Logs contain INFO level entries"
|
||||||
|
else
|
||||||
|
report_test "INFO log content" "FAIL" "Logs do not contain INFO level entries"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if grep -q "DEBUG" "$LOG_FILE"; then
|
||||||
|
report_test "DEBUG log content" "PASS" "Logs contain DEBUG level entries"
|
||||||
|
else
|
||||||
|
report_test "DEBUG log content" "FAIL" "Logs do not contain DEBUG level entries"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Generate an artificial error to test error logs
|
||||||
|
# Create a read-only file to force an error during synchronization
|
||||||
|
mkdir -p "/tmp/ram_disk_test_ramdisk/readonly_dir"
|
||||||
|
touch "/tmp/ram_disk_test_ramdisk/readonly_dir/readonly_file.txt"
|
||||||
|
chmod 444 "/tmp/ram_disk_test_ramdisk/readonly_dir"
|
||||||
|
|
||||||
|
# Run the script again to generate errors
|
||||||
|
../gramage.sh --config gramage_test.ini --one-time --logs "$LOG_FILE" --errors-log "$ERROR_LOG_FILE"
|
||||||
|
|
||||||
|
# Restore permissions
|
||||||
|
chmod 755 "/tmp/ram_disk_test_ramdisk/readonly_dir"
|
||||||
|
|
||||||
|
# Check if error logs contain information about errors
|
||||||
|
if [ -f "$ERROR_LOG_FILE" ]; then
|
||||||
|
if grep -q "ERROR\|WARN\|Error log file initialized" "$ERROR_LOG_FILE"; then
|
||||||
|
report_test "Error log content" "PASS" "Error logs contain appropriate entries"
|
||||||
|
else
|
||||||
|
report_test "Error log content" "FAIL" "Error logs do not contain ERROR or WARN level entries"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove log files
|
||||||
|
rm -f "$LOG_FILE" "$ERROR_LOG_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main test function
|
||||||
|
run_tests() {
|
||||||
|
echo -e "${YELLOW}=====================================${RESET}"
|
||||||
|
echo -e "${YELLOW}STARTING GNURAMAGE TESTS${RESET}"
|
||||||
|
echo -e "${YELLOW}=====================================${RESET}"
|
||||||
|
|
||||||
|
# Clean environment before starting tests
|
||||||
|
cleanup
|
||||||
|
|
||||||
|
# Run all tests
|
||||||
|
check_program_exists
|
||||||
|
check_script_generation
|
||||||
|
test_environment
|
||||||
|
test_copy_to_ramdisk
|
||||||
|
test_sync_to_disk
|
||||||
|
test_exclude_patterns
|
||||||
|
test_main_script
|
||||||
|
test_logging
|
||||||
|
|
||||||
|
# Display summary
|
||||||
|
print_summary
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run tests
|
||||||
|
run_tests
|
172
test/test_generator.sh
Executable file
172
test/test_generator.sh
Executable file
|
@ -0,0 +1,172 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Test Generator for GnuRAMage
|
||||||
|
# Creates sample files and directory structures for testing
|
||||||
|
|
||||||
|
# Default values
|
||||||
|
TEST_SOURCE_DIR="/tmp/ram_disk_test_source"
|
||||||
|
TEST_RAMDISK_DIR="/tmp/ram_disk_test_ramdisk"
|
||||||
|
FILE_COUNT=20
|
||||||
|
DIR_COUNT=5
|
||||||
|
FILE_SIZE="10k" # Default file size in KB
|
||||||
|
CONFIG_FILE="gnuramage_test.ini"
|
||||||
|
|
||||||
|
# Print usage information
|
||||||
|
print_usage() {
|
||||||
|
echo "Usage: $0 [OPTIONS]"
|
||||||
|
echo "Test Generator for GnuRAMage"
|
||||||
|
echo ""
|
||||||
|
echo "Options:"
|
||||||
|
echo " --source <dir> Path to the source directory (default: $TEST_SOURCE_DIR)"
|
||||||
|
echo " --ramdisk <dir> Path to the RAM disk directory (default: $TEST_RAMDISK_DIR)"
|
||||||
|
echo " --files <count> Number of files to create (default: $FILE_COUNT)"
|
||||||
|
echo " --dirs <count> Number of directories to create (default: $DIR_COUNT)"
|
||||||
|
echo " --size <size> Size of each file (default: $FILE_SIZE)"
|
||||||
|
echo " --config <file> Path to write the test configuration (default: $CONFIG_FILE)"
|
||||||
|
echo " --help Display this help message and exit"
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
# Parse command line arguments
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
--source)
|
||||||
|
TEST_SOURCE_DIR="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--ramdisk)
|
||||||
|
TEST_RAMDISK_DIR="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--files)
|
||||||
|
FILE_COUNT="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--dirs)
|
||||||
|
DIR_COUNT="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--size)
|
||||||
|
FILE_SIZE="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--config)
|
||||||
|
CONFIG_FILE="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--help)
|
||||||
|
print_usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Error: Unknown option $1"
|
||||||
|
print_usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Create test directories
|
||||||
|
echo "Creating test directories..."
|
||||||
|
mkdir -p "$TEST_SOURCE_DIR"
|
||||||
|
# Note: We don't create the RAM disk directory here as the main script should handle that
|
||||||
|
|
||||||
|
# Create random directories
|
||||||
|
echo "Creating $DIR_COUNT random directories..."
|
||||||
|
for ((i=1; i<=DIR_COUNT; i++)); do
|
||||||
|
dir_name="dir_$i"
|
||||||
|
mkdir -p "$TEST_SOURCE_DIR/$dir_name"
|
||||||
|
|
||||||
|
# Create subdirectories with random depth
|
||||||
|
depth=$((RANDOM % 3 + 1))
|
||||||
|
subdir="$TEST_SOURCE_DIR/$dir_name"
|
||||||
|
for ((j=1; j<=depth; j++)); do
|
||||||
|
subdir="$subdir/subdir_$j"
|
||||||
|
mkdir -p "$subdir"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
# Create random files
|
||||||
|
echo "Creating $FILE_COUNT random files..."
|
||||||
|
for ((i=1; i<=FILE_COUNT; i++)); do
|
||||||
|
# Decide whether to put the file in a directory or the root
|
||||||
|
if [ $((RANDOM % 3)) -eq 0 ] || [ $DIR_COUNT -eq 0 ]; then
|
||||||
|
# Put in root
|
||||||
|
file_path="$TEST_SOURCE_DIR/file_$i.txt"
|
||||||
|
else
|
||||||
|
# Put in a random directory
|
||||||
|
dir_num=$((RANDOM % DIR_COUNT + 1))
|
||||||
|
dir_path="$TEST_SOURCE_DIR/dir_$dir_num"
|
||||||
|
|
||||||
|
# Check if there are subdirectories
|
||||||
|
subdirs=($(find "$dir_path" -type d))
|
||||||
|
if [ ${#subdirs[@]} -gt 1 ]; then
|
||||||
|
# Pick a random subdirectory
|
||||||
|
subdir_index=$((RANDOM % ${#subdirs[@]}))
|
||||||
|
file_path="${subdirs[$subdir_index]}/file_$i.txt"
|
||||||
|
else
|
||||||
|
file_path="$dir_path/file_$i.txt"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create file with random content
|
||||||
|
dd if=/dev/urandom of="$file_path" bs="$FILE_SIZE" count=1 status=none
|
||||||
|
echo "Created: $file_path"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Create a special .rsyncignore file
|
||||||
|
echo "Creating .rsyncignore file..."
|
||||||
|
cat > "$TEST_SOURCE_DIR/.rsyncignore" << EOF
|
||||||
|
# Test ignore patterns
|
||||||
|
*.bak
|
||||||
|
*.tmp
|
||||||
|
temp_*
|
||||||
|
test_ignore_dir/
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Create some files that should be ignored
|
||||||
|
echo "Creating files that should be ignored..."
|
||||||
|
mkdir -p "$TEST_SOURCE_DIR/test_ignore_dir"
|
||||||
|
touch "$TEST_SOURCE_DIR/file1.bak"
|
||||||
|
touch "$TEST_SOURCE_DIR/file2.tmp"
|
||||||
|
touch "$TEST_SOURCE_DIR/temp_file.txt"
|
||||||
|
touch "$TEST_SOURCE_DIR/test_ignore_dir/should_be_ignored.txt"
|
||||||
|
|
||||||
|
# Create a test config file
|
||||||
|
echo "Creating test configuration file: $CONFIG_FILE"
|
||||||
|
cat > "$CONFIG_FILE" << EOF
|
||||||
|
# GnuRAMage Test Configuration File
|
||||||
|
|
||||||
|
[SETTINGS]
|
||||||
|
# Interval between synchronizations in seconds (short for testing)
|
||||||
|
sync_interval = 10
|
||||||
|
|
||||||
|
# Log level: ERROR, WARN, INFO, DEBUG
|
||||||
|
log_level = DEBUG
|
||||||
|
|
||||||
|
# Verify checksums during sync (test both true and false)
|
||||||
|
verify_checksums = true
|
||||||
|
|
||||||
|
[DIRECTORIES]
|
||||||
|
# Source directory on hard disk
|
||||||
|
source_dir = $TEST_SOURCE_DIR
|
||||||
|
|
||||||
|
# Target directory on RAM disk
|
||||||
|
ramdisk_dir = $TEST_RAMDISK_DIR
|
||||||
|
|
||||||
|
[EXCLUDE]
|
||||||
|
# Patterns to exclude from synchronization
|
||||||
|
# Each line is a pattern in rsync format
|
||||||
|
*.bak
|
||||||
|
*.tmp
|
||||||
|
temp_*
|
||||||
|
test_ignore_dir/
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "Test environment setup complete!"
|
||||||
|
echo "Created $FILE_COUNT files across $DIR_COUNT directories"
|
||||||
|
echo ""
|
||||||
|
echo "To use the test environment, run:"
|
||||||
|
echo "../gramage.sh --config ../test/$CONFIG_FILE"
|
||||||
|
echo ""
|
||||||
|
echo "For a dry run test first, use:"
|
||||||
|
echo "../gramage.sh --config ../test/$CONFIG_FILE --dry-run --verbose"
|
Loading…
Add table
Add a link
Reference in a new issue