Compare commits

...

1473 Commits

Author SHA1 Message Date
Orsiris de Jong f02cbfdc92
Add codespell 2025-03-08 14:14:21 +01:00
Orsiris de Jong 6c6b2e5b12
Spellfix 2025-03-08 14:00:23 +01:00
Orsiris de Jong 7a6cb155cc Rebuilt targets 2025-01-20 14:49:56 +01:00
Orsiris de Jong 266fa0d97f Reapply #267 to common install script 2025-01-20 14:49:11 +01:00
Orsiris de Jong a566549875 Rebuilt targets 2025-01-20 14:17:21 +01:00
Orsiris de Jong bc1878bf7f
Merge pull request #270 from gruoner/kerberos-patch
Kerberos patch
2025-01-20 11:27:15 +01:00
deajan 59d99823e4 Update largefileset URL 2025-01-20 10:31:50 +01:00
gruoner c5ef7a916e
Merge branch 'deajan:master' into kerberos-patch 2025-01-19 14:11:29 +01:00
gruoner f0d9cfcf35 with the KRB5 parameter one can use kerberos credentials to access SSH or RSYNC 2025-01-19 14:03:33 +01:00
Orsiris de Jong 548f3c5730
Fix Spinner must work without env vars 2024-09-21 20:39:26 +02:00
Orsiris de Jong f094fb0481
Merge pull request #267 from new2f7/patch-3
Update uninstaller to remove all services files
2024-09-04 15:32:39 +02:00
Orsiris de Jong b1e08fe947
Fix typos as per #264 2024-09-04 15:25:54 +02:00
Orsiris de Jong 3a9accaea0
Merge pull request #266 from new2f7/patch-2
Fix spacing in usage help
2024-09-04 15:18:37 +02:00
Orsiris de Jong 6a717859b8
Merge pull request #265 from new2f7/patch-1
Add missing '$' in 'systemctl start $SERVICE_NAME@instance.conf'
2024-09-04 15:17:39 +02:00
new2f7 6d13e3976a Update uninstaller to remove all services files 2024-07-03 13:54:35 +02:00
new2f7 0d00fa8ab9
Fix spacing in usage help 2024-06-12 09:13:36 +02:00
new2f7 05e594e101
Add missing '$' in 'systemctl start $SERVICE_NAME@instance.conf' 2024-06-12 09:10:51 +02:00
Orsiris de Jong 639055bf00
Merge pull request #262 from vitorhcl/add-tested-platforms-table
Transform tested platforms list into a table
2024-03-27 01:00:23 +01:00
Vitor Henrique 35afd1af8a Transform methods column in footnotes 2024-03-23 12:36:05 -03:00
Orsiris de Jong 09225de945
Merge pull request #263 from vitorhcl/improve-usage-section
Improve "Usage" section
2024-03-13 16:39:49 +01:00
Vitor Henrique 99d01b2ed0
Improve monitor mode section 2024-03-13 12:33:20 -03:00
Vitor Henrique e34ebfd4cd
Improve wording of "Monitor mode" section 2024-03-13 12:27:27 -03:00
Vitor Henrique 7aeb2e3b69 Improve Monitor mode section 2024-03-13 11:26:58 -03:00
Vitor Henrique 51e79cb56a Fix modes links 2024-03-13 11:16:55 -03:00
Vitor Henrique 2ce2561f99 Improve Usage section 2024-03-13 11:16:49 -03:00
Vitor Henrique 88e1f3f4f6 Move Termux method to version column 2024-03-13 10:23:32 -03:00
Orsiris de Jong b1a0510a0e
Merge pull request #261 from vitorhcl/fix-code-blocks
Fix code blocks in README
2024-03-13 08:27:31 +01:00
Vitor Henrique b3d723ad07 Transform tested platforms list into a table 2024-03-13 00:42:50 -03:00
Vitor Henrique ed2e8438d2 Fix code blocks in README 2024-03-13 00:19:22 -03:00
Orsiris de Jong f2ff318f46
Merge pull request #260 from vitorhcl/improve-readme
Improve README
2024-03-12 21:18:47 +01:00
Vitor Henrique f889eb99e8 Use "monitor mode" instead of "daemon mode" and move note to note box 2024-03-07 18:54:18 -03:00
Vitor Henrique 737008d662 Improve README 2024-03-07 18:40:05 -03:00
Orsiris de Jong 19dbdeb28a Merge branch 'master' of https://github.com/deajan/osync 2023-09-12 11:00:06 +02:00
Orsiris de Jong f39fb6613e
Merge pull request #257 from nzalev/master
Typo fix
2023-07-12 12:58:22 +02:00
Noah Zalev f6fd288cfa
Typo fix 2023-07-04 14:33:04 -04:00
Orsiris de Jong 63cbe3786e Update changelog 2023-06-16 00:20:54 +02:00
Orsiris de Jong 98a4d6bb0c Rebuilt targets 2023-06-14 19:09:33 +02:00
Orsiris de Jong e47c1d7f58 Bump version 2023-06-14 19:09:05 +02:00
Orsiris de Jong cef25b646f
Prepare v1.3 release 2023-06-14 19:05:58 +02:00
Orsiris de Jong 4054f3ca75 Make sure we update remote.conf rsa key path 2023-06-14 14:30:28 +02:00
Orsiris de Jong ea1b3b379e
Fix misc option names 2023-06-14 14:23:16 +02:00
Orsiris de Jong 988009a438 RebuÃilt targets 2023-06-14 14:06:40 +02:00
Orsiris de Jong b2f221cb86 Make rsync old arguments fix permanent 2023-06-14 14:06:18 +02:00
Orsiris de Jong c4349bc945 Rebuilt targets 2023-06-14 13:50:04 +02:00
Orsiris de Jong 99f107fcb0 Add general fix for #242 2023-06-14 13:49:36 +02:00
Orsiris de Jong 776c07386d Fix tests 2023-06-14 13:49:18 +02:00
Orsiris de Jong edfc292486 Temporarily disable merge test 2023-06-14 11:25:12 +02:00
Orsiris de Jong 9ade468ed8 Add permission fixes for tests 2023-06-14 11:10:24 +02:00
Orsiris de Jong d9e22b06e5 Add preflight merge 2023-06-11 11:26:02 +02:00
Orsiris de Jong d0af0804a0 Fix systemd detection on windows 2023-06-11 11:24:38 +02:00
Orsiris de Jong 9b9c1105eb Rebuilt targets 2023-06-11 11:19:25 +02:00
Orsiris de Jong 9b862ae49d Fix typo 2023-06-11 11:18:39 +02:00
Orsiris de Jong 57ef919364 Update sync paths. Remove log garbage 2023-06-11 11:04:44 +02:00
Orsiris de Jong 833c16ca43 Move osync test dir to /tmp 2023-06-11 09:43:44 +02:00
Orsiris de Jong 83a0f5c328 Rebuilt targets 2023-06-10 19:45:58 +02:00
Orsiris de Jong 5a7455173c Fix typo 2023-06-10 19:45:33 +02:00
Orsiris de Jong edd35d42aa Enable writing partial logs for alerting 2023-06-10 19:44:37 +02:00
Orsiris de Jong 50f975d2df Add --non-interactive switch 2023-06-10 19:43:16 +02:00
Orsiris de Jong 43e1aaaaa1 Bump ofunctions version to 2.4.4 2023-06-10 19:40:24 +02:00
Orsiris de Jong b15e8e8f88 Preserve env variables for sudo calls 2023-06-10 19:20:43 +02:00
Orsiris de Jong 91950446f0 Coherent yaml workflow 2023-06-10 13:51:03 +02:00
Orsiris de Jong 0ef4af40dc Coherent yaml workflow 2023-06-10 13:49:20 +02:00
Orsiris de Jong 6b6f723094 Fix remote tests not updating conf file properly 2023-06-10 13:03:05 +02:00
Orsiris de Jong d100841bd9 Try to fix github env variables 2023-06-10 12:59:42 +02:00
Orsiris de Jong 52a42bc1d7 Add export for env variables 2023-06-10 12:51:41 +02:00
Orsiris de Jong 30d66003ef Use export for env variables 2023-06-10 12:35:26 +02:00
Orsiris de Jong b95e75aa0b Add SSH_PORT info 2023-06-10 12:31:14 +02:00
Orsiris de Jong 8ef2262421 Fix typo in env vars 2023-06-10 12:04:34 +02:00
root fa7f6d1088 Configure default SSH port for github actions 2023-06-10 11:58:12 +02:00
Orsiris de Jong 5f4e7af910
Re-enable all tests since we got remote tests to work 2023-06-10 11:14:46 +02:00
Orsiris de Jong a9da549e4f
Add openssh-server for remote tests 2023-06-10 11:08:32 +02:00
Orsiris de Jong 4bf065f94e
Make tests run on github runner's WSL and macos versions too 2023-06-10 11:07:51 +02:00
Orsiris de Jong 912906ef8c Revert "foo"
This reverts commit 77cbcd97d9.
2023-06-10 10:56:21 +02:00
Orsiris de Jong 77cbcd97d9
foo 2023-06-04 19:53:37 +02:00
Orsiris de Jong 5beb9220d1
Update run_tests.sh 2023-06-04 19:08:55 +02:00
Orsiris de Jong 53193aceb6
WIP ssh test fixes for github actions 2023-06-04 18:57:07 +02:00
Orsiris de Jong 4d08791d04
Try to diag ssh errors in github actions 2023-06-04 18:51:35 +02:00
Orsiris de Jong 01769189b7
Merge pull request #254 from poessl/fix-macos-directory-FileMove
Fix FileMove (used on deletions) not working for directories on macOS
2023-06-04 16:49:36 +02:00
Orsiris de Jong 9dd69349ad
Require macos tests to run as root 2023-06-04 15:48:53 +02:00
Orsiris de Jong ef0cd58d49
Add sudo to linux tests 2023-06-04 15:17:11 +02:00
Orsiris de Jong d8915512ea
Add rsync package to WSL windows tests 2023-06-04 14:57:13 +02:00
Orsiris de Jong 9fa4c45b6c
Renamce License file 2023-06-04 14:48:53 +02:00
J. Poessl 22e269902b
Fix FileMove (used on deletions) not working for directories on macOS 2023-05-31 13:36:13 +02:00
Orsiris de Jong edaeb9a400
Do not enable both SSH and RSYNC compression #251 2023-01-19 22:01:50 +01:00
Orsiris de Jong f646fffc79 WIP macosx tests 2022-07-07 21:58:58 +02:00
Orsiris de Jong ce4b435eb2
Add fswatch package 2022-07-07 21:51:05 +02:00
Orsiris de Jong e395e8ca65
Add dos2unix for windows 2022-07-07 21:49:34 +02:00
Orsiris de Jong 60ceccfff1 WIP run tests on github actions 2022-07-07 17:08:31 +02:00
Orsiris de Jong cf78875ab5 WIP debug github actions tests 2022-07-07 16:40:26 +02:00
Orsiris de Jong 059f95d4a8 WIP fixing github actions tests 2022-07-07 16:34:46 +02:00
Orsiris de Jong 9edeb39d45
add dos2unix package 2022-07-07 16:25:09 +02:00
Orsiris de Jong 55c4cffcf0 Merge branch 'master' of https://github.com/deajan/osync 2022-07-07 16:22:56 +02:00
Orsiris de Jong 59bd176e48 Update shunit to current master 2022-07-07 16:22:35 +02:00
Orsiris de Jong 7da01328b2
Update windows.yml 2022-07-07 12:19:38 +02:00
Orsiris de Jong 36db883ab0
Fix yaml syntax 2022-07-07 11:42:13 +02:00
Orsiris de Jong 632db7d9a2
Create windows.yml 2022-07-07 11:33:04 +02:00
Orsiris de Jong 999aeed303
Add macos github action file 2022-07-07 11:27:39 +02:00
Orsiris de Jong a83f76c639
Update linux.yml 2022-07-07 11:16:45 +02:00
Orsiris de Jong 663b5be3be
Update linux.yml 2022-07-07 11:14:45 +02:00
Orsiris de Jong 898fcbb8c1
Update linux.yml 2022-07-07 11:14:15 +02:00
Orsiris de Jong ecc4c1d396 Merge branch 'master' of https://github.com/deajan/osync 2022-07-07 11:13:57 +02:00
Orsiris de Jong 89f8533c27 Update env var for github actions 2022-07-07 11:12:25 +02:00
Orsiris de Jong 7168aa9d02
Make sure we can run tests 2022-07-07 11:12:19 +02:00
Orsiris de Jong 9245030a9d
Fix typo 2022-07-07 11:06:26 +02:00
Orsiris de Jong a1f8773953
Add github actions workflow 2022-07-07 11:05:40 +02:00
Orsiris de Jong 35a71ad517 Prepare for v1.3.0 release 2022-07-07 11:00:31 +02:00
Orsiris de Jong e01d8c410b Rebuilt targets 2022-07-07 10:58:39 +02:00
Orsiris de Jong 4e44020619 Update ofunctions from pmocr 2022-07-07 10:58:16 +02:00
Orsiris de Jong f2761d6a42
Merge pull request #244 from zhemant/fix/operator-error
Fix/operator error
2022-07-07 10:54:37 +02:00
Hemant Zope f48ff41072 regerate osync using merge.sh 2022-06-17 12:54:40 +02:00
Hemant Zope 08759b895c fix bash operator error 2022-06-17 12:50:14 +02:00
deajan 508cd4bf50 Merged back remote changes 2021-06-29 09:31:02 +02:00
deajan 87dd5d07ea Rebuilt targets 2021-06-29 09:28:21 +02:00
deajan 134acff3a9 Add ALWAYS_SEND_MAILS option 2021-06-29 09:27:54 +02:00
Orsiris de Jong c091996231
Bump version 2021-05-18 20:43:22 +02:00
Orsiris de Jong a7e1b4505b
Fix typo 2021-05-18 20:42:53 +02:00
Orsiris de Jong 803d25ac8b
Fix typo 2021-05-18 20:42:12 +02:00
Orsiris de Jong a36fd05069
Change CheckConnectivity3rdPartyHosts to allow external IPs 2021-05-18 20:36:42 +02:00
Orsiris de Jong 96c26e2791
Add TimeCheck and Ping functions 2021-05-05 14:24:12 +02:00
Orsiris de Jong f74108ed4a
Merge pull request #229 from deajan/custom_statedir
Custom statedir
2021-04-23 09:44:08 +02:00
deajan 27866f1db5 Rebuilt targets 2021-02-24 17:35:17 +01:00
deajan 904105904e Fix remote call not using RemoteLogger 2021-02-24 17:34:47 +01:00
deajan c2efdb2063 Allow custom statedir 2021-02-24 17:23:05 +01:00
deajan edcfe337c3 Mute error when detecting wget/curl 2020-11-29 13:04:31 +01:00
Orsiris de Jong 56c8fa868a
Update bug_report.md 2020-11-19 12:15:26 +01:00
deajan 3c1eb0989e Rebuilt targets 2020-11-15 22:09:21 +01:00
deajan 2bc8e899d7 Fix ofunctions GenericTrapQuit lacks closing comment 2020-11-15 22:08:57 +01:00
deajan 9a8b028c96 Rename variable 2020-11-15 22:07:17 +01:00
deajan e5922f04a5 Simplify --skip-compress rsync argument 2020-11-15 22:00:12 +01:00
Orsiris de Jong 11e19108f5
Merge pull request #219 from kendarorg/master
Support for Qnap local and remote (no ctime support)
2020-11-15 21:47:54 +01:00
Enrico Da Ros 4076423d98 Changed ofunctions to prev version 2020-11-05 09:31:41 +00:00
Enrico Da Ros 536f8ce6f0 Changed support for -z/-zz on Qnap 2020-11-05 09:25:07 +00:00
Enrico Da Ros 88c74dda70 Changed support for -z/-zz on Qnap 2020-11-05 09:17:34 +00:00
Enrico Da Ros 2ebd22c441 Changed support for -z/-zz on Qnap 2020-11-05 09:14:55 +00:00
Enrico Da Ros ca822566d4 Updated with suggestions 2020-11-05 08:52:55 +00:00
Enrico Da Ros 009a4aabe0 Updated with suggestions 2020-11-05 08:49:40 +00:00
Enrico Da Ros cc21cc6acc ps -a instead of ps -A, % diskspace 2020-11-04 15:44:54 +01:00
Enrico Da Ros 81437b5824 Support for Qnap without ctime 2020-11-04 12:13:18 +01:00
Enrico Da Ros 45304c608c Support for Qnap without ctime 2020-11-04 12:09:53 +01:00
Orsiris de Jong 8451024ae2
Merge pull request #204 from deajan/fast-deletion
Fast deletion
2020-07-28 23:33:56 +02:00
deajan 5ea103b36b Rebuilt targets 2020-07-22 13:35:52 +01:00
deajan f2be25f83d Fix #203 check file presence for get file attribs 2020-07-22 13:35:27 +01:00
deajan 5852d76cd3 Rebuilt targets 2020-06-30 11:48:10 +01:00
deajan 67dc58f3b5 Added deleted file list simplification, fix #202 2020-06-30 11:47:48 +01:00
deajan b589c32ce7 Rebuilt targets 2020-06-30 09:21:13 +01:00
deajan 8e4e745420 Make GetConfFileValue reports DEBUG level when noerror is set 2020-06-29 11:02:33 +01:00
deajan f9694d6478 Rebuilt targets 2020-06-29 09:48:32 +01:00
deajan ea0ca4e4c2 Update changelog 2020-06-29 09:48:05 +01:00
deajan 3c0f0b542d Tidy up conflict log messages 2020-06-29 09:24:06 +01:00
deajan 179bf6281e Rebuilt targets 2020-05-13 09:08:14 +01:00
deajan f5403bd13a Make comment more clear about SSH_COMPRESSION options 2020-05-13 09:06:41 +01:00
deajan 5870003c73 Improved example config file comments 2020-05-12 13:19:38 +01:00
deajan 7ed547786f Rebuilt targets 2020-05-03 09:21:40 +01:00
deajan 747e9c710e Fix #195 by removing orphan WIP 2020-05-03 09:21:14 +01:00
deajan 7a7653957e Update changelog 2020-05-03 09:12:36 +01:00
deajan ad7d022dcf Quote all rsync result files 2020-05-03 09:11:15 +01:00
deajan e6088c88de Rebuilt targets 2020-05-03 09:08:37 +01:00
deajan 347f9a9ae8 Make sure all files are quoted 2020-05-03 08:58:01 +01:00
Orsiris de Jong 7577f220dc
Merge pull request #194 from zhangzhishan/master
Fix space problem for getting lock file.
2020-05-03 09:47:52 +02:00
Zhang Zhishan acf388bc7b Fix space problem for getting lock file. 2020-05-02 18:47:25 +08:00
deajan 5881c71212 Rebuilt target 2020-04-29 11:44:28 +01:00
deajan 60f2005209 More init platform exclusions 2020-04-29 11:44:17 +01:00
Orsiris de Jong 7688317bd1
Merge pull request #184 from dbingham/macos-install
Fix install on MacOS to not return error code 2 after a normal install
2020-04-29 12:41:11 +02:00
deajan e997493fb5 Update changelog 2020-04-29 11:35:29 +01:00
deajan be3fc2e848 Rebuilt targets 2020-04-29 11:32:14 +01:00
deajan 844e08f92f More explicit stop on error explanantion 2020-04-29 11:31:44 +01:00
deajan 38190c6139 Fixed STOP_ON_ERROR_CMD did not work anymore 2020-04-29 11:30:59 +01:00
deajan 45a8a7a589 Added parenthesis to tests 2020-04-29 11:19:49 +01:00
deajan 3a9d00ff4f Merged changes 2020-04-29 11:15:03 +01:00
deajan 7bc80b9574 Removed parenthesis from remote logs 2020-04-29 11:12:56 +01:00
deajan a912a7d7c3 Fixed long standing issue with remote rsync calls containing special characters 2020-04-29 11:12:25 +01:00
deajan 1c7d21c485 Cosmetic change 2020-04-29 11:03:54 +01:00
root 51a4c8bcce Rebuilt targets 2020-03-15 22:51:21 +01:00
root fbce80bc0a Renamed ofunctions TrapQuit to GeneralTrapQuit 2020-03-15 22:50:56 +01:00
root 6edce242b0 Rebuilt targetsé 2020-03-15 22:31:33 +01:00
root 8788582f63 TrapQuit function should exist as subset 2020-03-15 22:31:07 +01:00
Daniel Bingham cc4ce385ee Fix install on MacOS to not return error code 2 after a normal install 2020-01-28 10:59:32 -08:00
deajan 98c1b97fb0 Fix file deletion on remote MacOS might not work from /tmp 2020-01-23 19:40:25 +01:00
deajan 17e2bf6dce Update changelog 2020-01-23 18:52:37 +01:00
deajan c2fef97c84 Rebuilt targets 2020-01-23 18:47:01 +01:00
deajan eaeb218508 Fixed MINIMUM_SPACE=0 should not check space requirements, Thanks Val 2020-01-23 18:46:32 +01:00
deajan a9cb30ffb4 Added missing SYNC_TYPE 2020-01-22 18:49:20 +01:00
deajan 08ab938477 Rebuilt targets 2020-01-22 18:40:11 +01:00
deajan 5e71ed0854 Fix usage called before definition 2020-01-22 18:39:34 +01:00
deajan f5356ea702 Update changelog 2020-01-10 11:18:27 +01:00
deajan 10adfe6128 Rebuilt targets 2020-01-10 11:17:10 +01:00
deajan 572a055901 Fixed target helper service overwrites osync service, fix #176 2020-01-10 11:16:24 +01:00
deajan 45915611f6 Rebuilt targets 2020-01-10 11:07:55 +01:00
deajan e4970830ac Update copyright year 2020-01-10 11:07:25 +01:00
deajan b6181e15d9 Update copyright year 2020-01-10 11:07:05 +01:00
deajan b8cfce2eb8 Set default LOG_CONFLICTS=false, fixes #181 2020-01-10 11:03:32 +01:00
deajan d8bdf2d721 Changed file mod from 755 to 644 since we deal with systemd 2020-01-10 10:58:57 +01:00
deajan e4d52aec2f Rebuilt targets 2019-12-25 23:11:28 +01:00
deajan a4b03b12e2 Update merge for FileMove 2019-12-25 21:03:56 +01:00
deajan bf86cc5f6f Refactor mv calls to FileMove just because of macos 2019-12-25 19:29:25 +01:00
deajan 39a8a309f5 Remove beta 1.3 statement 2019-12-25 18:58:09 +01:00
deajan 97fb53f6de Again remarklint fixes 2019-12-25 18:52:07 +01:00
deajan 314505eb4a Fix shellcheck issues 2019-12-25 18:39:53 +01:00
deajan fb57fb9d74 Make remarklint happy 2019-12-25 18:14:47 +01:00
deajan 689928eac1 Merge branch 'master' of https://github.com/deajan/osync 2019-12-25 18:13:34 +01:00
deajan 42c7493ef0 Make remarklint happy 2019-12-25 18:13:18 +01:00
Orsiris de Jong 6139fa002b
Another remarklint fix 2019-12-25 18:03:44 +01:00
Orsiris de Jong a48f4a85e6
Make remarklint happy in codacy 2019-12-25 17:59:20 +01:00
deajan cbff578ec5 Update changelog 2019-12-25 17:45:28 +01:00
deajan dc901282dc Rebuilt targets 2019-12-25 15:13:52 +01:00
deajan 08372e74ba Final fix for #175 correcting symlinks too 2019-12-25 15:13:29 +01:00
deajan 7d8978dc88 WIP #174 2019-12-25 13:51:37 +01:00
deajan 925adbd488 Still doing apple BS fixes 2019-12-24 18:25:17 +01:00
deajan e0b2f0435e Another #174 fix 2019-12-24 18:11:34 +01:00
deajan cb7dbbe2af Another bad fix for #175 2019-12-06 10:53:30 +01:00
deajan 3d94544337 Rebuilt targets 2019-12-06 10:45:14 +01:00
deajan 8197ea3ddb Prevent spinner from logging in service mode 2019-12-06 10:44:51 +01:00
deajan 78323cc06a Rebuilt targets 2019-11-02 14:53:28 +01:00
deajan ba830fe7d0 Removed (big) typo 2019-11-02 14:53:02 +01:00
deajan 87dd470344 Rebuilt targets 2019-11-02 14:49:09 +01:00
deajan 2c45d58659 Test before move 2019-11-02 14:48:43 +01:00
deajan 4d4728b90c Rebuilt targets 2019-11-02 14:45:23 +01:00
deajan 22538907b3 Fix typo 2019-11-02 14:44:14 +01:00
deajan f3365ed5ff [WIP] fix for #175 2019-11-02 14:40:58 +01:00
deajan 145814f231 Removed unused code 2019-10-21 13:56:26 +02:00
deajan 21bd1657ec Added upgrade finished message 2019-10-21 13:55:48 +02:00
deajan 6be95a3cff Added CleanUp function 2019-09-09 14:12:29 +02:00
deajan a7526c8a87 Added missing TrapQuit function 2019-09-09 14:10:13 +02:00
deajan 8b757bf083 Bump version to 2.3.0-RC3 2019-09-09 14:08:59 +02:00
deajan be1281ffa3 Merge branch 'master' of https://github.com/deajan/osync 2019-09-09 13:08:11 +02:00
deajan bdc9e42046 Upgrade script checks for old master/slave dirs before rewriting state files 2019-09-09 13:07:58 +02:00
Orsiris de Jong d66ea211d5
Removed double s7z extension from rsync skip compress 2019-09-04 10:32:36 +02:00
deajan da5140d3f0 Typo fixes 2019-08-18 22:05:50 +02:00
deajan d37872c730 Added source for cipher performance 2019-08-14 15:27:56 +02:00
deajan 997a7904ed Add chacha20-poly1305@openssh.com to cipher list 2019-08-14 15:17:19 +02:00
deajan 712c3179ee Revert non WIP KEEP_LOGGING time 2019-08-14 15:11:38 +02:00
deajan 0d28d0c482 Enhance rsync --skip-compress list 2019-08-14 15:11:10 +02:00
deajan f22cff5a49 Enabled Rsync compression in quicksync mode 2019-08-14 15:09:30 +02:00
deajan 7fb8eb7004 Allow SSH_OPTIONAL_ARGS to be set 2019-08-14 13:43:49 +02:00
deajan afdc5334f4 Updated log with truncated mention 2019-08-09 10:31:57 +02:00
deajan c02a7af424 Fixed typo in _REMOTE_TOKEN log removal 2019-08-09 10:24:40 +02:00
deajan 17a97d129b Cleaning up various remote logging 2019-08-09 10:12:23 +02:00
deajan 183ca45b63 Added missing RemoteLogger prefix 2019-08-09 10:07:38 +02:00
deajan 31986d0d19 WIP cleanup 2019-08-09 10:05:27 +02:00
deajan bf3b846026 Better _REMOTE_TOKEN cleanup 2019-08-09 10:04:45 +02:00
deajan 7d137ed0c5 Another flatten array fix 2019-08-08 21:10:13 +02:00
deajan 723501526c Fixed flatten array comparaison 2019-08-08 21:08:38 +02:00
deajan 2f4384d911 Updated changelog 2019-08-08 20:50:43 +02:00
deajan 8f2b22a117 Added more debugging for ExecTasks 2019-08-08 20:48:10 +02:00
deajan 5f6f7482dd Add warning about truncated output 2019-08-08 20:42:08 +02:00
deajan f0ea6df5ea Prevent possible bash buffer overflow, fixes #171 2019-08-08 18:00:20 +02:00
deajan 4df4c594b7 Obfuscate only part of remote token env 2019-08-08 10:37:57 +02:00
deajan 08910b3895 Fixed typo in build number 2019-07-23 10:40:40 +02:00
deajan 21c59cfd27 Updated RSA key file for quickRemote tests 2019-07-23 10:39:40 +02:00
deajan 151cfb8d39 Updated RSA key file 2019-07-23 10:38:52 +02:00
deajan 3b545648ac Enabled all tests again 2019-07-19 16:46:42 +02:00
deajan 0ae3a0c629 Fixed authorized_keys cleaning 2019-07-19 16:45:54 +02:00
deajan 9c7ef090f1 Rebuilt targets 2019-07-19 16:45:00 +02:00
deajan b124f7dfaf Exit SSH controlmaster before cleanup 2019-07-19 16:44:36 +02:00
deajan f87b529195 Remote remote token after usage #158 2019-07-09 11:29:25 +02:00
deajan 3cddb9b97e Added default SSH_CONTROLMASTER option 2019-07-05 23:27:25 +02:00
deajan 80f3b2f0bc Minor fixes in upgrade script 2019-07-05 23:26:50 +02:00
deajan 31b8ce4c52 Added bogus encryption warning 2019-07-05 23:19:19 +02:00
deajan f81291c0eb Fix cornercase where SSH_CONTROLMASTER might be used in local tests 2019-07-05 23:13:21 +02:00
deajan 59ec9e42c1 Added --ssh-controlmaster test for #169 2019-07-05 23:00:03 +02:00
deajan 9cfa13c59a Rebuilt targets 2019-07-05 22:56:03 +02:00
deajan ca78d76bb2 Fix for junk /osync.remote folder not being deleted 2019-07-05 22:55:34 +02:00
deajan b0b91a4db0 Removed elder PoorMansRandomGenerator function 2019-07-05 22:46:02 +02:00
deajan 8d9e95c6cd Rebuilt targets 2019-07-05 22:37:37 +02:00
deajan 154318be0f Added SSH_CONTROLMASTER option 2019-07-05 22:37:12 +02:00
deajan ddb820d2fa Added #169 CONTROLMASTER option 2019-07-05 22:35:35 +02:00
deajan dce4092085 Add --ssh-controlmaster option 2019-07-05 22:34:24 +02:00
deajan 219067be26 Allow multiple concurrent control masters, and allow spaces in path, enhances #169 2019-07-05 22:30:10 +02:00
Orsiris de Jong 8f85d20a68
Merge pull request #169 from bmorgenthaler/ssh-controlmaster
Initial changes to support SSH Multiplexing
2019-07-05 22:28:03 +02:00
Orsiris de Jong 492064f8e2
Comment about _REMOTE_EXECUTION variable 2019-07-05 22:24:48 +02:00
bmorgenthaler 32ee9f8071 Initial changes to support SSH Multiplexing 2019-07-05 11:25:50 -05:00
deajan 33971c359c Merge branch 'master' of https://github.com/deajan/osync 2019-05-28 09:15:48 +02:00
deajan d9d5aaf1e8 Added more quoting 2019-05-28 09:14:43 +02:00
Orsiris de Jong bd25ef4b72
Added codacy badge 2019-05-22 23:10:04 +02:00
deajan 2b17326630 Rebuilt targets 2019-05-22 22:57:04 +02:00
deajan 228a4d1f51 Revert "Refactored rsync patterns"
This reverts commit 679b4bc29e.
2019-05-22 22:56:27 +02:00
deajan 679b4bc29e Refactored rsync patterns 2019-05-22 22:29:07 +02:00
deajan f1b558d646 Updated changelog 2019-05-22 21:30:21 +02:00
deajan c8bb8c214f Fixed _Logger leaving tmp files 2019-05-22 21:26:12 +02:00
deajan c801d6b418 Fixed quoting 2019-05-22 21:02:26 +02:00
deajan 0b539e6153 Removed unused variable 2019-05-22 20:36:18 +02:00
deajan 8256bbef88 Removed unused variable 2019-05-22 20:35:04 +02:00
deajan b3a7572c0e Fixed typo 2019-05-22 20:33:49 +02:00
deajan 9976b3a6e5 Remove unnecessary $ 2019-05-22 20:30:27 +02:00
deajan bcd79e06aa Remove unused variable 2019-05-22 20:28:51 +02:00
deajan 6459a9dd4c Updated booleans in ssh filter 2019-05-22 19:47:20 +02:00
deajan 9b481467f6 Merge branch 'master' of https://github.com/deajan/osync 2019-05-22 19:44:02 +02:00
deajan 72f2e43071 Rebuilt targets 2019-05-22 19:43:48 +02:00
deajan a6e4c4a0ee Updated target helper config file 2019-05-22 19:43:19 +02:00
deajan b4892b9fdc Removed old helper config file 2019-05-22 19:40:37 +02:00
deajan 63f6194305 Less helper config file checks 2019-05-22 19:39:19 +02:00
deajan 3dae261b9b Less required options in helper config file 2019-05-22 19:38:48 +02:00
deajan c6876924c7 Fixed intentation 2019-05-22 19:33:09 +02:00
Orsiris de Jong 0c343662f4
Update copyright year 2019-05-22 19:26:32 +02:00
Orsiris de Jong f4130119ef
Updated beta version since we made another release 2019-05-22 19:26:03 +02:00
deajan 971ea2b358 Rebuilt targets 2019-05-22 19:13:10 +02:00
deajan 2ce8007b9d Bumped version 2019-05-22 19:12:49 +02:00
Orsiris de Jong 39da290577
Merge pull request #167 from deajan/beta2-platform-tests
Beta2 platform tests
2019-05-22 19:10:42 +02:00
Orsiris de Jong cdeae14fd7
v1.3-beta2 announcement 2019-05-22 14:50:00 +02:00
deajan 3cd2f16bc3 Fixed newer Win10 bash version ping 2019-05-21 23:52:26 +02:00
deajan 9435c48f20 Fix newer bash on Windows10 got rid of elder find cmd bug 2019-05-21 22:11:01 +02:00
deajan 4a1001a40f Set default SSH port for test 2019-05-21 21:31:15 +02:00
Orsiris de Jong f0811b3f56
Make codacy happy 2019-05-21 17:07:41 +02:00
deajan f95155c310 Fixed horrible typo 2019-05-21 14:30:26 +02:00
deajan 1b8c07332f Fix for very old config files 2019-05-21 14:09:30 +02:00
deajan d17ece7e2c Fixed bogus copy paste 2019-05-21 13:54:12 +02:00
deajan e1a081a7f1 Fixed backup before upgrading 2019-05-21 12:51:29 +02:00
deajan 590e299821 Fixed sections are rewritten after inserts 2019-05-21 12:43:10 +02:00
deajan f8fbbaef57 Unexpanded ofunctions 2019-05-21 00:38:59 +02:00
deajan 7fffa454e9 Rebuilt targets 2019-05-21 00:08:44 +02:00
deajan 22af510375 Fixed _QUICK_SYNC value too high 2019-05-21 00:08:19 +02:00
deajan 61729d1245 Update changelog 2019-05-20 23:44:59 +02:00
deajan c089ccc63b Rebuilt targets 2019-05-20 23:31:26 +02:00
deajan 3edd80949f Allow commandline override of config file values 2019-05-20 23:31:04 +02:00
deajan 9bd2b7eeaf Minor tweak 2019-05-20 23:19:59 +02:00
deajan 9142f873f4 Rebuilt targets 2019-05-20 22:54:31 +02:00
deajan dc25cba3c8 Fixed bogus SKIP_DELETION logic when SYNC_TYPE set 2019-05-20 22:54:11 +02:00
deajan f781f35ea1 Rebuilt targets 2019-05-20 22:50:41 +02:00
deajan c07897b7cb Disabled conflictDetect test for v1.3 2019-05-20 22:50:01 +02:00
deajan 301e0d69e1 Enfore SKIP_DELETION when SYNC_TYPE set 2019-05-20 22:43:31 +02:00
deajan aca0be5a9b Rebuilt targets 2019-05-20 22:19:27 +02:00
deajan 5638565f6a Refactored locking handling 2019-05-20 22:18:59 +02:00
deajan c10a175c90 Change work comments 2019-05-20 21:58:35 +02:00
deajan 968c732d94 Re-enabled all tests 2019-05-20 21:56:29 +02:00
deajan b290d4e35e Fixed ACL tests 2019-05-20 21:56:01 +02:00
deajan de383c9c0f Removed unused code 2019-05-20 21:55:45 +02:00
deajan 0c1f4403fb Update comment 2019-05-20 21:38:05 +02:00
deajan 555d8e6d23 Unexpanded current dev 2019-05-20 18:20:01 +02:00
deajan 02d0024df9 Rebuilt targets 2019-05-20 18:18:20 +02:00
deajan 3accf5f254 Improved --summary output 2019-05-20 18:18:00 +02:00
deajan bd8fc2f043 Rebuilt targets 2019-05-20 17:53:04 +02:00
deajan 40c44368ec Fixed deletion logging in unidirectional sync 2019-05-20 17:52:43 +02:00
deajan 7331612a11 Rebuilt targets 2019-05-20 17:35:05 +02:00
deajan e12d30d9c5 Minor code tweaks 2019-05-20 17:15:27 +02:00
deajan c18977bcef Added target helper to install script 2019-05-20 14:55:59 +02:00
deajan 3d6ec17f27 Rebuilt targets 2019-05-20 14:30:04 +02:00
deajan a0e5e791cd Update changelog 2019-05-20 14:29:42 +02:00
deajan 44d8635042 Added --sync-type for unidirectional sync, implements #147 2019-05-20 14:28:26 +02:00
deajan 71f857f9c8 Added --syncÃ-type for unidirectional sync 2019-05-20 14:26:59 +02:00
deajan de99f0efdf Removed work output 2019-05-20 14:06:21 +02:00
deajan 0d501209fa Fixed litteral 'synced' state instead of step 2019-05-20 12:13:24 +02:00
deajan efeb665818 Fixed typo generating bogus resume actions 2019-05-20 12:11:30 +02:00
deajan 7e945197c2 WIP SYNC_TYPE 2019-05-20 12:11:04 +02:00
deajan a52068dec0 Fixed possible issues with spaces 2019-05-20 11:50:58 +02:00
deajan 7b57980e57 Codacy improvements 2019-05-20 11:47:39 +02:00
deajan c96bdfe5ce Rebuilt targets 2019-05-20 11:37:55 +02:00
deajan 8018871168 Minor code improvements 2019-05-20 11:37:37 +02:00
deajan 826ebe1c2c Fix potential quick_sync parameter issues 2019-05-20 11:32:55 +02:00
deajan 4b90ac3a27 WIP --sync-type 2019-05-20 11:19:38 +02:00
deajan 0e7f969588 Fixed summary counters should be global 2019-05-20 11:11:12 +02:00
deajan 01c469b019 Fix indentation 2019-05-20 11:04:02 +02:00
deajan aa92531b99 Rebuilt targets 2019-05-19 17:22:07 +02:00
deajan 4542f62fce Fix subshell variables not propagated 2019-05-19 17:21:32 +02:00
deajan 020f674932 Rebuilt targets 2019-05-19 17:12:53 +02:00
deajan 22fe557c54 Typo fixes 2019-05-19 17:12:12 +02:00
deajan 1339e6463a Rebuilt targets 2019-05-19 17:02:20 +02:00
deajan 99a7c932f7 Quick typo fix 2019-05-19 17:01:50 +02:00
deajan 932ecd93fd Rebuilt targets 2019-05-19 17:01:02 +02:00
deajan 201aadd33d Update summary 2019-05-19 17:00:22 +02:00
deajan 5eecb719d3 Rebuilt targets 2019-05-19 16:42:32 +02:00
deajan 76d80b17f6 Deprecat LOG_CONFLICTS as experimental feature 2019-05-19 16:42:08 +02:00
deajan 094d1538bb More --summary statistics 2019-05-19 16:39:19 +02:00
deajan 30411c72c7 Updated changelog 2019-05-19 13:08:14 +02:00
deajan 26b661396a Improved config file upgrade script 2019-05-19 12:56:41 +02:00
deajan e64ec1232e Updated changelog 2019-05-18 13:43:45 +02:00
deajan c2f0b41076 Rebuilt targets 2019-05-18 13:40:29 +02:00
deajan e8470218f6 Bumped build 2019-05-18 13:40:03 +02:00
deajan 3a9c427855 Improve deletion tests to address #165 2019-05-18 13:39:32 +02:00
Orsiris de Jong 63a434cc55
Merge pull request #166 from weinhold/fix-quoting-escaping-issues
fix several quoting/escaping issues
2019-05-18 13:35:23 +02:00
Ingo Weinhold 56c0197b6b fix several quoting/escaping issues
... reproducible when the remote target sync dir contains spaces.
2019-04-05 14:25:15 +02:00
deajan 5b0c40f3f0 Rebuilt targets 2019-03-15 12:10:27 +01:00
deajan 61a9aa6a91 Bumped version 2019-03-15 12:10:06 +01:00
deajan 8a57b568e9 Improved version check 2019-03-15 12:09:40 +01:00
deajan 5e42a088d0 Rebuilt targets 2019-03-15 11:58:45 +01:00
deajan 0f5bed992f Fixed bogus config file revision check on error 2019-03-15 11:54:40 +01:00
deajan 51dded275b Mailer fixes and semantic fixes 2019-03-01 10:41:09 +01:00
deajan 61f6593cbe Ported fixes from backup_tool_script 2019-03-01 09:28:36 +01:00
deajan 8fe0afae56 Fixed typo 2019-02-26 12:10:13 +01:00
deajan 5477ed96fe Rebuilt targets 2019-02-26 12:07:57 +01:00
deajan c15f9ea4a2 Removed bogus SIMPLE log calls 2019-02-26 12:07:35 +01:00
deajan 39feb76d2e Simpler current log 2019-02-14 10:02:37 +01:00
deajan cc2d283f23 Fixed typo introduced with boolean changes 2019-02-08 13:22:03 +01:00
Orsiris de Jong 8e8ed101bb
Merge pull request #163 from deajan/osync2-compat
Osync2 compat
2019-02-08 13:10:46 +01:00
deajan d9b587fd4a Fixed email RFC822 check 2019-02-07 17:04:41 +01:00
deajan 027422b014 Cosmetic changes 2019-01-29 10:04:27 +01:00
deajan e44bdee73e Fixed more boolean replacements 2019-01-22 18:11:18 +01:00
deajan 22bd6181f1 Removed debug log line 2019-01-12 11:46:42 +01:00
deajan e850f8f792 Fixed boolean conversion after init 2019-01-12 10:49:30 +01:00
deajan 2da2109229 Fixed conflict backup multiple unit test 2019-01-11 23:56:48 +01:00
deajan 52c059fc29 Updated conf file upgrade script 2019-01-11 00:43:19 +01:00
deajan f1cf7eb8e2 Updated config file structure, checks and upgrade script 2019-01-11 00:34:12 +01:00
deajan f3bbaceb73 Reenabled local and remote tests 2019-01-02 20:54:57 +01:00
deajan 88491d0fee Disabled conflictList test 2019-01-02 20:19:24 +01:00
deajan 1c9db7136f No conflictlist file will not trigger an error 2018-12-29 18:41:12 +01:00
deajan 71942082f8 Added config file version check 2018-12-21 19:07:56 +01:00
deajan 6e56e2b63e Removed extra tabs 2018-12-21 18:51:34 +01:00
deajan 3931b7b771 Improved log readability from ExecTasks command output 2018-12-21 14:35:11 +01:00
deajan 9e64753569 Removed extra tabs 2018-12-21 12:44:41 +01:00
deajan 98201cf615 Fixed possible deadlock in ExecTasks 2018-12-17 22:43:34 +01:00
deajan 6ac45eea02 Added comment to variable 2018-12-17 20:07:22 +01:00
deajan 17fb0c6bf5 Merge branch 'master' of https://github.com/deajan/osync 2018-12-17 19:37:25 +01:00
deajan cae3bb73f7 Improved command output logging 2018-12-17 19:37:09 +01:00
Orsiris de Jong 5a5e60d651
Added open issue badge 2018-11-16 12:18:27 +01:00
deajan fad217447d Rebuilt targets 2018-11-05 12:14:03 +01:00
deajan 5857d8200b Added patch from Vladimirek 2018-11-05 12:13:07 +01:00
deajan a466e94b9c Some exit logs should be flagged as errors 2018-11-05 12:10:22 +01:00
deajan 08af105dd9 Added busybox-w32 detection 2018-10-26 12:28:31 +02:00
deajan 3314f947b0 Improved SetConfFileValue 2018-10-26 12:25:11 +02:00
deajan 27d6b80fad Minor fixes 2018-10-18 22:33:46 +02:00
deajan 34724352f7 Update texte files 2018-10-18 00:02:23 +02:00
deajan 27f6d2a948 Rebuilt targets 2018-10-17 23:53:13 +02:00
deajan b8f18ac860 Update coding conventions 2018-10-17 23:52:46 +02:00
deajan 01e4ec9ef1 Update tests 2018-10-17 23:33:52 +02:00
deajan fb1fd00f0e Fixed multiple race conditions 2018-10-17 23:33:30 +02:00
deajan 569048c19b Fixed bogus WAIT_FOR_TASK_COMPLETION_ return from ExecTasks 2018-10-15 19:23:48 +02:00
deajan efd8dca58e Fixed another batch of wrong ExecTaks ids 2018-10-14 23:15:38 +02:00
deajan 92dbd6b2fc Fixed partial WAIT_FOR_TASK_COMPLETION_ output 2018-10-14 23:10:34 +02:00
deajan 7e7388a9eb Fixed variable leak 2018-10-14 23:08:03 +02:00
deajan 109f0a0887 Fixed bogus ExecTasks id checks 2018-10-14 23:06:19 +02:00
deajan 54a665fe7e Removed debugging code 2018-10-14 22:51:01 +02:00
deajan 255be72c43 Removed diagnostic lines 2018-10-14 22:41:18 +02:00
deajan 04f11fcab8 Reactivated all tests 2018-10-14 19:14:22 +02:00
deajan 39e5bb92f0 Removed travis debug lines 2018-10-14 19:13:04 +02:00
deajan 0f0ba9b001 Change remote RUN_DIR for unit tests only 2018-10-14 19:12:16 +02:00
deajan 330495b1e8 Prevent variable leak in Logger 2018-10-14 16:35:34 +02:00
deajan 203400000f Minor code cleanup 2018-10-14 16:17:58 +02:00
deajan 85ac20080b ExecTasks debug __CheckArguments should happen before debug log 2018-10-14 16:06:07 +02:00
deajan a28c20d9bd Fixed variable mismatch 2018-10-14 10:51:11 +02:00
deajan c9bc7f4b6c Change all occurences of '-' in ExecTasks id 2018-10-13 23:41:13 +02:00
deajan 17cf11eb0b ExecTasks ids may not include dots 2018-10-13 17:20:18 +02:00
deajan 39053f59e3 More precise ExecTasks ids 2018-10-13 17:05:53 +02:00
deajan 295c74ca58 More logging for ExecTasks 2018-10-13 17:02:02 +02:00
deajan 1896ec793e Removed empty line making missing shebang 2018-10-13 10:43:11 +02:00
deajan 5c6132dd2c Moved rsyncCmd background execution to eval 2018-10-13 10:36:31 +02:00
deajan 438c85b777 Removed unnecessary ExecTasks from _getFileCtimeMtimeRemote function 2018-10-12 19:42:39 +02:00
deajan bbc960d566 No more ping/ping between initiator/target daemons 2018-10-10 20:58:28 +02:00
deajan c963d71ecd Fixing ping/pong between initiator and targets 2018-10-10 20:57:48 +02:00
deajan 1b8f2ea7fc Added daemon mode known issue 2018-10-10 20:57:22 +02:00
deajan 4c999ec229 Remote deletion returns error when no error has happened 2018-10-10 20:47:11 +02:00
deajan a2e3e96827 WIP for target-helper 2018-10-10 20:39:49 +02:00
deajan 4be8429b96 Allow setting MIN_WAIT and MAX_WAIT on the fly 2018-10-10 15:19:32 +02:00
deajan 0e103cd98b Added push file exclusion in RSYNC_FULL_PATTERNS 2018-10-10 15:13:36 +02:00
deajan 83cfabed6f Litte performance improvement by not running code again 2018-10-10 15:02:00 +02:00
deajan dfe09f2fa3 Rebuilt targets 2018-10-10 02:19:59 +02:00
deajan ff26961e82 Fixed BSD daemon mode 2018-10-10 02:19:38 +02:00
deajan ca63bfabe0 Testing for directories in triggerupdate functions 2018-10-10 02:12:57 +02:00
deajan 2aa36b626a Replaced Logger with RemoteLogger in triggerUpdate 2018-10-10 02:09:46 +02:00
deajan f0336c0dec Added target-helper syncdir checks 2018-10-10 01:57:20 +02:00
deajan 3dc8478ba7 Added default MIN_WAIT and MAX_WAIT values 2018-10-10 01:45:39 +02:00
deajan 633e6397d0 Fixed missing equal sign for password-file 2018-10-10 01:40:26 +02:00
deajan babeea9d9a Fixed unlocking 2018-10-10 01:33:31 +02:00
deajan 9cb6cc57af Fixed typos 2018-10-10 01:31:12 +02:00
deajan 7eb4ee68ae Added unlockReplica pid initialisation 2018-10-10 00:05:46 +02:00
deajan 660e856986 Unlocking only when locks exist 2018-10-10 00:04:30 +02:00
deajan ac31de2388 Cleanup also called when bogus config detected 2018-10-09 23:57:53 +02:00
deajan ae64a967f6 Continuing isolating ConflictLog detection issue 2018-10-08 22:40:41 +02:00
deajan 2ca8803b3a No need for paranoia debug in CleanUp for remote exec 2018-10-08 21:53:30 +02:00
deajan ad9d978fc2 Typo fixing 2018-10-08 21:50:35 +02:00
deajan 7570794632 Improved remote execution results 2018-10-08 21:40:57 +02:00
deajan 4651ff0e06 Added remote detection 2018-10-08 21:34:41 +02:00
deajan 0e2189c441 Added RUN_DIR subset 2018-10-08 21:29:47 +02:00
deajan 1ab6042a62 Fixed typo in _getFileCtimeMtimeRemote 2018-10-08 21:17:36 +02:00
deajan a5f5b3a800 Rebuilt targets 2018-10-08 20:12:59 +02:00
deajan b95474a8e6 Updated expr to not use extended regular expressions 2018-10-08 20:11:39 +02:00
deajan e3855c4256 Revert work on _getCtimeMtimeFileRemote error detection 2018-10-07 17:51:15 +02:00
deajan 51f6dcbd71 Trying to identify concurrency issue with ConflictDetection 2018-10-07 17:50:37 +02:00
deajan 3d68a135a4 Conflict detection random bug isolation 2018-10-07 14:43:31 +02:00
deajan 9e17e114f7 Rebuilt targets 2018-10-07 14:42:41 +02:00
deajan 94a71620a1 Made ctime.mtime functions more clear in syntax 2018-10-07 13:23:45 +02:00
deajan bad7767809 Harmonize ExecTasks calls 2018-10-07 12:59:56 +02:00
deajan fa5cf2de57 Another set of conflictLog issue isolation 2018-10-07 12:25:53 +02:00
deajan 9eb29c3454 Rebuilt targets 2018-10-07 12:25:27 +02:00
deajan 4129dfff37 Typo fix 2018-10-07 12:25:07 +02:00
deajan c452bd45e6 Increased TSTAMP randomization 2018-10-07 12:24:35 +02:00
deajan 6b0bab0984 Removed unused variable 2018-10-07 12:23:59 +02:00
deajan 89d63d83b8 Removed unused variable 2018-10-06 22:16:11 +02:00
deajan e0f177f5c2 Added comment about unit file verification 2018-10-06 21:57:11 +02:00
deajan 6bd5862702 Removed unused argument from conflictList 2018-10-06 21:41:58 +02:00
deajan eb8c780d84 Rebuilt targets 2018-10-06 20:03:58 +02:00
deajan 58e5c654d3 Isolate conflict detect bug 2018-10-05 00:51:20 +02:00
deajan e411c81f3d Removed double debug logs 2018-10-05 00:46:11 +02:00
deajan 57647b8960 Isolate ConflictDetection function 2018-10-05 00:39:48 +02:00
deajan 5b395b3c04 Travis debug can fail 2018-10-02 23:37:33 +02:00
deajan 4bd4bbc247 Reverted travis debug lines 2018-10-02 23:26:04 +02:00
deajan 4de784d90f Added default umask 2018-10-02 23:20:26 +02:00
deajan 6c1b7a541b Fixed bogous CreateDir rights 2018-10-02 23:06:33 +02:00
deajan 6e7b99debb IsInteger should be part of ofunctions micro/mini 2018-10-02 23:00:54 +02:00
deajan 996e6251e1 Added missing IsInteger function 2018-10-02 22:43:24 +02:00
deajan a265ca4eef Travis here and travis there 2018-10-02 22:38:57 +02:00
deajan 306d5ff1ad Added permissions on CreateDir 2018-10-02 22:36:30 +02:00
deajan 74271d220c I f*cking hate travis 2018-10-02 21:27:12 +02:00
deajan 8a350333a8 Travis debug... 2018-10-02 19:32:21 +02:00
deajan e9daf2b2bf Removed unused code 2018-10-02 19:30:36 +02:00
deajan d58071c898 Why is travis so bad... 2018-10-02 19:29:15 +02:00
deajan b07ee4a645 Fixed installer directive 2018-10-02 19:26:57 +02:00
deajan 6c65f9098f Merge branch 'master' of https://github.com/deajan/osync 2018-10-02 19:02:40 +02:00
deajan 9537b92bf6 Rebuilt targets 2018-10-02 19:02:31 +02:00
deajan 2c857a1e83 Fixed removing directories on soft deletion 2018-10-02 19:01:44 +02:00
Orsiris de Jong b0cdb17328 Update issue templates 2018-10-02 18:30:04 +02:00
Orsiris de Jong 5c0c494526
Create PULL_REQUEST_TEMPLATE.md 2018-10-02 18:27:01 +02:00
deajan 6f2e1af3d7 Added release policy 2018-10-02 18:24:40 +02:00
deajan 0b7b6808d5 Add shellcheck exclusions 2018-10-02 18:22:36 +02:00
deajan 7eab6df734 Better log message 2018-10-02 18:19:32 +02:00
deajan 32c2ab17e4 Rebuilt targets 2018-10-02 18:14:07 +02:00
deajan bc6ebdb80e Fixed merge paths and removed unused code 2018-10-02 18:13:48 +02:00
deajan 0d6f7e0ca0 Merge cleanup 2018-10-02 18:11:01 +02:00
deajan 49948dd637 Fixed installer 2018-10-02 18:09:21 +02:00
deajan f35d5841c2 Added cleanup routine 2018-10-02 18:09:12 +02:00
deajan 81148db1fa Fixed merge producing rogue logs 2018-10-02 18:08:03 +02:00
deajan 250ac48ed6 Indentation fix 2018-10-02 11:41:46 +02:00
deajan 65d4c3c3ff Random generator improvements 2018-10-02 11:37:46 +02:00
deajan bbfa4c9d3b Rebuilt targets 2018-10-02 10:52:25 +02:00
deajan 25070032c4 Typo fix 2018-10-02 10:51:45 +02:00
deajan 4f76bb4ad2 Simpler merge process 2018-10-02 10:49:28 +02:00
deajan 465a3b9b80 IsNumeric and IsNumericExpand are now busybox compatible 2018-10-02 10:49:16 +02:00
deajan a9434e605b Removed unused dummy function 2018-10-02 10:09:40 +02:00
deajan 06004ac05d Function reorganisation 2018-10-02 10:07:01 +02:00
deajan b2463d2e08 Added includes to batcher 2018-10-02 09:37:25 +02:00
deajan 13286c2720 [WIP] Merge simplifications 2018-10-02 09:35:48 +02:00
deajan a734dadfde Don't dev at night kids... 2018-10-02 09:24:15 +02:00
deajan c694580ae5 Yet another typo fix 2018-10-02 09:22:41 +02:00
deajan 4f3e6a11d2 Fixed typo 2018-10-02 09:17:59 +02:00
deajan f028f3b6d2 Added preprocessing to batch runner 2018-10-02 09:07:19 +02:00
deajan 2e6e17962c Removed space 2018-10-01 21:04:41 +02:00
deajan 52cf42a53c Add TSTAMP and SCRIPT_PID variables 2018-10-01 21:03:00 +02:00
deajan 5bc77dfe76 Add PoorMansRandomGenerator subset 2018-10-01 21:02:47 +02:00
deajan 1869b1e82f Added Trapquit to trigger CleanUp 2018-10-01 20:49:53 +02:00
deajan 3532b50c38 Added CleanUp subset 2018-10-01 20:46:55 +02:00
deajan d0b40257fa Added cleanup function to installer 2018-10-01 20:46:21 +02:00
deajan 59b7562a3e Fixed Logger missing RUN_DIR 2018-10-01 20:43:27 +02:00
deajan c99a1293c7 Debug conflictLog in travis 2018-10-01 20:28:46 +02:00
deajan eb609f7faa Some release details 2018-10-01 20:13:58 +02:00
deajan 7e678b6480 Debug output for travis conflictDetect tests 2018-10-01 20:01:26 +02:00
deajan b4cd0834cd Fixed shellcheck SC2027 in RsyncPatterns 2018-10-01 14:13:05 +02:00
deajan 55534e0669 Fixed shellcheck SC2053 in Vercomp 2018-10-01 14:10:16 +02:00
deajan 2eba91a58f Removed unused variables 2018-10-01 14:09:20 +02:00
deajan 01864e4980 Rebuilt targets 2018-10-01 14:03:09 +02:00
deajan 87cdc8eb98 Removed extra output from PoorMansRandomGenerator 2018-10-01 14:02:44 +02:00
deajan 740d5277cc Rebuilt targets 2018-10-01 11:31:22 +02:00
deajan a230d32042 Improve PoorMansRandomGenerator function 2018-10-01 11:27:01 +02:00
deajan dde31090fe Improved inotifywait call 2018-10-01 10:49:35 +02:00
deajan c07fa8b267 Added target helper service files 2018-10-01 10:31:01 +02:00
deajan 88597d6a7a Initial target-helper mode working 2018-10-01 10:27:01 +02:00
deajan 6bce2e1755 [WIP] Less restrictive preflight checks in target-helper mode 2018-10-01 10:08:22 +02:00
deajan fe808ca909 [WIP] target_helper switch should not be a half bool half char 2018-10-01 10:01:00 +02:00
deajan 90a09c422b [WIP] Use same variable names in target-helper mode 2018-10-01 09:57:27 +02:00
deajan 47bb01b0dc [WIP] Pass initiator ssh uri on target-helper mode 2018-10-01 09:54:24 +02:00
deajan 2b51f06f21 Removed earlier target helper file 2018-10-01 07:28:03 +02:00
deajan f50048180a Rebuilt targets 2018-10-01 07:27:20 +02:00
deajan 5945988e96 Fix wrong log message on MacOS 2018-10-01 07:26:56 +02:00
deajan 07775d7390 [WIP] osync-target-helper mode 2018-09-30 21:24:09 +02:00
deajan c80bec2fe2 osync target-helper service config file 2018-09-30 16:41:59 +02:00
deajan af7542d8f5 [WIP] target helpder service in osync 2018-09-30 16:08:12 +02:00
deajan b44c0c13ad Rebuilt targets 2018-09-30 14:50:51 +02:00
deajan d727bc353c Fixed rsync args built logic 2018-09-30 14:50:00 +02:00
deajan 3af0bc7a11 Rebuilt targets 2018-09-30 14:07:09 +02:00
deajan f1e40d54e4 Fixed typo 2018-09-30 14:06:24 +02:00
deajan 76f9f31e6d Moved RSYNC_ARGS to RSYNC_DEFAULT_ARGS 2018-09-30 13:57:57 +02:00
deajan 50496070f6 Merge branch 'master' of https://github.com/deajan/osync 2018-08-08 11:45:08 +02:00
deajan 68d8556585 Updated changelog 2018-08-08 11:32:53 +02:00
deajan 1eec242cb0 Rebuilt targets 2018-08-08 11:31:58 +02:00
deajan 4cf697cd28 Bump osync version 2018-08-08 11:31:11 +02:00
deajan 23a9f357fe Bump ofunctions version 2018-08-08 11:30:45 +02:00
Orsiris de Jong 7c11240034
Change logger date output to be language agnostic 2018-07-14 15:37:14 +02:00
deajan 6222fd6872 Fixed variable leak 2018-07-09 15:01:45 +02:00
deajan c80871cb63 Updated changelog 2018-07-09 15:01:12 +02:00
deajan cabd90c570 Fixed error log color not working in busybox #151 2018-07-09 15:00:38 +02:00
deajan 3f46c69c6d Removed redundant partial exclude dir from daemon 2018-07-08 13:19:30 +02:00
deajan 24599c3057 Fix for #119 2018-07-08 13:18:26 +02:00
deajan fa64c49244 Added EscapeDoubleQuotes function 2018-07-03 17:29:51 +02:00
deajan cf609998aa Updated shunit test framework 2018-07-02 23:25:49 +02:00
deajan 82e60bdffe Tidyup 2018-07-02 22:40:55 +02:00
deajan 83321db4ea WIP on conflict detection 2018-07-02 22:40:23 +02:00
deajan 76ed396602 More comment fixes 2018-07-02 22:21:36 +02:00
deajan f3215c0474 Quick typo fix 2018-07-02 22:17:17 +02:00
deajan 7cb987a32b More email checks 2018-07-02 22:09:28 +02:00
deajan f79acad239 Fixed conflictLsit output and typos 2018-07-02 22:09:18 +02:00
deajan 548c766920 Fixed conflict list initialization 2018-07-02 18:19:47 +02:00
deajan 9b3af0596e Comment tidyup 2018-07-02 17:29:50 +02:00
deajan b45e50584f Comment tidyup 2018-07-02 17:29:18 +02:00
deajan 1ea4584027 Fix typo 2018-07-02 15:46:45 +02:00
deajan 61f7ebe156 WIP: no conflictDetection tests while working on it 2018-07-02 15:44:27 +02:00
deajan 41144f5705 Fixed fakeroot for ssh_filter 2018-07-02 15:41:30 +02:00
deajan 5438941c88 Help..travis is killing me 2018-07-02 15:37:35 +02:00
deajan 888309f420 Well... change FAKEROOT from /tmp to /home 2018-07-02 15:34:53 +02:00
deajan 704d3d20a7 Travis... travis...travis... 2018-07-02 15:33:49 +02:00
deajan 503e325e14 Comment reorganization 2018-07-02 15:32:48 +02:00
deajan 182e3921d5 Why do you do this travis ? 2018-07-02 15:23:44 +02:00
deajan e094e04038 Travis sudo to create a tmp file... 2018-07-02 15:15:39 +02:00
deajan a2a6d843b9 More travis tests 2018-07-02 15:12:02 +02:00
deajan 7ddd13f122 Trying various travis fixes 2018-07-02 14:44:16 +02:00
deajan f0f3cd64b1 Added email encoding comment 2018-07-02 10:42:32 +02:00
deajan 9cac01d9fd Unexpanded and removed work comments 2018-07-02 10:40:10 +02:00
deajan c04e0fa21a Some comment love 2018-07-02 10:20:34 +02:00
deajan 9e869e2bc4 Fix travis won't allow file creating in /tmp/osync_test_install 2018-07-02 10:12:16 +02:00
deajan 948a2b2f87 Log messages improvements for travis 2018-07-02 10:07:48 +02:00
deajan c3b468d932 Travis related test 2018-07-02 10:00:38 +02:00
deajan 2f5e21caea Fixed typo 2018-07-02 09:58:25 +02:00
deajan 0a8811cfb9 Temporarily disabled conflictList test 2018-07-01 10:55:07 +02:00
deajan 4d322f7e6b WIP: initialization should take create conflict list possibility 2018-07-01 10:54:17 +02:00
deajan 9b4914c49e cmdline arg improvements 2018-07-01 10:46:16 +02:00
deajan 21bc4e1ee7 WIP: conflict detection and fakeroot install 2018-06-30 19:46:11 +02:00
deajan 3d6eaef447 Bumped version to 1.3-dev 2018-06-30 19:40:24 +02:00
deajan 381313dc41 Fixed typo 2018-06-29 22:11:33 +02:00
deajan a64da2ba3d Some minor text changes for openRC #142 2018-06-26 15:30:34 +02:00
Orsiris de Jong f6db6fb9e3
Merge pull request #142 from kozross/master
Add OpenRC support, fixed daemon script
2018-06-26 15:18:18 +02:00
deajan b3cccc373a Quick OS detection fix 2018-06-26 09:56:54 +02:00
deajan 42ed3b156a Rebuilt targets 2018-06-26 00:23:01 +02:00
deajan de57e37217 Added OpenRC support 2018-06-26 00:21:00 +02:00
deajan bf54ce8693 Finished WIP on --summary for deletions 2018-06-25 23:59:06 +02:00
deajan 7621f3ec25 Implemented --initialize 2018-06-25 23:55:13 +02:00
deajan ad22361ee5 Updated os detection 2018-06-25 15:10:11 +02:00
deajan 494fcda098 Fixed BASHVERBOSE variable 2018-06-25 14:49:15 +02:00
deajan bd2e5a16c6 Replaced QuickLogger with Logger for #148 2018-06-25 14:12:05 +02:00
deajan 844cf56307 Replaced QuickLogger with Logger 2018-06-25 14:11:46 +02:00
deajan 8dfe59220a Removed quicklogger function 2018-06-25 14:11:29 +02:00
deajan a60ece6950 Updated changelog to reflect roadmap 2018-06-25 11:27:34 +02:00
deajan c39544d79c Removed finished working comments 2018-06-25 11:18:53 +02:00
deajan 0ccc737631 Conflict log line only appears if used 2018-06-25 11:16:57 +02:00
deajan d9f749e28a Less verbose ExecTasks logging 2018-06-24 19:10:35 +02:00
deajan 1ed49b7d41 Quick note about file updates 2018-06-24 19:10:23 +02:00
deajan 166a37865e UrlEncode function now works with busybox 2018-06-05 11:51:49 +02:00
deajan dc31bfb42d Fixed rundir timestamp filename bug on busybox 2018-06-04 14:13:10 +02:00
deajan 01e359ae3c Merge branch 'master' of https://github.com/deajan/osync 2018-05-28 08:28:19 +02:00
deajan 4d9eb8830b Fixed missing usage 2018-05-28 08:28:01 +02:00
Orsiris de Jong beed970e49
Merge pull request #144 from Jookia/RFC_srv-errno
osync-srv: Fix syntax errors when setting errno
2018-05-18 12:30:26 +02:00
deajan 1314a3381b Updated osync test file URL 2018-05-18 12:29:39 +02:00
Jookia a0d7ec544d
osync-srv: Fix syntax errors when setting errno
Two instances in the osync-srv script throw an error when setting errno to 1.
In both instances errno is expanded from '$errno=1' to '0=1'.
In the first instance there is invalid spacing around the equals symbol.

Signed-off-by: Jookia <166291@gmail.com>
2018-05-18 13:07:16 +10:00
Koz Ross 44d2df4906 Amend README for Gentoo and OpenRC stuff 2018-05-17 15:08:11 +12:00
Koz Ross 601c8ace14 Fix README.md typo 2018-05-17 15:06:10 +12:00
Koz Ross 33b7b89a36 Adding OpenRC script 2018-05-17 15:05:19 +12:00
deajan 6d37e161c8 Merge branch 'master' of https://github.com/deajan/osync 2018-03-22 17:24:36 +01:00
deajan f627daf25a bootstrap can now use BASH_VERBOSE=yes 2018-03-22 17:24:04 +01:00
deajan ee8016ef9a Rebuilt targets 2018-03-22 17:23:48 +01:00
deajan 1b33068422 Fixed #135 2018-03-22 17:23:14 +01:00
Orsiris de Jong 1917c33cd1
Merge pull request #130 from Shadowigor/master
Rework of the packaging script for Arch Linux
2018-03-22 12:21:15 +01:00
Orsiris de Jong c2960e3315
Merge pull request #136 from roguh/master
Fixed variables that required config file
2018-03-21 21:14:03 +01:00
Hugo Rivera 3c1c606de4 Set `MAX_EXEC_TIME_PER_CMD_*` variables without config file 2018-03-20 03:58:21 -06:00
Hugo Rivera 4725370d8e Set `MIN_WAIT` without config file 2018-03-20 03:58:10 -06:00
deajan 041de62c36 Rebuilt targets 2018-03-15 09:57:04 +01:00
deajan e8436e46bd Fixed typo for function name 2018-03-15 09:54:12 +01:00
deajan 36daadd7aa Ported fixes from obackup 2018-03-15 09:53:35 +01:00
deajan dee5b4037c Minor improvements to ExecTasksé 2018-02-24 16:34:53 +01:00
deajan d0bd873def Merge branch 'master' of https://github.com/deajan/osync 2018-02-20 22:54:19 +01:00
deajan d13b76087f Rebuilt targets 2018-02-20 22:54:07 +01:00
deajan 46a990c4d8 Fixed inotifywait cannot load loop 2018-02-20 22:53:30 +01:00
deajan bfa9d72c8d Fix service file wildcard expansion 2018-02-20 22:49:36 +01:00
deajan a7d0c6f515 Added comment about #121 2018-02-20 22:44:53 +01:00
deajan d8b30d7711 Added sed regex compat for MacOS 2018-02-20 22:39:42 +01:00
deajan 190e46c785 Added sex regex compat for MacOS 2018-02-20 22:37:46 +01:00
deajan da381175ed Addec CheckRFC822 subset 2018-02-20 22:15:20 +01:00
deajan 034c1693e9 Updated ExecTasks version 2018-02-20 22:15:04 +01:00
deajan 686a28cf08 Merged improvements from burp branch 2018-02-20 22:14:41 +01:00
deajan 57cf91e4c6 Added better failed remote connection log 2018-01-31 21:04:48 +01:00
Shadowigor b2b5714469 Rework of the packaging script for Arch Linux to make it more flexible and reliable 2018-01-18 17:16:55 +01:00
Orsiris de Jong 477eb9ea84
Merge pull request #128 from imdreamrunner/patch-1
Fix a type of daemon at README.md
2018-01-09 20:11:19 +01:00
Ivor Xinzi Zhou 0bda80355b
Fix a type of daemon at README.md
As the title suggests, just a simple fix.
2018-01-08 13:01:14 +08:00
deajan df9a90896a Rebuilt targets 2018-01-03 17:41:06 +01:00
deajan 328a07e406 More ExecTasks fixes 2018-01-03 17:40:29 +01:00
deajan ebf8b106d5 Fixed ExecTasks parallelExec runs 2018-01-03 15:11:16 +01:00
deajan 276fc8c082 Update changelog 2018-01-02 20:08:01 +01:00
deajan 9a0dba00e4 Rebuilt targets 2018-01-02 20:06:31 +01:00
deajan 9b8fe3774e Fixed time counting for new ExecTasks 2018-01-02 20:05:54 +01:00
deajan 73d592ad34 Merged WaitForTaskCompletion and ParallelExec into ExecTasks 2018-01-02 20:02:57 +01:00
deajan cbd7607836 Rebuilt targets 2017-12-30 17:59:48 +01:00
deajan 8fb3ea2532 Added fix from PR #123 2017-12-30 17:59:12 +01:00
deajan 1b079ebee5 Rebuilt targets 2017-12-30 17:56:03 +01:00
deajan 755edb0654 Fixed #116 in master too 2017-12-30 17:55:27 +01:00
Orsiris de Jong 3ef4160cc8
Merge pull request #124 from aero31aero/patch-1
readme: Fix typos in batch-mode instructions.
2017-12-15 09:03:50 +01:00
Rohitt Vashishtha de45d000e0
readme: Fix typos in batch-mode instructions. 2017-12-15 07:29:49 +05:30
deajan c78d6bc4ce Fixed process counting message 2017-12-02 13:16:48 +01:00
deajan 7e26863daf Backports from other projects 2017-12-02 12:45:00 +01:00
deajan 69b2283719 Added another troubleshooting guideline 2017-11-27 08:32:08 +01:00
deajan 7d22be8375 Rebuilt targets 2017-11-23 16:58:49 +01:00
deajan 0a1dc91fad Fixed bogus global WAIT_FOR variable 2017-11-23 16:58:29 +01:00
deajan c05499c5f2 Improved ParallelExec status message 2017-11-23 00:38:12 +01:00
deajan a65bec4410 Replaced IsNumeric with IsInteger for pid checks 2017-11-23 00:30:47 +01:00
deajan a5618c80d8 Rebuilt targets 2017-11-22 15:05:26 +01:00
deajan 6d217c1e15 Reintroduced fix from #120 2017-11-22 15:05:09 +01:00
deajan fdc0b1b242 Merge branch 'master' of https://github.com/deajan/osync 2017-11-22 15:02:51 +01:00
deajan 9833ce9032 Rebuilt targets 2017-11-22 15:02:36 +01:00
deajan 71a0437de6 Ensured writeLocks=false at beginning of lock handling 2017-11-22 15:02:17 +01:00
Orsiris de Jong ff38685105
Merge pull request #120 from acuthbert/master
Fixed --skip-deletion not parsing argument
2017-11-21 11:24:48 +01:00
acuthbert b195abf59f
Fixed --skip-deletion not parsing argument
Skip deletion was broken in the argument parsing.
2017-11-21 09:07:48 +00:00
deajan 0b665be787 Updated changelog 2017-08-15 01:27:12 +02:00
deajan 972b8481f1 Rebuilt targets 2017-08-14 22:22:28 +02:00
deajan 86930737b0 Added -f to local replica unlock 2017-08-14 22:21:41 +02:00
deajan 86ff4dc5e9 Rebuilt targets 2017-07-27 23:20:24 +02:00
deajan f26b1118a1 Add install.sh help 2017-07-27 23:18:05 +02:00
deajan 168fc7b2f5 Updated usage 2017-07-27 23:16:51 +02:00
deajan 7cbbdb960a Installer adds --prefix option + fixes 2017-07-27 23:15:35 +02:00
deajan 09c664fe4b Moved commandline args setup to sub function 2017-07-27 22:50:48 +02:00
deajan a80b65860a Quick preflight check for bootstrap 2017-06-20 15:20:42 +02:00
deajan 1375ab425b Initial upload of target helper service 2017-06-19 16:08:17 +02:00
deajan 29dc7a3e9e Merge now requires program name 2017-06-19 16:01:47 +02:00
deajan 2038a2ecb9 Made bootstrap and merge program agnostic 2017-06-19 16:01:16 +02:00
deajan e07cb136c4 Permit merge of other executables 2017-06-18 22:53:57 +02:00
deajan 5bcc7c75ea Permit bootstrap of other executables 2017-06-18 22:48:38 +02:00
deajan 8d9a6be16a Typo fixing 2017-06-18 22:11:09 +02:00
deajan 06becc5181 Updated ofunctions 2017-06-09 11:49:13 +02:00
deajan 1dc9408044 Fix double compression extension 2017-06-09 09:56:11 +02:00
deajan 9676ccccad Removed work comments 2017-06-09 08:34:48 +02:00
deajan 45e4419a0f Fixed typo 2017-06-09 08:33:57 +02:00
Orsiris de Jong c9772b0fc3 Merge pull request #106 from deajan/fix-sed
Changed sed -E to sed -r for compat issues
2017-06-08 16:32:31 +02:00
deajan 9b9631fe2c Changed sed -E to sed -r for compat issues 2017-06-08 16:30:20 +02:00
deajan 5c36e803d8 Revert "More sort enforcing"
This reverts commit fbb36b51b7.
2017-06-08 15:39:57 +02:00
deajan fbb36b51b7 More sort enforcing 2017-06-08 15:20:36 +02:00
deajan 9220cecebc Rebuilt targets 2017-06-08 14:43:17 +02:00
deajan a7f9a28c93 Merge branch 'master' of https://github.com/deajan/osync 2017-06-08 14:42:12 +02:00
deajan 1f6fe47c2c Rebuilt targets 2017-06-08 14:41:59 +02:00
deajan d926a26cf1 Updated changelog 2017-06-08 14:41:44 +02:00
deajan 4678ab7e71 Fixed missing env for LC_ALL 2017-06-08 09:25:33 +02:00
deajan 261521d047 Added LC_ALL to all ssh calls 2017-06-07 12:48:52 +02:00
deajan 10ebfaae16 Added LC_ALL=C to all ssh calls 2017-06-07 12:43:56 +02:00
deajan e096413eb0 Merge branch 'master' of https://github.com/deajan/osync 2017-06-07 12:25:36 +02:00
deajan 30c6b3ec46 timestampList is not used for ACL lists yet 2017-06-07 12:17:39 +02:00
Orsiris de Jong 3667ccfb6f Typo fixing Fixes #104 2017-06-06 18:46:29 +02:00
deajan 543cfc1159 Fixing sort order in conflictList 2017-06-06 17:39:53 +02:00
deajan 679e140084 Fix new regex in treelist for rsync output 2017-06-06 16:47:32 +02:00
deajan e73e395ed8 Removed empty line 2017-06-06 16:45:01 +02:00
deajan 7c44b7342b Added new conflict configurations 2017-06-06 16:23:04 +02:00
deajan 3e9a380b6b Updated config to v1.2.2-dev 2017-06-06 16:21:56 +02:00
deajan cbea41be56 Fixed double entry 2017-06-06 16:03:05 +02:00
deajan 85cd7bd75e Updated changelog 2017-06-06 16:02:13 +02:00
deajan 2f20edf823 Updated changelog 2017-06-06 09:44:47 +02:00
deajan 84a108dd41 Rebuilt targets 2017-06-05 18:59:44 +02:00
deajan d0d7be40c3 Added --dry support for conflict list 2017-06-05 18:59:05 +02:00
deajan 7a24cf49cd Implemented --alert-conflicts options 2017-06-05 18:53:15 +02:00
deajan be3b3d39b6 Added error handling to conflict list functions 2017-06-05 15:32:38 +02:00
deajan 11408d2de0 Add more locale exports 2017-06-05 15:03:01 +02:00
deajan 7260d43416 Improved conflict list work 2017-06-04 19:07:22 +02:00
deajan 1d7cb5be53 Multiple file list fixes 2017-06-04 13:01:34 +02:00
deajan b4f1bd37ea Rebuilt targets 2017-06-03 13:58:33 +02:00
deajan 2b786abc6a Some comment removal 2017-06-03 13:57:10 +02:00
deajan bd6b1a60e8 Rebuilt targets 2017-06-03 13:52:12 +02:00
deajan 967ce33977 WIP: conflict list 2017-06-03 13:51:49 +02:00
deajan 37ca73a6f9 moved unfortunate comment placement 2017-06-03 01:28:34 +02:00
deajan 9e1c3c2a65 WIP: conflict list 2017-06-03 01:20:38 +02:00
deajan 862a6fd235 Fixed some more typo 2017-06-02 15:42:45 +02:00
deajan 83fd33bf78 WIP: conflict list 2017-06-01 17:45:02 +02:00
deajan 99b606fef8 WIP: conflict list 2017-05-31 18:02:18 +02:00
deajan b0307fd555 Another typo fix 2017-05-31 12:36:39 +02:00
deajan eb73d49c69 Typo fixing 2017-05-31 12:31:18 +02:00
deajan d91230e22f WIP: conflict list 2017-05-31 11:16:36 +02:00
deajan 825e051e3b WIP: conflict list 2017-05-30 15:45:43 +02:00
deajan a7ceea1dac WIP: conflict list 2017-05-30 15:00:05 +02:00
Orsiris de Jong 3ff8a123e1 Merge pull request #103 from deajan/no-resume
Added --no-resume option
2017-05-30 14:51:35 +02:00
Orsiris de Jong 6a4b3701d0 Merge branch 'master' into no-resume 2017-05-30 14:50:21 +02:00
deajan 45cb042fa0 Added --no-resume option 2017-05-30 14:46:35 +02:00
deajan 5c60e7a9a2 WIP: conflict detection 2017-05-30 14:36:04 +02:00
deajan a99a96e871 WIP: conflict detection 2017-05-30 14:35:44 +02:00
deajan f98a9a0748 WIP: getting conflict list of files 2017-05-30 12:16:59 +02:00
deajan b541a7c98e WIP: detect conflict files 2017-05-30 11:14:11 +02:00
Orsiris de Jong d587e49e67 Merge pull request #101 from deajan/fix_options
Fix missing daemon subprocess options
2017-05-30 10:18:57 +02:00
Orsiris de Jong a32314c720 Merge branch 'master' into fix_options 2017-05-30 10:18:48 +02:00
Orsiris de Jong 63834b5714 Merge pull request #100 from deajan/fix_options
Fix missing options to daemon subprocess
2017-05-30 10:14:31 +02:00
deajan 520c20659f Added missing options to subprocess in daemon mode 2017-05-30 10:12:28 +02:00
deajan f962f86f30 Updated changelog 2017-05-30 10:09:19 +02:00
deajan 908c9af888 Added --log-conflicts option 2017-05-30 09:29:16 +02:00
deajan 0b442e2bcf Updated work comments 2017-05-30 09:19:47 +02:00
deajan a32b5f8321 Bumped version to next dev 2017-05-30 09:15:48 +02:00
deajan 2c1e688d8e Bumped dev versions to rc 2017-05-30 09:11:00 +02:00
deajan 8f946cb476 Updated changelog 2017-05-30 09:10:26 +02:00
deajan 78dc39b86f Change 23242 to 2017-05-30 09:09:25 +02:00
deajan f8df6b8eab Rebuilt targets 2017-05-29 16:54:02 +02:00
deajan 2b163d385b KillChilds shoudln't allow a pid of 1 either 2017-05-29 16:53:43 +02:00
deajan 3174981b9a Rebuilt targets 2017-05-29 15:14:00 +02:00
deajan ab40ea64e2 Checking pid doesn't contain 0 2017-05-29 15:13:17 +02:00
deajan ee8b213894 Rebuilt targets 2017-05-28 22:20:57 +02:00
deajan 11bd517982 Last fix for KillChilds pgrep issue on Mac 2017-05-28 22:20:41 +02:00
deajan 1400390f57 Rebuilt targets 2017-05-28 21:25:22 +02:00
deajan c2b24688ef Another fix in the wall 2017-05-28 21:25:03 +02:00
deajan 300108641a Rebuilt targets 2017-05-28 20:17:57 +02:00
deajan 011a316f94 Added pid test in KillChilds 2017-05-28 20:17:38 +02:00
deajan fe210877dc Prevent possible recursive loop with bogus pgrep implementation 2017-05-28 13:37:12 +02:00
Orsiris de Jong a740d9b63b Added BSD license badge 2017-05-22 14:57:16 +02:00
deajan 623408bf31 Rebuilt targets 2017-05-22 11:19:23 +02:00
deajan 5677335c24 Removed WIP dev sleep command in treeList 2017-05-22 11:19:03 +02:00
deajan 722e366ade Rebuilt targets 2017-05-22 09:32:50 +02:00
deajan 762fd236a0 Bumped version to dev again 2017-05-22 09:32:34 +02:00
deajan 1a85d5ded9 Added -q parameter to ssh to inhibate banners 2017-05-22 09:32:12 +02:00
deajan 8d99a74710 Updated xattr comment 2017-05-03 00:19:18 +02:00
deajan d8ad5f746b Added zfs performance comment 2017-04-27 10:59:31 +02:00
deajan d1bb2fe68e Rebuilt targets 2017-04-26 21:03:25 +02:00
deajan 402adba191 Fixed GetRemoteOS os-release getinfo 2017-04-26 21:03:04 +02:00
deajan bc3b6b3a5d Updated readme with RPM file 2017-04-26 15:42:32 +02:00
deajan 96a3995545 Bumped version of specfile 2017-04-26 15:40:19 +02:00
deajan 49bdd17202 Rebuilt targets 2017-04-26 13:56:11 +02:00
deajan 2934951495 Added wchan to performance profiler 2017-04-26 13:55:52 +02:00
deajan ec857e8e01 Rebuilt targets 2017-04-26 13:51:58 +02:00
deajan 12685b3154 Added more params to performance profiler 2017-04-26 13:51:15 +02:00
deajan e10a120e74 Rebuilt targets 2017-04-26 13:36:11 +02:00
deajan 128051cd8f Added iostat to perf profiler 2017-04-26 13:35:54 +02:00
deajan b618970ea1 Update changelog 2017-04-26 13:15:53 +02:00
deajan 56b9efd686 Rebuilt targets 2017-04-26 12:04:21 +02:00
deajan bbff9d55d6 Added perf profiler 2017-04-26 12:04:00 +02:00
deajan ac0f7b3866 Updated ofunctions 2017-04-20 21:30:04 +02:00
deajan abd0ff640c Check program type for service files 2017-04-17 20:28:22 +02:00
deajan 9f89d4fdff Added VerComp Subset 2017-04-11 13:26:23 +02:00
deajan f15e9bf8af Updated installer from pmocr 2017-04-11 13:25:36 +02:00
deajan d530cbbe44 Updated ofunctions 2017-04-11 13:25:03 +02:00
deajan 9cfd6c4eb4 Reenabled all tests 2017-04-08 22:10:01 +02:00
deajan eb5ca2c39d Added default umask for test run 2017-04-08 22:05:22 +02:00
deajan feb2034b53 Bumped ofunctions version 2017-04-08 21:11:12 +02:00
deajan c55b39cff0 Updated changelog 2017-04-08 21:07:41 +02:00
deajan 26d698422b Added umask for log & run files 2017-04-08 21:07:21 +02:00
deajan 995787173e Updated install instructions 2017-03-26 15:21:25 +02:00
deajan b6ad2f2552 Updated documentation for v1.2 release again 2017-03-25 13:34:47 +01:00
deajan 2206fdbab7 Updated documentation for v1.2 release 2017-03-25 13:19:32 +01:00
deajan 8229cbd89e Updated documentation entry 2017-03-25 12:55:00 +01:00
deajan 9106e8996d Updated CHANGELOG 2017-03-25 12:53:59 +01:00
deajan 1eb04979a2 Updated install instructions for v1.2 release 2017-03-25 12:52:03 +01:00
deajan f400be4cc7 Updated RSYNC_OPTIONAL_ARGS already used list 2017-03-25 12:45:08 +01:00
deajan 191056bfa0 Updated crontab doc 2017-03-25 12:26:15 +01:00
deajan d416fd1782 Updated header 2017-03-25 12:13:04 +01:00
deajan 266c0e1e0f Rebuilt targets 2017-03-23 23:03:27 +01:00
deajan 19c15d2265 Bumped version to v1.2 final 2017-03-23 23:02:43 +01:00
deajan d9d7bd9f3c Added MINGW64 to supported OS list 2017-03-23 21:05:38 +01:00
deajan 1404b81d56 Added initiator dir check before running monitor mode 2017-03-21 22:56:03 +01:00
deajan 2c3e6ac7a9 Added --remove option in help 2017-03-21 22:48:44 +01:00
Orsiris de Jong df8e795519 Update README for install instructions 2017-03-14 23:12:32 +01:00
deajan 01f1392047 Updated installer from pmocr 2017-03-14 22:41:39 +01:00
deajan e1d7213e91 Rebuilt targets 2017-03-14 22:36:27 +01:00
deajan 7116fd594a Fixed program version 2017-03-14 22:35:39 +01:00
Orsiris de Jong 2a369b015c Update for testing query 2017-03-14 22:26:20 +01:00
Orsiris de Jong ebcba0bb55 Update README.md 2017-03-14 22:24:39 +01:00
deajan e45a7ccb49 Fixed binpath for service files 2017-03-14 22:09:53 +01:00
deajan 2a2fe1f773 Updated changelog 2017-03-14 21:45:10 +01:00
deajan d9f8cd5858 Reverted binary paths 2017-03-14 21:43:49 +01:00
deajan 50036b5849 Updated allowed exit codes 2017-03-14 21:32:48 +01:00
deajan 34aa22b110 Updated program path to be variable 2017-03-14 21:26:43 +01:00
Orsiris de Jong 31d32db211 Merge pull request #93 from liger1978/update_spec
Fixes #91 Improved spec file
2017-03-14 21:24:26 +01:00
deajan 4f8d57498c Updated installer version logic 2017-03-14 21:12:38 +01:00
deajan fa0e194819 Made TSTAMP more readable 2017-03-13 13:07:16 +01:00
deajan 6346a3a94c Added program check 2017-03-13 11:46:44 +01:00
Richard Grainger b4be4b8a53 Fixes #91 Improved spec file 2017-02-15 16:08:53 +00:00
deajan 24d76f1888 Prevent possibility to run remote cmds on local runs 2017-02-13 12:47:46 +01:00
deajan 8d717b6fdf Updated changelog for RC3 2017-02-10 11:54:18 +01:00
deajan b28f3fcc85 Rebuilt targets 2017-02-10 11:53:41 +01:00
deajan baaf1a621a Bumped version to v1.2RC3 2017-02-10 11:53:01 +01:00
deajan 0ef67b1dda Fixed typo 2017-02-10 11:43:05 +01:00
deajan d270e72718 Updated changelog 2017-02-10 11:30:15 +01:00
deajan 0e3894ff59 Installer now skips ssh_filter removal if needed 2017-02-10 11:28:43 +01:00
deajan 685d1d0bf1 Don't show failed commands in stdout, only log them 2017-02-10 11:15:41 +01:00
deajan 81438ce2fd Imported funny _REMOTE_TOKEN obfuscation from obackup :) 2017-02-10 11:14:11 +01:00
deajan 8c40e0c950 Removed unnecessary spaces 2017-02-10 10:35:17 +01:00
deajan 15e1d7fbe0 Updated ofunctions from obackup 2017-02-09 13:02:44 +01:00
deajan 237f17139b Updated readme file 2017-02-08 16:34:36 +01:00
deajan 72e9539134 Updated changelog 2017-02-08 16:34:25 +01:00
deajan 4597c85d0a Updated changelog 2017-02-08 16:30:47 +01:00
deajan e837eeeb61 Rebuilt targets 2017-02-08 16:28:18 +01:00
deajan d539892188 Bumped to stable state 2017-02-08 16:27:01 +01:00
deajan 98d3cc99b8 Simplified ssh_filter 2017-02-08 15:28:41 +01:00
deajan 8d0c8bf80d Add ssh filter comment 2017-02-08 15:08:21 +01:00
deajan 57facf189b Removed silent option from install test 2017-02-08 15:03:18 +01:00
deajan df95a48d9c Remove MacOS limitation 2017-02-08 15:01:41 +01:00
deajan 024662f7ad Fixed typo 2017-02-08 14:54:03 +01:00
deajan 5ca7b7e6a2 Fix for installer error on msys/cygwin 2017-02-08 14:53:18 +01:00
deajan f0ed2098be Fix installer on travis 2017-02-08 14:27:30 +01:00
deajan d320c84ce9 Fixed removing temp key from authorized_keys didn't work 2017-02-08 14:19:20 +01:00
deajan 215e4f2108 Added install and uninstall to test system 2017-02-08 14:06:43 +01:00
deajan 2a9a829876 Updated changelog 2017-02-08 13:54:12 +01:00
deajan 02b98249ad Recoded ssh_filter to be easier and more secure 2017-02-08 13:53:42 +01:00
deajan 228fca1254 Recoded ssh_filter to work really nicer 2017-02-08 13:52:55 +01:00
deajan 4135c59869 Added _REMOTE_TOKEN for ssh_filter 2017-02-08 13:52:04 +01:00
deajan f5c00a82ce Added ssh_filter comment 2017-02-08 13:51:41 +01:00
deajan 70c858dc3d Added ssh_filter to tests 2017-02-08 13:51:26 +01:00
deajan 72da1882d4 Added _REMOTE_TOKEN entry 2017-02-08 13:35:53 +01:00
deajan c7f676bd6e Added _REMOTE_TOKEN to test list 2017-02-08 13:32:40 +01:00
deajan 3bd6dd09c7 Rebuilt targets for v1.2RC2 2017-02-08 08:39:59 +01:00
deajan 77e4a05613 Bumped version to v1.2RC2 2017-02-08 08:39:26 +01:00
deajan ebec33e15e Make shellcheck happier 2017-02-08 08:34:24 +01:00
deajan f5228fbbbf Fixed variable name 2017-02-08 08:32:55 +01:00
deajan 7aa1457971 Removed unnecessary comments 2017-02-08 08:30:15 +01:00
deajan ce9ddee19d Be able to create /usr/local/bin 2017-02-07 23:39:20 +01:00
deajan 48f9cfc973 Added mac commands 2017-02-07 22:51:26 +01:00
deajan 839c287ec9 Better BSD ping when not root 2017-02-07 22:28:54 +01:00
deajan 2a63707cf7 Quick ping fix for FreeBSD non root 2017-02-07 22:24:54 +01:00
deajan 18a4dc4fe9 Missing sudo is critical 2017-02-07 22:19:05 +01:00
deajan 0aaf988c48 check for sudo when needed 2017-02-07 22:13:52 +01:00
deajan ea58a65954 Quick fix for BSD service files 2017-02-07 22:10:24 +01:00
deajan a186964bc8 Moved some functions to ofunctions.sh 2017-02-07 22:05:27 +01:00
deajan c1ca28bd41 Improved os detection here too 2017-02-07 22:04:50 +01:00
deajan 1e7a8d643c Improved os detection 2017-02-07 22:04:36 +01:00
deajan f9077b7ff6 Added new list of subsets 2017-02-07 22:04:19 +01:00
deajan 317975c03f Fixed need to overwrite executables 2017-02-07 21:39:58 +01:00
deajan b07df720d9 path fixes for rsync and bash 2017-02-07 21:28:50 +01:00
deajan 84ee16cc12 Minor tweaks for cleanup 2017-02-07 21:21:41 +01:00
deajan 33413fe80d Another minor fix 2017-02-07 21:09:36 +01:00
deajan 7fc9a2c4fb Minor fixes 2017-02-07 21:06:02 +01:00
deajan 724f488ab7 Quick and dirty sudo prepare script 2017-02-07 20:59:01 +01:00
deajan 0c9ab163f0 Fixed typo 2017-02-07 17:43:30 +01:00
deajan 32c2b391e7 Added uninstall instructions 2017-02-07 16:01:44 +01:00
deajan bb6e9e895c Rebuilt target 2017-02-07 16:00:44 +01:00
deajan 1444d44b6b Quick installer refactor with uninstall support 2017-02-07 16:00:23 +01:00
deajan 1b354012b8 Added rsyncCmd debug info 2017-02-06 17:15:07 +01:00
deajan e24becdea1 Added debug command info 2017-02-06 17:11:39 +01:00
deajan 1fb1ab92fb Fixed typo 2017-02-06 16:39:27 +01:00
deajan 8417221b5c Added MAIL_BODY_CHARSET to upgrade script 2017-02-06 12:07:02 +01:00
deajan e201217935 Fixed inline messages when encoding used 2017-02-05 13:24:17 +01:00
deajan 6031036ae1 Trying to resolve mail encoding issues 2017-02-05 13:11:00 +01:00
deajan 69f8945806 Fix for escaped UTF-8 characters in log files 2017-02-03 14:09:14 +01:00
deajan 1653a6da57 Added vercomp function 2017-02-03 12:00:03 +01:00
deajan 7e4400ba7a Fixed typo 2017-02-03 11:15:59 +01:00
deajan 08e1293f95 Merge branch 'remotesudo' 2017-02-03 09:54:19 +01:00
deajan 4838d8bd25 Back to a mergeable state 2017-02-03 09:54:10 +01:00
deajan d1e5a50c0d Update files 2017-02-03 09:52:24 +01:00
deajan e1ea7806cb Rebuilt targets 2017-02-03 09:51:52 +01:00
deajan 6fc4bef224 Updated ofunctions from obackup 2017-01-04 09:17:49 +01:00
deajan 9e5a2c82f1 Rebuilt targets 2016-12-28 23:37:29 +01:00
deajan 4c6ada2388 Added small fixes from obackup 2016-12-28 23:37:07 +01:00
deajan 2ec41074ae More unneeded fixes for old upgrade remote connections 2016-12-23 21:37:06 +01:00
deajan 1e0fb77cc8 Fixed possible issue with old file upgrade test when file is intended for remote cnx 2016-12-23 21:30:38 +01:00
deajan 9fd881647a Enabled remote host ping when not testing on travis 2016-12-23 21:25:04 +01:00
deajan 07daa13517 Some minor fixes from obackup 2016-12-23 20:41:52 +01:00
deajan f4126df723 Enable remote host ping on local tests 2016-12-23 20:41:23 +01:00
deajan 79402ef2da Updated ofunctions from obackup 2016-12-23 18:25:08 +01:00
deajan ea69a58b3d Fixed program name after fix from other project 2016-12-19 23:40:54 +01:00
deajan 266b35d81b Fixing typos 2016-12-19 22:39:03 +01:00
deajan e04e81446e Fixed typo 2016-12-19 22:38:13 +01:00
deajan 78ed3deab8 Added doublequotes around 3rd party hosts for sanity 2016-12-19 13:42:33 +01:00
deajan 97a1aa5e05 Updated sudo behavior 2016-12-19 13:19:21 +01:00
deajan 1d318b2e8c Added systemd support for spec file 2016-12-18 13:12:47 +01:00
deajan bd0450d95e Fixed wrong __CheckArguments call 2016-12-15 12:01:10 +01:00
deajan eee2bdf565 Made critical error message more readable 2016-12-15 11:53:22 +01:00
deajan 091f9ed1be Avoid possible log interference between parallel functions 2016-12-15 11:24:45 +01:00
deajan 03a83b598d Logging tweaks. Also fixed remote find cmd used instead of local one 2016-12-15 10:12:36 +01:00
deajan 622b607bac Revised log levels of command output for --errors-only 2016-12-14 08:12:35 +01:00
deajan 114ea896d6 Bumped version to RC1+dev 2016-12-13 20:55:15 +01:00
deajan 4ac9702357 Rebuilt targets for v1.2-RC1 2016-12-13 20:52:33 +01:00
deajan d9ff0b9ed1 Fixed boolean value 2016-12-13 20:52:09 +01:00
deajan 5f1e0a8305 Rebuilt targets for v1.2-RC1 release 2016-12-13 20:42:14 +01:00
deajan 6667f21638 Added release date to v1.2-RC1 2016-12-13 20:41:49 +01:00
deajan 7039a8a16c Bumped version to v1.2-RC1 2016-12-13 20:41:25 +01:00
deajan b8b74a5096 Fixed typo 2016-12-13 20:07:48 +01:00
deajan a207f1745a Rebuilt targets 2016-12-13 19:38:22 +01:00
deajan 535f8ccb1f Updated readme file 2016-12-13 19:37:25 +01:00
deajan 3e9e560cfd Better folder detection 2016-12-13 19:28:47 +01:00
deajan b16422fc08 Updated changelog 2016-12-13 19:20:08 +01:00
deajan 9530aa8689 Updated documentation file 2016-12-13 19:06:13 +01:00
deajan f4f71a22c8 Fixed resume does not exit with warn anymore 2016-12-13 18:35:34 +01:00
deajan caccb04c06 Fixed RemoteLogger prefix 2016-12-13 18:31:17 +01:00
deajan 69568e8132 Removed unnecessary code 2016-12-13 12:41:42 +01:00
deajan 18851f6114 Added execution path check 2016-12-13 12:33:30 +01:00
deajan 28dbd94ce0 Misc changes 2016-12-13 12:29:33 +01:00
deajan bd800dc5e9 Critical fix for random errors when CheckConnectivity fails in sub function of Sync 2016-12-13 12:28:06 +01:00
deajan 11b494069a Resuming previous operation should not be a warning message 2016-12-13 11:45:51 +01:00
deajan 9ba28177e7 Added RSYNC_OPTIONAL_ARGS to update script 2016-12-13 09:22:30 +01:00
deajan e934ab63e7 Rebuilt targets 2016-12-13 09:19:14 +01:00
deajan 8fbe4d716d Added RSYNC_OPTIONAL_ARGS parameter 2016-12-13 09:18:47 +01:00
deajan 36bcaecc74 Improved unit tests for soft deletion directories 2016-12-12 23:58:42 +01:00
deajan 68d0306713 Minor fix 2016-12-12 23:42:29 +01:00
deajan c7ad48bb80 Fixing directory soft deletion 2016-12-12 23:33:57 +01:00
deajan 98502dd1a6 Fix Fix rsync 3.0.6 C6 obscure --skip-compress verbosity 2016-12-12 22:41:01 +01:00
deajan 6a3499ca88 Fix obscure rsync 3.0.6 skip-compress too verbose bug 2016-12-12 21:46:44 +01:00
deajan be18397865 Reworked comment 2016-12-12 19:30:09 +01:00
deajan 4fdebf66a7 Skipping certain tests on cygwin 2016-12-12 19:27:34 +01:00
deajan ae8ef5ff13 Uncommented CleanUp as debugging is done 2016-12-12 19:23:58 +01:00
deajan 486f63043d Fixed stupid typos 2016-12-12 11:38:27 +01:00
deajan a3af29804d Fixed missing env variables for remote calls 2016-12-12 11:16:53 +01:00
deajan 4d52f71061 Added some degree of randomisation on RUN_DIR files 2016-12-12 10:14:59 +01:00
deajan b8b648f9b8 Missing fi 2016-12-12 09:37:17 +01:00
deajan 5e52049bae Disable rsync --skip-compress on MacOS 2016-12-12 09:36:10 +01:00
deajan 5c4b76ab9e Reverted simplification of remote stat 2016-12-12 08:57:31 +01:00
deajan 1fc8f9567e Updated coding style 2016-12-11 23:03:07 +01:00
deajan 4ecdbfb0c0 Added working silent parameter 2016-12-11 22:58:31 +01:00
deajan ded6203ae3 Removed unnecessary comments 2016-12-11 22:54:56 +01:00
deajan d031a5504b Fixed skip-compress regex not liked by bsd 2016-12-11 22:44:01 +01:00
deajan bd28ca8837 Minor changes & fixes 2016-12-11 22:40:27 +01:00
deajan 28460a714e Added more check skips 2016-12-11 21:57:31 +01:00
deajan c3894b7694 Multiple typo fixes and shellcheck improvements 2016-12-11 21:57:13 +01:00
deajan 235b32e20f Fixed multiple typos 2016-12-11 21:27:30 +01:00
deajan 23cac5cad6 Unexpanded all source files 2016-12-11 20:54:40 +01:00
deajan 7bc93df5e6 Fixed RemoteLogger debugging 2016-12-11 17:07:34 +01:00
deajan 76512b5a13 Added _OFUNCTIONS_BOOTSTRAP subset 2016-12-11 14:58:52 +01:00
deajan 882cd7099e Bootstrap test 2016-12-11 14:57:02 +01:00
deajan 47c887a78e Updated coding style 2016-12-11 14:55:55 +01:00
deajan 8bce416b62 Fixed typo 2016-12-11 14:52:09 +01:00
deajan e834059721 Multiple error detection fixes 2016-12-11 14:45:01 +01:00
deajan f607cd9ab2 Quick _SoftDeleteLocal refactor 2016-12-11 14:36:26 +01:00
deajan cc4636e298 Remote logging debug improvements 2016-12-11 14:29:17 +01:00
deajan cdde314029 Code compliance 2016-12-11 14:26:48 +01:00
deajan 991734de03 Moving coding style 2016-12-11 14:25:54 +01:00
deajan 85d5d78045 Improved comments in sync.conf example file 2016-12-11 12:10:01 +01:00
deajan 63bee68be0 Added android to OS exclusion list for ACL sync 2016-12-11 11:48:41 +01:00
deajan f11cc81c01 File attrib skip logic fix 2016-12-11 11:38:36 +01:00
deajan 0761f15b22 Switched to new rsync compression, added excluded extensions, fix ACL for busybox 2016-12-11 11:33:42 +01:00
deajan 852ff0adf5 Reverted openssl silent becauce sendmail: NOOP failed 2016-12-10 18:40:36 +01:00
deajan d2be7e43a8 Fixing typos and rendering openssl silent 2016-12-10 18:39:25 +01:00
deajan c9635d48d3 Fixed ambiguous redirect 2016-12-10 18:37:18 +01:00
deajan c5d83a18bf quick and dirty debug test 2016-12-10 18:31:39 +01:00
deajan 4e61b23cc5 Various typo fixes + arrayToString fix 2016-12-10 18:27:56 +01:00
deajan 72dfd4e94c Fixes in android email sending 2016-12-10 18:07:00 +01:00
deajan 9beeffe3bb Added bootstrap termux-fix-shebang 2016-12-10 17:56:03 +01:00
deajan a7393818d4 Debug code to resolve random thrown error alert 2016-12-10 10:57:25 +01:00
deajan 9bce1a7f1c Less code for spinner 2016-12-09 21:54:42 +01:00
deajan 4308678cc2 Smaller spinner code 2016-12-09 21:44:57 +01:00
deajan 785c12b364 Merge branch 'forced_bash' 2016-12-09 19:27:12 +01:00
deajan b715343b46 Merge forced_bash into master 2016-12-09 19:26:58 +01:00
deajan 4c61d0c53d Ye 2016-12-09 19:25:23 +01:00
deajan 738c11e315 Disabled symlink tests on msys 2016-12-09 19:22:14 +01:00
deajan 229a9800cc Make difference between msys and cygwin 2016-12-09 19:19:52 +01:00
deajan d15069a85b More FreeBSD acl fix 2016-12-09 19:01:58 +01:00
deajan a08ce8904b Reverted bogus var name change 2016-12-09 17:10:04 +01:00
deajan be0d0ab8d9 Fixed daemon exclusions 2016-12-09 11:04:56 +01:00
deajan 435b597513 Workaround for FreeBSD inotifywait only wants one exclude 2016-12-08 22:10:54 +01:00
deajan a543099eed Added msys2 detection and bootstrap safe code 2016-12-08 22:06:36 +01:00
deajan 61adfc6c6f Workaround for FreeBSD 11 get ctime default shell 2016-12-08 21:59:52 +01:00
deajan 7033337984 Quick fix for remaining tmp file after ParallelExec test 2016-12-08 20:36:13 +01:00
deajan 696140b575 Another msys fix 2016-12-08 12:09:52 +01:00
deajan 97eee22944 Added env for csh... Fuck you csh ! 2016-12-08 11:36:55 +01:00
deajan 15c49f3aa4 Removed typo 2016-12-08 11:04:51 +01:00
deajan d6b5fcc20f Added pgrep test 2016-12-08 10:59:07 +01:00
deajan 31b1f0791a Added comment 2016-12-08 10:58:59 +01:00
deajan 467cb717ad Some msys fixes 2016-12-08 10:53:47 +01:00
deajan b0e589ad78 Re-enabled tmp file deletion after debug 2016-12-08 09:00:58 +01:00
deajan ce6b674ba3 Minor function renames 2016-12-08 08:58:56 +01:00
deajan 80cf34cedd Removed unnecessary code 2016-12-08 08:56:35 +01:00
deajan c8e2c4e438 Fixed typo 2016-12-08 08:56:13 +01:00
deajan 731fc81abf Made ofunctions "includable" 2016-12-07 21:30:10 +01:00
deajan 7e44139325 Minor adjustment to _Logger 2016-12-07 11:45:34 +01:00
deajan f14903cce5 Remote functions should not log to files 2016-12-07 09:06:28 +01:00
deajan 226bf33e29 Code compliance on ArrayContains 2016-12-06 23:24:02 +01:00
deajan 9735a83b35 Reverted test disable HandleLocks 2016-12-06 22:51:19 +01:00
root ae16cefe54 Refactored CheckDiskSpace & CheckReplicaPath into CheckReplicas 2016-12-06 22:41:44 +01:00
root 59b8764da6 Merged CreateStateDirs, CheckLocks and WriteLocks into HandleLocks 2016-12-06 21:32:27 +01:00
deajan 00ae0f5fda Fixing remote third party check url not set right 2016-12-06 14:00:48 +01:00
root 54cf89cb27 Force bash as remote shell. Also refactor remote soft deletion and fix directory ctime find 2016-12-06 13:30:05 +01:00
deajan 9246c2aa6e Simplified test suite 2016-12-06 09:23:43 +01:00
deajan 372834cfee Removed spam email sending on unit tests 2016-12-05 23:30:53 +01:00
deajan 2d4b8cf572 Fixed typo 2016-12-05 23:28:43 +01:00
deajan 39fc865db9 Added detected os string 2016-12-05 20:06:00 +01:00
deajan 653ff919c3 SSH_PORT is now an environment variable 2016-12-05 20:03:53 +01:00
deajan 5db2f8e594 Fixed inverted symlink tests 2016-12-05 12:22:59 +01:00
deajan f2cc39dec0 Merge branch 'master' of https://github.com/deajan/osync 2016-12-05 11:29:15 +01:00
deajan d655f942b1 Removed some tests from travis because of time limit 2016-12-05 11:23:48 +01:00
Orsiris de Jong 3c77ed65da Merge pull request #84 from najamkhn/patch-1
Corrected typo in README.md
2016-12-05 11:12:23 +01:00
Najam 9100e61ad2 Corrected typo in README.md 2016-12-05 01:29:32 +04:00
deajan eaef234a8a Added symlink / broken symlink tests 2016-12-04 18:57:39 +01:00
deajan 9eefe38e3c Rebuilt target 2016-12-04 11:31:18 +01:00
deajan 4d490697c4 Fixed batch did only pass last argument 2016-12-04 11:31:02 +01:00
deajan 48a1fcd065 Rebuilt targets 2016-12-04 11:15:57 +01:00
deajan ed1a4c152a Removed unnecessary comments 2016-12-04 11:15:27 +01:00
deajan 3dcdeb20b1 Removed unnecessary code 2016-12-04 11:12:55 +01:00
deajan bdf72843ee Added ofunctions header for next branch identification 2016-12-04 11:11:35 +01:00
deajan 078d47403f Reorganized function chronology 2016-12-04 11:10:02 +01:00
deajan 3a414da41d Program finish should always be logged 2016-12-04 10:58:53 +01:00
deajan a87c44b9dc Rendered WaitForTaskCompletion global output thread safe 2016-12-03 10:40:30 +01:00
deajan 3128cb1841 Added global var HARD_MAX_EXEC_TIME_REACHED 2016-12-03 10:06:15 +01:00
deajan 3d8f20d2ed Removed more unnecessary comments 2016-12-03 09:59:59 +01:00
deajan 52e7921b53 Quick semantic update for soft stop 2016-12-03 09:53:44 +01:00
deajan a7e41410e9 Removed unnecessary comments 2016-12-03 09:47:51 +01:00
deajan 88b135118d Coped with really old TODO fixing rsyncpatterns when path separator isn't semicolon 2016-12-03 09:39:09 +01:00
deajan 569d5f63a2 Emulate earlier batch behavior by adding maxdepth 1 to find 2016-12-03 09:34:26 +01:00
deajan 3f278173c1 Simplified batch runner, also less error prone 2016-12-01 23:14:22 +01:00
deajan 6f94429f52 More clear log output 2016-12-01 22:18:03 +01:00
deajan 01c62aa4ca Multiple recipient compat for mutt 2016-12-01 21:27:28 +01:00
deajan edc358f2ff Finish work on symlink detection in treeList 2016-12-01 21:14:07 +01:00
deajan a9c3f04b1b Updated comments 2016-12-01 21:12:47 +01:00
deajan 651bf48990 Added symlink support in deletion propagation 2016-12-01 20:51:45 +01:00
deajan 33f985b751 WIP: getting treeList to work with or without symlinks 2016-12-01 20:20:55 +01:00
deajan 9bb849dec7 Quick paranoia debug fix 2016-12-01 19:50:06 +01:00
deajan 2cb5084d8b WIP on treeList in order to list but bypass bad symlinks 2016-12-01 19:24:01 +01:00
deajan 175df3d81e More explicit error message in treeList 2016-12-01 09:51:06 +01:00
deajan bd12d809c9 Updated unit tests 2016-11-30 13:50:49 +01:00
deajan 7ca8bbc902 Updated tests with v1.1 branch timed execution tests 2016-11-30 13:02:01 +01:00
deajan 8e89b3dd82 Disabled mail sending on travis tests 2016-11-30 09:42:48 +01:00
deajan b8f38152d5 Soft time alerts aren't anymore redundant when counting=false 2016-11-29 22:43:28 +01:00
deajan be852ca7df Better time control in sync function 2016-11-29 22:40:43 +01:00
deajan e15587524b Finished adding timed execution tests 2016-11-29 22:40:10 +01:00
deajan 3371e9a8f3 Improved timed execution tests 2016-11-29 20:28:15 +01:00
deajan 745688d982 Improved timed execution of sync function 2016-11-29 20:28:00 +01:00
deajan 8ee4b824da Work on WaitForTaskCompletion hard exec time 2016-11-25 22:15:27 +01:00
deajan 8500bfa5d9 Work on WaitForTaskCompletion ongoing 2016-11-25 22:15:03 +01:00
deajan dde1d2e3f8 Updated comments of sync file 2016-11-24 18:27:16 +01:00
deajan e4026f537e Rebuilt targets 2016-11-24 14:50:48 +01:00
deajan 42b0c8d406 Batch mode does not produce stdout/stderr output 2016-11-24 14:48:41 +01:00
deajan 0c1215059d Simplified osync-batch program 2016-11-24 14:43:05 +01:00
deajan 37e294161a Fixed bogus busybox detection 2016-11-24 14:27:04 +01:00
deajan bda1c158d0 Reenabled all tests 2016-11-24 13:33:26 +01:00
deajan 804a284cb3 Updated parallelexec and fixed soft max time enforcement 2016-11-24 13:26:32 +01:00
deajan 507122b08f Added more parallelexec tests 2016-11-24 13:26:10 +01:00
deajan 0baed43267 Updated osync with new WaitForTaskCompletion syntax 2016-11-24 09:40:55 +01:00
deajan a0fd7941c7 Changed to more clear WaitForTaskCompletion & ParallelExec argument list 2016-11-24 09:40:33 +01:00
deajan 3a3e7cfa02 Disabling ACL / XATTR on Mac & msys 2016-11-22 19:45:53 +01:00
deajan c460eac640 Initial cygwin test compat 2016-11-22 19:24:51 +01:00
deajan f45911a548 Fixed summary does reset logger prefix 2016-11-22 19:08:05 +01:00
deajan c3013347bb Fixing OS detection on Cygwin 2016-11-22 19:02:13 +01:00
deajan b3d17f8fec Fixed WinNT10 detection 2016-11-22 18:50:09 +01:00
deajan 15630c4b6d msys/cygwin don't know about process states 2016-11-22 18:18:35 +01:00
deajan 7e8463ec50 Fixing typos 2016-11-22 17:43:43 +01:00
deajan 9fb9d3504e Added Win10 bash detection 2016-11-22 17:41:06 +01:00
deajan 2f9f2f4f57 Added Win10 bypass for some tests 2016-11-22 17:40:47 +01:00
deajan 6d0e7cd0c7 Updated WaitForTaskcompletion to emulate wait 2016-11-22 17:19:30 +01:00
deajan da302b0f3a inotifywait timeout emulation only needed on mac 2016-11-22 17:18:35 +01:00
deajan 2fd60182c0 Fixing softdel cleanup test...Again 2016-11-22 08:56:13 +01:00
deajan 23bb0ac804 Safer conflict multiple test 2016-11-21 19:41:35 +01:00
deajan 85466e0ab0 Added MAX_WAIT support for MacOS daemon mode 2016-11-21 19:18:22 +01:00
deajan 070d7b7e3a Wow... fixed the fix that should have fixed the bug 2016-11-21 19:13:15 +01:00
deajan 66316b49be Fixed BSD/Mac config header sed mismatch 2016-11-21 18:58:12 +01:00
deajan a3c5df9a85 Feeling stupid for this basic error 2016-11-21 18:38:43 +01:00
deajan b8cf2e2694 Fixed skip tests logic for BSD & Mac 2016-11-21 17:31:02 +01:00
deajan d55ecf7781 Added QaD daemon mode for Mac 2016-11-21 17:02:05 +01:00
deajan 33b103a64c Cosmetic typo fix 2016-11-21 16:34:31 +01:00
deajan eb9b34c22d Disabled all debugfs related tests on BSD / Mac / Travis 2016-11-21 16:33:22 +01:00
deajan 6c7678a49a Updated sync file comments regarding Mac ACL / XATTR 2016-11-21 15:14:26 +01:00
deajan 2b8fe18217 Disable ACL and XATTR preserve by default on Mac 2016-11-21 15:13:15 +01:00
deajan 07f31e6b1e Fixed mkdir syntax to be BSD / Mac compatible 2016-11-21 15:12:52 +01:00
deajan eec2df90e3 Fixed old executability exclusion on MacOS 2016-11-21 14:48:02 +01:00
deajan 4dd007ae56 Render SendEmail function MacOS compatible 2016-11-21 14:04:05 +01:00
deajan a0c1ad5a20 Reenabled all tests 2016-11-21 13:45:37 +01:00
deajan f10feb9806 Fix for BSD skip deletion test 2016-11-21 13:42:10 +01:00
deajan 6987a7f0f3 Better check if remote deletion file is present 2016-11-21 13:21:26 +01:00
deajan 5d7e54c743 Remote deletion log is always ERROR level 2016-11-21 11:34:54 +01:00
deajan ec95b8683c Added missing log from remote deletion 2016-11-21 10:55:35 +01:00
deajan 58037d2d9a Reverted to a should-build state 2016-11-21 10:25:08 +01:00
deajan 3fbcc4a4c7 More ACL testing 2016-11-21 10:19:21 +01:00
deajan c74078d122 More travis ACL testing 2016-11-21 10:12:11 +01:00
deajan 25aa245191 More travis ACL / chattr tests 2016-11-21 10:04:00 +01:00
deajan 3304814bcd More travis ACL / setuid tests 2016-11-21 09:59:17 +01:00
deajan 384b9b9582 Added unit tests that will fail to trigger travis errors 2016-11-21 09:47:45 +01:00
deajan 394f1537db Added inotify-tools to travis env 2016-11-21 09:47:11 +01:00
deajan 5ec5d01dca Fixed possible issue if global var toggle is used 2016-11-20 22:18:36 +01:00
deajan 4bae4fa917 Render setfacl BSD compatible 2016-11-20 21:47:56 +01:00
deajan 2a1ab2b40f More BSD love 2016-11-20 20:56:47 +01:00
deajan 8190bef067 Fix for failed deletion repropagation in BSD 2016-11-20 19:25:19 +01:00
deajan 5663403ddc Added forgotten cat 2016-11-20 18:57:51 +01:00
deajan 70e9936fd1 More BSD compat 2016-11-20 18:18:07 +01:00
deajan 85367b4b2f Improved unit tests compat with BSD 2016-11-20 18:04:32 +01:00
deajan 0718eb6f60 More optional checks to remove if not paranoia debug 2016-11-20 17:43:13 +01:00
deajan f8015b735a Rendered merge BSD compatible 2016-11-20 17:41:52 +01:00
deajan 1a680e04ac Added more ACL tests 2016-11-20 17:22:03 +01:00
deajan aa465f8365 Rebuilt targets 2016-11-19 16:16:35 +01:00
deajan 9194e004d3 Enabled other tests again 2016-11-19 15:09:58 +01:00
deajan 0ffb336a6d Added SSH removal after test 2016-11-19 15:06:32 +01:00
deajan 9a584eef73 Removed unused test file 2016-11-19 14:23:49 +01:00
deajan 4a8a7e7a49 Improved unit tests with no ssh test 2016-11-19 14:21:42 +01:00
deajan 82eaa8fa52 Updated changelog 2016-11-19 13:23:45 +01:00
deajan bbee571d3e Fixing obscure upgrade bug on CentOS 5 2016-11-19 13:15:57 +01:00
deajan 325c4e5d5c GetRemoteOS executed anyway 2016-11-19 13:13:08 +01:00
deajan 56dabb97c1 Fixed bypassing some taks for android 2016-11-19 12:54:24 +01:00
deajan cd86eac828 Commit cc16c29 related changes 2016-11-19 12:50:30 +01:00
deajan cc16c29c2c Disable PRESERVE ACL & ATTR by default for compat reasons 2016-11-19 12:49:19 +01:00
deajan 630f26f8d2 Corrected variable # of arguments for _WriteLockFiles 2016-11-19 12:47:17 +01:00
deajan 6efe00938b Better android detection 2016-11-19 12:37:33 +01:00
deajan 8ba36de138 Fixing issues between android and centos 5 2016-11-19 12:37:26 +01:00
deajan 00ac1645e1 More fixes for CentOS 5 compat 2016-11-18 13:34:49 +01:00
deajan 2ed0fa7a0a Fixed bug introduced with CentOS 5 compat 2016-11-18 13:09:26 +01:00
deajan 80432de248 Rendered tests compatible with CentOS 5 2016-11-18 12:56:52 +01:00
deajan d89980e1bd Fixed _CheckDiskSpaceRemote compat on CentOS 5 2016-11-18 12:53:07 +01:00
deajan f6682dabf6 Fixed CheckDiskSpace compat on CentOS 5 2016-11-18 12:49:48 +01:00
deajan cafbf43222 Rebuilt targets 2016-11-18 09:05:06 +01:00
deajan 7283729eae Added test run destination mail 2016-11-18 09:04:17 +01:00
deajan cad227d13c Updated changelog 2016-11-18 00:04:47 +01:00
deajan d90baf7083 Disabled Travis daemon mode tests for now 2016-11-18 00:03:34 +01:00
deajan d50d66731d Added elapsed time to unit tests 2016-11-17 23:48:06 +01:00
deajan 8314116c52 Add basic daemon tests 2016-11-17 23:40:17 +01:00
deajan 2488b1ece7 Removed debugging exit 2016-11-17 21:19:59 +01:00
deajan 28a9c908d5 Moved cleanup function according to new ofunctions 2016-11-17 21:04:42 +01:00
deajan 557bfb097d Removed unncecessary code 2016-11-17 21:02:45 +01:00
deajan 3c9780c55e Updated coding style 2016-11-17 20:12:18 +01:00
deajan e4fb2c5938 Updated changelog for comming beta3 2016-11-17 20:02:30 +01:00
deajan 5e1452a92f Minor logger changes 2016-11-17 20:01:12 +01:00
deajan 853f2692dd Some work on Logger function 2016-11-17 20:00:23 +01:00
deajan 8648980dd3 Added --errors-only to service files 2016-11-17 19:44:31 +01:00
deajan fddba8ee93 Added archlinux package URL 2016-11-17 18:16:28 +01:00
deajan c155e0ccf5 SLEEP_TIME default value 2016-11-17 14:02:34 +01:00
deajan 0dd472f2c2 Some semantic updates for locking functions 2016-11-17 13:29:34 +01:00
deajan 07227858de Reenabled all other tests :) 2016-11-17 12:20:51 +01:00
deajan 71f866aaba Added locking resume tests 2016-11-17 12:15:24 +01:00
deajan c4302a46ef Fixed locking checks 2016-11-17 12:13:56 +01:00
deajan e7e240abf8 Added deletion skip tests 2016-11-16 15:48:33 +01:00
deajan ae20963871 Fixed skip deletions from config file not handled properly 2016-11-16 15:47:42 +01:00
deajan 3ca410f673 Refactored some functions 2016-11-16 11:46:09 +01:00
deajan ddd2e482ae Fixed tests depending on minor version 2016-11-16 00:47:27 +01:00
deajan e41b48ed2e Disabled some tests on v1.1x 2016-11-15 23:20:20 +01:00
deajan 79971ec36f Fixed tests depending on osync version 2016-11-15 22:56:02 +01:00
deajan 8884d77be0 Added default separator char in quicksync mode 2016-11-15 22:32:33 +01:00
deajan 5bee165076 Removed deletion_failure test from travis (lack of chattr support) 2016-11-15 21:42:49 +01:00
deajan 290fbcafe2 Added failed deletion rerun test 2016-11-15 21:29:12 +01:00
deajan 317791da5a Fixed failed delete rerun & fixed logger flags in subprocesses 2016-11-15 21:27:32 +01:00
deajan 752d7f3bb9 Logger now creates flag files 2016-11-15 21:26:52 +01:00
deajan 8de65e0bf4 Fixed remote instance id in unit tests 2016-11-15 20:33:20 +01:00
deajan dddf0bd663 Added (single/multiple) conflict backup tests 2016-11-15 19:31:52 +01:00
deajan a8cc864259 Added ACL / Xattr preservation to config files 2016-11-15 19:28:14 +01:00
deajan 02e26538c7 Added ACL/Xattr default values for quicksync 2016-11-15 19:25:22 +01:00
deajan caad06379d Fixed wrong number of arguments for _SummaryFromFile checks 2016-11-15 19:21:24 +01:00
deajan fe0492d052 Fixed backups gone to the wrong directory 2016-11-15 13:49:00 +01:00
deajan b68162fd8e More accurate syncattr skip check 2016-11-15 13:25:35 +01:00
deajan dbd28f13ef Rebuilt targets 2016-11-15 13:16:52 +01:00
deajan 75e6a58580 Fixed typo and removed unneeded code 2016-11-15 13:14:41 +01:00
deajan 229abbf9c1 Removed unnecessary local variables 2016-11-15 13:12:30 +01:00
deajan e4d940c5c8 Cosmetic change 2016-11-15 13:11:59 +01:00
deajan 2200611e23 Cosmetic change 2016-11-15 13:11:35 +01:00
deajan ce7c712329 Finished work on summary function 2016-11-15 13:10:47 +01:00
deajan 6cc1286fe9 Allow set external sleep time in debug mode 2016-11-15 12:24:42 +01:00
deajan 9cafba436d Refactor GetRemoteOS 2016-11-14 23:10:37 +01:00
deajan e4188b0f4c Minor fixes 2016-11-14 22:17:02 +01:00
deajan 076ace4b43 Fixed TrapError shell color 2016-11-14 22:04:54 +01:00
deajan 6bdd5b0a1a Added color to TrapError output 2016-11-14 22:01:44 +01:00
deajan 111d3569a7 WIP on summary 2016-11-14 21:14:10 +01:00
deajan 9c9f5f01a2 Rebuilt targets 2016-11-14 19:17:50 +01:00
deajan 63c64c5d5e Added --summary and --no-prefix arguments 2016-11-14 19:17:30 +01:00
deajan 4fb0b5f5f7 Added ALWAYS loger option, also fixed boolean capitalization 2016-11-14 19:05:29 +01:00
deajan 8ccad34d01 Fixed option name 2016-11-14 17:20:26 +01:00
deajan 632e07b896 Rebuilt targets 2016-11-14 17:13:19 +01:00
deajan 7b9fde680e Added error only support in Logger 2016-11-14 17:12:57 +01:00
deajan 10f5fa9c0f Added --errors-only switch 2016-11-14 17:11:50 +01:00
deajan a122cc9b2a skipping ACL tests on travis (no get/setfacl support) 2016-11-13 20:38:16 +01:00
deajan 458f8e0ea2 Disabled ACL propagation test on travis, lack of ACL support 2016-11-13 20:32:18 +01:00
deajan 0ccb88ff19 Add ACL propagation tests 2016-11-13 20:22:52 +01:00
deajan f4a59e8897 Fixed typo preventing remote ACL sync 2016-11-13 20:12:09 +01:00
deajan 085a182ce6 Fixed softdeletion cleanup tests 2016-11-13 16:23:04 +01:00
deajan 4869e3e89a Fixed checking remote pings regarless of mode 2016-11-13 15:59:12 +01:00
deajan 6f7a87b2de Fixed bogus value shown with preflight checks 2016-11-13 15:53:16 +01:00
deajan 16a717a8bb Fixed debug trapError show warnings in IsNumeric functions when not numeric 2016-11-13 15:49:40 +01:00
deajan 91bd655fa1 Added quicksync instance IDs 2016-11-13 15:11:06 +01:00
deajan 6841513702 Fixed sync title 2016-11-13 15:09:30 +01:00
deajan afff4eff67 Updated changelog and readme.md 2016-11-13 14:46:59 +01:00
deajan a1c2634a4f Fixed travis remote username 2016-11-13 14:41:17 +01:00
deajan 2a94223c62 Added more unit tests 2016-11-13 14:12:51 +01:00
deajan 382db0d804 Minor fixes 2016-11-12 14:36:59 +01:00
deajan 48a1c80024 WIP: added osync.spec file for RPM builds 2016-11-12 00:35:57 +01:00
deajan 8756c3f871 Rebuilt targets 2016-11-12 00:31:49 +01:00
deajan b732fe1ece Updated sync.conf comments 2016-11-12 00:30:42 +01:00
deajan 4442c571f9 Refactored SendAlert and SendEmail 2016-11-12 00:30:25 +01:00
deajan 8127991919 Rebuilt target 2016-11-12 00:07:50 +01:00
deajan 4b9c3b5769 Fixed #73 2016-11-12 00:07:38 +01:00
deajan 69c681fd57 Made pkgver automatic 2016-11-11 23:44:17 +01:00
Orsiris de Jong cc2875f2d7 Merge pull request #70 from Shadowigor/arch-pkg-update
Add script to automatically update the PKGBUILD
2016-11-11 23:39:52 +01:00
deajan 7e14544e64 Rebuilt targets 2016-11-10 16:24:01 +01:00
deajan 6321951bd2 Fixed typo 2016-11-10 16:23:43 +01:00
deajan 99576ef2c3 Rebuilt targets 2016-11-10 16:18:05 +01:00
deajan d9a3fa9427 Remove forgotten -f parameter 2016-11-10 16:16:38 +01:00
deajan a640726d94 More logging fixes 2016-11-10 16:15:29 +01:00
deajan 51fb8b8bac Fixed alert log name when instance isn't kwnown yet 2016-11-10 15:54:59 +01:00
deajan b461b5bc95 Fixed attachment command in SendEmail 2016-11-09 17:36:18 +01:00
deajan aa311ee8ac Rebuilt targets 2016-11-09 17:31:59 +01:00
deajan d36ecd1f32 Fixed alert log filenames per instance 2016-11-09 17:31:31 +01:00
deajan a464fa37a3 Implement TLS and SSL support for busybox sendmail 2016-10-23 20:25:46 +02:00
deajan 646fdff063 Added old config file for travis environment 2016-10-23 19:18:37 +02:00
deajan 0bd6f61a34 Added upgrade script test 2016-10-23 19:17:25 +02:00
deajan bd2265b76c Fixed missing value in upgrade script 2016-10-23 19:16:45 +02:00
deajan bddd7c87da Updated ofunctions with better busybox support 2016-10-23 18:23:44 +02:00
deajan 06d2171a31 Code compliance 2016-10-23 13:28:28 +02:00
deajan 0e897f66c5 Fixed HumanToNumeric function 2016-10-23 13:27:35 +02:00
deajan 80a5bb0102 More portable grep -E treeList 2016-10-23 11:04:24 +02:00
deajan 0e049c4850 More busybox love 2016-10-23 10:44:27 +02:00
deajan 6665b7d9d9 Added remote busybox detection 2016-10-23 10:40:21 +02:00
deajan 6fa212bbca Added dirty workaround for human readable df output in busybox 2016-10-23 10:35:55 +02:00
deajan 97a1db5f55 Added HumanToNumeric function 2016-10-23 10:35:38 +02:00
deajan a450cf39d0 busybox working now 2016-10-23 09:46:20 +02:00
deajan 9e6f3b8e57 Rebuilt targets 2016-10-22 21:04:19 +02:00
deajan fe2a3037f7 Cosmetic fix 2016-10-22 21:03:36 +02:00
deajan ae89b7506e More and more busybox love 2016-10-22 21:02:35 +02:00
deajan 101cb26549 Cosmetic fixes 2016-10-22 20:59:50 +02:00
deajan 620484a6d8 More busybox love again 2016-10-22 20:56:14 +02:00
deajan d71540d609 More busybox love 2016-10-22 20:47:10 +02:00
deajan 4e73a17efa More busybox fixes 2016-10-22 12:27:08 +00:00
deajan dae886681c Merge branch 'master' of https://github.com/deajan/osync 2016-10-22 14:15:49 +02:00
deajan 84f266568d pidState command busybox compat 2016-10-22 14:14:52 +02:00
Orsiris de Jong 1f2b0f1243 Cosmetic fix 2016-10-22 13:03:18 +02:00
deajan ff16854b88 Fixed introduced bug with IsNumericExpand 2016-10-21 21:46:59 +02:00
deajan 67be5560af Removed SC2002 warning 2016-10-21 18:25:53 +02:00
deajan beea979440 Another check for log writing 2016-10-21 18:23:45 +02:00
deajan c26b7e6b0f Rebuilt targets 2016-10-21 15:30:10 +02:00
deajan 1366b0c10c Prefered C style boolean values 2016-10-21 15:29:49 +02:00
deajan d844a5b696 Rebuilt targets 2016-10-21 12:38:34 +02:00
deajan 9c212c1bd1 Added SKIP_DELETION support 2016-10-21 12:38:03 +02:00
deajan 3ae961c4b9 Added arrayContains function 2016-10-21 12:37:38 +02:00
deajan d68e4d1e1b Prevent locking race conditions 2016-10-19 13:30:08 +02:00
deajan a4312e31fd Rebuilt targets 2016-10-19 12:45:10 +02:00
deajan 5e52e395ef Added ssh password test 2016-10-19 12:44:52 +02:00
deajan f85efe97d4 Added sshpass comment 2016-10-19 12:31:20 +02:00
deajan 8d98355867 Rebuilt targets 2016-10-19 12:30:20 +02:00
deajan 6bae927a05 Added SSH_PASSWORD_FILE to upgrade script 2016-10-19 12:29:46 +02:00
deajan 72c0105387 Added ssh password file option 2016-10-19 12:28:48 +02:00
deajan 0be2bc3bc3 Updated ofunctions 2016-10-19 12:28:30 +02:00
deajan 408eb170c4 Added ssh password file support 2016-10-19 12:28:11 +02:00
deajan a6ab8b686e Improved upgrade script 2016-10-17 17:40:37 +02:00
deajan ceba2ba0b9 Updated changelog 2016-10-17 16:46:08 +02:00
deajan 2d195eb660 Updated unit tests 2016-10-17 16:45:02 +02:00
deajan a57d4ab98a Fixed deletion detection when bad symlinks present 2016-10-17 09:56:40 +02:00
deajan c2959fb98b Removed SC2086 from __CheckArguments call 2016-10-16 22:08:16 +02:00
deajan b63e4da847 Fixed deletion propagation after last code simplification 2016-10-16 22:00:31 +02:00
deajan 038db76178 Merge branch 'master' of https://github.com/deajan/osync 2016-10-16 14:36:40 +02:00
deajan a37bb85e65 Simplified function calls due to code compliance 2016-10-16 14:25:29 +02:00
deajan e77d3be37f Simplified deleted_list function 2016-10-16 12:33:53 +02:00
deajan 130b0ed113 Added symlink delete and broken symlink detection support 2016-10-16 12:12:59 +02:00
Orsiris de Jong 80b714f2a7 Update README.md 2016-10-12 12:10:27 +02:00
deajan b4bb334938 Removed remote ping on exclusion test 2016-09-16 17:23:25 +02:00
deajan 6d51ae45a9 Fixed exclusion test 2016-09-16 17:19:04 +02:00
deajan 7505832914 Fixed semantic 2016-09-16 17:18:48 +02:00
deajan 3495a49f17 Rendered basic exclusion test usable 2016-09-16 10:16:18 +02:00
deajan 951f6b1996 Allow default inclusion / exclusions for quicksync 2016-09-16 10:11:59 +02:00
deajan 8e07fb1d0d WIP on exclusion tests 2016-09-16 09:51:29 +02:00
deajan 6ac9e6f235 Fixing typo renaming initiator type 2016-09-16 09:48:58 +02:00
Shadowigor 38dc01ee39 Removed makepkg dependency 2016-09-10 12:35:54 +02:00
Shadowigor 5657a2a461 Added script to automatically update the PKGBUILD 2016-09-10 11:25:11 +02:00
deajan 413f9c24ab Updated tests for ParallelExec 2016-09-08 22:57:57 +02:00
deajan ae2df407d8 Rebuilt targets 2016-09-08 22:50:13 +02:00
deajan 4c3aa02954 Updated common scripts 2016-09-08 22:49:51 +02:00
deajan 4725bafb35 Improved ParallelExec 2016-09-06 19:27:45 +02:00
deajan ca9304af96 mend
Added more ParallelExec tests
2016-09-06 19:26:47 +02:00
deajan 0d6da8d044 Added more ParallelExec testsé 2016-09-06 19:26:37 +02:00
deajan 6e80c4772f Improved ParallelExec functions 2016-09-06 19:08:53 +02:00
deajan f521d75dbc Updated test to disable remote host ping 2016-09-05 22:30:03 +02:00
deajan c0b62913b0 Updated Readme for quick usage 2016-09-05 22:29:07 +02:00
deajan 0df40f7964 Fixed tests 2016-09-05 22:25:25 +02:00
deajan b79e26bcc6 Added SSH remote tests for Travis 2016-09-05 22:21:25 +02:00
deajan 873ff7971f Updated ofunctions with minor fixes 2016-09-05 22:06:57 +02:00
deajan b94dd28a6c Rebuilt targets 2016-09-02 21:43:14 +02:00
deajan ce38085cac Made merge output exit codes 2016-08-30 18:20:41 +02:00
deajan 939bc45dc7 Improved unit tests 2016-08-30 17:08:00 +02:00
deajan 7256055042 Added merge test 2016-08-30 16:34:15 +02:00
deajan 18775728f2 Merge README.md with Travis Info 2016-08-30 16:17:28 +02:00
deajan 8779930321 Added os info for travis CI 2016-08-30 16:17:15 +02:00
Orsiris de Jong 192676bc29 Added Travis CI info to README 2016-08-30 14:06:56 +02:00
deajan f1c306295f Removed remote ssh tests for travis 2016-08-30 14:03:32 +02:00
deajan 57759e1758 Fixed typo 2016-08-30 13:58:03 +02:00
deajan d27aed1c09 Made work dirs relative 2016-08-30 13:55:37 +02:00
deajan ac967f25ab Made test dirs relative 2016-08-30 13:52:58 +02:00
deajan adc675cb1b Added travis CI file 2016-08-30 13:47:15 +02:00
deajan aa1811ce79 Added .travis.yml file 2016-08-30 13:44:08 +02:00
deajan dde2f279b0 Added travis CI test file 2016-08-30 13:42:48 +02:00
deajan 5fd64ffa3c Added test dir to include shunit2 2016-08-30 13:42:35 +02:00
deajan 093613dfe3 Added minimal function run 2016-08-30 12:55:04 +02:00
deajan 609bf1bd6f Rebuilt targets for v1.2-betaé 2016-08-30 12:28:54 +02:00
deajan 9dd21ae3cb Moved email alert after last log message 2016-08-30 12:28:26 +02:00
deajan 90d16862d2 Rendered associative like arrays bash 3 compatible 2016-08-30 12:19:12 +02:00
deajan f5698c6037 Updated readme 2016-08-30 11:59:25 +02:00
deajan 31ba152069 Rebuilt targets for v1.2-beta 2016-08-30 11:57:39 +02:00
deajan e552a2d9bc Bumped version to v1.2-beta 2016-08-30 11:54:00 +02:00
deajan 415c153683 Added some other paranoia debug checks 2016-08-30 11:49:21 +02:00
deajan a31cceedc6 Made WaitFor and ParallelExec functions more robust 2016-08-30 11:37:25 +02:00
deajan 9804334821 Removed finished working comments 2016-08-30 11:36:29 +02:00
deajan 2db1046fee Fixed initiator and target arrays aren't global 2016-08-30 11:29:11 +02:00
deajan d48e3c4f26 Made replica array indexes more clear 2016-08-30 11:01:53 +02:00
deajan bd0c36071a Fixed sync_update steps 2016-08-29 21:59:40 +02:00
deajan 4be3823b27 Various minor fixes 2016-08-29 21:54:51 +02:00
deajan b77e28b5d6 Added some work comments 2016-08-29 21:30:36 +02:00
deajan b2b1b0ba18 Removed finished todo 2016-08-29 21:09:03 +02:00
deajan aabb67d4b6 Improved soft deletion messages 2016-08-29 21:05:46 +02:00
deajan fe8b254b01 Fixed 1 instead of true 2016-08-29 20:47:21 +02:00
deajan 854accdcd2 Fixed remote deletion logs 2016-08-29 20:40:29 +02:00
deajan aa4b7dddc8 Fixed verbose logging 2016-08-29 19:03:19 +02:00
deajan a17872282c Fixed typo 2016-08-29 18:59:53 +02:00
deajan 6de96338eb Merge branch 'master' of https://github.com/deajan/osync 2016-08-29 18:46:30 +02:00
deajan 2ce199e69d Added arch PKGBUILD file from Shadowigor 2016-08-29 18:46:04 +02:00
Orsiris de Jong a4ce89d5e8 Merge pull request #60 from Shadowigor/master
Enable installation with different root for (Arch) packaging
2016-08-29 18:39:40 +02:00
deajan 109e67e5b2 Simplified usage of verbose 2016-08-29 18:08:30 +02:00
Shadowigor 88e71f57cd Merge branch 'master' of https://github.com/deajan/osync 2016-08-29 18:03:03 +02:00
deajan ca02051fd7 Improved error message 2016-08-29 18:02:15 +02:00
deajan a7d49602d3 Fixed os detection 2016-08-29 17:53:23 +02:00
deajan 1428c0e127 Fixed os detection 2016-08-29 17:53:11 +02:00
deajan 9520ff2c76 Rebuilt targets 2016-08-29 17:40:45 +02:00
deajan 53e9ebccee Updated unit tests 2016-08-29 17:40:32 +02:00
deajan b8acf1d6dc Updated coding style 2016-08-29 17:39:56 +02:00
deajan 0903db9d2c Updated changelog 2016-08-29 17:38:30 +02:00
deajan 2764930dc4 Replaced 0/1 with bolean logic 2016-08-29 17:37:48 +02:00
deajan 472e5e2251 Replaced 0,1 with false,true 2016-08-29 13:54:24 +02:00
deajan 385bc5d40f Simplified verbose. Also replaced 0,1 with false,true 2016-08-29 13:48:03 +02:00
deajan e18bacedfd Fixed deletion propagation 2016-08-29 13:16:07 +02:00
Shadowigor b7f21f2d89 Updated auto-generated scripts 2016-08-29 01:33:21 +02:00
Shadowigor d8cb176ec6 Merge branch 'master' of https://github.com/deajan/osync 2016-08-29 01:29:26 +02:00
deajan 7294fa8846 Updated common merge from other projects 2016-08-28 21:39:09 +02:00
deajan edfb092ff7 Removed elder comments 2016-08-28 21:17:13 +02:00
Shadowigor d886b77acb Modified dev/common_install.sh instead of the autogenerated file 2016-08-28 21:15:19 +02:00
deajan 0aa2d49678 Another lock/unlock fix 2016-08-28 21:07:40 +02:00
deajan 52b31f7bca Fixed locking / unlocking mechanism 2016-08-28 18:40:39 +02:00
Shadowigor f1c62c03bb Executing mkdir for BIN_DIR should be dependent on FAKEROOT for installation 2016-08-28 18:28:19 +02:00
deajan 7190ffeae5 Indented function chronology description 2016-08-28 18:26:12 +02:00
deajan 7e51ad5497 WIP: fixing unlocking depending on lock success 2016-08-28 18:22:37 +02:00
Shadowigor cbe5ba598e Making the binary installation path variable is useless, it is hardcoded in too many places 2016-08-28 18:14:00 +02:00
Shadowigor 58eb1d85c9 Installation path of the binary is now dependant of FAKEROOT 2016-08-28 18:04:36 +02:00
deajan c5f6874ad8 Added some preflight checks 2016-08-28 17:58:03 +02:00
deajan e019fb98f9 Added missing local declarations 2016-08-28 17:54:20 +02:00
Shadowigor dba871e9bf Merge branch 'master' of https://github.com/deajan/osync 2016-08-28 17:50:53 +02:00
Shadowigor ba8ebce09b Changed spaces to tabs 2016-08-28 17:03:08 +02:00
Shadowigor 21116f470e Directory creation for fakeroot is more dynamic now 2016-08-28 16:37:43 +02:00
deajan e9cf493e58 Updated changelog 2016-08-28 12:00:43 +02:00
deajan c984a3cb74 Renamed sync.conf to sync.conf.example 2016-08-28 12:00:30 +02:00
deajan 32fbb24259 Updated ofunctions with ParallelExec 2016-08-28 11:32:25 +02:00
deajan adf742775d Updated changelog & coding style 2016-08-28 11:30:28 +02:00
deajan d79f53760b Updated coding style file 2016-08-22 10:31:47 +02:00
deajan 3ae3005ace Updated sync file 2016-08-22 10:27:36 +02:00
deajan 8393c2e7cd Updated changelog 2016-08-22 10:27:08 +02:00
deajan 6f921205f5 Added basic unit tests 2016-08-22 10:26:38 +02:00
deajan cf89a2fb31 Rebuilt targets 2016-08-22 09:09:59 +02:00
deajan e1bcaea6a3 Updated serials 2016-08-22 09:07:58 +02:00
deajan ff6a0b95fc Fixed RunAfterHook not executed on normal runs 2016-08-22 08:32:24 +02:00
deajan bcbd43fafb Fixed code removal 2016-08-22 08:31:48 +02:00
deajan df2cfe8fa5 Removed unused code 2016-08-22 08:12:08 +02:00
deajan f052422c44 Prevent double kill in WaitForTaskCompletion 2016-08-22 08:09:48 +02:00
deajan fd2dfabce2 Made signals posix compliant 2016-08-22 07:55:03 +02:00
deajan 1db8adfa98 Reenabled path comparaison 2016-08-20 10:43:22 +02:00
Shadowigor 2e0f2cbb55 Added support for different install path and fakeroot 2016-08-20 01:46:37 +02:00
deajan fd08e00abb Increased soft warn value for remote internet checks 2016-08-19 11:09:07 +02:00
deajan 20d8fafa8d Rebuilt targets 2016-08-19 10:57:20 +02:00
deajan c1e4f9fa51 Fixed typo 2016-08-19 10:55:02 +02:00
deajan a753e988c3 Improved resume to bypass succeed substeps 2016-08-19 10:53:13 +02:00
deajan ff70828d71 Replaced program name with variable 2016-08-19 10:24:42 +02:00
deajan 99619f842d Upgrade script updates header too and adds KEEP_LOGGING 2016-08-19 10:20:56 +02:00
deajan a994e9a590 Added dead process test program 2016-08-19 00:13:27 +02:00
deajan ca7be5d945 Rebuilt target 2016-08-18 23:30:10 +02:00
deajan 216ee8adf7 Updated batch processor from obackup project 2016-08-18 23:29:51 +02:00
deajan 52b4df4bc1 Rebuilt targets 2016-08-18 23:29:35 +02:00
deajan 416f2c1e45 Updated ofunctions from obackup project 2016-08-18 23:28:41 +02:00
deajan a1044687b5 Updated WaitFor functions & comments 2016-08-18 23:28:25 +02:00
deajan 959ac5bd50 Updated ofunctions 2016-08-13 11:56:54 +02:00
deajan 193aab025e Rebuilt targets 2016-08-13 11:56:41 +02:00
deajan 2b5b8a82a8 Updated changelog 2016-08-13 11:56:15 +02:00
deajan 09601664a5 Fixed soft deletion when SUDO_EXEC enabled 2016-08-13 11:55:08 +02:00
deajan 1186ff0de7 Updated comments 2016-08-09 22:24:50 +02:00
deajan 0e8fa07889 Updated changelog 2016-08-09 22:17:43 +02:00
deajan cfdb2087ec Rebuilt targets 2016-08-09 22:16:54 +02:00
deajan 8b19d51042 Parallelized sync functions 2016-08-09 22:14:17 +02:00
deajan d41d100395 Merge branch 'master' of https://github.com/deajan/osync 2016-08-09 16:06:56 +02:00
deajan 9a94eb2211 Updated upgrade script to v1.2x 2016-08-09 16:06:39 +02:00
Orsiris de Jong 8d20d861fb Update README.md 2016-08-09 15:41:27 +02:00
Orsiris de Jong 4640a30a2b Updated tag to v 1.1.1 2016-08-09 15:40:30 +02:00
deajan 921b1ea25c Rebuilt targets 2016-08-09 14:12:49 +02:00
deajan 06ca2f6a37 Fixed executability for macosX 2016-08-09 14:12:07 +02:00
deajan a3145519b7 Skip attr sync if RSYNC_ATTR_ARGS is empty 2016-08-09 13:51:14 +02:00
deajan 0162721513 Added missing fi 2016-08-09 13:48:21 +02:00
deajan 1472fba4bc Added initial preserve permissions 2016-08-09 13:44:43 +02:00
deajan 7f7e6ae5a4 Rebuilt targets 2016-08-08 19:08:15 +02:00
deajan 846f064556 Added shellcheck wrapper for debug version 2016-08-08 19:07:42 +02:00
deajan 8efb5019c8 Added -r to while statements 2016-08-08 19:05:57 +02:00
deajan aa4e16f4a6 Rebuilt targets 2016-08-08 18:27:22 +02:00
deajan 6f1307a4fd Minor fixes in ofunctions 2016-08-08 18:06:31 +02:00
deajan 51487be79c Replaced IFS for loops with while 2016-08-08 18:06:03 +02:00
deajan cdbad63e87 Updated ofunctions 2016-08-08 00:16:38 +02:00
deajan bf0051c63d Refactored wait functions 2016-08-07 23:54:46 +02:00
deajan bef9a92526 Rebuilt targets 2016-08-06 13:26:16 +02:00
deajan b16737e326 Fixed double pattern delcaration 2016-08-06 13:17:56 +02:00
deajan 2275efa3cc Rebuilt target 2016-08-04 12:20:11 +02:00
deajan 4418b28846 Various fixes 2016-08-04 11:52:28 +02:00
deajan 8116206f19 Rebuilt targets 2016-08-04 00:53:37 +02:00
deajan c519639aec more and more parallelisation 2016-08-04 00:52:05 +02:00
deajan 6f59e37e94 Paralellized run before / after functions 2016-08-04 00:28:09 +02:00
deajan 3a6d2b405a Made disk space tests non mandatory 2016-08-04 00:02:20 +02:00
deajan 6f91d4a442 Rebuild target 2016-08-03 23:58:59 +02:00
deajan 29c99dae67 Added new _LOGGER variables 2016-08-03 23:58:38 +02:00
deajan 6bb5ab9c22 Various minor fixes 2016-08-03 23:58:24 +02:00
deajan a444d24de8 Better parellelization 2016-08-03 10:02:18 +02:00
deajan 5c43179ef4 Multi pid wait and killchild functions 2016-08-03 10:02:07 +02:00
deajan 0fea93bbbf Updated changelog 2016-08-02 22:21:28 +02:00
deajan 0637b7260f Rebuilt targets 2016-08-02 22:20:04 +02:00
deajan 33467ca56c Rebuild targets 2016-08-02 22:10:02 +02:00
deajan 0e5b000679 Fixed soft deletion always enabled remotely 2016-08-02 22:09:19 +02:00
deajan 7be29fdb05 New wait function handles multiple pids 2016-08-02 14:26:04 +02:00
deajan 87ee14ba48 Fix attribute list 2016-08-02 13:24:48 +02:00
deajan 23222f7922 Updated changelog 2016-08-02 12:58:08 +02:00
deajan 7578d0a047 Various fixes 2016-08-02 12:53:41 +02:00
deajan 8c80400b4a Updated text files 2016-08-02 11:11:19 +02:00
deajan 2cbe7a2f86 Fixed typo 2016-08-02 11:10:09 +02:00
deajan 2a007b4e83 Ported fixes from v1.1-maint branch 2016-08-02 10:01:48 +02:00
deajan 62676fee40 Misc fixes 2016-08-01 18:04:35 +02:00
Orsiris de Jong 2d19cba036 Merge pull request #55 from allter/master
Fixes remote files deletion #54
2016-08-01 12:13:58 +02:00
Andrey M. Smirnov 836659947f Wrapped $DELETE_CMD_INPUT with "" 2016-07-28 00:31:02 +00:00
Andrey M. Smirnov 0ab67c02ce Possible typo 2016-07-28 00:30:38 +00:00
Andrey M. Smirnov 16fc23c66d Fixed a (probable) mistake 2016-07-28 00:09:34 +00:00
Andrey M. Smirnov b46a79784e Log verbosely what's happening on remote side on deletion 2016-07-28 00:09:05 +00:00
Andrey M. Smirnov 9129020daf Write logs to STDERR on remote side 2016-07-28 00:08:40 +00:00
Andrey M. Smirnov 7bb6eebea3 typo 2016-07-27 23:01:33 +00:00
Andrey M. Smirnov 3b2924d7d9 Correct arguments for remote deletion command + debug printing it those arguments and a command input 2016-07-27 22:48:04 +00:00
deajan 554ca98c1b Removed parallelism from unlock function for now 2016-07-27 17:55:31 +02:00
deajan 3e9bc05d67 More parallism 2016-07-27 14:10:59 +02:00
deajan 4101e11f67 Trying parallelism patch 2016-07-27 13:53:31 +02:00
deajan 166f67bb55 Added lock check before unlocking 2016-07-27 12:04:27 +02:00
deajan e685da33fa Removed trivial sleep after heredoc 2016-07-27 11:49:57 +02:00
deajan b3935b43d3 Lowered sleep time 2016-07-27 11:49:21 +02:00
76 changed files with 34020 additions and 12980 deletions

33
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,33 @@
---
name: Bug report
about: Create a report to help us improve
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Setup osync with the following config file / the following parameters (please provide either anonymized)
2. Run osync with following parameters
3. Result
**Expected behavior**
A clear and concise description of what you expected to happen.
** Deviated behavior**
How does the actual result deviate from the expected behavior.
**Logs**
Please send logs of what happens.
Also, you might run osync with _DEBUG=yes environement variable to have more verbose debug logs.
**Environment (please complete the following information):**
- Full osync version (including build)
- OS: [e.g. iOS]
- Bitness [e.g. x64 or x86]
- Shell (busybox or else)
**Additional context**
Add any other context about the problem here.

25
.github/workflows/codespell.yml vendored Normal file
View File

@ -0,0 +1,25 @@
# Codespell configuration is within .codespellrc
---
name: Codespell
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Annotate locations with typos
uses: codespell-project/codespell-problem-matcher@v1
- name: Codespell
uses: codespell-project/actions-codespell@v2

25
.github/workflows/linux.yml vendored Normal file
View File

@ -0,0 +1,25 @@
name: linux-tests
on: [push, pull_request]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt-get install inotify-tools acl
- name: Execute tests and generate coverage report
run: |
export RUNNING_ON_GITHUB_ACTIONS=true
export SSH_PORT=22
echo "Running on github actions: ${RUNNING_ON_GITHUB_ACTIONS}"
echo "Running on ssh port ${SSH_PORT}"
sudo -E bash ./dev/tests/run_tests.sh
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v1

28
.github/workflows/macos.yml vendored Normal file
View File

@ -0,0 +1,28 @@
name: macosx-tests
on: [push, pull_request]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest]
steps:
- uses: actions/checkout@v2
- name: Install Bash 4
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew update
brew install bash
brew install fswatch
echo "/usr/local/bin" >> $GITHUB_PATH
- name: Execute tests and generate coverage report
run: |
export RUNNING_ON_GITHUB_ACTIONS=true
export SSH_PORT=22
sudo -E bash ./dev/tests/run_tests.sh
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v1

29
.github/workflows/windows.yml vendored Normal file
View File

@ -0,0 +1,29 @@
name: windows-tests
on: [push, pull_request]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
steps:
- uses: actions/checkout@v2
- uses: Vampire/setup-wsl@v1
with:
additional-packages:
dos2unix
rsync
openssh-server
- name: Execute tests and generate coverage report
shell: wsl-bash {0}
run: |
export RUNNING_ON_GITHUB_ACTIONS=true
export SSH_PORT=22
find ./ -type f ! -path "./.git/*" -print0 | xargs -0 -n 1 -P 4 dos2unix
service ssh start
./dev/tests/run_tests.sh
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v1

16
.travis.yml Normal file
View File

@ -0,0 +1,16 @@
language:
bash
os:
linux
osx
before_install:
sudo apt-get install inotify-tools acl
sudo:
required
script:
TRAVIS_RUN=true dev/tests/run_tests.sh

698
CHANGELOG.md Normal file → Executable file
View File

@ -1,217 +1,493 @@
KNOWN ISSUES
------------
## RECENT CHANGES
- Cannot finish sync if one replica contains a directory and the other replica contains a file named the same way (Unix doesn't allow this)
- Soft deletion does not honor exclusion lists
### Current master
RECENT CHANGES
--------------
- Make --log-conflicts non experimental (randomly fails)
- ! new option FORCE_CONFLICT_PREVALANCE which will always use Initiator or Target, regardless of best time
- ! target-helper: destination mails etc on target, also, no cmd after on configs
27 Jul 2016: osync v1.1 released
- More msys and cygwin compatibility
- Logging begins now before any remote checks
- Improved process killing and process time control
- Redirected ERROR and WARN messages to stderr to systemd catches them into it's journal
- Added systemd unit files
- Added an option to ignore ssh known hosts (use with caution, can lead to security risks), also updated upgrade script accordingly
- Added optional installation statistics
- Fixed a nasty bug with log writing and tree_list function
- Improved mail fallback
- Improved more logging
- Fixed conflict prevalance is target in quicksync mode
- Fixed file attributes aren't updated in a right manner when file mtime is not altered (Big thanks to vstefanoxx)
- Better upgrade script (adding missing new config values)
- More fixes for GNU / non-GNU versions of mail command
- Added bogus config file checks & environment checks
- Added delta copies disable option
- Revamped rsync patterns to allow include and exclude patterns
- Fully merged codebase with obackup
- Passed shellCheck.net
- Simplified EscapeSpaces to simple bash substitution
- Corrected a lot of minor warnings in order to make code more bullet proof
- Added v1.0x to v1.1 upgrade script
- Added (much) more verbose debugging (and possibility to remove debug code to gain speed)
- Force tree function to overwrite earlier tree files
- Add Logger DEBUG to all eval statements
- Unlocking happens after TrapQuit has successfully killed any child processes
- Replace child_pid by $? directly, add a better sub process killer in TrapQuit
- Refactor [local master, local slave, remote slave] code to [local, remote][initiator, target]code
- Renamed a lot of code in order to prepare v2 code (master becomes initiator, slave becomes target, sync_id becomes instance_id)
- Added some automatic checks in code, for _DEBUG mode (and _PARANOIA_DEBUG now)
- Improved Logging
- Updated osync to be fully compliant with coding style
- Uploaded coding style manifest
### 16 June 2023: osync v1.3 release (for full changelog since v1.2 branch see all v1.3-beta/RC entries)
v0-v1.0x - Jun 2013 - Sep 2015
- Added LSB info to init script for Debian based distros
22 Jul. 2015: Osync v1.00a released
- Small improvements in osync-batch.sh time management
- Improved various logging on error
- Work in progress: Unit tests (intial tests written by onovy, Thanks again!)
- Small Improvements on install and ssh_filter scripts
- Improved ssh uri recognition (thanks to onovy)
- Fixed #22 (missing full path in soft deletion)
- Fixed #21 by adding portable shell readlink / realpath from https://github.com/mkropat/sh-realpath
- Added detection of osync.sh script in osync-batch.sh to overcome mising path in crontab
- Fixed osync-batch.sh script when osync is in executable path like /usr/local/bin
- Fixed multiple keep logging messages since sleep time between commands has been lowered under a second
- Added optional checksum parameter for the paranoid :)
- Fixed typo in soft deletion code preventing logging slave deleted backup files
- Removed legacy lockfile code from init script
- Removed hardcoded program name from init script
01 Avr. 2015: Osync v1.00pre
- Improved and refactored the soft deletion routine by merging conflict backup and soft deletion
- Reworked soft deletion code to handle a case where a top level directory gets deleted even if the files contained in it are not old enough (this obviously shouldn't happen on most FS)
- Added more logging
- Merged various fixes from onovy (http://github.com/onovy) Thanks!
- Lowered sleep time between commands
- Check if master and slave directories are the same
- Check script parameters in osync.sh and osync-batch.sh
- Run sync after timeout in --on-changes mode when no changes are detected (helps propagate slave changes)
- Fix for locking in --on-changes mode (child should lock/unlock, master process shouldn't unlock)
- Remote user is now optional in quicksync mode
- Replaced default script execution storage from /dev/shm to /tmp because some rootkit detection software doesn't like this
- Fixed bogus error in DEBUG for quicksync mode where no max execution time is set
- Prevent debug mode to send alert emails
- Fixed an infamous bug introduced with exclude pattern globbing preventing multiple exludes to be processed
- Fixed an issue with empty RSYNC_EXCLUDE_FILES
- Lowered default compression level for email alerts (for low end systems)
- Prevent exclude pattern globbing before the pattern reaches the rsync cmd
- Fixed some missing child pids for time control to work
- Prevent creation of a sync-id less log file when DEBUG is set
- Added a sequential run batch script that can rerun failed batches
- Fixed an issue where a failed task never gets resumed after a successfull file replication phase
- Added experimental partial downloads support for rsync so big files can be resumed on slow links
- Added the ability to keep partial downloads that can be resumed on next run (usefull for big files on slow links that reach max execution time)
- Moved msys specific code to Init(Local|Remote)OSSettings
- Added a patch by igngvs to fix some issues with Rsync Exclude files
- Added a patch by Gary Clark to fix some issues with remote deletion
- Minor fixes from obackup codebase
- Added compression method fallback (xz, lzma, pigz and gzip)
- Removed unused code
- Fixed remote OS detection when a banner is used on SSH
- Added a routine that reinjects failed deletions for next run in order to prevent bringing back when deletion failed with permission issues
- Added treat dir symlink as dir parameter
27 May 2014: Osync 0.99 RC3
- Additionnal delete fix for *BSD and MSYS (deleted file list not created right)
- Fixed dry mode to use non dry after run treelists to create delete lists
- Added follow symlink parameter
- Minor fixes in parameter list when bandwidth parameter is used
- Added some additionnal checks for *BSD and MacOS environments
- Changed /bin/bash to /usr/bin/env bash for sanity on other systems, also check for bash presence before running
- Changed default behavior for quick sync tasks: Will try to resume failed sync tasks once
- Some code cleanup for state filenames and sync action names
- Fixed deletion propagation (again). Rsync is definitly not designed to delete a list of files / folders. Rsync replaced by rm function which downloads deletion list to remote system.
- Added path detection for exclude list file
- Added a simple init script and an install script
- Fixed an issue with MacOSX using rsync -E differently than other *nix (Thanks to Pierre Clement)
- Multislave asynchronous task support (Thanks to Ulrich Norbisrath)
- This breaks compat with elder osync runs. Add the SYNC_ID suffix to elder state files to keep deleted file information.
- Added an easier debug setting i.e DEBUG=yes ./osync.sh (Again, thanks to Ulrich Norbisrath)
- Added hardlink preservation (Thanks to Ulrich Norbisrath)
- Added external exclusion file support (Thanks to Pierre Clement)
- Fixed some typos in doc and program itself (Thanks to Pierre Clement)
- More detailled verbose status messages
- More detailled status messages
- Fixed a bug preventing propagation of empty directory deletions
- Fixed a nasty bug preventing writing lock files on remote system as superuser
- Gzipped logs are now deleted once sent
- Fixed some typos (thanks to Pavel Kiryukhin)
- Fixed a bug with double trailing slashes in certain sceanrios
- Sync execution don't fails anymore if files vanish during execution, also vanished files get logged
- Add eventual "comm -23" replacement by "grep -F -x -v -f" to enhance compatibility with other platforms (comm is still much faster than grep, so we keep it)
- Replaced xargs rm with find -exec rm to better handle file names in soft deletion
- Fixed soft deletion not happening with relative paths
- Improved process termination behavior
- More code merging and cleanup
- Fixed a bug preventing deleted files in subdirectories propagation (Thanks to Richard Faasen for pointing that out)
- Some more function merge in sync process
- Dry mode won't create or modifiy state files anymore and will use dry-state files instead
- Improved file monitor mode
- Added possibility to daemonize osync in monitor mode
- Added monitor mode, which will launch a sync task upon file operations on master replica
- Changed conf file default format for ssh uri (old format is still compatible)
- Added ssh uri support for slave replicas
- Improved execution hooks logs
- Various bugfixes introduced with function merge
- Added basic MacOS X support (yet not fully tested)
- Merged tree list functions into one
- Added possibility to quick sync two local directories without any prior configuration
- Added time control on OS detection
02 Nov. 2013: Osync 0.99 RC2
- Minor improvement on operating system detection
- Improved RunLocalCommand execution hook
- Minor improvements on permission checks
- Made more portability improvements (mostly for FreeBSD, must be run with bash shell)
- Added local and remote operating system detection
- Added forced usage of MSYS find on remote MSYS hosts
- Updated MSYS handling
- Merged MSYS (MinGW minimal system) bash compatibility under Windows from Obackup
- Added check for /var/log directory
- Added check for shared memory directory
- Added alternative way to kill child processes for other OSes and especially for MSYS (which is a very odd way)
- Added Sendemail.exe support for windows Alerting
- Replaced which commend by type -p, as it is more portable
- Added support for ping.exe from windows
- Forced usage of MSYS find instead of Windows' find.exe on master
- Added an optionnal remote rsync executable path parameter
- Fixed an issue with CheckConnectivity3rdPartyHosts
- Added an option to stop execution if a local / remote command fails
- Improved forced quit command by killing all child processes
- Before / after commands are now ignored on dryruns
- Improved verbose output
- Fixed various typos
- Enforced CheckConnectivityRemoteHost and CheckConnectivity3rdPartyHosts checks (if one of these fails, osync is stopped)
18 Aug. 2013: Osync 0.99 RC1
- Added possibility to change default logfile
- Fixed a possible error upon master replica lock check
- Fixed exclude directorires with spaces in names generate errros on master replica tree functions
- Dryruns won't create after run tree lists and therefore not prevent building real run delete lists
- Softdelete and conflict backup functions are now time controlled
- Added bandwidth limit
- Update and delete functions now run rsync with --stats parameter
- Fixed LoadConfigFile function will not warn on wrong config file
- Added --no-maxtime parameter for sync big changes without enforcing execution time checks
03 Aug. 2013: beta 3 milestone
- Softdelete functions do now honor --dry switch
- Simplified sync delete functions
- Enhanced compatibility with different charsets in filenames
- Added CentOS 5 compatibility (comm v5.97 without --nocheck-order function replaced by sort)
- Tree functions now honor supplementary rsync arguments
- Tree functions now honor exclusion lists
01 Aug. 2013: beta 2 milestone
- Fixed an issue with spaces in directory trees
- Fixed an issue with recursive directory trees
- Revamped a bit code to add bash 3.2 compatibility
24 Jul. 2013: beta milestone
- Fixed some bad error handling in CheckMasterSlaveDirs and LockDirectories
- Added support for spaces in sync dirs and exclude lists
- Fixed false exit code if no remote slave lock present
- Added minimum disk space checks
- Added osync support in ssh_filter.sh
- Added support for sudo exec on remote slave
- Added support for alternative rsync executable
- Added support for spaces in sync directories names
- Added support for ACL and xattr
- Added --force-unlock parameter to bypass any existing locks on replicas
- Added full remote support for slave replica
- Improved error detection
- Made some changes in execution hook output
- Fixed an issue with task execution handling exit codes
- Added master and slave replicas lock functionnality
- Added rsync exclude patterns support
- Improved backup items, can now have multiple backups of the same file
- Added maximum number of resume tries before trying a fresh stateless execution
- Added possibility to resume a sync after an error
- Improved task execution time handling
- Improved SendAlert handling
- Fixed cleanup launched even if DEBUG=yes
- Added verbose rsync output
- Added --dry and --silent parameters
- Added time control
- Added master/slave conflict prevalance option
- Added soft-deleted items
- Added backup items in case of conflict
- Fix for new RSYNC protocol
- New options ALWAYS_SEND_MAILS to allow sending logs regardless of execution states
19 Jun. 2013: Project begin as Obackup fork
### 29 June 2020: osync v1.3-RC1 release
- New option to use SSH_CONTROLMASTER in order to speed up remote sync tasks and preserve a single ssh channel
- New option SSH_OPTIONAL_ARGS
- Fixed a problem with macos mv not preserving ownership of files from /tmp
- Fixed very long outstanding issue with special characters in remote target handling
- Fixed an issue where STOP_ON_ERROR_CMD did not work anymore
- Fixed a remote file lock problem (thanks to https://github.com/zhangzhishan)
- Fixed various cosmetic issues with code and logs
- Improved upgrade script
- Fixed a possible bash buffer overflow when synchronizing large filesets (tested with 2M files)
- This fix actually truncats every string sent to Logger not being more than 16KB
- Fixed osync leaving temporary log files behind in RUN_DIR (/tmp by default)
- Updated target helper service configuration file
- Improved codacy results
- Added more debugging
- Fixed service logs being junked by spinner
- Fixed MINIMUM_SPACE=0 didn't stop the disk space check anymore (Thanks to Val)
- Fixed conflict file logs to be less verbose when no conflicts happen
### 22 May 2019: osync v1.3-beta3 release
- Config file update script fixes
- Removed old Win10 1607 bash fixes to make Win10 1809 work (breaks Win10 1607 beta bash version...Yeah, nothing I can do about that)
### 20 May 2019: osync v1.3-beta2 release
- More --summary statistics
- Config file syntax now uses booleans instead of yes / no (but still accepts old syntax)
- Added boolean update in upgrade script
- Config file revision check
- Added config file revision in upgrade script
- New option --sync-type=initator2target|target2initiator that allows using osync as rsync wrapper for unidirectional sync
- New osync target helper service
- Fixed multiple race conditions in parallel executions (which also fixes random conflict logs failures)
- Fixed directory softdeletion bug
- Fixed multiple failed deletions will be retried as many times as failures happened
- Fixed remote running on FreeBSD for some commands, thanks to Vladimirek
- Fixed (again) deletion propagation when file contains spaces (thanks to http://github.com/weinhold)
- Deprecated --log-conflicts for 1.3 branch (is now experimental)
- Updated ofunctions
- Has better random number generator
- IsInteger, IsNumeric and IsNumericExpand are now busybox compatible
- Multiple installer fixes
- Multiple batch fixes
### 08 Aug 2018: osync v1.3-beta1 release
- Added an option to log conflictual files
- Presence of conflictual files can trigger a special mail
- New option --initialize (see #141)
- Added OpenRC support (thanks to kozross, see #140)
- Added --no-resume option in order to disable resuming execution on failure
- Added basic performance profiler to debug version
- Fixed summary for file deletions
- Fixed an issue with filenames ending with spaces, their deletion not being propagated, and ACL / conflicts not being managed (still they got synced)
- Fixed missing options passed to subprocess in daemon mode
- Fixed bogus pgrep can lead to segfault 11 because of recursive KillChilds
- Fixed osync deletion not working on systems with ssh banner enabled
- Improved GetLocalOS and GetRemoteOS OS detection
- Fixed GetRemoteOS missing GetConfFileValue preventing to get OS details from /etc/os-release
- Fixed low severity security issue where log and run files could be read by other users
- Merged Logger and QuickLogger for simplified usage
- Fixed inotifyway error in FreeBSD (see #119)
- Minor enhancements in installer / ofunctions
- Added --prefix option for installer
- Installer path fixes
- Fixed logging bug with QuickLogger
- Refactored time control and parallel execution functions into one single function
- Multiple portability improvements
- UrlEncode function is now Busybox compatible
- IsInteger function is now Busybox compatible
- Prevented non unique runtime filenames on some systems where no milliseconds exist
- Fixed bogus runtime filenames on Busybox
- Upgraded shunit2 test framework to v2.1.8pre (git commit 07bb329)
- Multiple smaller fixes and improvements
### 25 Mar 2017: osync v1.2 release (for full changelog of v1.2 branch see all v1.2-beta/RC entries)
- Check for initiator directory before launching monitor mode
- Updated RPM spec file (Thanks to https://github.com/liger1978)
- Fixed remote commands can be run on local runs and obviously fail
- Minor fixes in installer logic
### 10 Feb 2017: osync v1.2-RC3 release
- Uninstaller skips ssh_filter if needed by other program (osync/obackup)
- Logger now automatically obfuscates _REMOTE_TOKEN
- Logger doesn't show failed commands in stdout, only logs them
### 08 Feb 2017: osync v1.2-RC2 release
- Tests have run on CentOS 5,7 and 7, Debian 8, Linux Mint 18, Fedora 25, FreeBSD 10.3/pfSense, FreeBSD 11, MacOSX Sierra, Win10 1607 (14393.479) bash, Cygwin x64 and MSYS2 current
- Hugely improved ssh_filter
- Improved privilege elevation compatibility on SUDO_EXEC=yes runs
- Refactored installer logic and added --remove option
- Added optional mail body characterset encoding
- Fixed log output has escaped UTF-8 characters because of LC_ALL=C
- Fixed installer statistics don't report OS
- Minor tweaks and fixes in ofunctions
### 13 Dec 2016: osync v1.2-RC1 release
- Unit tests have run on CentOS 5,6 and 7, Debian 8, Linux Mint 18, FreeBSD 10.3/pfSense, FreeBSD 11, MacOSX Sierra, Win10 1607 (14393.479) bash, Cygwin x64 and MSYS2 current
- Added optional rsync arguments configuration value
- Fixed another random error involving warns and errors triggered by earlier runs with same PID flag files
- Adde more preflight checks
- Fixed a random appearing issue with Sync being stopped on internet failure introduced in v1.2 rewrite
- Resuming operation will not send warnings anymore unless resumed too many timess
- Spinner is less prone to move logging on screen
- Fixed daemon mode didn't enforce exclusions
- Made a quick and dirty preprocessor
- ofunctions can now directly be loaded into osync via an include statement
- n_osync.sh can be assembled on the fly using bootstrap.sh
- Forced remote ssh to use bash (fixes FreeBSD 11 compatibility when default shell is csh)
- Faster execution
- Reduced number of needed sequential SSH connections for remote sync (4 connections less)
- Refactored CheckReplicaPath and CheckDiskSpace into one functon CheckReplicas
- Refactored CheckDiskSpace, CheckLocks and WriteLocks into one function HandleLocks
- Removed noclobber locking in favor of a more direct method
- Improved remote logging
- Fixed directory ctime softdeletion
- Using mutt as mail program now supports multiple recipients
- osync now properly handles symlink deletions (previous bugfix didn't work properly)
- Simplified osync-batch runner (internally and for user)
- Better filename handling
- Easier to read log output
- Always passes --silent to osync
- All options that do not belong to osync-batch are automatically passed to osync
- Improved installer OS detection
- Added daemon capability on MacOS X
- Fixed upgrade script cannot update header on BSD / MacOS X
- Fixed SendEmail function on MacOS X
- Fixed MAX_HARD_EXEC_TIME not enforced in sync function introduced with v1.2 rewrite
- Fixed MAX_SOFT_EXEC_TIME not enforced bug introduced with v1.2 rewrite
- PRESERVE_ACL and PRESERVE_XATTR are ignored when local or remote OS is MacOS or msys or Cygwin
- Fixed PRESERVE_EXECUTABILITY was ommited volontary on MacOS X because of rsync syntax
- Fixed failed deletion rescheduling under BSD bug introduced with v1.2 rewrite
- merge.sh is now BSD and Mac compatible
- More work on unit tests:
- Unit tests are now BSD / MacOSX / MSYS / Cygwin and Windows 10 bash compatible
- Added more ACL tests
- Added directory soft deletion tests
- Added symlink and broken symlink copy / deletion tests
- Made unit tests more robust when aborted
- Simplified unit tests needed config files (merged travis and local config files)
- Added timed execution tests
- More code compliance
- Lots of minor fixes
### 19 Nov 2016: osync v1.2-beta3 re-release
- Fixed blocker bug where local tests tried GetRemoteOS Anyway
- Fixed CentOS 5 compatibility bug for checking disk space introduced in beta3
- More Android / Busybox compatibility
- Made unit tests clean authorized_keys file after usage
- Added local unit test where remote OS connection would fail
### 18 Nov 2016: osync v1.2-beta3 released
- Improved locking / unlocking replicas
- Fixed killing local pid that has lock bug introduced in v1.2 rewrite
- Allow remote unlocking when INSTANCE_ID of lock matches local INSTANCE_ID
- Fixed failed deletions re-propagation bug introduced in v1.2 rewrite
- Faster remote OS detection
- New output switches, --no-prefix, --summary, --errors-only
- Added busybox (and Android Termux) support
- More portable file size functions
- More portable compression program commands
- More paranoia checks
- Added busybox sendmail support
- Added tls and ssl support for sendmail
- Added --skip-deletion support in config and quicksync modes
- Added possibility to skip deletion on initiator or target replica
- Prevent lock file racing condition (thanks to https://github.com/allter)
- Added ssh password file support
- Hugely improved unit tests
- Added conflict resolution tests
- Added softdeletion tests
- Added softdeletion cleanup tests
- Added lock tests
- Added skip-deletion tests
- Added configuration file tests
- Added upgrade script test
- Added basic daemon mode tests
- Simplified logger
- All fixes from v1.1.5
### 17 Oct 2016: osync v1.2-beta2 released
- osync now propagates symlink deletions and moves symlinks without referrents to deletion dir
- Upgrade script now has the ability to add any missing value
- Improved unit tests
- Added upgrade script test
- Added deletion propagation tests
### 30 Aug 2016: osync v1.2-beta released
- Rendered more recent code compatible with bash 3.2+
- Added a PKGBUILD file for ArchLinux thanks to Shadowigor (https://github.com/shaodwigor). Builds available at https://aur.archlinux.org/packages/osync/
- Some more code compliance & more paranoia checks
- Added more preflight checks
- Logs sent by mail are easier to read
- Better subject (currently running or finished run)
- Fixed bogus double log sent in alert mails
- Made unix signals posix compliant
- Config file upgrade script now updates header
- Improved batch runner
- Made keep logging value configurable and not mandatory
- Fixed handling of processes in uninterruptible sleep state
- Parallelized sync functions
- Rewrite sync resume process
- Added options to ignore permissions, ownership and groups
- Refactored WaitFor... functions into one
- Improved execution speed
- Rewrite sync resume process
- Added parallel execution for most secondary fuctions
- Lowered sleep time in wait functions
- Removed trivial sleep and forking in remote deletion code, send the whole function to background instead
- Unlock functions no longer launched if locking failed
- Improved WaitFor... functions to accept multiple pids
- Added KillAllChilds function to accept multiple pids
- Improved logging
### 17 Nov 2016: osync v1.1.5 released
- Backported unit tests from v1.2-beta allowing to fix the following
- Allow quicksync mode to specify rsync include / exclude patterns as environment variables
- Added default path separator char in quicksync mode for multiple includes / exclusions
- Local runs should not check for remote connectivity
- Fixed backups go into root of replica instead of .osync_wordir/backups
- Fixed error alerts cannot be triggered from subprocesses
- Fixed remote locked targets are unlocked in any case
### 10 Nov 2016: osync v1.1.4 released
- Fixed a corner case with sending alerts with logfile attachments when osync is used by multiple users
### 02 Sep 2016: osync v1.1.3 released
- Fixed installer for CYGWIN / MSYS environment
### 28 Aug 2016: osync v1.1.2 released
- Renamed sync.conf to sync.conf.example (thanks to https://github.com/hortimech)
- Fixed RunAfterHook may be executed twice
- Fixed soft deletion when SUDO_EXEC is enabled
### 06 Aug 2016: osync v1.1.1 released
- Fixed bogus rsync pattern file adding
- Fixed soft deletion always enabled on target
- Fixed problem with attributes file list function
- Fixed deletion propagation code
- Fixed missing deletion / backup diretories message in verbose mode
### 27 Jul 2016: osync v1.1 released
- More msys and cygwin compatibility
- Logging begins now before any remote checks
- Improved process killing and process time control
- Redirected ERROR and WARN messages to stderr to systemd catches them into it's journal
- Added systemd unit files
- Added an option to ignore ssh known hosts (use with caution, can lead to security risks), also updated upgrade script accordingly
- Added optional installation statistics
- Fixed a nasty bug with log writing and tree_list function
- Improved mail fallback
- Improved more logging
- Fixed conflict prevalance is target in quicksync mode
- Fixed file attributes aren't updated in a right manner when file mtime is not altered (Big thanks to vstefanoxx)
- Better upgrade script (adding missing new config values)
- More fixes for GNU / non-GNU versions of mail command
- Added bogus config file checks & environment checks
- Added delta copies disable option
- Revamped rsync patterns to allow include and exclude patterns
- Fully merged codebase with obackup
- Passed shellCheck.net
- Simplified EscapeSpaces to simple bash substitution
- Corrected a lot of minor warnings in order to make code more bullet proof
- Added v1.0x to v1.1 upgrade script
- Added (much) more verbose debugging (and possibility to remove debug code to gain speed)
- Force tree function to overwrite earlier tree files
- Add Logger DEBUG to all eval statements
- Unlocking happens after TrapQuit has successfully killed any child processes
- Replace child_pid by $? directly, add a better sub process killer in TrapQuit
- Refactor [local master, local slave, remote slave] code to [local, remote][initiator, target]code
- Renamed a lot of code in order to prepare v2 code (master becomes initiator, slave becomes target, sync_id becomes instance_id)
- Added some automatic checks in code, for _DEBUG mode (and _PARANOIA_DEBUG now)
- Improved Logging
- Updated osync to be fully compliant with coding style
- Uploaded coding style manifest
- Added LSB info to init script for Debian based distros
## v0-v1.0x - Jun 2013 - Sep 2015
### 22 Jul. 2015: Osync v1.00a released
- Small improvements in osync-batch.sh time management
- Improved various logging on error
- Work in progress: Unit tests (intial tests written by onovy, Thanks again!)
- Small Improvements on install and ssh_filter scripts
- Improved ssh uri recognition (thanks to onovy)
- Fixed #22 (missing full path in soft deletion)
- Fixed #21 by adding portable shell readlink / realpath from https://github.com/mkropat/sh-realpath
- Added detection of osync.sh script in osync-batch.sh to overcome mising path in crontab
- Fixed osync-batch.sh script when osync is in executable path like /usr/local/bin
- Fixed multiple keep logging messages since sleep time between commands has been lowered under a second
- Added optional checksum parameter for the paranoid :)
- Fixed typo in soft deletion code preventing logging slave deleted backup files
- Removed legacy lockfile code from init script
- Removed hardcoded program name from init script
### 01 Avr. 2015: Osync v1.00pre
- Improved and refactored the soft deletion routine by merging conflict backup and soft deletion
- Reworked soft deletion code to handle a case where a top level directory gets deleted even if the files contained in it are not old enough (this obviously shouldn't happen on most FS)
- Added more logging
- Merged various fixes from onovy (http://github.com/onovy) Thanks!
- Lowered sleep time between commands
- Check if master and slave directories are the same
- Check script parameters in osync.sh and osync-batch.sh
- Run sync after timeout in --on-changes mode when no changes are detected (helps propagate slave changes)
- Fix for locking in --on-changes mode (child should lock/unlock, master process shouldn't unlock)
- Remote user is now optional in quicksync mode
- Replaced default script execution storage from /dev/shm to /tmp because some rootkit detection software doesn't like this
- Fixed bogus error in DEBUG for quicksync mode where no max execution time is set
- Prevent debug mode to send alert emails
- Fixed an infamous bug introduced with exclude pattern globbing preventing multiple exludes to be processed
- Fixed an issue with empty RSYNC_EXCLUDE_FILES
- Lowered default compression level for email alerts (for low end systems)
- Prevent exclude pattern globbing before the pattern reaches the rsync cmd
- Fixed some missing child pids for time control to work
- Prevent creation of a sync-id less log file when DEBUG is set
- Added a sequential run batch script that can rerun failed batches
- Fixed an issue where a failed task never gets resumed after a successfull file replication phase
- Added experimental partial downloads support for rsync so big files can be resumed on slow links
- Added the ability to keep partial downloads that can be resumed on next run (usefull for big files on slow links that reach max execution time)
- Moved msys specific code to Init(Local|Remote)OSSettings
- Added a patch by igngvs to fix some issues with Rsync Exclude files
- Added a patch by Gary Clark to fix some issues with remote deletion
- Minor fixes from obackup codebase
- Added compression method fallback (xz, lzma, pigz and gzip)
- Removed unused code
- Fixed remote OS detection when a banner is used on SSH
- Added a routine that reinjects failed deletions for next run in order to prevent bringing back when deletion failed with permission issues
- Added treat dir symlink as dir parameter
### 27 May 2014: Osync 0.99 RC3
- Additionnal delete fix for *BSD and MSYS (deleted file list not created right)
- Fixed dry mode to use non dry after run treelists to create delete lists
- Added follow symlink parameter
- Minor fixes in parameter list when bandwidth parameter is used
- Added some additionnal checks for *BSD and MacOS environments
- Changed /bin/bash to /usr/bin/env bash for sanity on other systems, also check for bash presence before running
- Changed default behavior for quick sync tasks: Will try to resume failed sync tasks once
- Some code cleanup for state filenames and sync action names
- Fixed deletion propagation (again). Rsync is definitly not designed to delete a list of files / folders. Rsync replaced by rm function which downloads deletion list to remote system.
- Added path detection for exclude list file
- Added a simple init script and an install script
- Fixed an issue with MacOSX using rsync -E differently than other *nix (Thanks to Pierre Clement)
- Multislave asynchronous task support (Thanks to Ulrich Norbisrath)
- This breaks compat with elder osync runs. Add the SYNC_ID suffix to elder state files to keep deleted file information.
- Added an easier debug setting i.e DEBUG=yes ./osync.sh (Again, thanks to Ulrich Norbisrath)
- Added hardlink preservation (Thanks to Ulrich Norbisrath)
- Added external exclusion file support (Thanks to Pierre Clement)
- Fixed some typos in doc and program itself (Thanks to Pierre Clement)
- More detailled verbose status messages
- More detailled status messages
- Fixed a bug preventing propagation of empty directory deletions
- Fixed a nasty bug preventing writing lock files on remote system as superuser
- Gzipped logs are now deleted once sent
- Fixed some typos (thanks to Pavel Kiryukhin)
- Fixed a bug with double trailing slashes in certain sceanrios
- Sync execution don't fails anymore if files vanish during execution, also vanished files get logged
- Add eventual "comm -23" replacement by "grep -F -x -v -f" to enhance compatibility with other platforms (comm is still much faster than grep, so we keep it)
- Replaced xargs rm with find -exec rm to better handle file names in soft deletion
- Fixed soft deletion not happening with relative paths
- Improved process termination behavior
- More code merging and cleanup
- Fixed a bug preventing deleted files in subdirectories propagation (Thanks to Richard Faasen for pointing that out)
- Some more function merge in sync process
- Dry mode won't create or modifiy state files anymore and will use dry-state files instead
- Improved file monitor mode
- Added possibility to daemonize osync in monitor mode
- Added monitor mode, which will launch a sync task upon file operations on master replica
- Changed conf file default format for ssh uri (old format is still compatible)
- Added ssh uri support for slave replicas
- Improved execution hooks logs
- Various bugfixes introduced with function merge
- Added basic MacOS X support (yet not fully tested)
- Merged tree list functions into one
- Added possibility to quick sync two local directories without any prior configuration
- Added time control on OS detection
### 02 Nov. 2013: Osync 0.99 RC2
- Minor improvement on operating system detection
- Improved RunLocalCommand execution hook
- Minor improvements on permission checks
- Made more portability improvements (mostly for FreeBSD, must be run with bash shell)
- Added local and remote operating system detection
- Added forced usage of MSYS find on remote MSYS hosts
- Updated MSYS handling
- Merged MSYS (MinGW minimal system) bash compatibility under Windows from Obackup
- Added check for /var/log directory
- Added check for shared memory directory
- Added alternative way to kill child processes for other OSes and especially for MSYS (which is a very odd way)
- Added Sendemail.exe support for windows Alerting
- Replaced which commend by type -p, as it is more portable
- Added support for ping.exe from windows
- Forced usage of MSYS find instead of Windows' find.exe on master
- Added an optionnal remote rsync executable path parameter
- Fixed an issue with CheckConnectivity3rdPartyHosts
- Added an option to stop execution if a local / remote command fails
- Improved forced quit command by killing all child processes
- Before / after commands are now ignored on dryruns
- Improved verbose output
- Fixed various typos
- Enforced CheckConnectivityRemoteHost and CheckConnectivity3rdPartyHosts checks (if one of these fails, osync is stopped)
### 18 Aug. 2013: Osync 0.99 RC1
- Added possibility to change default logfile
- Fixed a possible error upon master replica lock check
- Fixed exclude directorires with spaces in names generate errros on master replica tree functions
- Dryruns won't create after run tree lists and therefore not prevent building real run delete lists
- Softdelete and conflict backup functions are now time controlled
- Added bandwidth limit
- Update and delete functions now run rsync with --stats parameter
- Fixed LoadConfigFile function will not warn on wrong config file
- Added --no-maxtime parameter for sync big changes without enforcing execution time checks
### 03 Aug. 2013: beta 3 milestone
- Softdelete functions do now honor --dry switch
- Simplified sync delete functions
- Enhanced compatibility with different charsets in filenames
- Added CentOS 5 compatibility (comm v5.97 without --nocheck-order function replaced by sort)
- Tree functions now honor supplementary rsync arguments
- Tree functions now honor exclusion lists
### 01 Aug. 2013: beta 2 milestone
- Fixed an issue with spaces in directory trees
- Fixed an issue with recursive directory trees
- Revamped a bit code to add bash 3.2 compatibility
### 24 Jul. 2013: beta milestone
- Fixed some bad error handling in CheckMasterSlaveDirs and LockDirectories
- Added support for spaces in sync dirs and exclude lists
- Fixed false exit code if no remote slave lock present
- Added minimum disk space checks
- Added osync support in ssh_filter.sh
- Added support for sudo exec on remote slave
- Added support for alternative rsync executable
- Added support for spaces in sync directories names
- Added support for ACL and xattr
- Added --force-unlock parameter to bypass any existing locks on replicas
- Added full remote support for slave replica
- Improved error detection
- Made some changes in execution hook output
- Fixed an issue with task execution handling exit codes
- Added master and slave replicas lock functionnality
- Added rsync exclude patterns support
- Improved backup items, can now have multiple backups of the same file
- Added maximum number of resume tries before trying a fresh stateless execution
- Added possibility to resume a sync after an error
- Improved task execution time handling
- Improved SendAlert handling
- Fixed cleanup launched even if DEBUG=yes
- Added verbose rsync output
- Added --dry and --silent parameters
- Added time control
- Added master/slave conflict prevalance option
- Added soft-deleted items
- Added backup items in case of conflict
### 19 Jun. 2013: Project begin as Obackup fork

View File

@ -1,156 +0,0 @@
Coding style used for my bash projects (v2.1 Oct 2015)
++++++ Header
Always use the following header
----BEGIN HEADER
#!/usr/bin/env bash
PROGRAM="program-name" # Long description
AUTHOR="(C) 20XX-20YY by Orsiris \"Ozy\" de Jong"
CONTACT="http://www.example.com me@example.com"
PROGRAM_BUILD=YYYYMMDDVV
## Optional instructions
----END HEADER
Using bind style versionning:
YYYYMMDDVV (Year, Month, Day, Revision): Example: 2015012402 = 2nd revision of 24 Jan 2015
#!/usr/bin/env bash instead of #!/bin/bash
Change old scripts with
for i in $(grep -r '#!/bin/bash' * |cut -f1 -d':'); do sed -i 's&#!/bin/bash&#!/usr/bin/env bash&g' $i; done
type instead of type -p for bash test (other shells don't know -p)
++++++ Indentation
Using tabs
Transform old shell scripts using unexpand command
++++++ Comments
Some command # comment
## Some comment on a new line
################################################# Some separation
++++++ Work comments
Whenever there is some idea to postpone, use #TODO[-version]:[dev-name:] some remark
A marker must be left where on the line a dev is working (when the work isn't finished). Marker is #WIP:dev-name: some remark
dev-name is mandatory if more than one person is coding
Example: #TODO-v2.1:deajan: need to do something
++++++ Variables
All local variables are lowercase, separated by _ (ex: low_wait)
All global variables full upercase, separated by _ (ex: EXEC_TIME)
All environment variables (verbose, silent, debug, etc) have prefix _ and are full upercase, separated by _ (ex: _PARANOIA_DEBUG)
++++++ Functions
Every word in a function begins with an uppercase (ex: SomeFunctionDoesThings)
Define functions this way. Use sed ':a;N;$!ba;s/\n{\n/ {\n/g' to adapt when opening bracket is on a new line.
function something {
}
If function has some arguments, use local variable names that are more readable than $1...$n. Explain via comments what those variables contain if needed.
function anotherthing {
local var_name="${1}"
local other_var_name="${2}" # This variable contains stuff
}
Functions should always have return status
function thirdthing {
some_command
return $?
}
++++++ Sub functions
When a function is a subroutine of another function, it is called _SomethingAsSubFunction
++++++ Function argument check
Bash does not provide any checks against missing function arguments. Also, missing quotes can lead to an inconsistent number of arguments.
Every function call will be checked by __CheckArguments which takes the number of arguments, $# (the real number of args given), the parent function name and the parent function's arguments.
__CheckArguments will trigger a critical error if number of arguments if incorrect. This will also prevent silent typo errors.
Ex:
function Something {
local some="${1}"
local other="${2}"
local args="${3}"
__CheckArguments 3 $# $FUNCNAME "$*"
__CheckArguments will only trigger if script is called with DEBUG=yes
Also, with PARANOIA_DEBUG=yes, __CheckArguments will recount all arguments given by "$*" and compare. This can mislead if arguments contain spaces.
++++++ If statements
If statements will be fully written (word "if" must be used). then is written on the same line.
(Use sed ':a;N;$!ba;s/]\n\t*then/]; then/g' to convert files to this format... Replace "],new line, zero or more tabs, then" by "; then")
if [ something ]; then
stuff
else
other stuff
fi
++++++ Logging
A logging function is available with the following levels of logging:
- DEBUG: Only log this when DEBUG flas is set in program. Any command forged for eval should be logged by this.
- NOTICE: Standard messages
- WARN: Requires attention
- ERROR: Program produced an error but continues execution
- CRITICAL: Program execution is halted
++++++ Eval
Most commands should be logged to a tmp file.
The basic way of doing is:
cmd='"something '$somevar'" > some_file 2>&1'
eval $cmd &
WaitForTaskCompletion $! 0 0 $FUNCNAME
Remote commands should exist as:
cmd=$SSH_CMD' "some; commands \"'$VARIABLE'\" some; other; commands" > some_file 2>&1'
++++++ File variables
All eval cmd should exit their content to a file called "$RUNDIR/osync.$FUNCNAME.$SCRIPT_PID"
Dots are used instead of '_' so variables can be separated with a forbidden char in variables, so they get detected.
++++++ Finding code errors
Use shellcheck.net now and then (ignore SC2086 in our case)
Use a low tech approach to find uneven number of quotes per line
tr -cd "'\n" < my_bash_file.sh | awk 'length%2==1 {print NR, $0}'
tr -cd "\"\n" < my_bash_file.sh | awk 'length%2==1 {print NR, $0}'
++++++ ofunctions
As obackup and osync share alot of common functions, ofunctions.sh will host all shared code.
Dev programs n_osync.sh and n_obackup.sh will source ofunctions.sh
Release programs will still include ofunctions.sh in order to enhance ease of use.
Ofunctions are defined like:
#__FUNC:FunctionName
function FunctionName {
}
#__ENDFUNC
These functions are inserted into code that has placeholders like #__FUNC:FuncName

6
KNOWNISSUES.md Normal file
View File

@ -0,0 +1,6 @@
## KNOWN ISSUES
- Cannot finish sync if one replica contains a directory and the other replica contains a file named the same way (Unix doesn't allow this)
- Daemon mode monitors changes in the whole replica directories, without honoring exclusion lists
- Soft deletion does not honor exclusion lists (ie soft deleted files will be cleaned regardless of any exlude pattern because they are in the deleted folder)
- Colors don't work in mac shell

View File

@ -1,4 +1,4 @@
Copyright (c) 2013-2016, Orsiris de Jong. ozy@netpower.fr
Copyright (c) 2013-2023, Orsiris de Jong. ozy@netpower.fr
All rights reserved.
Redistribution and use in source and binary forms, with or without

4
PULL_REQUEST_TEMPLATE.md Normal file
View File

@ -0,0 +1,4 @@
When submitting a pull request, please modify the files in dev directory rather than those generated on-the-fly.
You may find all code contained in osync.sh in n_osync.sh and ofunctions.sh
You may run your modified code by using `merge.sh osync` in order to generate ../osync.sh

252
README.md
View File

@ -1,107 +1,176 @@
osync
=====
# osync
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
[![GitHub Release](https://img.shields.io/github/release/deajan/osync.svg?label=Latest)](https://github.com/deajan/osync/releases/latest)
[![Percentage of issues still open](http://isitmaintained.com/badge/open/deajan/osync.svg)](http://isitmaintained.com/project/deajan/osync "Percentage of issues still open")
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/651acb2fd64642eb91078ba523b7f887)](https://www.codacy.com/app/ozy/osync?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=deajan/osync&amp;utm_campaign=Badge_Grade)
[![linux tests](https://github.com/deajan/osync/actions/workflows/linux.yml/badge.svg)](https://github.com/deajan/osync/actions/workflows/linux.yml/badge.svg)
[![windows tests](https://github.com/deajan/osync/actions/workflows/windows.yml/badge.svg)](https://github.com/deajan/osync/actions/workflows/windows.yml/badge.svg)
[![macos tests](https://github.com/deajan/osync/actions/workflows/macos.yml/badge.svg)](https://github.com/deajan/osync/actions/workflows/macos.yml/badge.svg)
A two way filesync script with fault tolerance, resume, soft deletion, conflictual file backups running on bash (linux, BSD and virtually any system supporting bash).
File synchronization is bidirectional, based on rsync, can be run manually, as scheduled task, or triggered on file changes.
A two way filesync script running on bash Linux, BSD, Android, MacOSX, Cygwin, MSYS2, Win10 bash and virtually any system supporting bash.
File synchronization is bidirectional, and can be run manually, as scheduled task, or triggered on file changes in monitor mode.
It is a command line tool rsync wrapper with a lot of additional features baked in.
This is a quickstart guide, you can find the full documentation on the [author's site](http://www.netpower.fr/osync).
## About
Osync provides the following capabilities
- Fault tolerance with resume scenarios
- Email alerts
- Logging facility
- Soft deletition and multiple backups handling
- Before / after command execution
- Time control
- Directory monitoring
- Running on schedule or as daemon
- Batch runner for multiple sync tasks with rerun option for failed sync tasks
- ACL synchronization
osync provides the following capabilities:
osync uses a initiator / target sync schema. It can sync local to local or local to remote directories. By definition, initiator replica is always a local directory on the system osync runs on.
osync uses pidlocks to prevent multiple concurrent sync processes on/to the same initiator / target replica.
You may launch concurrent sync processes on the same system but only for different initiator replicas.
osync tasks may be launched sequentially by osync osync-batch tool.
- Local-Local and Local-Remote sync
- Fault tolerance with resume scenarios
- POSIX ACL and extended attributes synchronization
- Full script Time control
- Soft deletions and multiple backups handling
- Before/after run command execution
- Email alerts
- Logging facility
- Directory monitoring
- Running on schedule or as daemon
- Batch runner for multiple sync tasks with rerun option for failed sync tasks
Currently, it has been tested on CentOS 5.x, 6.x, 7.x, Debian 6, Debian 7, Linux Mint 14-17, Ubuntu 12.04, 12.10, FreeBSD 8.3, 10.1, 10.3, Mac OS X and pfSense.
Microsoft Windows is supported via MSYS or Cygwin.
osync is a stateful synchronizer. This means it's agentless and doesn't have to monitor files for changes. Instead, it compares replica file lists between two runs.
A full run takes about 2 seconds on a local-local replication and about 7 seconds on a local-remote replication.
Disabling some features file like attributes preservation and disk space checks may speed up execution.
osync uses a initiator/target sync schema. It can sync local to local or local to remote directories. By definition, initiator replica is always a local directory on the system osync runs on.
osync uses pidlocks to prevent multiple concurrent sync processes on/to the same initiator/target replica.
You may launch concurrent sync processes on the same system but as long as the replicas to synchronize are different.
Multiple osync tasks may be launched sequentially by osync osync-batch tool.
## Tested platforms
| Operating system | Version |
|------------------|------------------------|
| AlmaLinux | 9 |
| Android\* | Not known |
| CentOS | 5.x, 6.x, 7.x |
| Fedora | 22-25 |
| FreeBSD | 8.3-11 |
| Debian | 6-11 |
| Linux Mint | 14-18 |
| macOS | Not known |
| pfSense | 2.3.x |
| QTS (x86) | 4.5.1 |
| Ubuntu | 12.04-22.04 |
| Windows\*\* | 10 |
\* via Termux.
\*\* via MSYS, Cygwin and WSL.
Some users also have successfully used osync on Gentoo and created an OpenRC init script for it.
## Installation
Osync has been designed to not delete any data, but rather make backups of conflictual files or soft deletes.
osync has been designed to not delete any data, but rather make backups of conflictual files or soft deletes.
Nevertheless, you should always have a neat backup of your data before trying a new sync tool.
You can download the latest stable release of Osync at www.netpower.fr/osync or https://github.com/deajan/osync/archive/v1.1.tar.gz
Getting osync via GitHub (remove the -b "stable" if you want latest dev snapshot)
You may also get the last development version at https://github.com/deajan/osync with the following command
$ git clone -b "stable" https://github.com/deajan/osync
$ cd osync
$ bash install.sh
$ git clone -b "v1.1" https://github.com/deajan/osync
$ sh install.sh
Installer script accepts some parameters for automation. Launch install.sh --help for options.
Osync will install itself to /usr/local/bin and an example configuration file will be installed to /etc/osync
There is also an RPM file that should fit RHEL/CentOS/Fedora and basically any RPM based distro, see the GitHub release.
Please note that RPM files will install osync to `/usr/bin` instead of `/usr/local/bin` in order to enforce good practices.
Osync needs to run with bash shell. Using any other shell will most probably result in errors.
osync will install itself to `/usr/local/bin` and an example configuration file will be installed to `/etc/osync`.
osync needs to run with bash shell. Using any other shell will most probably result in errors.
If bash is not your default shell, you may invoke it using
$ bash osync.sh [options]
On *BSD, be sure to have bash installed.
On MSYS, On top of your basic install, you need msys-rsync and msys-coreutils-ext packages.
On *BSD and BusyBox, be sure to have bash installed.
## Upgrade from v1.0x
If you can't install osync, you may just copy osync.sh where you needed and run it from there.
Arch Linux packages are available at <https://aur.archlinux.org/packages/osync/> (thanks to Shadowigor, <https://github.com/shadowigor>).
## Upgrade from previous configuration files
Since osync v1.1 the config file format has changed in semantics and adds new config options.
Also, master is now called initiator and slave is now called target.
osync v1.3 also added multiple new configuration options.
You can upgrade all v1.0x-v1.1-dev config files by running the upgrade script
You can upgrade all v1.0x-v1.3-dev config files by running the upgrade script
$ ./upgrade-v1.0x-v1.1x.sh /etc/osync/your-config-file.conf
$ ./upgrade-v1.0x-v1.3x.sh /etc/osync/your-config-file.conf
The script will backup your config file, update it's content and try to connect to initiator and target replicas to update the state dir.
## Usage
Osync can work with in three flavors: Quick sync mode, configuration file mode, and daemon mode.
While quick sync mode is convenient to do fast syncs between some directories, a configuration file gives much more functionnality.
Please use double quotes as path delimiters. Do not use escaped characters in path names.
Osync can work in 3 modes:
1. [:rocket: Quick sync mode](#quick-sync-mode)
2. [:gear: Configuration file mode](#configuration-file-mode)
3. [:mag_right: Monitor mode](#monitor-mode)
> [!NOTE]
> Please use double quotes as path delimiters. Do not use escaped characters in path names.
### <a id="quick-sync-mode"></a>:rocket: Quick sync mode
Quick sync mode is convenient to do fast syncs between some directories. However, the [configuration file mode](#configuration-file-mode) gives much more functionality.
QuickSync example
-----------------
# osync.sh --initiator="/path/to/dir1" --target="/path/to/remote dir2"
# osync.sh --initiator="/path/to/another dir" --target="ssh://user@host.com:22//path/to/dir2" --rsakey=/home/user/.ssh/id_rsa_private_key_example.com
Running osync with a Configuration file
---------------------------------------
You'll have to customize the sync.conf file according to your needs.
If you intend to sync a remote directory, osync will need a pair of private / public RSA keys to perform remote SSH connections.
Also, running sync as superuser requires to configure /etc/sudoers file.
Please read the documentation about remote sync setups.
Once you've customized a sync.conf file, you may run osync with the following test run:
#### Quick sync with minimal options
In order to run osync the quickest (without transferring file attributes, without softdeletion, without prior space checks and without remote connectivity checks, you may use the following:
# MINIMUM_SPACE=0 PRESERVE_ACL=no PRESERVE_XATTR=no SOFT_DELETE_DAYS=0 CONFLICT_BACKUP_DAYS=0 REMOTE_HOST_PING=no osync.sh --initiator="/path/to/another dir" --target="ssh://user@host.com:22//path/to/dir2" --rsakey=/home/user/.ssh/id_rsa_private_key_example.com
All the settings described here may also be configured in the conf file.
### Summary mode
osync will output only file changes and errors with the following:
# osync.sh --initiator="/path/to/dir1" --target="/path/to/dir" --summary --errors-only --no-prefix
This also works in configuration file mode.
### <a id="configuration-file-mode"></a>:gear: Configuration file mode
You'll have to customize the `sync.conf` file according to your needs.
If you intend to sync a remote directory, osync will need a pair of private/public RSA keys to perform remote SSH connections. Also, running sync as superuser requires to configure the `/etc/sudoers` file.
> [!TIP]
> Read the [example configuration file](https://github.com/deajan/osync/blob/master/sync.conf.example) for documentation about remote sync setups.
Once you've customized a `sync.conf` file, you may run osync with the following test run:
# osync.sh /path/to/your.conf --dry
If everything went well, you may run the actual configuration with one of the following:
If everything went well, you may run the actual configuration with:
# osync.sh /path/to/your.conf
To display which files and attrs are actually synchronized and which files are to be soft deleted / are in conflict, use `--verbose` (you may mix it with `--silent` to output verbose input only in the log files):
# osync.sh /path/to/your.conf --verbose
# osync.sh /path/to/your.conf --no-maxtime
Verbose option will display which files and attrs are actually synchronized and which files are to be soft deleted / are in conflict.
You may mix "--silent" and "--verbose" parameters to output verbose input only in the log files.
No-Maxtime option will disable execution time checks, which is usefull for big initial sync tasks that might take long time. Next runs should then only propagate changes and take much less time.
Use `--no-maxtime` to disable execution time checks, which is usefull for big initial sync tasks that might take long time. Next runs should then only propagate changes and take much less time:
# osync.sh /path/to/your.conf --no-maxtime
Once you're confident about your fist runs, you may add osync as cron task like the following in /etc/crontab which would run osync every 30 minutes:
Once you're confident about your first runs, you may add osync as a cron task like the following in `/etc/crontab` which would run osync every 30 minutes:
*/30 * * * * root /usr/local/bin/osync.sh /etc/osync/my_sync.conf --silent
Batch mode
----------
Please note that this syntax works for RedHat/CentOS. On Debian you might want to remove the username (i.e. root) in order to make the crontab entry work.
You may want to sequentially run multiple sync sets between the same servers. In that case, osync-batch.sh is a nice tool that will run every osync conf file, and, if a task fails,
### Batch mode
You may want to sequentially run multiple sync sets between the same servers. In that case, `osync-batch.sh` is a nice tool that will run every osync conf file, and, if a task fails,
run it again if there's still some time left.
The following example will run all .conf files found in /etc/osync, and retry 3 times every configuration that fails, if the whole sequential run took less than 2 hours.
To run all `.conf` files found in `/etc/osync`, and retry 3 times every configuration that fails if the whole sequential run took less than 2 hours, use:
# osync-batch.sh --path=/etc/osync --max-retries=3 --max-exec-time=7200
@ -109,34 +178,75 @@ Having multiple conf files can then be run in a single cron command like
00 00 * * * root /usr/local/bin/osync-batch.sh --path=/etc/osync --silent
Daemon mode
-----------
Additionnaly, you may run osync in monitor mode, which means it will perform a sync upon file operations on initiator replica.
This can be a drawback on functionnality versus scheduled mode because this mode only launches a sync task if there are file modifications on the initiator replica, without being able to monitor the target replica.
Target replica changes are only synced when initiator replica changes occur, or when a given amount of time (default 600 seconds) passed without any changes on initiator replica.
File monitor mode can also be launched as a daemon with an init script. Please read the documentation for more info.
Note that monitoring changes requires inotifywait command (inotify-tools package for most Linux distributions).
BSD, MacOS X and Windows are not yet supported for this operation mode, unless you find a inotify-tools package on these OSes.
### <a id="monitor-mode"></a>:mag_right: Monitor mode
> [!NOTE]
> Monitoring changes requires inotifywait command (`inotify-tools` package for most Linux distributions). BSD, macOS and Windows are not yet supported for this operation mode, unless you find an `inotify-tool` package on these OSes.
Monitor mode will perform a sync upon file operations on initiator replica. This can be a drawback on functionality versus scheduled mode because this mode only launches a sync task if there are file modifications on the initiator replica, without being able to monitor the target replica. Target replica changes are only synced when initiator replica changes occur, or when a given amount of time (600 seconds by default) passed without any changes on initiator replica.
This mode can also be launched as a daemon with an init script. Please read the documentation for more info.
To use this mode, use `--on-changes`:
# osync.sh /etc/osync/my_sync.conf --on-changes
Osync file monitor mode may be run as system service with the osync-srv init script. Any configuration file found in /etc/osync will then create a osync daemon instance.
You may run the install.sh script which should work in most cases or copy the files by hand (osync.sh to /usr/bin/local, osync-srv to /etc/init.d, sync.conf to /etc/osync).
To run this mode as a system service with the `osync-srv` script, you can run the `install.sh` script (which should work in most cases) or copy the files by hand:
- `osync.sh` to `/usr/bin/local`
- `sync.conf` to `/etc/osync`
- For InitV, `osync-srv` to `/etc/init.d`
- For systemd, `osync-srv@.service` to `/usr/lib/systemd/system`
- For OpenRC, `osync-srv-openrc` to `/etc/init.d/osync-srv-openrc`
For InitV (any configuration file found in `/etc/osync` will create an osync daemon instance when service is launched on initV):
$ service osync-srv start
$ chkconfig osync-srv on
Systemd specific (one service per config file)
For systemd, launch service (one service per config file to launch) with:
$ systemctl start osync-srv@configfile.conf
$ systemctl enable osync-srv@configfile.conf
Troubleshooting
---------------
You may find osync's logs in /var/log/osync.*.log (or current directory if /var/log is not writable).
For OpenRC (user contrib), launch service (one service per config file to launch) with:
$ rc-update add osync-srv.configfile default
## Security enhancements
Remote SSH connection security can be improved by limiting what hostnames may connect, disabling some SSH options and using ssh filter.
Please read full documentation in order to configure ssh filter.
## Contributions
All kind of contribs are welcome.
When submitting a PR, please be sure to modify files in dev directory (`dev/n_osync.sh`, `dev/ofunctions.sh`, `dev/common_install.sh etc`) as most of the main files are generated via merge.sh.
When testing your contribs, generate files via merge.sh or use bootstrap.sh which generates a temporary version of n_osync.sh with all includes.
Unit tests are run by travis on every PR, but you may also run them manually which adds some tests that travis can't do, via `dev/tests/run_tests.sh`.
SSH port can be changed on the fly via environment variable SSH_PORT, e.g.:
# SSH_PORT=2222 dev/tests/run_tests.sh
Consider reading CODING_CONVENTIONS.TXT before submitting a patch.
## Troubleshooting
You may find osync's logs in `/var/log/osync.[INSTANCE_ID].log` (or current directory if `/var/log` is not writable).
Additionnaly, you can use the --verbose flag see to what actions are going on.
When opening an issue, please post the corresponding log files. Also, you may run osync with _DEBUG option in order to have more precise logs, e.g.:
# _DEBUG=yes ./osync.sh /path/to/conf
## Uninstalling
The installer script also has an uninstall mode that will keep configuration files. Use it with
$ ./install.sh --remove
## Author
Feel free to mail me for limited support in my free time :)
Feel free to open an issue on GitHub or mail me for support in my spare time :)
Orsiris de Jong | ozy@netpower.fr

276
dev/CODING_CONVENTIONS.TXT Normal file
View File

@ -0,0 +1,276 @@
Coding style used for my bash projects (v3.2 Oct 2018)
As bash is clearly an error prone script language, we'll use as much standard coding as possible, including some quick and dirty debug techniques described here.
++++++ Header
Always use the following header
----BEGIN HEADER
#!/usr/bin/env bash
PROGRAM="program-name" # Long description
AUTHOR="(C) 20XX-20YY by Orsiris de Jong"
CONTACT="http://www.example.com me@example.com"
PROGRAM_BUILD=YYYYMMDDVV
## Optional instructions
----END HEADER
Using bind style versionning:
YYYYMMDDVV (Year, Month, Day, Revision): Example: 2015012402 = 2nd revision of 24 Jan 2015
#!/usr/bin/env bash instead of #!/bin/bash
Change old scripts with
for i in $(grep -r '#!/bin/bash' * |cut -f1 -d':'); do sed -i 's&#!/bin/bash&#!/usr/bin/env bash&g' $i; done
type instead of type -p for bash test (other shells don't know -p)
++++++ Indentation
Using tabs
Transform old shell scripts using unexpand command
++++++ Comments
Some command # comment
## Some comment on a new line
################################################# Some separation
++++++ Work comments
Whenever there is some idea to postpone, use #TODO(priority):[dev-name:] some remark
Priority can be critical, high, medium, low, verylow. No release can happen if there are TODOs other than low or verylow.
Example: #TODO(high):deajan: need to do something
A "work in progress" marker must be left on the line a dev is working when it's work isn't finished). Marker is #WIP:dev-name: some remark
dev-name is mandatory if more than one person is coding
Example: #WIP:deajan: missing function something
++++++ Variables
All local variables names have each first letter of the words uppercase and all others lowercase, except for the first word where all letters are lowercase
Example: someLongVariable
All global variables are full upercase, separated by _
Example: EXEC_TIME
All environment variables (verbose, silent, debug, etc) have prefix _ and are full upercase, separated by _
Example: _PARANOIA_DEBUG
Exec time variables that can take boolean values should use true and false instead of 1 and 0.
++++++ Functions
All function names should begin with an uppercase letter for every word, the other letters should be lowercase
Example: SomeFunctionThatRocks
Bash does not provide any checks against missing function arguments. Also, missing quotes can lead to an inconsistent number of arguments.
Most functions should have a first line that calls the special function __CheckArguments, which checks the number of given arguments for a function in order
to find possible problems. Number of arguments are given as first argument to __CheckArguments. May be a number or a range, eg 0-2 if the function takes optional arguments.
__CheckArguments will only trigger when the script is launched with _PARANOIA_DEBUG=yes. Also, it will only exist in the debug version.
Use the following convention for function definition:
function SomeFunction {
__CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG
...
}
Use sed ':a;N;$!ba;s/\n{\n/ {\n/g' to convert functions that have opening brackets on a new line.
If the function has arguments, use local variable names that are more readable than $1...$n. Explain via comments what those variables contain if needed.
Declare arguments before launching __CheckArguments:
function AnotherFunction {
local varName="${1}"
local otherVarName="${2}" # This variable contains stuff
__CheckArguments 2 $# "$@" #__WITH_PARANOIA_DEBUG
...
}
Functions should always have return status
function RandomFunction {
...
return $?
}
++++++ Sub functions
When a function is a subroutine of another function, it is called _SomethingAsSubFunction:
Example:
function _ApplyLocally
function _ApplyRemotely
function Apply
++++++ For and While statements
For and while statements will have the "do" part on the first line.
Example:
for i in "${var[@]}"; do
...
done
while [ $i -eq 1 ]; do
...
done
++++++ If statements
If statements will be fully written (word "if" must be used). then is written on the same line.
(Use sed ':a;N;$!ba;s/]\n\t*then/]; then/g' to convert files to this format... Replace "],new line, zero or more tabs, then" by "; then")
if [ something ]; then
stuff
else
other stuff
fi
++++++ Logging
A logging function is available that writes both to log file and stdout/stderr.
It has the following global variable modifiers:
_LOGGER_SILENT=true/false: disables any output to stdout/stderr
_LOGGER_VERBOSE=true/false: logs messages with log level VERBOSE
_LOGGER_ERR_ONLY=true/false: disables logging to log file and stdout/stderr except for CRITICAL, ERROR, WARN and ALWAYS log levels.
The following log levels exist:
- PARANOIA_DEBUG: Only used by debugging functions themselves
- DEBUG: Only log this when _DEBUG flag is set in program. Any command forged for eval instruction should be logged by this.
- NOTICE: Standard messages
- ALWAYS: Standard messages, regardless of _LOGGER_ERR_ONLY
- WARN: Requires attention
- ERROR: Program produced an error but continues execution
- CRITICAL: Program execution is halted
Can be called with:
Logger "My message" "LOGLEVEL" $retval
$retval is an optional parameter that passes the exit code of the command that triggered the logging message
$retval, along with function stack, script pid and current pid can be found in the ERROR /WARN alert files ($RUN_DIR/$PROGRAM.Logger.error.$SCRIPT_PID)
++++++ Eval
Most commands should be logged to a tmp file.
The basic way of doing is:
cmd='"something '$somevar'" > some_file 2>&1'
eval $cmd &
WaitForTaskCompletion $! 0 0 1 0 true false true false
retval=$?
if [ $retval -ne 0 ]; then
Logger "Some error message" "ERROR" $retval
fi
++++++ includes
Using merge.sh, the program may have includes like
include #### RemoteLogger SUBSET ####
All possible includes are listed in ofunctions.sh
Mostly, includes are needed to port functions to a remote shell without writing them again.
++++++ Remote execution
Remote commands should always invoke bash (using '"'"' to escape single quotes of 'bash -c "command"'). It is preferable to use ssh heredoc in order to use plain code.
If local and remote code is identical, wrap remote code in a function so only minor modifications are needed.
Remote code return code is transmitted via exit.
cmd=$SSH_CMD' '"'"'bash -c "some; commands \"'$VARIABLE'\" some; other; commands" > some_file'"'"' 2>&1'
Better formule
$SSH_CMD remoteVar="'$localVar'" 'bash -s' << 'ENDSSH' > 2>&1
function remoteSub {
some code
return 0
}
remoteSub
exit $?
ENDSSH
retval=$?
if [ $retval -ne 0 ]; then
Logger "Some error message" "ERROR" $retval
fi
We also need to transmit a couple of environment variables (RUN_DIR; PROGRAM; _LOGGER_VERBOSE... see current setups) in order to make standard code.
Include works here too.
++++++ File variables
All eval cmd should exit their content to a file called "$RUNDIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID"
Dots are used instead of '_' so variables can be separated with a forbidden char in variable names, so the separtors apply as wished.
++++++ String function calls
String returning functions should only be called this way in order to deal with spaces:
Quoting happens outside the function call.
echo "$(myStringFunction $myStringVar)"
++++++ ofunctions
As obackup and osync share alot of common functions, ofunctions.sh will host all shared code.
Dev programs n_osync.sh and n_obackup.sh will source ofunctions.sh
Release programs will still include ofunctions.sh in order to enhance ease of use.
Ofunctions are defined like:
#__FUNC:FunctionName
function FunctionName {
}
#__ENDFUNC
These functions are inserted into code that has placeholders like #__FUNC:FuncName
+++++++ includes
ofunctions parts can be directly included in shell scripts.
The parts that needs to be included must be contained within specific comments:
#### MyFunction SUBSET ####
function MyFunction {
...
}
#### MyFunction SUBSET END ####
These can later be included in shell scripts with:
include #### MyFunction SUBSET ####
In order to have those includes parsed, we use bootstrap.sh to launch the original shell script.
Original shell script will not work because include is not a bash statement.
Include the following code into original shell script
include #### _OFUNCTIONS_BOOTSTRAP SUBSET ####
[ "$_OFUNCTIONS_BOOTSTRAP" != true ] && echo "Please use bootstrap.sh to load this dev version of $(basename $0)" && exit 1
+++++++ Exit codes
Normal exit code = 0
Run with errors exit code = 1
Run with warnings exit code = 2
Wrong shell exit code = 127
Usage function exit code = 128
+++++++ Detailled debugging
When launching the program with 'bash -x', add SLEEP_TIME=1 so wait functions won't spam output
Ex:
SLEEP_TIME=1 bash -x ./program.sh
++++++ Finding code errors
Before every release, shellcheck must be run
Also a grep -Eri "TODO|WIP" osync/* must be run in order to find potential release blockers
Use shellcheck.net now and then (ignore SC2086 in our case)
Use a low tech approach to find uneven number of quotes per line
tr -cd "'\n" < my_bash_file.sh | awk 'length%2==1 {print NR, $0}'
tr -cd "\"\n" < my_bash_file.sh | awk 'length%2==1 {print NR, $0}'

17
dev/RELEASES Normal file
View File

@ -0,0 +1,17 @@
## Releases require the following
- Documentation must be up to date
- grep -Eri "TODO|WIP" osync/* must be run in order to find potential release blockers, including in unit tests and config files
Run program and then use declare -p to find any leaked variables that should not exist outside of the program
- packaging files must be updated (RHEL / Arch)
- Before every release, shellcheck must be run
- ./shellcheck.sh -e SC2034 -e SC2068 ofunctions.sh
- ./shellcheck.sh n_osync.sh
- ./shellcheck.sh ../install.sh
- ./shellcheck.sh ../osync-batch.sh
- ./shellcheck.sh ../ssh_filter.sh
- Unexpansion of main and subprograms must be done
- Arch repo must be updated
- Source must be put to download on www.netpower.fr/osync
- Tests must be run against all supported operating systems via run_tests.sh

75
dev/bootstrap.sh Executable file
View File

@ -0,0 +1,75 @@
#!/usr/bin/env bash
## dev pre-processor bootstrap rev 2019052001
## Yeah !!! A really tech sounding name... In fact it's just include emulation in bash
function Usage {
echo "$0 - Quick and dirty preprocessor for including ofunctions into programs"
echo "Creates and executes $0.tmp.sh"
echo "Usage:"
echo ""
echo "$0 --program=osync|obackup|pmocr [options to pass to program]"
echo "Can also be run with BASHVERBOSE=yes environment variable in order to prefix program with bash -x"
}
if [ ! -f "./merge.sh" ]; then
echo "Plrase run bootstrap.sh from osync/dev directory."
exit 1
fi
bootstrapProgram=""
opts=()
outputFileName="$0"
for i in "${@}"; do
case "$i" in
--program=*)
bootstrapProgram="${i##*=}"
;;
*)
opts+=("$i")
;;
esac
done
if [ "$bootstrapProgram" == "" ]; then
Usage
exit 128
else
source "merge.sh"
__PREPROCESSOR_PROGRAM=$bootstrapProgram
__PREPROCESSOR_PROGRAM_EXEC="n_$bootstrapProgram.sh"
__PREPROCESSOR_Constants
if [ ! -f "$__PREPROCESSOR_PROGRAM_EXEC" ]; then
echo "Cannot find file $__PREPROCESSOR_PROGRAM executable [n_$bootstrapProgram.sh]."
exit 1
fi
fi
cp "$__PREPROCESSOR_PROGRAM_EXEC" "$outputFileName.tmp.sh"
if [ $? != 0 ]; then
echo "Cannot copy original file [$__PREPROCESSOR_PROGRAM_EXEC] to [$outputFileName.tmp.sh]."
exit 1
fi
for subset in "${__PREPROCESSOR_SUBSETS[@]}"; do
__PREPROCESSOR_MergeSubset "$subset" "${subset//SUBSET/SUBSET END}" "ofunctions.sh" "$outputFileName.tmp.sh"
done
chmod +x "$outputFileName.tmp.sh"
if [ $? != 0 ]; then
echo "Cannot make [$outputFileName] executable."
exit 1
fi
# Termux fix
if type termux-fix-shebang > /dev/null 2>&1; then
termux-fix-shebang "$outputFileName.tmp.sh"
fi
if [ "$BASHVERBOSE" == "yes" ]; then
bash -x "$outputFileName.tmp.sh" "${opts[@]}"
else
"$outputFileName.tmp.sh" "${opts[@]}"
fi

157
dev/common_batch.sh Executable file
View File

@ -0,0 +1,157 @@
#!/usr/bin/env bash
SUBPROGRAM=[prgname]
PROGRAM="$SUBPROGRAM-batch" # Batch program to run osync / obackup instances sequentially and rerun failed ones
AUTHOR="(L) 2013-2020 by Orsiris de Jong"
CONTACT="http://www.netpower.fr - ozy@netpower.fr"
PROGRAM_BUILD=2020031502
## Runs an osync /obackup instance for every conf file found
## If an instance fails, run it again if time permits
if ! type "$BASH" > /dev/null; then
echo "Please run this script only with bash shell. Tested on bash >= 3.2"
exit 127
fi
## If maximum execution time is not reached, failed instances will be rerun. Max exec time is in seconds. Example is set to 10 hours.
MAX_EXECUTION_TIME=36000
## Specifies the number of total runs an instance may get
MAX_RUNS=3
## Log file path
if [ -w /var/log ]; then
LOG_FILE=/var/log/$SUBPROGRAM-batch.log
else
LOG_FILE=./$SUBPROGRAM-batch.log
fi
## Default directory where to store temporary run files
if [ -w /tmp ]; then
RUN_DIR=/tmp
elif [ -w /var/tmp ]; then
RUN_DIR=/var/tmp
else
RUN_DIR=.
fi
# No need to edit under this line ##############################################################
include #### Logger SUBSET ####
include #### CleanUp SUBSET ####
include #### GenericTrapQuit SUBSET ####
function CheckEnvironment {
## osync / obackup executable full path can be set here if it cannot be found on the system
if ! type $SUBPROGRAM.sh > /dev/null 2>&1
then
if [ -f /usr/local/bin/$SUBPROGRAM.sh ]
then
SUBPROGRAM_EXECUTABLE=/usr/local/bin/$SUBPROGRAM.sh
else
Logger "Could not find [/usr/local/bin/$SUBPROGRAM.sh]" "CRITICAL"
( >&2 echo "Could not find [/usr/local/bin/$SUBPROGRAM.sh]" )
exit 1
fi
else
SUBPROGRAM_EXECUTABLE=$(type -p $SUBPROGRAM.sh)
fi
if [ "$CONF_FILE_PATH" == "" ]; then
Usage
fi
}
function Batch {
local runs=1 # Number of batch runs
local runList # Actual conf file list to run
local runAgainList # List of failed conf files sto run again
local confFile
local result
local i
# Using -e because find will accept directories or files
if [ ! -e "$CONF_FILE_PATH" ]; then
Logger "Cannot find conf file path [$CONF_FILE_PATH]." "CRITICAL"
Usage
else
# Ugly hack to read files into an array while preserving special characters
runList=()
while IFS= read -d $'\0' -r file; do runList+=("$file"); done < <(find "$CONF_FILE_PATH" -maxdepth 1 -iname "*.conf" -print0)
while ([ $MAX_EXECUTION_TIME -gt $SECONDS ] || [ $MAX_EXECUTION_TIME -eq 0 ]) && [ "${#runList[@]}" -gt 0 ] && [ $runs -le $MAX_RUNS ]; do
runAgainList=()
Logger "Sequential run n°$runs of $SUBPROGRAM instances for:" "NOTICE"
for confFile in "${runList[@]}"; do
Logger "$(basename $confFile)" "NOTICE"
done
for confFile in "${runList[@]}"; do
$SUBPROGRAM_EXECUTABLE "$confFile" --silent $opts &
wait $!
result=$?
if [ $result != 0 ]; then
if [ $result == 1 ] || [ $result == 128 ]; then # Do not handle exit code 128 because it is already handled here
Logger "Instance $(basename $confFile) failed with exit code [$result]." "ERROR"
runAgainList+=("$confFile")
elif [ $result == 2 ]; then
Logger "Instance $(basename $confFile) finished with warnings." "WARN"
fi
else
Logger "Instance $(basename $confFile) succeed." "NOTICE"
fi
done
runList=("${runAgainList[@]}")
runs=$((runs + 1))
done
fi
}
function Usage {
echo "$PROGRAM $PROGRAM_BUILD"
echo "$AUTHOR"
echo "$CONTACT"
echo ""
echo "Batch script to sequentially run osync or obackup instances and rerun failed ones."
echo "Usage: $PROGRAM.sh [OPTIONS] [$SUBPROGRAM OPTIONS]"
echo ""
echo "[OPTIONS]"
echo "--path=/path/to/conf Path to osync / obackup conf files, defaults to /etc/osync or /etc/obackup"
echo "--max-runs=X Number of max runs per instance, (defaults to 3)"
echo "--max-exec-time=X Retry failed instances only if max execution time not reached (defaults to 36000 seconds). Set to 0 to bypass execution time check"
echo "[$SUBPROGRAM OPTIONS]"
echo "Specify whatever options $PROGRAM accepts. Example"
echo "$PROGRAM.sh --path=/etc/$SUBPROGRAM --no-maxtime"
echo ""
echo "No output will be written to stdout/stderr."
echo "Verify log file in [$LOG_FILE]."
exit 128
}
trap GenericTrapQuit TERM EXIT HUP QUIT
opts=""
for i in "$@"
do
case $i in
--path=*)
CONF_FILE_PATH=${i##*=}
;;
--max-runs=*)
MAX_RUNS=${i##*=}
;;
--max-exec-time=*)
MAX_EXECUTION_TIME=${i##*=}
;;
--help|-h|-?)
Usage
;;
*)
opts="$opts$i "
;;
esac
done
CheckEnvironment
Logger "$(date) $SUBPROGRAM batch run" "NOTICE"
Batch

478
dev/common_install.sh Normal file
View File

@ -0,0 +1,478 @@
#!/usr/bin/env bash
## Installer script suitable for osync / obackup / pmocr
PROGRAM=[prgname]
PROGRAM_VERSION=$(grep "PROGRAM_VERSION=" $PROGRAM.sh)
PROGRAM_VERSION=${PROGRAM_VERSION#*=}
PROGRAM_BINARY=$PROGRAM".sh"
PROGRAM_BATCH=$PROGRAM"-batch.sh"
SSH_FILTER="ssh_filter.sh"
SCRIPT_BUILD=2025012001
INSTANCE_ID="installer-$SCRIPT_BUILD"
## osync / obackup / pmocr / zsnap install script
## Tested on RHEL / CentOS 6 & 7, Fedora 23, Debian 7 & 8, Mint 17 and FreeBSD 8, 10 and 11
## Please adapt this to fit your distro needs
include #### OFUNCTIONS MICRO SUBSET ####
# Get current install.sh path from http://stackoverflow.com/a/246128/2635443
SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
_LOGGER_SILENT=false
_STATS=1
ACTION="install"
FAKEROOT=""
## Default log file
if [ -w "$FAKEROOT/var/log" ]; then
LOG_FILE="$FAKEROOT/var/log/$PROGRAM-install.log"
elif ([ "$HOME" != "" ] && [ -w "$HOME" ]); then
LOG_FILE="$HOME/$PROGRAM-install.log"
else
LOG_FILE="./$PROGRAM-install.log"
fi
include #### UrlEncode SUBSET ####
include #### GetLocalOS SUBSET ####
include #### GetConfFileValue SUBSET ####
include #### CleanUp SUBSET ####
include #### GenericTrapQuit SUBSET ####
function SetLocalOSSettings {
USER=root
DO_INIT=true
# LOCAL_OS and LOCAL_OS_FULL are global variables set at GetLocalOS
case $LOCAL_OS in
*"BSD"*)
GROUP=wheel
;;
*"MacOSX"*)
GROUP=admin
DO_INIT=false
;;
*"Cygwin"*|*"Android"*|*"msys"*|*"BusyBox"*)
USER=""
GROUP=""
DO_INIT=false
;;
*)
GROUP=root
;;
esac
if [ "$LOCAL_OS" == "Android" ] || [ "$LOCAL_OS" == "BusyBox" ]; then
Logger "Cannot be installed on [$LOCAL_OS]. Please use $PROGRAM.sh directly." "CRITICAL"
exit 1
fi
if ([ "$USER" != "" ] && [ "$(whoami)" != "$USER" ] && [ "$FAKEROOT" == "" ]); then
Logger "Must be run as $USER." "CRITICAL"
exit 1
fi
OS=$(UrlEncode "$LOCAL_OS_FULL")
}
function GetInit {
init="none"
if [ -f /sbin/openrc-run ]; then
init="openrc"
Logger "Detected openrc." "NOTICE"
elif [ -f /usr/lib/systemd/systemd ]; then
init="systemd"
Logger "Detected systemd." "NOTICE"
elif [ -f /sbin/init ]; then
if type -p file > /dev/null 2>&1; then
if file /sbin/init | grep systemd > /dev/null; then
init="systemd"
Logger "Detected systemd." "NOTICE"
else
init="initV"
fi
else
init="initV"
fi
if [ $init == "initV" ]; then
Logger "Detected initV." "NOTICE"
fi
else
Logger "Can't detect initV, systemd or openRC. Service files won't be installed. You can still run $PROGRAM manually or via cron." "WARN"
init="none"
fi
}
function CreateDir {
local dir="${1}"
local dirMask="${2}"
local dirUser="${3}"
local dirGroup="${4}"
if [ ! -d "$dir" ]; then
(
if [ $(IsInteger $dirMask) -eq 1 ]; then
umask $dirMask
fi
mkdir -p "$dir"
)
if [ $? == 0 ]; then
Logger "Created directory [$dir]." "NOTICE"
else
Logger "Cannot create directory [$dir]." "CRITICAL"
exit 1
fi
fi
if [ "$dirUser" != "" ]; then
userGroup="$dirUser"
if [ "$dirGroup" != "" ]; then
userGroup="$userGroup"":$dirGroup"
fi
chown "$userGroup" "$dir"
if [ $? != 0 ]; then
Logger "Could not set directory ownership on [$dir] to [$userGroup]." "CRITICAL"
exit 1
else
Logger "Set file ownership on [$dir] to [$userGroup]." "NOTICE"
fi
fi
}
function CopyFile {
local sourcePath="${1}"
local destPath="${2}"
local sourceFileName="${3}"
local destFileName="${4}"
local fileMod="${5}"
local fileUser="${6}"
local fileGroup="${7}"
local overwrite="${8:-false}"
local userGroup=""
if [ "$destFileName" == "" ]; then
destFileName="$sourceFileName"
fi
if [ -f "$destPath/$destFileName" ] && [ $overwrite == false ]; then
destFileName="$sourceFileName.new"
Logger "Copying [$sourceFileName] to [$destPath/$destFileName]." "NOTICE"
fi
cp "$sourcePath/$sourceFileName" "$destPath/$destFileName"
if [ $? != 0 ]; then
Logger "Cannot copy [$sourcePath/$sourceFileName] to [$destPath/$destFileName]. Make sure to run install script in the directory containing all other files." "CRITICAL"
Logger "Also make sure you have permissions to write to [$BIN_DIR]." "ERROR"
exit 1
else
Logger "Copied [$sourcePath/$sourceFileName] to [$destPath/$destFileName]." "NOTICE"
if [ "$(IsInteger $fileMod)" -eq 1 ]; then
chmod "$fileMod" "$destPath/$destFileName"
if [ $? != 0 ]; then
Logger "Cannot set file permissions of [$destPath/$destFileName] to [$fileMod]." "CRITICAL"
exit 1
else
Logger "Set file permissions to [$fileMod] on [$destPath/$destFileName]." "NOTICE"
fi
elif [ "$fileMod" != "" ]; then
Logger "Bogus filemod [$fileMod] for [$destPath] given." "WARN"
fi
if [ "$fileUser" != "" ]; then
userGroup="$fileUser"
if [ "$fileGroup" != "" ]; then
userGroup="$userGroup"":$fileGroup"
fi
chown "$userGroup" "$destPath/$destFileName"
if [ $? != 0 ]; then
Logger "Could not set file ownership on [$destPath/$destFileName] to [$userGroup]." "CRITICAL"
exit 1
else
Logger "Set file ownership on [$destPath/$destFileName] to [$userGroup]." "NOTICE"
fi
fi
fi
}
function CopyExampleFiles {
exampleFiles=()
exampleFiles[0]="sync.conf.example" # osync
exampleFiles[1]="host_backup.conf.example" # obackup
exampleFiles[2]="exclude.list.example" # osync & obackup
exampleFiles[3]="snapshot.conf.example" # zsnap
exampleFiles[4]="default.conf" # pmocr
for file in "${exampleFiles[@]}"; do
if [ -f "$SCRIPT_PATH/$file" ]; then
CopyFile "$SCRIPT_PATH" "$CONF_DIR" "$file" "$file" "" "" "" false
fi
done
}
function CopyProgram {
binFiles=()
binFiles[0]="$PROGRAM_BINARY"
if [ "$PROGRAM" == "osync" ] || [ "$PROGRAM" == "obackup" ]; then
binFiles[1]="$PROGRAM_BATCH"
binFiles[2]="$SSH_FILTER"
fi
local user=""
local group=""
if ([ "$USER" != "" ] && [ "$FAKEROOT" == "" ]); then
user="$USER"
fi
if ([ "$GROUP" != "" ] && [ "$FAKEROOT" == "" ]); then
group="$GROUP"
fi
for file in "${binFiles[@]}"; do
CopyFile "$SCRIPT_PATH" "$BIN_DIR" "$file" "$file" 755 "$user" "$group" true
done
}
function CopyServiceFiles {
if ([ "$init" == "systemd" ] && [ -f "$SCRIPT_PATH/$SERVICE_FILE_SYSTEMD_SYSTEM" ]); then
CreateDir "$SERVICE_DIR_SYSTEMD_SYSTEM"
CopyFile "$SCRIPT_PATH" "$SERVICE_DIR_SYSTEMD_SYSTEM" "$SERVICE_FILE_SYSTEMD_SYSTEM" "$SERVICE_FILE_SYSTEMD_SYSTEM" "" "" "" true
if [ -f "$SCRIPT_PATH/$SERVICE_FILE_SYSTEMD_USER" ]; then
CreateDir "$SERVICE_DIR_SYSTEMD_USER"
CopyFile "$SCRIPT_PATH" "$SERVICE_DIR_SYSTEMD_USER" "$SERVICE_FILE_SYSTEMD_USER" "$SERVICE_FILE_SYSTEMD_USER" "" "" "" true
fi
if [ -f "$SCRIPT_PATH/$TARGET_HELPER_SERVICE_FILE_SYSTEMD_SYSTEM" ]; then
CopyFile "$SCRIPT_PATH" "$SERVICE_DIR_SYSTEMD_SYSTEM" "$TARGET_HELPER_SERVICE_FILE_SYSTEMD_SYSTEM" "$TARGET_HELPER_SERVICE_FILE_SYSTEMD_SYSTEM" "" "" "" true
Logger "Created optional service [$TARGET_HELPER_SERVICE_NAME] with same specifications as below." "NOTICE"
fi
if [ -f "$SCRIPT_PATH/$TARGET_HELPER_SERVICE_FILE_SYSTEMD_USER" ]; then
CopyFile "$SCRIPT_PATH" "$SERVICE_DIR_SYSTEMD_USER" "$TARGET_HELPER_SERVICE_FILE_SYSTEMD_USER" "$TARGET_HELPER_SERVICE_FILE_SYSTEMD_USER" "" "" "" true
fi
Logger "Created [$SERVICE_NAME] service in [$SERVICE_DIR_SYSTEMD_SYSTEM] and [$SERVICE_DIR_SYSTEMD_USER]." "NOTICE"
Logger "Can be activated with [systemctl start SERVICE_NAME@instance.conf] where instance.conf is the name of the config file in $CONF_DIR." "NOTICE"
Logger "Can be enabled on boot with [systemctl enable $SERVICE_NAME@instance.conf]." "NOTICE"
Logger "In userland, active with [systemctl --user start $SERVICE_NAME@instance.conf]." "NOTICE"
elif ([ "$init" == "initV" ] && [ -f "$SCRIPT_PATH/$SERVICE_FILE_INIT" ] && [ -d "$SERVICE_DIR_INIT" ]); then
#CreateDir "$SERVICE_DIR_INIT"
CopyFile "$SCRIPT_PATH" "$SERVICE_DIR_INIT" "$SERVICE_FILE_INIT" "$SERVICE_FILE_INIT" "755" "" "" true
if [ -f "$SCRIPT_PATH/$TARGET_HELPER_SERVICE_FILE_INIT" ]; then
CopyFile "$SCRIPT_PATH" "$SERVICE_DIR_INIT" "$TARGET_HELPER_SERVICE_FILE_INIT" "$TARGET_HELPER_SERVICE_FILE_INIT" "755" "" "" true
Logger "Created optional service [$TARGET_HELPER_SERVICE_NAME] with same specifications as below." "NOTICE"
fi
Logger "Created [$SERVICE_NAME] service in [$SERVICE_DIR_INIT]." "NOTICE"
Logger "Can be activated with [service $SERVICE_FILE_INIT start]." "NOTICE"
Logger "Can be enabled on boot with [chkconfig $SERVICE_FILE_INIT on]." "NOTICE"
elif ([ "$init" == "openrc" ] && [ -f "$SCRIPT_PATH/$SERVICE_FILE_OPENRC" ] && [ -d "$SERVICE_DIR_OPENRC" ]); then
# Rename service to usual service file
CopyFile "$SCRIPT_PATH" "$SERVICE_DIR_OPENRC" "$SERVICE_FILE_OPENRC" "$SERVICE_FILE_INIT" "755" "" "" true
if [ -f "$SCRPT_PATH/$TARGET_HELPER_SERVICE_FILE_OPENRC" ]; then
CopyFile "$SCRIPT_PATH" "$SERVICE_DIR_OPENRC" "$TARGET_HELPER_SERVICE_FILE_OPENRC" "$TARGET_HELPER_SERVICE_FILE_OPENRC" "755" "" "" true
Logger "Created optional service [$TARGET_HELPER_SERVICE_NAME] with same specifications as below." "NOTICE"
fi
Logger "Created [$SERVICE_NAME] service in [$SERVICE_DIR_OPENRC]." "NOTICE"
Logger "Can be activated with [rc-update add $SERVICE_NAME.instance] where instance is a configuration file found in /etc/osync." "NOTICE"
else
Logger "Cannot properly find how to deal with init on this system. Skipping service file installation." "NOTICE"
fi
}
function Statistics {
if type wget > /dev/null 2>&1; then
wget -qO- "$STATS_LINK" > /dev/null 2>&1
if [ $? == 0 ]; then
return 0
fi
fi
if type curl > /dev/null 2>&1; then
curl "$STATS_LINK" -o /dev/null > /dev/null 2>&1
if [ $? == 0 ]; then
return 0
fi
fi
Logger "Neiter wget nor curl could be used for. Cannot run statistics. Use the provided link please." "WARN"
return 1
}
function RemoveFile {
local file="${1}"
if [ -f "$file" ]; then
rm -f "$file"
if [ $? != 0 ]; then
Logger "Could not remove file [$file]." "ERROR"
else
Logger "Removed file [$file]." "NOTICE"
fi
else
Logger "File [$file] not found. Skipping." "NOTICE"
fi
}
function RemoveAll {
RemoveFile "$BIN_DIR/$PROGRAM_BINARY"
if [ "$PROGRAM" == "osync" ] || [ "$PROGRAM" == "obackup" ]; then
RemoveFile "$BIN_DIR/$PROGRAM_BATCH"
fi
if [ ! -f "$BIN_DIR/osync.sh" ] && [ ! -f "$BIN_DIR/obackup.sh" ]; then # Check if any other program requiring ssh filter is present before removal
RemoveFile "$BIN_DIR/$SSH_FILTER"
else
Logger "Skipping removal of [$BIN_DIR/$SSH_FILTER] because other programs present that need it." "NOTICE"
fi
# Try to uninstall every possible service file
if [ $init == "systemd" ]; then
RemoveFile "$SERVICE_DIR_SYSTEMD_SYSTEM/$SERVICE_FILE_SYSTEMD_SYSTEM"
RemoveFile "$SERVICE_DIR_SYSTEMD_USER/$SERVICE_FILE_SYSTEMD_USER"
RemoveFile "$SERVICE_DIR_SYSTEMD_SYSTEM/$TARGET_HELPER_SERVICE_FILE_SYSTEMD_SYSTEM"
RemoveFile "$SERVICE_DIR_SYSTEMD_USER/$TARGET_HELPER_SERVICE_FILE_SYSTEMD_USER"
elif [ $init == "initV" ]; then
RemoveFile "$SERVICE_DIR_INIT/$SERVICE_FILE_INIT"
RemoveFile "$SERVICE_DIR_INIT/$TARGET_HELPER_SERVICE_FILE_INIT"
elif [ $init == "openrc" ]; then
RemoveFile "$SERVICE_DIR_OPENRC/$SERVICE_FILE_OPENRC"
RemoveFile "$SERVICE_DIR_OPENRC/$TARGET_HELPER_SERVICE_FILE_OPENRC"
else
Logger "Can uninstall only from initV, systemd or openRC." "WARN"
fi
Logger "Skipping configuration files in [$CONF_DIR]. You may remove this directory manually." "NOTICE"
}
function Usage {
echo "Installs $PROGRAM into $BIN_DIR"
echo "options:"
echo "--silent Will log and bypass user interaction."
echo "--no-stats Used with --silent in order to refuse sending anonymous install stats."
echo "--remove Remove the program."
echo "--prefix=/path Use prefix to install path."
exit 127
}
############################## Script entry point
function GetCommandlineArguments {
for i in "$@"; do
case $i in
--prefix=*)
FAKEROOT="${i##*=}"
;;
--silent)
_LOGGER_SILENT=true
;;
--no-stats)
_STATS=0
;;
--remove)
ACTION="uninstall"
;;
--help|-h|-?)
Usage
;;
*)
Logger "Unknown option '$i'" "ERROR"
Usage
exit
;;
esac
done
}
GetCommandlineArguments "$@"
CONF_DIR=$FAKEROOT/etc/$PROGRAM
BIN_DIR="$FAKEROOT/usr/local/bin"
SERVICE_DIR_INIT=$FAKEROOT/etc/init.d
# Should be /usr/lib/systemd/system, but /lib/systemd/system exists on debian & rhel / fedora
SERVICE_DIR_SYSTEMD_SYSTEM=$FAKEROOT/lib/systemd/system
SERVICE_DIR_SYSTEMD_USER=$FAKEROOT/etc/systemd/user
SERVICE_DIR_OPENRC=$FAKEROOT/etc/init.d
if [ "$PROGRAM" == "osync" ]; then
SERVICE_NAME="osync-srv"
TARGET_HELPER_SERVICE_NAME="osync-target-helper-srv"
TARGET_HELPER_SERVICE_FILE_INIT="$TARGET_HELPER_SERVICE_NAME"
TARGET_HELPER_SERVICE_FILE_SYSTEMD_SYSTEM="$TARGET_HELPER_SERVICE_NAME@.service"
TARGET_HELPER_SERVICE_FILE_SYSTEMD_USER="$TARGET_HELPER_SERVICE_NAME@.service.user"
TARGET_HELPER_SERVICE_FILE_OPENRC="$TARGET_HELPER_SERVICE_NAME-openrc"
elif [ "$PROGRAM" == "pmocr" ]; then
SERVICE_NAME="pmocr-srv"
fi
SERVICE_FILE_INIT="$SERVICE_NAME"
SERVICE_FILE_SYSTEMD_SYSTEM="$SERVICE_NAME@.service"
SERVICE_FILE_SYSTEMD_USER="$SERVICE_NAME@.service.user"
SERVICE_FILE_OPENRC="$SERVICE_NAME-openrc"
## Generic code
trap GenericTrapQuit TERM EXIT HUP QUIT
if [ ! -w "$(dirname $LOG_FILE)" ]; then
echo "Cannot write to log [$(dirname $LOG_FILE)]."
else
Logger "Script begin, logging to [$LOG_FILE]." "DEBUG"
fi
# Set default umask
umask 0022
GetLocalOS
SetLocalOSSettings
# On Mac OS this always produces a warning which causes the installer to fail with exit code 2
# Since we know it won't work anyway, and that's fine, just skip this step
if $DO_INIT; then
GetInit
fi
STATS_LINK="http://instcount.netpower.fr?program=$PROGRAM&version=$PROGRAM_VERSION&os=$OS&action=$ACTION"
if [ "$ACTION" == "uninstall" ]; then
RemoveAll
Logger "$PROGRAM uninstalled." "NOTICE"
else
CreateDir "$CONF_DIR"
CreateDir "$BIN_DIR"
CopyExampleFiles
CopyProgram
if [ "$PROGRAM" == "osync" ] || [ "$PROGRAM" == "pmocr" ]; then
CopyServiceFiles
fi
Logger "$PROGRAM installed. Use with $BIN_DIR/$PROGRAM_BINARY" "NOTICE"
if [ "$PROGRAM" == "osync" ] || [ "$PROGRAM" == "obackup" ]; then
echo ""
Logger "If connecting remotely, consider setup ssh filter to enhance security." "NOTICE"
echo ""
fi
fi
if [ $_STATS -eq 1 ]; then
if [ $_LOGGER_SILENT == true ]; then
Statistics
else
Logger "In order to make usage statistics, the script would like to connect to $STATS_LINK" "NOTICE"
read -r -p "No data except those in the url will be send. Allow [Y/n] " response
case $response in
[nN])
exit
;;
*)
Statistics
exit $?
;;
esac
fi
fi

File diff suppressed because it is too large Load Diff

View File

@ -1,53 +1,204 @@
#!/usr/bin/env bash
## Merges ofunctions.sh and $PROGRAM
## MERGE 2020031501
PROGRAM=osync
VERSION=$(grep "PROGRAM_VERSION=" n_$PROGRAM.sh)
VERSION=${VERSION#*=}
FUNC_PATH=/home/git/common
## Merges ofunctions.sh and n_program.sh into program.sh
## Adds installer
PARANOIA_DEBUG_LINE="#__WITH_PARANOIA_DEBUG"
PARANOIA_DEBUG_BEGIN="#__BEGIN_WITH_PARANOIA_DEBUG"
PARANOIA_DEBUG_END="#__END_WITH_PARANOIA_DEBUG"
PROGRAM=merge
INSTANCE_ID=dev
function Unexpand {
unexpand n_$PROGRAM.sh > tmp_$PROGRAM.sh
function Usage {
echo "Merges ofunctions.sh and n_program.sh into debug_program.sh and ../program.sh"
echo "Usage"
echo "$0 osync|obackup|pmocr"
}
function Merge {
function __PREPROCESSOR_Merge {
local nPROGRAM="$1"
sed "/source \"\.\/ofunctions.sh\"/r /home/git/common/ofunctions.sh" tmp_$PROGRAM.sh | grep -v 'source "./ofunctions.sh"' > debug_$PROGRAM.sh
chmod +x debug_$PROGRAM.sh
if [ -f "$nPROGRAM" ]; then
Logger "$nPROGRAM is not found in local path." "CRITICAL"
exit 1
fi
VERSION=$(grep "PROGRAM_VERSION=" n_$nPROGRAM.sh)
VERSION=${VERSION#*=}
__PREPROCESSOR_Constants
__PREPROCESSOR_Unexpand "n_$nPROGRAM.sh" "debug_$nPROGRAM.sh"
for subset in "${__PREPROCESSOR_SUBSETS[@]}"; do
__PREPROCESSOR_MergeSubset "$subset" "${subset//SUBSET/SUBSET END}" "ofunctions.sh" "debug_$nPROGRAM.sh"
done
__PREPROCESSOR_CleanDebug "debug_$nPROGRAM.sh" "../$nPROGRAM.sh"
}
function CleanDebug {
function __PREPROCESSOR_Constants {
PARANOIA_DEBUG_LINE="#__WITH_PARANOIA_DEBUG"
PARANOIA_DEBUG_BEGIN="#__BEGIN_WITH_PARANOIA_DEBUG"
PARANOIA_DEBUG_END="#__END_WITH_PARANOIA_DEBUG"
# sed explanation
#/pattern1/{ # if pattern1 is found
# p # print it
# :a # loop
# N # and accumulate lines
# /pattern2/!ba # until pattern2 is found
# s/.*\n// # delete the part before pattern2
#}
#p
sed -n '/'$PARANOIA_DEBUG_BEGIN'/{p; :a; N; /'$PARANOIA_DEBUG_END'/!ba; s/.*\n//}; p' debug_$PROGRAM.sh | grep -v "$PARANOIA_DEBUG_LINE" > ../$PROGRAM.sh
chmod +x ../$PROGRAM.sh
__PREPROCESSOR_SUBSETS=(
'#### OFUNCTIONS FULL SUBSET ####'
'#### OFUNCTIONS MINI SUBSET ####'
'#### OFUNCTIONS MICRO SUBSET ####'
'#### PoorMansRandomGenerator SUBSET ####'
'#### _OFUNCTIONS_BOOTSTRAP SUBSET ####'
'#### RUN_DIR SUBSET ####'
'#### DEBUG SUBSET ####'
'#### TrapError SUBSET ####'
'#### RemoteLogger SUBSET ####'
'#### Logger SUBSET ####'
'#### GetLocalOS SUBSET ####'
'#### IsInteger SUBSET ####'
'#### UrlEncode SUBSET ####'
'#### HumanToNumeric SUBSET ####'
'#### ArrayContains SUBSET ####'
'#### VerComp SUBSET ####'
'#### GetConfFileValue SUBSET ####'
'#### SetConfFileValue SUBSET ####'
'#### CheckRFC822 SUBSET ####'
'#### CleanUp SUBSET ####'
'#### GenericTrapQuit SUBSET ####'
'#### FileMove SUBSET ####'
)
}
function CopyCommons {
sed "s/\[prgname\]/$PROGRAM/g" /home/git/common/common_install.sh > ../tmp_install.sh
sed "s/\[version\]/$VERSION/g" ../tmp_install.sh > ../install.sh
sed "s/\[prgname\]/$PROGRAM/g" /home/git/common/common_batch.sh > ../$PROGRAM-batch.sh
chmod +x ../install.sh
chmod +x ../$PROGRAM-batch.sh
function __PREPROCESSOR_Unexpand {
local source="${1}"
local destination="${2}"
unexpand "$source" > "$destination"
if [ $? != 0 ]; then
Logger "Cannot unexpand [$source] to [$destination]." "CRITICAL"
exit 1
fi
}
Unexpand
Merge
CleanDebug
rm -f tmp_$PROGRAM.sh
rm -f ../tmp_install.sh
CopyCommons
function __PREPROCESSOR_MergeSubset {
local subsetBegin="${1}"
local subsetEnd="${2}"
local subsetFile="${3}"
local mergedFile="${4}"
sed -n "/$subsetBegin/,/$subsetEnd/p" "$subsetFile" > "$subsetFile.$subsetBegin"
if [ $? != 0 ]; then
Logger "Cannot sed subset [$subsetBegin -- $subsetEnd] in [$subsetFile]." "CRTICIAL"
exit 1
fi
sed "/include $subsetBegin/r $subsetFile.$subsetBegin" "$mergedFile" | grep -v -E "$subsetBegin\$|$subsetEnd\$" > "$mergedFile.tmp"
if [ $? != 0 ]; then
Logger "Cannot add subset [$subsetBegin] to [$mergedFile]." "CRITICAL"
exit 1
fi
rm -f "$subsetFile.$subsetBegin"
if [ $? != 0 ]; then
Logger "Cannot remove temporary subset [$subsetFile.$subsetBegin]." "CRITICAL"
exit 1
fi
rm -f "$mergedFile"
if [ $? != 0 ]; then
Logger "Cannot remove merged original file [$mergedFile]." "CRITICAL"
exit 1
fi
mv "$mergedFile.tmp" "$mergedFile"
if [ $? != 0 ]; then
Logger "Cannot move merged tmp file to original [$mergedFile]." "CRITICAL"
exit 1
fi
}
function __PREPROCESSOR_CleanDebug {
local source="${1}"
local destination="${2:-$source}"
sed '/'$PARANOIA_DEBUG_BEGIN'/,/'$PARANOIA_DEBUG_END'/d' "$source" | grep -v "$PARANOIA_DEBUG_LINE" > "$destination.tmp"
if [ $? != 0 ]; then
Logger "Cannot remove PARANOIA_DEBUG code from standard build." "CRITICAL"
exit 1
else
mv -f "$destination.tmp" "$destination"
if [ $? -ne 0 ]; then
Logger "Cannot move [$destination.tmp] to [$destination]." "CRITICAL"
exit 1
fi
fi
chmod +x "$source"
if [ $? != 0 ]; then
Logger "Cannot chmod [$source]." "CRITICAL"
exit 1
else
Logger "Prepared [$source]." "NOTICE"
fi
if [ "$source" != "$destination" ]; then
chmod +x "$destination"
if [ $? != 0 ]; then
Logger "Cannot chmod [$destination]." "CRITICAL"
exit 1
else
Logger "Prepared [$destination]." "NOTICE"
fi
fi
}
function __PREPROCESSOR_CopyCommons {
local nPROGRAM="$1"
sed "s/\[prgname\]/$nPROGRAM/g" common_install.sh > ../install.sh
if [ $? != 0 ]; then
Logger "Cannot assemble install." "CRITICAL"
exit 1
fi
for subset in "${__PREPROCESSOR_SUBSETS[@]}"; do
__PREPROCESSOR_MergeSubset "$subset" "${subset//SUBSET/SUBSET END}" "ofunctions.sh" "../install.sh"
done
__PREPROCESSOR_CleanDebug "../install.sh"
if [ -f "common_batch.sh" ]; then
sed "s/\[prgname\]/$nPROGRAM/g" common_batch.sh > ../$nPROGRAM-batch.sh
if [ $? != 0 ]; then
Logger "Cannot assemble batch runner." "CRITICAL"
exit 1
fi
for subset in "${__PREPROCESSOR_SUBSETS[@]}"; do
__PREPROCESSOR_MergeSubset "$subset" "${subset//SUBSET/SUBSET END}" "ofunctions.sh" "../$nPROGRAM-batch.sh"
done
__PREPROCESSOR_CleanDebug "../$nPROGRAM-batch.sh"
fi
}
# If sourced don't do anything
if [ "$(basename $0)" == "merge.sh" ]; then
source "./ofunctions.sh"
if [ $? != 0 ]; then
echo "Please run $0 in dev directory with ofunctions.sh"
exit 1
fi
trap GenericTrapQuit TERM EXIT HUP QUIT
if [ "$1" == "osync" ]; then
__PREPROCESSOR_Merge osync
__PREPROCESSOR_CopyCommons osync
elif [ "$1" == "obackup" ]; then
__PREPROCESSOR_Merge obackup
__PREPROCESSOR_CopyCommons obackup
elif [ "$1" == "pmocr" ]; then
__PREPROCESSOR_Merge pmocr
__PREPROCESSOR_CopyCommons pmocr
else
echo "No valid program given."
Usage
exit 1
fi
fi

File diff suppressed because it is too large Load Diff

2943
dev/ofunctions.sh Normal file → Executable file

File diff suppressed because it is too large Load Diff

10
dev/shellcheck.sh Executable file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env bash
#SC1090 = not following non constants source
#SC1091 = not following source
#SC2086 = quoting errors (shellcheck is way too picky about quoting)
#SC2120 = only for debug version
#SC2034 = unused variabled (can be ignored in ofunctions.sh)
#SC2068 = bad array usage (can be ignored in ofunctions.sh)
shellcheck -e SC1090,SC1091,SC2086,SC2119,SC2120 $@

View File

@ -2,38 +2,45 @@
###### osync - Rsync based two way sync engine with fault tolerance
###### (C) 2013-2016 by Orsiris de Jong (www.netpower.fr)
###### osync v1.1x config file rev 2016071801
## ---------- GENERAL OPTIONS
[GENERAL]
CONFIG_FILE_REVISION=1.3.0
## Sync job identification
INSTANCE_ID="sync_test"
INSTANCE_ID="local"
## Directories to synchronize.
## Initiator is the system osync runs on. The initiator directory must be a local path.
INITIATOR_SYNC_DIR="/home/git/osync/dir1"
INITIATOR_SYNC_DIR="${HOME}/osync-tests/initiator"
## Target is the system osync synchronizes to (can be the same system as the initiator in case of local sync tasks). The target directory can be a local or remote path.
TARGET_SYNC_DIR="/home/git/osync/dir2"
TARGET_SYNC_DIR="${HOME}/osync-tests/target"
#TARGET_SYNC_DIR="ssh://backupuser@yourhost.old:22//home/git/osync/dir2"
## If the target system is remote, you can specify a RSA key (please use full path). If not defined, the default ~/.ssh/id_rsa will be used. See documentation for further information.
SSH_RSA_PRIVATE_KEY="/home/backupuser/.ssh/id_rsa"
## Alternatively, you may specify an SSH password file (less secure). Needs sshpass utility installed.
SSH_PASSWORD_FILE=""
## When using ssh filter, you must specify a remote token matching the one setup in authorized_keys
_REMOTE_TOKEN=SomeAlphaNumericToken9
## Create sync directories if they do not exist
CREATE_DIRS=no
CREATE_DIRS=false
## Log file location. Leaving this empty will create a logfile at /var/log/osync_version_SYNC_ID.log (or current directory if /var/log doesn't exist)
LOGFILE=""
## Generate an alert if initiator or target replicas have less free space than given value in KB.
## Generate an alert if initiator or target replicas have less free space than given value in KB. Set this to zero to skip disk space tests.
MINIMUM_SPACE=10240
## Bandwidth limit Kbytes / second. Leave 0 to disable limitation
BANDWIDTH=0
## If enabled, synchronization on remote system will be processed as superuser. See documentation for /etc/sudoers file configuration.
SUDO_EXEC=no
SUDO_EXEC=false
## Paranoia option. Don't change this unless you read the documentation.
RSYNC_EXECUTABLE=rsync
## Remote rsync executable path. Leave this empty in most cases
@ -45,7 +52,7 @@ RSYNC_PATTERN_FIRST=include
## List of files / directories to incldue / exclude from sync on both sides (see rsync patterns, wildcards work).
## Paths are relative to sync dirs. List elements are separated by a semicolon.
RSYNC_INCLUDE_PATTERN=""
RSYNC_EXCLUDE_PATTERN=""
RSYNC_EXCLUDE_PATTERN="*.php"
#RSYNC_EXCLUDE_PATTERN="tmp;archives"
## Files that contains lists of files / directories to include / exclude from sync on both sides. Leave this empty if you don't want to use an exclusion file.
@ -58,45 +65,62 @@ RSYNC_EXCLUDE_FROM=""
## List elements separator char. You may set an alternative separator char for your directories lists above.
PATH_SEPARATOR_CHAR=";"
## ---------- REMOTE SYNC OPTIONS
[REMOTE_OPTIONS]
## ssh compression should be used unless your remote connection is good enough (LAN)
SSH_COMPRESSION=yes
SSH_COMPRESSION=true
## Ignore ssh known hosts. DANGER WILL ROBINSON DANGER ! This can lead to security issues. Only enable this if you know what you're doing.
SSH_IGNORE_KNOWN_HOSTS=no
SSH_IGNORE_KNOWN_HOSTS=false
SSH_CONTROLMASTER=false
## Check for connectivity to remote host before launching remote sync task. Be sure the hosts responds to ping. Failing to ping will stop sync.
REMOTE_HOST_PING=no
REMOTE_HOST_PING=false
## Check for internet access by pinging one or more 3rd party hosts before remote sync task. Leave empty if you don't want this check to be be performed. Failing to ping will stop sync.
## If you use this function, you should set more than one 3rd party host, and be sure you can ping them.
## Be aware some DNS like opendns redirect false hostnames. Also, this adds an extra execution time of a bit less than a minute.
REMOTE_3RD_PARTY_HOSTS="www.kernel.org www.google.com"
## ---------- MISC OPTIONS
[MISC_OPTIONS]
## Optional arguments passed to rsync executable. The following are already managed by the program and shoul never be passed here
## -r -l -p -t -g -o -D -E - u- i- n --executability -A -X -L -K -H -8 -zz skip-compress checksum bwlimit partial partial-dir no-whole-file whole-file backup backup-dir suffix
## --exclude --exclude-from --include --include-from --list-only --stats
RSYNC_OPTIONAL_ARGS=""
## Preserve basic linux permissions
PRESERVE_PERMISSIONS=true
PRESERVE_OWNER=true
PRESERVE_GROUP=true
## On MACOS X, does not work and will be ignored
PRESERVE_EXECUTABILITY=true
## Preserve ACLS. Make sure source and target FS can manage same ACLs or you'll get loads of errors.
PRESERVE_ACL=no
PRESERVE_ACL=false
## Preserve Xattr. Make sure source and target FS can manage same Xattrs or you'll get loads of errors.
PRESERVE_XATTR=no
PRESERVE_XATTR=false
## Transforms symlinks into referent files/dirs
COPY_SYMLINKS=no
COPY_SYMLINKS=false
## Treat symlinked dirs as dirs. CAUTION: This also follows symlinks outside of the replica root.
KEEP_DIRLINKS=no
KEEP_DIRLINKS=false
## Preserve hard links. Make sure source and target FS can manage hard links or you will lose them.
PRESERVE_HARDLINKS=no
PRESERVE_HARDLINKS=false
## Do a full checksum on all files that have identical sizes, they are checksummed to see if they actually are identical. This can take a long time.
CHECKSUM=no
CHECKSUM=false
## Let RSYNC compress file transfers. Do not use this if both initator and target replicas are on local system. Also, do not use this if you already enabled SSH compression.
RSYNC_COMPRESS=yes
RSYNC_COMPRESS=true
## Maximum execution time (in seconds) for sync process. Set these values zero will disable max execution times.
## Soft exec time only generates a warning. Hard exec time will generate a warning and stop sync process.
SOFT_MAX_EXEC_TIME=7200
HARD_MAX_EXEC_TIME=10600
## Log a message every KEEP_LOGGING seconds just to know the task is still alive
KEEP_LOGGING=1801
## Minimum time (in seconds) in file monitor /daemon mode between modification detection and sync task in order to let copy operations finish.
MIN_WAIT=60
@ -104,43 +128,60 @@ MIN_WAIT=60
## Use 0 to wait indefinitely.
MAX_WAIT=7200
## ---------- BACKUP AND DELETION OPTIONS
[BACKUP_DELETE_OPTIONS]
## Log a list of conflictual files
LOG_CONFLICTS=true
## Send an email when conflictual files are found (implies LOG_CONFLICTS)
ALERT_CONFLICTS=false
## Enabling this option will keep a backup of a file on the target replica if it gets updated from the source replica. Backups will be made to .osync_workdir/backups
CONFLICT_BACKUP=yes
CONFLICT_BACKUP=true
## Keep multiple backup versions of the same file. Warning, This can be very space consuming.
CONFLICT_BACKUP_MULTIPLE=no
CONFLICT_BACKUP_MULTIPLE=false
## Osync will clean backup files after a given number of days. Setting this to 0 will disable cleaning and keep backups forever. Warning: This can be very space consuming.
CONFLICT_BACKUP_DAYS=30
## If the same file exists on both replicas, newer version will be synced. However, if both files have the same timestamp but differ, CONFILCT_PREVALANCE sets winner replica.
CONFLICT_PREVALANCE=initiator
## On deletion propagation to the target replica, a backup of the deleted files can be kept. Deletions will be kept in .osync_workdir/deleted
SOFT_DELETE=yes
SOFT_DELETE=true
## Osync will clean deleted files after a given number of days. Setting this to 0 will disable cleaning and keep deleted files forever. Warning: This can be very space consuming.
SOFT_DELETE_DAYS=30
## ---------- RESUME OPTIONS
## Optional deletion skip on replicas. Valid values are "initiator", "target", or "initiator,target"
SKIP_DELETION=
[RESUME_OPTIONS]
## Try to resume an aborted sync task
RESUME_SYNC=yes
RESUME_SYNC=true
## Number maximum resume tries before initiating a fresh sync.
RESUME_TRY=2
## When a pidlock exists on slave replica that does not correspond to the initiator's instance-id, force pidlock removal. Be careful with this option if you have multiple initiators.
FORCE_STRANGER_LOCK_RESUME=no
FORCE_STRANGER_LOCK_RESUME=false
## Keep partial uploads that can be resumed on next run, experimental feature
PARTIAL=no
PARTIAL=false
## Use delta copy algortithm (usefull when local paths are network drives), defaults to yes
DELTA_COPIES=yes
DELTA_COPIES=true
## ---------- ALERT OPTIONS
[ALERT_OPTIONS]
## List of alert mails separated by spaces
DESTINATION_MAILS="your@alert.tld"
## Most Unix systems (including Win10 bash) have mail support out of the box
## Just make sure that the current user has enough privileges to use mail / mutt / sendmail and that the mail system is configured to allow outgoing mails
## on pfSense platform, smtp support needs to be configured in System > Advanced > Notifications
DESTINATION_MAILS=""
## Windows specific (msys / cygwin environment) only mail options (used with mailsend.exe from muquit, http://github.com/muquit/mailsend or from sendemail.exe from Brandon Zehm, http://caspian.dotconf.net/menu/Software/SendEmail/)
## Optional change of mail body encoding (using iconv)
## By default, all mails are sent in UTF-8 format without header (because of maximum compatibility of all platforms)
## You may specify an optional encoding here (like "ISO-8859-1" or whatever iconv can handle)
MAIL_BODY_CHARSET=""
## Additional mail parameters needed for Android / Busybox / Cygwin / MSYS
## Android & Busybox use sendmail (and openssl if encryption is needed)
## MSYS & Cygwin Windows mail support relies on mailsend.exe from muquit, http://github.com/muquit/mailsend which needs to be in %PATH% environment variable
SENDER_MAIL="alert@your.system.tld"
SMTP_SERVER=smtp.your.isp.tld
SMTP_PORT=25
@ -149,7 +190,7 @@ SMTP_ENCRYPTION=none
SMTP_USER=
SMTP_PASSWORD=
## ---------- EXECUTION HOOKS
[EXECUTION_HOOKS]
## Commands can will be run before and / or after sync process (remote execution will only happen if REMOTE_OPERATION is set).
LOCAL_RUN_BEFORE_CMD=""
@ -163,7 +204,7 @@ MAX_EXEC_TIME_PER_CMD_BEFORE=0
MAX_EXEC_TIME_PER_CMD_AFTER=0
## Stops osync execution if one of the above commands fail
STOP_ON_CMD_ERROR=yes
STOP_ON_CMD_ERROR=true
## Run local and remote after sync commands even on failure
RUN_AFTER_CMD_ON_ERROR=no
RUN_AFTER_CMD_ON_ERROR=false

71
tests/conf/local.conf → dev/tests/conf/old.conf Executable file → Normal file
View File

@ -1,20 +1,17 @@
#!/usr/bin/env bash
#!/bin/bash
###### Osync - Rsync based two way sync engine with fault tolerance
###### (L) 2013-2014 by Orsiris "Ozy" de Jong (www.netpower.fr)
###### Config file rev 2611201401
###### (L) 2013 by Orsiris "Ozy" de Jong (www.netpower.fr)
#### Config file rev 0211201302
## ---------- GENERAL OPTIONS
## Sync job identification
SYNC_ID="sync_test"
SYNC_ID="old"
## Directories to synchronize. Master must be on the system Osync runs on. Slave can be either a local directory, or a remote one.
MASTER_SYNC_DIR="master"
SLAVE_SYNC_DIR="slave"
#SLAVE_SYNC_DIR="ssh://backupuser@yourhost.old:22//home/git/osync/dir2"
## If slave replica is a remote directory, you must specify a RSA key (please use full path). Please see documentation for further information.
#SSH_RSA_PRIVATE_KEY="/home/backupuser/.ssh/id_rsa"
## Directories to synchronize. Master must be on the system Osync runs on. Slave can be either on the same system, or on a remote one.
MASTER_SYNC_DIR="${HOME}/osync-tests/initiator"
SLAVE_SYNC_DIR="${HOME}/osync-tests/target"
## Create sync directories if they do not exist
CREATE_DIRS=no
@ -22,19 +19,10 @@ CREATE_DIRS=no
## Log file location. Leaving this empty will create a logfile at /var/log/osync_version_SYNC_ID.log (or current directory if /var/log doesn't exist)
LOGFILE=""
## List of directories to exclude from sync on both sides (rsync patterns, wildcards work).
## Paths are relative to sync dirs. List elements are separated by a semicolon.
RSYNC_EXCLUDE_PATTERN=""
#RSYNC_EXCLUDE_PATTERN="tmp;archives"
## File that contains the list of directories or files to exclude from sync on both sides. Leave this empty if you don't want to use an exclusion file.
## This file has to be in the same directory as the config file
## Paths are relative to sync dirs. One element per line.
RSYNC_EXCLUDE_FROM=""
#RSYNC_EXCLUDE_FROM="exclude.list"
## List elements separator char. You may set an alternative separator char for your directories lists above.
RSYNC_EXCLUDE_PATTERN="tmp;archives"
## List elements separator char. You may set an alternative seperator char for your directories lists above.
PATH_SEPARATOR_CHAR=";"
## Generate an alert if master or slave replicas have less free space than given value in KB.
@ -43,26 +31,33 @@ MINIMUM_SPACE=10240
## Bandwidth limit Kbytes / second. Leave 0 to disable limitation
BANDWIDTH=0
## If enabled, synchronization on remote system will be processed as superuser. See documentation for /etc/sudoers file configuration.
## If enabled, synchronization will be processed as superuser. See documentation for /etc/sudoers file configuration.
SUDO_EXEC=no
## Paranoia option. Don't change this unless you read the documentation.
RSYNC_EXECUTABLE=rsync
## ---------- REMOTE SYNC OPTIONS
## The following options allow Osync to sync a slave replica on a remote system via an SSH tunnel.
## Needs public RSA key need to be put into ~/.ssh/authorized_keys in remote users home directory. See documentation for remote sync.
REMOTE_SYNC=no
SSH_RSA_PRIVATE_KEY=~/.ssh/id_rsa
REMOTE_USER=syncuser
REMOTE_HOST=your-remote-host.tld
REMOTE_PORT=22
## ssh compression should be used unless your remote connection is good enough (LAN)
SSH_COMPRESSION=yes
## Check for connectivity to remote host before launching remote sync task. Be sure the hosts responds to ping. Failing to ping will stop sync.
REMOTE_HOST_PING=no
REMOTE_HOST_PING=yes
## Check for internet access by pinging one or more 3rd party hosts before remote sync task. Leave empty if you don't want this check to be be performed. Failing to ping will stop sync.
## If you use this function, you should set more than one 3rd party host, and be sure you can ping them.
## Be aware some DNS like opendns redirect false hostnames. Also, this adds an extra execution time of a bit less than a minute.
REMOTE_3RD_PARTY_HOSTS=""
REMOTE_3RD_PARTY_HOSTS="www.kernel.org www.google.com"
## Remote rsync executable path. Leave this empty in most cases
RSYNC_REMOTE_PATH=""
REMOTE_RSYNC_PATH=""
## ---------- MISC OPTIONS
@ -70,12 +65,6 @@ RSYNC_REMOTE_PATH=""
PRESERVE_ACL=no
## Preserve Xattr. Make sure source and target FS can manage same Xattrs or you'll get loads of errors.
PRESERVE_XATTR=no
## Transforms symlinks into referent files/dirs
COPY_SYMLINKS=no
## Treat symlinked dirs as dirs. CAUTION: This also follows symlinks outside of the replica root.
KEEP_DIRLINKS=no
## Preserve hard links. Make sure source and target FS can manage hard links or you will lose them.
PRESERVE_HARDLINKS=no
## Let RSYNC compress file transfers. Do not use this if both master and slave replicas are on local system. Also, do not use this if you already enabled SSH compression.
RSYNC_COMPRESS=yes
@ -84,10 +73,7 @@ RSYNC_COMPRESS=yes
SOFT_MAX_EXEC_TIME=7200
HARD_MAX_EXEC_TIME=10600
## Minimum time (in seconds) in file monitor /daemon mode between modification detection and sync task in order to let copy operations finish.
MIN_WAIT=60
## ---------- BACKUP AND DELETION OPTIONS
## ---------- BACKUP AND TRASH OPTIONS
## Enabling this option will keep a backup of a file on the target replica if it gets updated from the source replica. Backups will be made to .osync_workdir/backups
CONFLICT_BACKUP=yes
@ -98,7 +84,7 @@ CONFLICT_BACKUP_DAYS=30
## If the same file exists on both replicas, newer version will be synced. However, if both files have the same timestamp but differ, CONFILCT_PREVALANCE sets winner replica.
CONFLICT_PREVALANCE=master
## On deletion propagation to the target replica, a backup of the deleted files can be kept. Deletions will be kept in .osync_workdir/deleted
## On deletition propagation to the target replica, a backup of the deleted files can be kept. Deletions will be kept in .osync_workdir/deleted
SOFT_DELETE=yes
## Osync will clean deleted files after a given number of days. Setting this to 0 will disable cleaning and keep deleted files forever. Warning: This can be very space consuming.
SOFT_DELETE_DAYS=30
@ -107,22 +93,19 @@ SOFT_DELETE_DAYS=30
## Try to resume an aborted sync task
RESUME_SYNC=yes
## Number maximum resume tries before initiating a fresh sync.
## Number maximum resume tries before initating a fresh sync.
RESUME_TRY=2
## When a pidlock exists on slave replica that does not correspond to master's sync-id, force pidlock removal. Be careful with this option if you have multiple masters.
## When a pidlock exists on slave replica that does not correspond to master's sync-id, force pidlock removal. Be carefull with this option if you have multiple masters.
FORCE_STRANGER_LOCK_RESUME=no
## Keep partial uploads that can be resumed on next run, experimental feature
PARTIAL=no
## ---------- ALERT OPTIONS
## List of alert mails separated by spaces
DESTINATION_MAILS="your@alert.tld"
## Windows (MSYS environment) only mail options (used with sendemail.exe from Brandon Zehm)
SENDER_MAIL="alert@your.system.tld"
SMTP_SERVER=smtp.your.isp.tld
## Windows (MSYS environment) only mail options (used by sendemail.exe)
SENDER_MAIL="alert@your.system"
SMTP_SERVER=smtp.your.isp.com
SMTP_USER=
SMTP_PASSWORD=

210
dev/tests/conf/remote.conf Normal file
View File

@ -0,0 +1,210 @@
#!/usr/bin/env bash
###### osync - Rsync based two way sync engine with fault tolerance
###### (C) 2013-2016 by Orsiris de Jong (www.netpower.fr)
[GENERAL]
CONFIG_FILE_REVISION=1.3.0
## Sync job identification
INSTANCE_ID="remote"
## Directories to synchronize.
## Initiator is the system osync runs on. The initiator directory must be a local path.
INITIATOR_SYNC_DIR="${HOME}/osync-tests/initiator"
## Target is the system osync synchronizes to (can be the same system as the initiator in case of local sync tasks). The target directory can be a local or remote path.
#TARGET_SYNC_DIR="${HOME}/osync-tests/target"
TARGET_SYNC_DIR="ssh://root@localhost:44999/${HOME}/osync-tests/target"
## If the target system is remote, you can specify a RSA key (please use full path). If not defined, the default ~/.ssh/id_rsa will be used. See documentation for further information.
SSH_RSA_PRIVATE_KEY="${HOME}/.ssh/id_rsa_local_osync_tests"
## Alternatively, you may specify an SSH password file (less secure). Needs sshpass utility installed.
SSH_PASSWORD_FILE=""
## When using ssh filter, you must specify a remote token matching the one setup in authorized_keys
_REMOTE_TOKEN=SomeAlphaNumericToken9
## Create sync directories if they do not exist
CREATE_DIRS=false
## Log file location. Leaving this empty will create a logfile at /var/log/osync_version_SYNC_ID.log (or current directory if /var/log doesn't exist)
LOGFILE=""
## Generate an alert if initiator or target replicas have less free space than given value in KB. Set this to zero to skip disk space tests.
MINIMUM_SPACE=10240
## Bandwidth limit Kbytes / second. Leave 0 to disable limitation
BANDWIDTH=0
## If enabled, synchronization on remote system will be processed as superuser. See documentation for /etc/sudoers file configuration.
SUDO_EXEC=false
## Paranoia option. Don't change this unless you read the documentation.
RSYNC_EXECUTABLE=rsync
## Remote rsync executable path. Leave this empty in most cases
RSYNC_REMOTE_PATH=""
## Rsync exclude / include order (the option set here will be set first, eg: include will make include then exclude patterns)
RSYNC_PATTERN_FIRST=include
## List of files / directories to incldue / exclude from sync on both sides (see rsync patterns, wildcards work).
## Paths are relative to sync dirs. List elements are separated by a semicolon.
RSYNC_INCLUDE_PATTERN=""
RSYNC_EXCLUDE_PATTERN="*.php"
#RSYNC_EXCLUDE_PATTERN="tmp;archives"
## Files that contains lists of files / directories to include / exclude from sync on both sides. Leave this empty if you don't want to use an exclusion file.
## This file has to be in the same directory as the config file
## Paths are relative to sync dirs. One element per line.
RSYNC_INCLUDE_FROM=""
RSYNC_EXCLUDE_FROM=""
#RSYNC_EXCLUDE_FROM="exclude.list"
## List elements separator char. You may set an alternative separator char for your directories lists above.
PATH_SEPARATOR_CHAR=";"
[REMOTE_OPTIONS]
## ssh compression should be used unless your remote connection is good enough (LAN)
SSH_COMPRESSION=true
## Ignore ssh known hosts. DANGER WILL ROBINSON DANGER ! This can lead to security issues. Only enable this if you know what you're doing.
SSH_IGNORE_KNOWN_HOSTS=false
SSH_CONTROLMASTER=false
## Check for connectivity to remote host before launching remote sync task. Be sure the hosts responds to ping. Failing to ping will stop sync.
REMOTE_HOST_PING=true
## Check for internet access by pinging one or more 3rd party hosts before remote sync task. Leave empty if you don't want this check to be be performed. Failing to ping will stop sync.
## If you use this function, you should set more than one 3rd party host, and be sure you can ping them.
## Be aware some DNS like opendns redirect false hostnames. Also, this adds an extra execution time of a bit less than a minute.
REMOTE_3RD_PARTY_HOSTS="www.kernel.org www.google.com"
[MISC_OPTIONS]
## Optional arguments passed to rsync executable. The following are already managed by the program and shoul never be passed here
## -r -l -p -t -g -o -D -E - u- i- n --executability -A -X -L -K -H -8 -zz skip-compress checksum bwlimit partial partial-dir no-whole-file whole-file backup backup-dir suffix
## --exclude --exclude-from --include --include-from --list-only --stats
RSYNC_OPTIONAL_ARGS=""
## Preserve basic linux permissions
PRESERVE_PERMISSIONS=true
PRESERVE_OWNER=true
PRESERVE_GROUP=true
## On MACOS X, does not work and will be ignored
PRESERVE_EXECUTABILITY=true
## Preserve ACLS. Make sure source and target FS can manage same ACLs or you'll get loads of errors.
PRESERVE_ACL=false
## Preserve Xattr. Make sure source and target FS can manage same Xattrs or you'll get loads of errors.
PRESERVE_XATTR=false
## Transforms symlinks into referent files/dirs
COPY_SYMLINKS=false
## Treat symlinked dirs as dirs. CAUTION: This also follows symlinks outside of the replica root.
KEEP_DIRLINKS=false
## Preserve hard links. Make sure source and target FS can manage hard links or you will lose them.
PRESERVE_HARDLINKS=false
## Do a full checksum on all files that have identical sizes, they are checksummed to see if they actually are identical. This can take a long time.
CHECKSUM=false
## Let RSYNC compress file transfers. Do not use this if both initator and target replicas are on local system. Also, do not use this if you already enabled SSH compression.
RSYNC_COMPRESS=true
## Maximum execution time (in seconds) for sync process. Set these values zero will disable max execution times.
## Soft exec time only generates a warning. Hard exec time will generate a warning and stop sync process.
SOFT_MAX_EXEC_TIME=7200
HARD_MAX_EXEC_TIME=10600
## Log a message every KEEP_LOGGING seconds just to know the task is still alive
KEEP_LOGGING=1801
## Minimum time (in seconds) in file monitor /daemon mode between modification detection and sync task in order to let copy operations finish.
MIN_WAIT=60
## Maximum time (in seconds) waiting in file monitor / daemon mode. After this time, sync is run.
## Use 0 to wait indefinitely.
MAX_WAIT=7200
[BACKUP_DELETE_OPTIONS]
## Log a list of conflictual files
LOG_CONFLICTS=true
## Send an email when conflictual files are found (implies LOG_CONFLICTS)
ALERT_CONFLICTS=false
## Enabling this option will keep a backup of a file on the target replica if it gets updated from the source replica. Backups will be made to .osync_workdir/backups
CONFLICT_BACKUP=true
## Keep multiple backup versions of the same file. Warning, This can be very space consuming.
CONFLICT_BACKUP_MULTIPLE=false
## Osync will clean backup files after a given number of days. Setting this to 0 will disable cleaning and keep backups forever. Warning: This can be very space consuming.
CONFLICT_BACKUP_DAYS=30
## If the same file exists on both replicas, newer version will be synced. However, if both files have the same timestamp but differ, CONFILCT_PREVALANCE sets winner replica.
CONFLICT_PREVALANCE=initiator
## On deletion propagation to the target replica, a backup of the deleted files can be kept. Deletions will be kept in .osync_workdir/deleted
SOFT_DELETE=true
## Osync will clean deleted files after a given number of days. Setting this to 0 will disable cleaning and keep deleted files forever. Warning: This can be very space consuming.
SOFT_DELETE_DAYS=30
## Optional deletion skip on replicas. Valid values are "initiator", "target", or "initiator,target"
SKIP_DELETION=
[RESUME_OPTIONS]
## Try to resume an aborted sync task
RESUME_SYNC=true
## Number maximum resume tries before initiating a fresh sync.
RESUME_TRY=2
## When a pidlock exists on slave replica that does not correspond to the initiator's instance-id, force pidlock removal. Be careful with this option if you have multiple initiators.
FORCE_STRANGER_LOCK_RESUME=false
## Keep partial uploads that can be resumed on next run, experimental feature
PARTIAL=false
## Use delta copy algortithm (usefull when local paths are network drives), defaults to yes
DELTA_COPIES=true
[ALERT_OPTIONS]
## List of alert mails separated by spaces
## Most Unix systems (including Win10 bash) have mail support out of the box
## Just make sure that the current user has enough privileges to use mail / mutt / sendmail and that the mail system is configured to allow outgoing mails
## on pfSense platform, smtp support needs to be configured in System > Advanced > Notifications
DESTINATION_MAILS=""
## Optional change of mail body encoding (using iconv)
## By default, all mails are sent in UTF-8 format without header (because of maximum compatibility of all platforms)
## You may specify an optional encoding here (like "ISO-8859-1" or whatever iconv can handle)
MAIL_BODY_CHARSET=""
## Additional mail parameters needed for Android / Busybox / Cygwin / MSYS
## Android & Busybox use sendmail (and openssl if encryption is needed)
## MSYS & Cygwin Windows mail support relies on mailsend.exe from muquit, http://github.com/muquit/mailsend which needs to be in %PATH% environment variable
SENDER_MAIL="alert@your.system.tld"
SMTP_SERVER=smtp.your.isp.tld
SMTP_PORT=25
# encryption can be tls, ssl or none
SMTP_ENCRYPTION=none
SMTP_USER=
SMTP_PASSWORD=
[EXECUTION_HOOKS]
## Commands can will be run before and / or after sync process (remote execution will only happen if REMOTE_OPERATION is set).
LOCAL_RUN_BEFORE_CMD=""
LOCAL_RUN_AFTER_CMD=""
REMOTE_RUN_BEFORE_CMD=""
REMOTE_RUN_AFTER_CMD=""
## Max execution time of commands before they get force killed. Leave 0 if you don't wan't this to happen. Time is specified in seconds.
MAX_EXEC_TIME_PER_CMD_BEFORE=0
MAX_EXEC_TIME_PER_CMD_AFTER=0
## Stops osync execution if one of the above commands fail
STOP_ON_CMD_ERROR=true
## Run local and remote after sync commands even on failure
RUN_AFTER_CMD_ON_ERROR=false

1563
dev/tests/run_tests.sh Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at kate.ward@forestent.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

View File

@ -0,0 +1,147 @@
Coding Standards
================
shFlags is more than just a simple 20 line shell script. It is a pretty
significant library of shell code that at first glance is not that easy to
understand. To improve code readability and usability, some guidelines have been
set down to make the code more understandable for anyone who wants to read or
modify it.
Function declaration
--------------------
Declare functions using the following form:
```sh
doSomething() {
echo 'done!'
}
```
One-line functions are allowed if they can fit within the 80 char line limit.
```sh
doSomething() { echo 'done!'; }
```
Function documentation
----------------------
Each function should be preceded by a header that provides the following:
1. A one-sentence summary of what the function does.
1. (optional) A longer description of what the function does, and perhaps some
special information that helps convey its usage better.
1. Args: a one-line summary of each argument of the form:
`name: type: description`
1. Output: a one-line summary of the output provided. Only output to STDOUT
must be documented, unless the output to STDERR is of significance (i.e. not
just an error message). The output should be of the form:
`type: description`
1. Returns: a one-line summary of the value returned. Returns in shell are
always integers, but if the output is a true/false for success (i.e. a
boolean), it should be noted. The output should be of the form:
`type: description`
Here is a sample header:
```
# Return valid getopt options using currently defined list of long options.
#
# This function builds a proper getopt option string for short (and long)
# options, using the current list of long options for reference.
#
# Args:
# _flags_optStr: integer: option string type (__FLAGS_OPTSTR_*)
# Output:
# string: generated option string for getopt
# Returns:
# boolean: success of operation (always returns True)
```
Variable and function names
---------------------------
All shFlags specific constants, variables, and functions will be prefixed
appropriately with 'flags'. This is to distinguish usage in the shFlags code
from users own scripts so that the shell name space remains predictable to
users. The exceptions here are the standard `assertEquals`, etc. functions.
All non built-in constants and variables will be surrounded with squiggle
brackets, e.g. `${flags_someVariable}` to improve code readability.
Due to some shells not supporting local variables in functions, care in the
naming and use of variables, both public and private, is very important.
Accidental overriding of the variables can occur easily if care is not taken as
all variables are technically global variables in some shells.
Type | Sample
---- | ------
global public constant | `FLAGS_TRUE`
global private constant | `__FLAGS_SHELL_FLAGS`
global public variable | `flags_variable`
global private variable | `__flags_variable`
global macro | `_FLAGS_SOME_MACRO_`
public function | `flags_function`
public function, local variable | ``flags_variable_`
private function | `_flags_function`
private function, local variable | `_flags_variable_`
Where it makes sense to improve readability, variables can have the first
letter of the second and later words capitalized. For example, the local
variable name for the help string length is `flags_helpStrLen_`.
There are three special-case global public variables used. They are used due to
overcome the limitations of shell scoping or to prevent forking. The three
variables are:
- `flags_error`
- `flags_output`
- `flags_return`
Local variable cleanup
----------------------
As many shells do not support local variables, no support for cleanup of
variables is present either. As such, all variables local to a function must be
cleared up with the `unset` built-in command at the end of each function.
Indentation
-----------
Code block indentation is two (2) spaces, and tabs may not be used.
```sh
if [ -z 'some string' ]; then
someFunction
fi
```
Lines of code should be no longer than 80 characters unless absolutely
necessary. When lines are wrapped using the backslash character '\', subsequent
lines should be indented with four (4) spaces so as to differentiate from the
standard spacing of two characters, and tabs may not be used.
```sh
for x in some set of very long set of arguments that make for a very long \
that extends much too long for one line
do
echo ${x}
done
```
When a conditional expression is written using the built-in [ command, and that
line must be wrapped, place the control || or && operators on the same line as
the expression where possible, with the list to be executed on its own line.
```sh
[ -n 'some really long expression' -a -n 'some other long expr' ] && \
echo 'that was actually true!'
```

201
dev/tests/shunit2/LICENSE Normal file
View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

643
dev/tests/shunit2/README.md Normal file
View File

@ -0,0 +1,643 @@
# shUnit2
shUnit2 is a [xUnit](http://en.wikipedia.org/wiki/XUnit) unit test framework for
Bourne based shell scripts, and it is designed to work in a similar manner to
[JUnit](http://www.junit.org), [PyUnit](http://pyunit.sourceforge.net), etc.. If
you have ever had the desire to write a unit test for a shell script, shUnit2
can do the job.
[![Travis CI](https://api.travis-ci.com/kward/shunit2.svg)](https://app.travis-ci.com/github/kward/shunit2)
## Table of Contents
* [Introduction](#introduction)
* [Credits / Contributors](#credits-contributors)
* [Feedback](#feedback)
* [Quickstart](#quickstart)
* [Function Reference](#function-reference)
* [General Info](#general-info)
* [Asserts](#asserts)
* [Failures](#failures)
* [Setup/Teardown](#setup-teardown)
* [Skipping](#skipping)
* [Suites](#suites)
* [Advanced Usage](#advanced-usage)
* [Some constants you can use](#some-constants-you-can-use)
* [Error Handling](#error-handling)
* [Including Line Numbers in Asserts (Macros)](#including-line-numbers-in-asserts-macros)
* [Test Skipping](#test-skipping)
* [Running specific tests from the command line](#cmd-line-args)
* [Appendix](#appendix)
* [Getting help](#getting-help)
* [Zsh](#zsh)
---
## <a name="introduction"></a> Introduction
shUnit2 was originally developed to provide a consistent testing solution for
[log4sh][log4sh], a shell based logging framework similar to
[log4j](http://logging.apache.org). During the development of that product, a
repeated problem of having things work just fine under one shell (`/bin/bash` on
Linux to be specific), and then not working under another shell (`/bin/sh` on
Solaris) kept coming up. Although several simple tests were run, they were not
adequate and did not catch some corner cases. The decision was finally made to
write a proper unit test framework after multiple brown-bag releases were made.
_Research was done to look for an existing product that met the testing
requirements, but no adequate product was found._
### Tested software
**Tested Operating Systems** (varies over time)
OS | Support | Verified
----------------------------------- | --------- | --------
Ubuntu Linux (14.04.05 LTS) | Travis CI | continuous
macOS High Sierra (10.13.3) | Travis CI | continuous
FreeBSD | user | unknown
Solaris 8, 9, 10 (inc. OpenSolaris) | user | unknown
Cygwin | user | unknown
**Tested Shells**
* Bourne Shell (__sh__)
* BASH - GNU Bourne Again SHell (__bash__)
* DASH - Debian Almquist Shell (__dash__)
* Korn Shell - AT&T version of the Korn shell (__ksh__)
* mksh - MirBSD Korn Shell (__mksh__)
* zsh - Zsh (__zsh__) (since 2.1.2) _please see the Zsh shell errata for more information_
See the appropriate Release Notes for this release
(`doc/RELEASE_NOTES-X.X.X.txt`) for the list of actual versions tested.
### <a name="credits-contributors"></a> Credits / Contributors
A list of contributors to shUnit2 can be found in `doc/contributors.md`. Many
thanks go out to all those who have contributed to make this a better tool.
shUnit2 is the original product of many hours of work by Kate Ward, the primary
author of the code. For related software, check out https://github.com/kward.
### <a name="feedback"></a> Feedback
Feedback is most certainly welcome for this document. Send your questions,
comments, and criticisms via the
[shunit2-users](https://groups.google.com/a/forestent.com/forum/#!forum/shunit2-users/new)
forum (created 2018-12-09), or file an issue via
https://github.com/kward/shunit2/issues.
---
## <a name="quickstart"></a> Quickstart
This section will give a very quick start to running unit tests with shUnit2.
More information is located in later sections.
Here is a quick sample script to show how easy it is to write a unit test in
shell. _Note: the script as it stands expects that you are running it from the
"examples" directory._
```sh
#! /bin/sh
# file: examples/equality_test.sh
testEquality() {
assertEquals 1 1
}
# Load shUnit2.
. ../shunit2
```
Running the unit test should give results similar to the following.
```console
$ cd examples
$ ./equality_test.sh
testEquality
Ran 1 test.
OK
```
W00t! You've just run your first successful unit test. So, what just happened?
Quite a bit really, and it all happened simply by sourcing the `shunit2`
library. The basic functionality for the script above goes like this:
* When shUnit2 is sourced, it will walk through any functions defined whose name
starts with the string `test`, and add those to an internal list of tests to
execute. Once a list of test functions to be run has been determined, shunit2
will go to work.
* Before any tests are executed, shUnit2 again looks for a function, this time
one named `oneTimeSetUp()`. If it exists, it will be run. This function is
normally used to setup the environment for all tests to be run. Things like
creating directories for output or setting environment variables are good to
place here. Just so you know, you can also declare a corresponding function
named `oneTimeTearDown()` function that does the same thing, but once all the
tests have been completed. It is good for removing temporary directories, etc.
* shUnit2 is now ready to run tests. Before doing so though, it again looks for
another function that might be declared, one named `setUp()`. If the function
exists, it will be run before each test. It is good for resetting the
environment so that each test starts with a clean slate. **At this stage, the
first test is finally run.** The success of the test is recorded for a report
that will be generated later. After the test is run, shUnit2 looks for a final
function that might be declared, one named `tearDown()`. If it exists, it will
be run after each test. It is a good place for cleaning up after each test,
maybe doing things like removing files that were created, or removing
directories. This set of steps, `setUp() > test() > tearDown()`, is repeated
for all of the available tests.
* Once all the work is done, shUnit2 will generate the nice report you saw
above. A summary of all the successes and failures will be given so that you
know how well your code is doing.
We should now try adding a test that fails. Change your unit test to look like
this.
```sh
#! /bin/sh
# file: examples/party_test.sh
testEquality() {
assertEquals 1 1
}
testPartyLikeItIs1999() {
year=`date '+%Y'`
assertEquals "It's not 1999 :-(" '1999' "${year}"
}
# Load shUnit2.
. ../shunit2
```
So, what did you get? I guess it told you that this isn't 1999. Bummer, eh?
Hopefully, you noticed a couple of things that were different about the second
test. First, we added an optional message that the user will see if the assert
fails. Second, we did comparisons of strings instead of integers as in the first
test. It doesn't matter whether you are testing for equality of strings or
integers. Both work equally well with shUnit2.
Hopefully, this is enough to get you started with unit testing. If you want a
ton more examples, take a look at the tests provided with [log4sh][log4sh] or
[shFlags][shflags]. Both provide excellent examples of more advanced usage.
shUnit2 was after all written to meet the unit testing need that
[log4sh][log4sh] had.
If you are using distribution packaged shUnit2 which is accessible from
`/usr/bin/shunit2` such as Debian, you can load shUnit2 without specifying its
path. So the last 2 lines in the above can be replaced by:
```sh
# Load shUnit2.
. shunit2
```
---
## <a name="function-reference"></a> Function Reference
### <a name="general-info"></a> General Info
Any string values passed should be properly quoted -- they should be
surrounded by single-quote (`'`) or double-quote (`"`) characters -- so that the
shell will properly parse them.
### <a name="asserts"></a> Asserts
assertEquals [message] expected actual
Asserts that _expected_ and _actual_ are equal to one another. The _expected_
and _actual_ values can be either strings or integer values as both will be
treated as strings. The _message_ is optional, and must be quoted.
assertNotEquals [message] unexpected actual
Asserts that _unexpected_ and _actual_ are not equal to one another. The
_unexpected_ and _actual_ values can be either strings or integer values as both
will be treated as strings. The _message_ is optional, and must be quoted.
assertSame [message] expected actual
This function is functionally equivalent to `assertEquals`.
assertNotSame [message] unexpected actual
This function is functionally equivalent to `assertNotEquals`.
assertContains [message] container content
Asserts that _container_ contains _content_. The _container_ and _content_
values can be either strings or integer values as both will be treated as
strings. The _message_ is optional, and must be quoted.
assertNotContains [message] container content
Asserts that _container_ does not contain _content_. The _container_ and
_content_ values can be either strings or integer values as both will be treated
as strings. The _message_ is optional, and must be quoted.
assertNull [message] value
Asserts that _value_ is _null_, or in shell terms, a zero-length string. The
_value_ must be a string as an integer value does not translate into a zero-
length string. The _message_ is optional, and must be quoted.
assertNotNull [message] value
Asserts that _value_ is _not null_, or in shell terms, a non-empty string. The
_value_ may be a string or an integer as the latter will be parsed as a non-empty
string value. The _message_ is optional, and must be quoted.
assertTrue [message] condition
Asserts that a given shell test _condition_ is _true_. The condition can be as
simple as a shell _true_ value (the value `0` -- equivalent to
`${SHUNIT_TRUE}`), or a more sophisticated shell conditional expression. The
_message_ is optional, and must be quoted.
A sophisticated shell conditional expression is equivalent to what the __if__ or
__while__ shell built-ins would use (more specifically, what the __test__
command would use). Testing for example whether some value is greater than
another value can be done this way.
assertTrue "[ 34 -gt 23 ]"
Testing for the ability to read a file can also be done. This particular test
will fail.
assertTrue 'test failed' "[ -r /some/non-existant/file ]"
As the expressions are standard shell __test__ expressions, it is possible to
string multiple expressions together with `-a` and `-o` in the standard fashion.
This test will succeed as the entire expression evaluates to _true_.
assertTrue 'test failed' '[ 1 -eq 1 -a 2 -eq 2 ]'
<i>One word of warning: be very careful with your quoting as shell is not the
most forgiving of bad quoting, and things will fail in strange ways.</i>
assertFalse [message] condition
Asserts that a given shell test _condition_ is _false_. The condition can be as
simple as a shell _false_ value (the value `1` -- equivalent to
`${SHUNIT_FALSE}`), or a more sophisticated shell conditional expression. The
_message_ is optional, and must be quoted.
_For examples of more sophisticated expressions, see `assertTrue`._
### <a name="failures"></a> Failures
Just to clarify, failures __do not__ test the various arguments against one
another. Failures simply fail, optionally with a message, and that is all they
do. If you need to test arguments against one another, use asserts.
If all failures do is fail, why might one use them? There are times when you may
have some very complicated logic that you need to test, and the simple asserts
provided are simply not adequate. You can do your own validation of the code,
use an `assertTrue ${SHUNIT_TRUE}` if your own tests succeeded, and use a
failure to record a failure.
fail [message]
Fails the test immediately. The _message_ is optional, and must be quoted.
failNotEquals [message] unexpected actual
Fails the test immediately, reporting that the _unexpected_ and _actual_ values
are not equal to one another. The _message_ is optional, and must be quoted.
_Note: no actual comparison of unexpected and actual is done._
failSame [message] expected actual
Fails the test immediately, reporting that the _expected_ and _actual_ values
are the same. The _message_ is optional, and must be quoted.
_Note: no actual comparison of expected and actual is done._
failNotSame [message] expected actual
Fails the test immediately, reporting that the _expected_ and _actual_ values
are not the same. The _message_ is optional, and must be quoted.
_Note: no actual comparison of expected and actual is done._
failFound [message] content
Fails the test immediately, reporting that the _content_ was found. The
_message_ is optional, and must be quoted.
_Note: no actual search of content is done._
failNotFound [message] content
Fails the test immediately, reporting that the _content_ was not found. The
_message_ is optional, and must be quoted.
_Note: no actual search of content is done._
### <a name="setup-teardown"></a> Setup/Teardown
oneTimeSetUp
This function can be optionally overridden by the user in their test suite.
If this function exists, it will be called once before any tests are run. It is
useful to prepare a common environment for all tests.
oneTimeTearDown
This function can be optionally overridden by the user in their test suite.
If this function exists, it will be called once after all tests are completed.
It is useful to clean up the environment after all tests.
setUp
This function can be optionally overridden by the user in their test suite.
If this function exists, it will be called before each test is run. It is useful
to reset the environment before each test.
tearDown
This function can be optionally overridden by the user in their test suite.
If this function exists, it will be called after each test completes. It is
useful to clean up the environment after each test.
### <a name="skipping"></a> Skipping
startSkipping
This function forces the remaining _assert_ and _fail_ functions to be
"skipped", i.e. they will have no effect. Each function skipped will be recorded
so that the total of asserts and fails will not be altered.
endSkipping
This function returns calls to the _assert_ and _fail_ functions to their
default behavior, i.e. they will be called.
isSkipping
This function returns the current state of skipping. It can be compared against
`${SHUNIT_TRUE}` or `${SHUNIT_FALSE}` if desired.
### <a name="suites"></a> Suites
The default behavior of shUnit2 is that all tests will be found dynamically. If
you have a specific set of tests you want to run, or you don't want to use the
standard naming scheme of prefixing your tests with `test`, these functions are
for you. Most users will never use them though.
suite
This function can be optionally overridden by the user in their test suite.
If this function exists, it will be called when `shunit2` is sourced. If it does
not exist, shUnit2 will search the parent script for all functions beginning
with the word `test`, and they will be added dynamically to the test suite.
suite_addTest name
This function adds a function named _name_ to the list of tests scheduled for
execution as part of this test suite. This function should only be called from
within the `suite()` function.
---
## <a name="advanced-usage"></a> Advanced Usage
### <a name="some-constants-you-can-use"></a> Some constants you can use
There are several constants provided by shUnit2 as variables that might be of
use to you.
*Predefined*
| Constant | Value |
| --------------- | ----- |
| SHUNIT\_TRUE | Standard shell `true` value (the integer value 0). |
| SHUNIT\_FALSE | Standard shell `false` value (the integer value 1). |
| SHUNIT\_ERROR | The integer value 2. |
| SHUNIT\_TMPDIR | Path to temporary directory that will be automatically cleaned up upon exit of shUnit2. |
| SHUNIT\_VERSION | The version of shUnit2 you are running. |
*User defined*
| Constant | Value |
| ----------------- | ----- |
| SHUNIT\_CMD\_EXPR | Override which `expr` command is used. By default `expr` is used, except on BSD systems where `gexpr` is used. |
| SHUNIT\_COLOR | Enable colorized output. Options are 'auto', 'always', or 'none', with 'auto' being the default. |
| SHUNIT\_PARENT | The filename of the shell script containing the tests. This is needed specifically for Zsh support. |
| SHUNIT\_TEST\_PREFIX | Define this variable to add a prefix in front of each test name that is output in the test report. |
### <a name="error-handling"></a> Error handling
The constants values `SHUNIT_TRUE`, `SHUNIT_FALSE`, and `SHUNIT_ERROR` are
returned from nearly every function to indicate the success or failure of the
function. Additionally the variable `flags_error` is filled with a detailed
error message if any function returns with a `SHUNIT_ERROR` value.
### <a name="including-line-numbers-in-asserts-macros"></a> Including Line Numbers in Asserts (Macros)
If you include lots of assert statements in an individual test function, it can
become difficult to determine exactly which assert was thrown unless your
messages are unique. To help somewhat, line numbers can be included in the
assert messages. To enable this, a special shell "macro" must be used rather
than the standard assert calls. _Shell doesn't actually have macros; the name is
used here as the operation is similar to a standard macro._
For example, to include line numbers for a `assertEquals()` function call,
replace the `assertEquals()` with `${_ASSERT_EQUALS_}`.
_**Example** -- Asserts with and without line numbers_
```shell
#! /bin/sh
# file: examples/lineno_test.sh
testLineNo() {
# This assert will have line numbers included (e.g. "ASSERT:[123] ...").
echo "ae: ${_ASSERT_EQUALS_}"
${_ASSERT_EQUALS_} 'not equal' 1 2
# This assert will not have line numbers included (e.g. "ASSERT: ...").
assertEquals 'not equal' 1 2
}
# Load shUnit2.
. ../shunit2
```
Notes:
1. Due to how shell parses command-line arguments, _**all strings used with
macros should be quoted twice**_. Namely, single-quotes must be converted to single-double-quotes, and vice-versa.<br/>
<br/>
Normal `assertEquals` call.<br/>
`assertEquals 'some message' 'x' ''`<br/>
<br/>
Macro `_ASSERT_EQUALS_` call. Note the extra quoting around the _message_ and
the _null_ value.<br/>
`_ASSERT_EQUALS_ '"some message"' 'x' '""'`
1. Line numbers are not supported in all shells. If a shell does not support
them, no errors will be thrown. Supported shells include: __bash__ (>=3.0),
__ksh__, __mksh__, and __zsh__.
### <a name="test-skipping"></a> Test Skipping
There are times where the test code you have written is just not applicable to
the system you are running on. This section describes how to skip these tests
but maintain the total test count.
Probably the easiest example would be shell code that is meant to run under the
__bash__ shell, but the unit test is running under the Bourne shell. There are
things that just won't work. The following test code demonstrates two sample
functions, one that will be run under any shell, and the another that will run
only under the __bash__ shell.
_**Example** -- math include_
```sh
# file: examples/math.inc.
add_generic() {
num_a=$1
num_b=$2
expr $1 + $2
}
add_bash() {
num_a=$1
num_b=$2
echo $(($1 + $2))
}
```
And here is a corresponding unit test that correctly skips the `add_bash()` function when the unit test is not running under the __bash__ shell.
_**Example** -- math unit test_
```sh
#! /bin/sh
# file: examples/math_test.sh
testAdding() {
result=`add_generic 1 2`
assertEquals \
"the result of '${result}' was wrong" \
3 "${result}"
# Disable non-generic tests.
[ -z "${BASH_VERSION:-}" ] && startSkipping
result=`add_bash 1 2`
assertEquals \
"the result of '${result}' was wrong" \
3 "${result}"
}
oneTimeSetUp() {
# Load include to test.
. ./math.inc
}
# Load and run shUnit2.
. ../shunit2
```
Running the above test under the __bash__ shell will result in the following
output.
```console
$ /bin/bash math_test.sh
testAdding
Ran 1 test.
OK
```
But, running the test under any other Unix shell will result in the following
output.
```console
$ /bin/ksh math_test.sh
testAdding
Ran 1 test.
OK (skipped=1)
```
As you can see, the total number of tests has not changed, but the report
indicates that some tests were skipped.
Skipping can be controlled with the following functions: `startSkipping()`,
`endSkipping()`, and `isSkipping()`. Once skipping is enabled, it will remain
enabled until the end of the current test function call, after which skipping is
disabled.
### <a name="cmd-line-args"></a> Running specific tests from the command line.
When running a test script, you may override the default set of tests, or the suite-specified set of tests, by providing additional arguments on the command line. Each additional argument after the `--` marker is assumed to be the name of a test function to be run in the order specified. e.g.
```console
test-script.sh -- testOne testTwo otherFunction
```
or
```console
shunit2 test-script.sh testOne testTwo otherFunction
```
In either case, three functions will be run as tests, `testOne`, `testTwo`, and `otherFunction`. Note that the function `otherFunction` would not normally be run by `shunit2` as part of the implicit collection of tests as it's function name does not match the test function name pattern `test*`.
If a specified test function does not exist, `shunit2` will still attempt to run that function and thereby cause a failure which `shunit2` will catch and mark as a failed test. All other tests will run normally.
The specification of tests does not affect how `shunit2` looks for and executes the setup and tear down functions, which will still run as expected.
---
## <a name="appendix"></a> Appendix
### <a name="getting-help"></a> Getting Help
For help, please send requests to either the shunit2-users@forestent.com mailing
list (archives available on the web at
https://groups.google.com/a/forestent.com/forum/#!forum/shunit2-users) or
directly to Kate Ward <kate dot ward at forestent dot com>.
### <a name="zsh"></a> Zsh
For compatibility with Zsh, there is one requirement that must be met -- the
`shwordsplit` option must be set. There are three ways to accomplish this.
1. In the unit-test script, add the following shell code snippet before sourcing
the `shunit2` library.
```sh
setopt shwordsplit
```
2. When invoking __zsh__ from either the command-line or as a script with `#!`,
add the `-y` parameter.
```sh
#! /bin/zsh -y
```
3. When invoking __zsh__ from the command-line, add `-o shwordsplit --` as
parameters before the script name.
```console
$ zsh -o shwordsplit -- some_script
```
[log4sh]: https://github.com/kward/log4sh
[shflags]: https://github.com/kward/shflags

View File

@ -0,0 +1,88 @@
#! /bin/sh
# vim:et:ft=sh:sts=2:sw=2
#
# This script runs the provided unit tests and sends the output to the
# appropriate file.
#
# Copyright 2008-2017 Kate Ward. All Rights Reserved.
# Released under the Apache 2.0 license.
#
# Author: kate.ward@forestent.com (Kate Ward)
# https://github.com/kward/shunit2
#
# Source following.
# shellcheck disable=SC1090,SC1091
# FLAGS variables are dynamically created.
# shellcheck disable=SC2154
# Disagree with [ p ] && [ q ] vs [ p -a -q ] recommendation.
# shellcheck disable=SC2166
# Treat unset variables as an error.
set -u
die() {
[ $# -gt 0 ] && echo "error: $*" >&2
exit 1
}
BASE_DIR=$(dirname "$0")
LIB_DIR="${BASE_DIR}/lib"
### Load libraries.
. "${LIB_DIR}/shflags" || die 'unable to load shflags library'
. "${LIB_DIR}/shlib" || die 'unable to load shlib library'
. "${LIB_DIR}/versions" || die 'unable to load versions library'
# Redefining BASE_DIR now that we have the shlib functions. We need BASE_DIR so
# that we can properly load things, even in the event that this script is called
# from a different directory.
BASE_DIR=$(shlib_relToAbsPath "${BASE_DIR}")
# Define flags.
os_name=$(versions_osName |sed 's/ /_/g')
os_version=$(versions_osVersion)
DEFINE_boolean force false 'force overwrite' f
DEFINE_string output_dir "${TMPDIR}" 'output dir' d
DEFINE_string output_file "${os_name}-${os_version}.txt" 'output file' o
DEFINE_string runner 'test_runner' 'unit test runner' r
DEFINE_boolean dry_run false "suppress logging to a file" n
main() {
# Determine output filename.
# shellcheck disable=SC2154
output="${FLAGS_output_dir:+${FLAGS_output_dir}/}${FLAGS_output_file}"
output=$(shlib_relToAbsPath "${output}")
# Checks.
if [ "${FLAGS_dry_run}" -eq "${FLAGS_FALSE}" -a -f "${output}" ]; then
if [ "${FLAGS_force}" -eq "${FLAGS_TRUE}" ]; then
rm -f "${output}"
else
echo "not overwriting '${output}'" >&2
exit "${FLAGS_ERROR}"
fi
fi
if [ "${FLAGS_dry_run}" -eq "${FLAGS_FALSE}" ]; then
touch "${output}" 2>/dev/null || die "unable to write to '${output}'"
fi
# Run tests.
(
if [ "${FLAGS_dry_run}" -eq "${FLAGS_FALSE}" ]; then
"./${FLAGS_runner}" |tee "${output}"
else
"./${FLAGS_runner}"
fi
)
if [ "${FLAGS_dry_run}" -eq "${FLAGS_FALSE}" ]; then
echo >&2
echo "Output written to '${output}'." >&2
fi
}
FLAGS "$@" || exit $?
[ "${FLAGS_help}" -eq "${FLAGS_FALSE}" ] || exit
eval set -- "${FLAGS_ARGV}"
main "${@:-}"

View File

@ -0,0 +1,47 @@
#! /bin/sh
#
# Initialize the local git hooks this repository.
# https://git-scm.com/docs/githooks
topLevel=$(git rev-parse --show-toplevel)
if ! cd "${topLevel}"; then
echo "filed to cd into topLevel directory '${topLevel}'"
exit 1
fi
hooksDir="${topLevel}/.githooks"
if ! hooksPath=$(git config core.hooksPath); then
hooksPath="${topLevel}/.git/hooks"
fi
src="${hooksDir}/generic"
echo "linking hooks..."
for hook in \
applypatch-msg \
pre-applypatch \
post-applypatch \
pre-commit \
pre-merge-commit \
prepare-commit-msg \
commit-msg \
post-commit \
pre-rebase \
post-checkout \
post-merge \
pre-push \
pre-receive \
update \
post-receive \
post-update \
push-to-checkout \
pre-auto-gc \
post-rewrite \
sendemail-validate \
fsmonitor-watchman \
p4-pre-submit \
post-index-change
do
echo " ${hook}"
dest="${hooksPath}/${hook}"
ln -sf "${src}" "${dest}"
done

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,39 @@
# vim:et:ft=sh:sts=2:sw=2
#
# Copyright 2008 Kate Ward. All Rights Reserved.
# Released under the LGPL (GNU Lesser General Public License).
#
# Author: kate.ward@forestent.com (Kate Ward)
#
# Library of shell functions.
# Convert a relative path into it's absolute equivalent.
#
# This function will automatically prepend the current working directory if the
# path is not already absolute. It then removes all parent references (../) to
# reconstruct the proper absolute path.
#
# Args:
# shlib_path_: string: relative path
# Outputs:
# string: absolute path
shlib_relToAbsPath()
{
shlib_path_=$1
# prepend current directory to relative paths
echo "${shlib_path_}" |grep '^/' >/dev/null 2>&1 \
|| shlib_path_="${PWD}/${shlib_path_}"
# clean up the path. if all seds supported true regular expressions, then
# this is what it would be:
shlib_old_=${shlib_path_}
while true; do
shlib_new_=`echo "${shlib_old_}" |sed 's/[^/]*\/\.\.\/*//;s/\/\.\//\//'`
[ "${shlib_old_}" = "${shlib_new_}" ] && break
shlib_old_=${shlib_new_}
done
echo "${shlib_new_}"
unset shlib_path_ shlib_old_ shlib_new_
}

297
dev/tests/shunit2/lib/versions Executable file
View File

@ -0,0 +1,297 @@
#! /bin/sh
# vim:et:ft=sh:sts=2:sw=2
#
# Versions determines the versions of all installed shells.
#
# Copyright 2008-2020 Kate Ward. All Rights Reserved.
# Released under the Apache 2.0 License.
#
# Author: kate.ward@forestent.com (Kate Ward)
# https://github.com/kward/shlib
#
# This library provides reusable functions that determine actual names and
# versions of installed shells and the OS. The library can also be run as a
# script if set executable.
#
# Disable checks that aren't fully portable (POSIX != portable).
# shellcheck disable=SC2006
ARGV0=`basename "$0"`
LSB_RELEASE='/etc/lsb-release'
VERSIONS_SHELLS='ash /bin/bash /bin/dash /bin/ksh /bin/mksh /bin/pdksh /bin/zsh /usr/xpg4/bin/sh /bin/sh /sbin/sh'
true; TRUE=$?
false; FALSE=$?
ERROR=2
UNAME_R=`uname -r`
UNAME_S=`uname -s`
__versions_haveStrings=${ERROR}
versions_osName() {
os_name_='unrecognized'
os_system_=${UNAME_S}
os_release_=${UNAME_R}
case ${os_system_} in
CYGWIN_NT-*) os_name_='Cygwin' ;;
Darwin)
os_name_=`/usr/bin/sw_vers -productName`
os_version_=`versions_osVersion`
case ${os_version_} in
10.4|10.4.[0-9]*) os_name_='Mac OS X Tiger' ;;
10.5|10.5.[0-9]*) os_name_='Mac OS X Leopard' ;;
10.6|10.6.[0-9]*) os_name_='Mac OS X Snow Leopard' ;;
10.7|10.7.[0-9]*) os_name_='Mac OS X Lion' ;;
10.8|10.8.[0-9]*) os_name_='Mac OS X Mountain Lion' ;;
10.9|10.9.[0-9]*) os_name_='Mac OS X Mavericks' ;;
10.10|10.10.[0-9]*) os_name_='Mac OS X Yosemite' ;;
10.11|10.11.[0-9]*) os_name_='Mac OS X El Capitan' ;;
10.12|10.12.[0-9]*) os_name_='macOS Sierra' ;;
10.13|10.13.[0-9]*) os_name_='macOS High Sierra' ;;
10.14|10.14.[0-9]*) os_name_='macOS Mojave' ;;
10.15|10.15.[0-9]*) os_name_='macOS Catalina' ;;
11.*) os_name_='macOS Big Sur' ;;
12.*) os_name_='macOS Monterey' ;;
*) os_name_='macOS' ;;
esac
;;
FreeBSD) os_name_='FreeBSD' ;;
Linux) os_name_='Linux' ;;
SunOS)
os_name_='SunOS'
if [ -r '/etc/release' ]; then
if grep 'OpenSolaris' /etc/release >/dev/null; then
os_name_='OpenSolaris'
else
os_name_='Solaris'
fi
fi
;;
esac
echo ${os_name_}
unset os_name_ os_system_ os_release_ os_version_
}
versions_osVersion() {
os_version_='unrecognized'
os_system_=${UNAME_S}
os_release_=${UNAME_R}
case ${os_system_} in
CYGWIN_NT-*)
os_version_=`expr "${os_release_}" : '\([0-9]*\.[0-9]\.[0-9]*\).*'`
;;
Darwin)
os_version_=`/usr/bin/sw_vers -productVersion`
;;
FreeBSD)
os_version_=`expr "${os_release_}" : '\([0-9]*\.[0-9]*\)-.*'`
;;
Linux)
if [ -r '/etc/os-release' ]; then
os_version_=`awk -F= '$1~/PRETTY_NAME/{print $2}' /etc/os-release \
|sed 's/"//g'`
elif [ -r '/etc/redhat-release' ]; then
os_version_=`cat /etc/redhat-release`
elif [ -r '/etc/SuSE-release' ]; then
os_version_=`head -n 1 /etc/SuSE-release`
elif [ -r "${LSB_RELEASE}" ]; then
if grep -q 'DISTRIB_ID=Ubuntu' "${LSB_RELEASE}"; then
# shellcheck disable=SC2002
os_version_=`cat "${LSB_RELEASE}" \
|awk -F= '$1~/DISTRIB_DESCRIPTION/{print $2}' \
|sed 's/"//g;s/ /-/g'`
fi
fi
;;
SunOS)
if [ -r '/etc/release' ]; then
if grep 'OpenSolaris' /etc/release >/dev/null; then # OpenSolaris
os_version_=`grep 'OpenSolaris' /etc/release |awk '{print $2"("$3")"}'`
else # Solaris
major_=`echo "${os_release_}" |sed 's/[0-9]*\.\([0-9]*\)/\1/'`
minor_=`grep Solaris /etc/release |sed 's/[^u]*\(u[0-9]*\).*/\1/'`
os_version_="${major_}${minor_}"
fi
fi
;;
esac
echo "${os_version_}"
unset os_release_ os_system_ os_version_ major_ minor_
}
versions_shellVersion() {
shell_=$1
shell_present_=${FALSE}
case "${shell_}" in
ash) [ -x '/bin/busybox' ] && shell_present_=${TRUE} ;;
*) [ -x "${shell_}" ] && shell_present_=${TRUE} ;;
esac
if [ ${shell_present_} -eq ${FALSE} ]; then
echo 'not installed'
return ${FALSE}
fi
version_=''
case ${shell_} in
# SunOS shells.
/sbin/sh) ;;
/usr/xpg4/bin/sh) version_=`versions_shell_xpg4 "${shell_}"` ;;
# Generic shell.
*/sh)
# This could be one of any number of shells. Try until one fits.
version_=''
[ -z "${version_}" ] && version_=`versions_shell_bash "${shell_}"`
# dash cannot be self determined yet
[ -z "${version_}" ] && version_=`versions_shell_ksh "${shell_}"`
# pdksh is covered in versions_shell_ksh()
[ -z "${version_}" ] && version_=`versions_shell_xpg4 "${shell_}"`
[ -z "${version_}" ] && version_=`versions_shell_zsh "${shell_}"`
;;
# Specific shells.
ash) version_=`versions_shell_ash "${shell_}"` ;;
# bash - Bourne Again SHell (https://www.gnu.org/software/bash/)
*/bash) version_=`versions_shell_bash "${shell_}"` ;;
*/dash) version_=`versions_shell_dash` ;;
# ksh - KornShell (http://www.kornshell.com/)
*/ksh) version_=`versions_shell_ksh "${shell_}"` ;;
# mksh - MirBSD Korn Shell (http://www.mirbsd.org/mksh.htm)
*/mksh) version_=`versions_shell_ksh "${shell_}"` ;;
# pdksh - Public Domain Korn Shell (http://web.cs.mun.ca/~michael/pdksh/)
*/pdksh) version_=`versions_shell_pdksh "${shell_}"` ;;
# zsh (https://www.zsh.org/)
*/zsh) version_=`versions_shell_zsh "${shell_}"` ;;
# Unrecognized shell.
*) version_='invalid'
esac
echo "${version_:-unknown}"
unset shell_ version_
}
# The ash shell is included in BusyBox.
versions_shell_ash() {
busybox --help |head -1 |sed 's/BusyBox v\([0-9.]*\) .*/\1/'
}
versions_shell_bash() {
$1 --version : 2>&1 |grep 'GNU bash' |sed 's/.*version \([^ ]*\).*/\1/'
}
# Assuming Ubuntu Linux until somebody comes up with a better test. The
# following test will return an empty string if dash is not installed.
versions_shell_dash() {
eval dpkg >/dev/null 2>&1
[ $? -eq 127 ] && return # Return if dpkg not found.
dpkg -l |grep ' dash ' |awk '{print $3}'
}
versions_shell_ksh() {
versions_shell_=$1
versions_version_=''
# Try a few different ways to figure out the version.
versions_version_=`${versions_shell_} --version : 2>&1`
# shellcheck disable=SC2181
if [ $? -eq 0 ]; then
versions_version_=`echo "${versions_version_}" \
|sed 's/.*\([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\).*/\1/'`
else
versions_version_=''
fi
if [ -z "${versions_version_}" ]; then
# shellcheck disable=SC2016
versions_version_=`${versions_shell_} -c 'echo ${KSH_VERSION}'`
fi
if [ -z "${versions_version_}" ]; then
_versions_have_strings
versions_version_=`strings "${versions_shell_}" 2>&1 \
|grep Version \
|sed 's/^.*Version \(.*\)$/\1/;s/ s+ \$$//;s/ /-/g'`
fi
if [ -z "${versions_version_}" ]; then
versions_version_=`versions_shell_pdksh "${versions_shell_}"`
fi
echo "${versions_version_}"
unset versions_shell_ versions_version_
}
# mksh - MirBSD Korn Shell (http://www.mirbsd.org/mksh.htm)
# mksh is a successor to pdksh (Public Domain Korn Shell).
versions_shell_mksh() {
versions_shell_ksh
}
# pdksh - Public Domain Korn Shell
# pdksh is an obsolete shell, which was replaced by mksh (among others).
versions_shell_pdksh() {
_versions_have_strings
strings "$1" 2>&1 \
|grep 'PD KSH' \
|sed -e 's/.*PD KSH \(.*\)/\1/;s/ /-/g'
}
versions_shell_xpg4() {
_versions_have_strings
strings "$1" 2>&1 \
|grep 'Version' \
|sed -e 's/^@(#)Version //'
}
versions_shell_zsh() {
versions_shell_=$1
# Try a few different ways to figure out the version.
# shellcheck disable=SC2016
versions_version_=`echo 'echo ${ZSH_VERSION}' |${versions_shell_}`
if [ -z "${versions_version_}" ]; then
versions_version_=`${versions_shell_} --version : 2>&1`
# shellcheck disable=SC2181
if [ $? -eq 0 ]; then
versions_version_=`echo "${versions_version_}" |awk '{print $2}'`
else
versions_version_=''
fi
fi
echo "${versions_version_}"
unset versions_shell_ versions_version_
}
# Determine if the 'strings' binary installed.
_versions_have_strings() {
[ ${__versions_haveStrings} -ne ${ERROR} ] && return
if eval strings /dev/null >/dev/null 2>&1; then
__versions_haveStrings=${TRUE}
return
fi
echo 'WARN: strings not installed. try installing binutils?' >&2
__versions_haveStrings=${FALSE}
}
versions_main() {
# Treat unset variables as an error.
set -u
os_name=`versions_osName`
os_version=`versions_osVersion`
echo "os: ${os_name} version: ${os_version}"
for shell in ${VERSIONS_SHELLS}; do
shell_version=`versions_shellVersion "${shell}"`
echo "shell: ${shell} version: ${shell_version}"
done
}
if [ "${ARGV0}" = 'versions' ]; then
versions_main "$@"
fi

1377
dev/tests/shunit2/shunit2 Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,64 @@
#!/bin/sh
# vim:et:ft=sh:sts=2:sw=2
#
# shunit2 unit test for running subset(s) of tests based upon command line args.
#
# Copyright 2008-2021 Kate Ward. All Rights Reserved.
# Released under the Apache 2.0 license.
# http://www.apache.org/licenses/LICENSE-2.0
#
# https://github.com/kward/shunit2
#
# Also shows how non-default tests or a arbitrary subset of tests can be run.
#
# Disable source following.
# shellcheck disable=SC1090,SC1091
# Load test helpers.
. ./shunit2_test_helpers
CUSTOM_TEST_RAN=''
# This test does not normally run because it does not begin "test*". Will be
# run by setting the arguments to the script to include the name of this test.
custom_test() {
# Arbitrary assert.
assertTrue 0
# The true intent is to set this variable, which will be tested below.
CUSTOM_TEST_RAN='yup, we ran'
}
# Verify that `customTest()` ran.
testCustomTestRan() {
assertNotNull "'custom_test()' did not run" "${CUSTOM_TEST_RAN}"
}
# Fail if this test runs, which is shouldn't if arguments are set correctly.
testShouldFail() {
fail 'testShouldFail should not be run if argument parsing works'
}
oneTimeSetUp() {
th_oneTimeSetUp
}
# If zero/one argument(s) are provided, this test is being run in it's
# entirety, and therefore we want to set the arguments to the script to
# (simulate and) test the processing of command-line specified tests. If we
# don't, then the "test_will_fail" test will run (by default) and the overall
# test will fail.
#
# However, if two or more arguments are provided, then assume this test script
# is being run by hand to experiment with command-line test specification, and
# then don't override the user provided arguments.
if [ "$#" -le 1 ]; then
# We set the arguments in a POSIX way, inasmuch as we can;
# helpful tip:
# https://unix.stackexchange.com/questions/258512/how-to-remove-a-positional-parameter-from
set -- '--' 'custom_test' 'testCustomTestRan'
fi
# Load and run shunit2.
# shellcheck disable=SC2034
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
. "${TH_SHUNIT}"

View File

@ -0,0 +1,403 @@
#! /bin/sh
# vim:et:ft=sh:sts=2:sw=2
#
# shunit2 unit test for assert functions.
#
# Copyright 2008-2021 Kate Ward. All Rights Reserved.
# Released under the Apache 2.0 license.
# http://www.apache.org/licenses/LICENSE-2.0
#
# Author: kate.ward@forestent.com (Kate Ward)
# https://github.com/kward/shunit2
#
# In this file, all assert calls under test must be wrapped in () so they do not
# influence the metrics of the test itself.
#
# Disable source following.
# shellcheck disable=SC1090,SC1091
# These variables will be overridden by the test helpers.
stdoutF="${TMPDIR:-/tmp}/STDOUT"
stderrF="${TMPDIR:-/tmp}/STDERR"
# Load test helpers.
. ./shunit2_test_helpers
commonEqualsSame() {
fn=$1
# These should succeed.
desc='equal'
if (${fn} 'x' 'x' >"${stdoutF}" 2>"${stderrF}"); then
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
else
fail "${desc}: unexpected failure"
_showTestOutput
fi
desc='equal_with_message'
if (${fn} 'some message' 'x' 'x' >"${stdoutF}" 2>"${stderrF}"); then
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
else
fail "${desc}: unexpected failure"
_showTestOutput
fi
desc='equal_with_spaces'
if (${fn} 'abc def' 'abc def' >"${stdoutF}" 2>"${stderrF}"); then
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
else
fail "${desc}: unexpected failure"
_showTestOutput
fi
desc='equal_null_values'
if (${fn} '' '' >"${stdoutF}" 2>"${stderrF}"); then
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
else
fail "${desc}: unexpected failure"
_showTestOutput
fi
# These should fail.
desc='not_equal'
if (${fn} 'x' 'y' >"${stdoutF}" 2>"${stderrF}"); then
fail "${desc}: expected a failure"
_showTestOutput
else
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
fi
}
commonNotEqualsSame() {
fn=$1
# These should succeed.
desc='not_same'
if (${fn} 'x' 'y' >"${stdoutF}" 2>"${stderrF}"); then
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
else
fail "${desc}: unexpected failure"
_showTestOutput
fi
desc='not_same_with_message'
if (${fn} 'some message' 'x' 'y' >"${stdoutF}" 2>"${stderrF}"); then
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
else
fail "${desc}: unexpected failure"
_showTestOutput
fi
# These should fail.
desc='same'
if (${fn} 'x' 'x' >"${stdoutF}" 2>"${stderrF}"); then
fail "${desc}: expected a failure"
_showTestOutput
else
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
fi
desc='unequal_null_values'
if (${fn} '' '' >"${stdoutF}" 2>"${stderrF}"); then
fail "${desc}: expected a failure"
_showTestOutput
else
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
fi
}
testAssertEquals() { commonEqualsSame 'assertEquals'; }
testAssertNotEquals() { commonNotEqualsSame 'assertNotEquals'; }
testAssertSame() { commonEqualsSame 'assertSame'; }
testAssertNotSame() { commonNotEqualsSame 'assertNotSame'; }
testAssertContains() {
# Content is present.
while read -r desc container content; do
if (assertContains "${container}" "${content}" >"${stdoutF}" 2>"${stderrF}"); then
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
else
fail "${desc}: unexpected failure"
_showTestOutput
fi
done <<EOF
abc_at_start abcdef abc
bcd_in_middle abcdef bcd
def_at_end abcdef def
EOF
# Content missing.
while read -r desc container content; do
if (assertContains "${container}" "${content}" >"${stdoutF}" 2>"${stderrF}"); then
fail "${desc}: unexpected failure"
_showTestOutput
else
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
fi
done <<EOF
xyz_not_present abcdef xyz
zab_contains_start abcdef zab
efg_contains_end abcdef efg
acf_has_parts abcdef acf
EOF
desc="content_starts_with_dash"
if (assertContains 'abc -Xabc def' '-Xabc' >"${stdoutF}" 2>"${stderrF}"); then
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
else
fail "${desc}: unexpected failure"
_showTestOutput
fi
desc="contains_with_message"
if (assertContains 'some message' 'abcdef' 'abc' >"${stdoutF}" 2>"${stderrF}"); then
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
else
fail "${desc}: unexpected failure"
_showTestOutput
fi
}
testAssertNotContains() {
# Content not present.
while read -r desc container content; do
if (assertNotContains "${container}" "${content}" >"${stdoutF}" 2>"${stderrF}"); then
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
else
fail "${desc}: unexpected failure"
_showTestOutput
fi
done <<EOF
xyz_not_present abcdef xyz
zab_contains_start abcdef zab
efg_contains_end abcdef efg
acf_has_parts abcdef acf
EOF
# Content present.
while read -r desc container content; do
if (assertNotContains "${container}" "${content}" >"${stdoutF}" 2>"${stderrF}"); then
fail "${desc}: expected a failure"
_showTestOutput
else
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
fi
done <<EOF
abc_is_present abcdef abc
EOF
desc='not_contains_with_message'
if (assertNotContains 'some message' 'abcdef' 'xyz' >"${stdoutF}" 2>"${stderrF}"); then
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
else
fail "${desc}: unexpected failure"
_showTestOutput
fi
}
testAssertNull() {
while read -r desc value; do
if (assertNull "${value}" >"${stdoutF}" 2>"${stderrF}"); then
fail "${desc}: unexpected failure"
_showTestOutput
else
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
fi
done <<'EOF'
x_alone x
x_double_quote_a x"a
x_single_quote_a x'a
x_dollar_a x$a
x_backtick_a x`a
EOF
desc='null_without_message'
if (assertNull '' >"${stdoutF}" 2>"${stderrF}"); then
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
else
fail "${desc}: unexpected failure"
_showTestOutput
fi
desc='null_with_message'
if (assertNull 'some message' '' >"${stdoutF}" 2>"${stderrF}"); then
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
else
fail "${desc}: unexpected failure"
_showTestOutput
fi
desc='x_is_not_null'
if (assertNull 'x' >"${stdoutF}" 2>"${stderrF}"); then
fail "${desc}: expected a failure"
_showTestOutput
else
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
fi
}
testAssertNotNull() {
while read -r desc value; do
if (assertNotNull "${value}" >"${stdoutF}" 2>"${stderrF}"); then
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
else
fail "${desc}: unexpected failure"
_showTestOutput
fi
done <<'EOF'
x_alone x
x_double_quote_b x"b
x_single_quote_b x'b
x_dollar_b x$b
x_backtick_b x`b
EOF
desc='not_null_with_message'
if (assertNotNull 'some message' 'x' >"${stdoutF}" 2>"${stderrF}"); then
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
else
fail "${desc}: unexpected failure"
_showTestOutput
fi
desc="double_ticks_are_null"
if (assertNotNull '' >"${stdoutF}" 2>"${stderrF}"); then
fail "${desc}: expected a failure"
_showTestOutput
else
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
fi
}
testAssertTrue() {
# True values.
while read -r desc value; do
if (assertTrue "${value}" >"${stdoutF}" 2>"${stderrF}"); then
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
else
fail "${desc}: unexpected failure"
_showTestOutput
fi
done <<'EOF'
zero 0
zero_eq_zero [ 0 -eq 0 ]
EOF
# Not true values.
while read -r desc value; do
if (assertTrue "${value}" >"${stdoutF}" 2>"${stderrF}"); then
fail "${desc}: expected a failure"
_showTestOutput
else
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
fi
done <<EOF
one 1
zero_eq_1 [ 0 -eq 1 ]
null
EOF
desc='true_with_message'
if (assertTrue 'some message' 0 >"${stdoutF}" 2>"${stderrF}"); then
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
else
fail "${desc}: unexpected failure"
_showTestOutput
fi
}
testAssertFalse() {
# False values.
while read -r desc value; do
if (assertFalse "${value}" >"${stdoutF}" 2>"${stderrF}"); then
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
else
fail "${desc}: unexpected failure"
_showTestOutput
fi
done <<EOF
one 1
zero_eq_1 [ 0 -eq 1 ]
null
EOF
# Not true values.
while read -r desc value; do
if (assertFalse "${value}" >"${stdoutF}" 2>"${stderrF}"); then
fail "${desc}: expected a failure"
_showTestOutput
else
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
fi
done <<'EOF'
zero 0
zero_eq_zero [ 0 -eq 0 ]
EOF
desc='false_with_message'
if (assertFalse 'some message' 1 >"${stdoutF}" 2>"${stderrF}"); then
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
else
fail "${desc}: unexpected failure"
_showTestOutput
fi
}
FUNCTIONS='
assertEquals assertNotEquals
assertSame assertNotSame
assertContains assertNotContains
assertNull assertNotNull
assertTrue assertFalse
'
testTooFewArguments() {
for fn in ${FUNCTIONS}; do
# These functions support zero arguments.
case "${fn}" in
assertNull) continue ;;
assertNotNull) continue ;;
esac
desc="${fn}"
if (${fn} >"${stdoutF}" 2>"${stderrF}"); then
fail "${desc}: expected a failure"
_showTestOutput
else
got=$? want=${SHUNIT_ERROR}
assertEquals "${desc}: incorrect return code" "${got}" "${want}"
th_assertFalseWithError "${desc}" "${got}" "${stdoutF}" "${stderrF}"
fi
done
}
testTooManyArguments() {
for fn in ${FUNCTIONS}; do
desc="${fn}"
if (${fn} arg1 arg2 arg3 arg4 >"${stdoutF}" 2>"${stderrF}"); then
fail "${desc}: expected a failure"
_showTestOutput
else
got=$? want=${SHUNIT_ERROR}
assertEquals "${desc}: incorrect return code" "${got}" "${want}"
th_assertFalseWithError "${desc}" "${got}" "${stdoutF}" "${stderrF}"
fi
done
}
oneTimeSetUp() {
th_oneTimeSetUp
}
# showTestOutput for the most recently run test.
_showTestOutput() { th_showOutput "${SHUNIT_FALSE}" "${stdoutF}" "${stderrF}"; }
# Load and run shunit2.
# shellcheck disable=SC2034
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
. "${TH_SHUNIT}"

View File

@ -0,0 +1,137 @@
#! /bin/sh
# vim:et:ft=sh:sts=2:sw=2
#
# shUnit2 unit test for failure functions. These functions do not test values.
#
# Copyright 2008-2021 Kate Ward. All Rights Reserved.
# Released under the Apache 2.0 license.
# http://www.apache.org/licenses/LICENSE-2.0
#
# Author: kate.ward@forestent.com (Kate Ward)
# https://github.com/kward/shunit2
#
# Disable source following.
# shellcheck disable=SC1090,SC1091
# These variables will be overridden by the test helpers.
stdoutF="${TMPDIR:-/tmp}/STDOUT"
stderrF="${TMPDIR:-/tmp}/STDERR"
# Load test helpers.
. ./shunit2_test_helpers
testFail() {
# Test without a message.
desc='fail_without_message'
if ( fail >"${stdoutF}" 2>"${stderrF}" ); then
fail "${desc}: expected a failure"
th_showOutput
else
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
fi
# Test with a message.
desc='fail_with_message'
if ( fail 'some message' >"${stdoutF}" 2>"${stderrF}" ); then
fail "${desc}: expected a failure"
th_showOutput
else
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
fi
}
# FN_TESTS hold all the functions to be tested.
# shellcheck disable=SC2006
FN_TESTS=`
# fn num_args pattern
cat <<EOF
fail 1
failNotEquals 3 but was:
failFound 2 found:
failNotFound 2 not found:
failSame 3 not same
failNotSame 3 but was:
EOF
`
testFailsWithArgs() {
echo "${FN_TESTS}" |\
while read -r fn num_args pattern; do
case "${fn}" in
fail) continue ;;
esac
# Test without a message.
desc="${fn}_without_message"
if ( ${fn} arg1 arg2 >"${stdoutF}" 2>"${stderrF}" ); then
fail "${desc}: expected a failure"
th_showOutput
else
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
fi
# Test with a message.
arg1='' arg2=''
case ${num_args} in
1) ;;
2) arg1='arg1' ;;
3) arg1='arg1' arg2='arg2' ;;
esac
desc="${fn}_with_message"
if ( ${fn} 'some message' ${arg1} ${arg2} >"${stdoutF}" 2>"${stderrF}" ); then
fail "${desc}: expected a failure"
th_showOutput
else
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
if ! grep -- "${pattern}" "${stdoutF}" >/dev/null; then
fail "${desc}: incorrect message to STDOUT"
th_showOutput
fi
fi
done
}
testTooFewArguments() {
echo "${FN_TESTS}" \
|while read -r fn num_args pattern; do
# Skip functions that support a single message argument.
if [ "${num_args}" -eq 1 ]; then
continue
fi
desc="${fn}"
if (${fn} >"${stdoutF}" 2>"${stderrF}"); then
fail "${desc}: expected a failure"
_showTestOutput
else
got=$? want=${SHUNIT_ERROR}
assertEquals "${desc}: incorrect return code" "${got}" "${want}"
th_assertFalseWithError "${desc}" "${got}" "${stdoutF}" "${stderrF}"
fi
done
}
testTooManyArguments() {
echo "${FN_TESTS}" \
|while read -r fn num_args pattern; do
desc="${fn}"
if (${fn} arg1 arg2 arg3 arg4 >"${stdoutF}" 2>"${stderrF}"); then
fail "${desc}: expected a failure"
_showTestOutput
else
got=$? want=${SHUNIT_ERROR}
assertEquals "${desc}: incorrect return code" "${got}" "${want}"
th_assertFalseWithError "${desc}" "${got}" "${stdoutF}" "${stderrF}"
fi
done
}
oneTimeSetUp() {
th_oneTimeSetUp
}
# Load and run shUnit2.
# shellcheck disable=SC2034
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
. "${TH_SHUNIT}"

View File

@ -0,0 +1,99 @@
#! /bin/sh
# vim:et:ft=sh:sts=2:sw=2
#
# shUnit2 unit tests for general commands.
#
# Copyright 2008-2021 Kate Ward. All Rights Reserved.
# Released under the Apache 2.0 license.
# http://www.apache.org/licenses/LICENSE-2.0
#
# Author: kate.ward@forestent.com (Kate Ward)
# https://github.com/kward/shunit2
#
# Disable source following.
# shellcheck disable=SC1090,SC1091
# These variables will be overridden by the test helpers.
stdoutF="${TMPDIR:-/tmp}/STDOUT"
stderrF="${TMPDIR:-/tmp}/STDERR"
# Load test helpers.
. ./shunit2_test_helpers
testSkipping() {
# We shouldn't be skipping to start.
if isSkipping; then
th_error 'skipping *should not be* enabled'
return
fi
startSkipping
was_skipping_started=${SHUNIT_FALSE}
if isSkipping; then was_skipping_started=${SHUNIT_TRUE}; fi
endSkipping
was_skipping_ended=${SHUNIT_FALSE}
if isSkipping; then was_skipping_ended=${SHUNIT_TRUE}; fi
assertEquals "skipping wasn't started" "${was_skipping_started}" "${SHUNIT_TRUE}"
assertNotEquals "skipping wasn't ended" "${was_skipping_ended}" "${SHUNIT_TRUE}"
return 0
}
testStartSkippingWithMessage() {
unittestF="${SHUNIT_TMPDIR}/unittest"
sed 's/^#//' >"${unittestF}" <<\EOF
## Start skipping with a message.
#testSkipping() {
# startSkipping 'SKIP-a-Dee-Doo-Dah'
#}
#SHUNIT_COLOR='none'
#. ${TH_SHUNIT}
EOF
# Ignoring errors with `|| :` as we only care about `FAILED` in the output.
( exec "${SHELL:-sh}" "${unittestF}" >"${stdoutF}" 2>"${stderrF}" ) || :
if ! grep '\[skipping\] SKIP-a-Dee-Doo-Dah' "${stderrF}" >/dev/null; then
fail 'skipping message was not generated'
fi
return 0
}
testStartSkippingWithoutMessage() {
unittestF="${SHUNIT_TMPDIR}/unittest"
sed 's/^#//' >"${unittestF}" <<\EOF
## Start skipping with a message.
#testSkipping() {
# startSkipping
#}
#SHUNIT_COLOR='none'
#. ${TH_SHUNIT}
EOF
# Ignoring errors with `|| :` as we only care about `FAILED` in the output.
( exec "${SHELL:-sh}" "${unittestF}" >"${stdoutF}" 2>"${stderrF}" ) || :
if grep '\[skipping\]' "${stderrF}" >/dev/null; then
fail 'skipping message was unexpectedly generated'
fi
return 0
}
setUp() {
for f in "${stdoutF}" "${stderrF}"; do
cp /dev/null "${f}"
done
# Reconfigure coloring as some tests override default behavior.
_shunit_configureColor "${SHUNIT_COLOR_DEFAULT}"
# shellcheck disable=SC2034,SC2153
SHUNIT_CMD_TPUT=${__SHUNIT_CMD_TPUT}
}
oneTimeSetUp() {
SHUNIT_COLOR_DEFAULT="${SHUNIT_COLOR}"
th_oneTimeSetUp
}
# Load and run shUnit2.
# shellcheck disable=SC2034
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
. "${TH_SHUNIT}"

View File

@ -0,0 +1,247 @@
#! /bin/sh
# vim:et:ft=sh:sts=2:sw=2
#
# shunit2 unit test for macros.
#
# Copyright 2008-2021 Kate Ward. All Rights Reserved.
# Released under the Apache 2.0 license.
# http://www.apache.org/licenses/LICENSE-2.0
#
# Author: kate.ward@forestent.com (Kate Ward)
# https://github.com/kward/shunit2
#
# Disable source following.
# shellcheck disable=SC1090,SC1091
# These variables will be overridden by the test helpers.
stdoutF="${TMPDIR:-/tmp}/STDOUT"
stderrF="${TMPDIR:-/tmp}/STDERR"
# Load test helpers.
. ./shunit2_test_helpers
testAssertEquals() {
isLinenoWorking || startSkipping
( ${_ASSERT_EQUALS_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_ASSERT_EQUALS_ failed to produce an ASSERT message'
showTestOutput
fi
( ${_ASSERT_EQUALS_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_ASSERT_EQUALS_ (with a message) failed to produce an ASSERT message'
showTestOutput
fi
}
testAssertNotEquals() {
isLinenoWorking || startSkipping
( ${_ASSERT_NOT_EQUALS_} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_ASSERT_NOT_EQUALS_ failed to produce an ASSERT message'
showTestOutput
fi
( ${_ASSERT_NOT_EQUALS_} '"some msg"' 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_ASSERT_NOT_EQUALS_ (with a message) failed to produce an ASSERT message'
showTestOutput
fi
}
testSame() {
isLinenoWorking || startSkipping
( ${_ASSERT_SAME_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_ASSERT_SAME_ failed to produce an ASSERT message'
showTestOutput
fi
( ${_ASSERT_SAME_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_ASSERT_SAME_ (with a message) failed to produce an ASSERT message'
showTestOutput
fi
}
testNotSame() {
isLinenoWorking || startSkipping
( ${_ASSERT_NOT_SAME_} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_ASSERT_NOT_SAME_ failed to produce an ASSERT message'
showTestOutput
fi
( ${_ASSERT_NOT_SAME_} '"some msg"' 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_ASSERT_NOT_SAME_ (with a message) failed to produce an ASSERT message'
showTestOutput
fi
}
testNull() {
isLinenoWorking || startSkipping
( ${_ASSERT_NULL_} 'x' >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_ASSERT_NULL_ failed to produce an ASSERT message'
showTestOutput
fi
( ${_ASSERT_NULL_} '"some msg"' 'x' >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_ASSERT_NULL_ (with a message) failed to produce an ASSERT message'
showTestOutput
fi
}
testNotNull() {
isLinenoWorking || startSkipping
( ${_ASSERT_NOT_NULL_} '' >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_ASSERT_NOT_NULL_ failed to produce an ASSERT message'
showTestOutput
fi
( ${_ASSERT_NOT_NULL_} '"some msg"' '""' >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_ASSERT_NOT_NULL_ (with a message) failed to produce an ASSERT message'
showTestOutput
fi
}
testAssertTrue() {
isLinenoWorking || startSkipping
( ${_ASSERT_TRUE_} "${SHUNIT_FALSE}" >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_ASSERT_TRUE_ failed to produce an ASSERT message'
showTestOutput
fi
( ${_ASSERT_TRUE_} '"some msg"' "${SHUNIT_FALSE}" >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_ASSERT_TRUE_ (with a message) failed to produce an ASSERT message'
showTestOutput
fi
}
testAssertFalse() {
isLinenoWorking || startSkipping
( ${_ASSERT_FALSE_} "${SHUNIT_TRUE}" >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_ASSERT_FALSE_ failed to produce an ASSERT message'
showTestOutput
fi
( ${_ASSERT_FALSE_} '"some msg"' "${SHUNIT_TRUE}" >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_ASSERT_FALSE_ (with a message) failed to produce an ASSERT message'
showTestOutput
fi
}
testFail() {
isLinenoWorking || startSkipping
( ${_FAIL_} >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_FAIL_ failed to produce an ASSERT message'
showTestOutput
fi
( ${_FAIL_} '"some msg"' >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_FAIL_ (with a message) failed to produce an ASSERT message'
showTestOutput
fi
}
testFailNotEquals() {
isLinenoWorking || startSkipping
( ${_FAIL_NOT_EQUALS_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_FAIL_NOT_EQUALS_ failed to produce an ASSERT message'
showTestOutput
fi
( ${_FAIL_NOT_EQUALS_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_FAIL_NOT_EQUALS_ (with a message) failed to produce an ASSERT message'
showTestOutput
fi
}
testFailSame() {
isLinenoWorking || startSkipping
( ${_FAIL_SAME_} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_FAIL_SAME_ failed to produce an ASSERT message'
showTestOutput
fi
( ${_FAIL_SAME_} '"some msg"' 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_FAIL_SAME_ (with a message) failed to produce an ASSERT message'
showTestOutput
fi
}
testFailNotSame() {
isLinenoWorking || startSkipping
( ${_FAIL_NOT_SAME_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_FAIL_NOT_SAME_ failed to produce an ASSERT message'
showTestOutput
fi
( ${_FAIL_NOT_SAME_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
if ! wasAssertGenerated; then
fail '_FAIL_NOT_SAME_ (with a message) failed to produce an ASSERT message'
showTestOutput
fi
}
oneTimeSetUp() {
th_oneTimeSetUp
if ! isLinenoWorking; then
# shellcheck disable=SC2016
th_warn '${LINENO} is not working for this shell. Tests will be skipped.'
fi
}
# isLinenoWorking returns true if the `$LINENO` shell variable works properly.
isLinenoWorking() {
# shellcheck disable=SC2016
ln='eval echo "${LINENO:-}"'
case ${ln} in
[0-9]*) return "${SHUNIT_TRUE}" ;;
-[0-9]*) return "${SHUNIT_FALSE}" ;; # The dash shell produces negative values.
esac
return "${SHUNIT_FALSE}"
}
# showTestOutput for the most recently run test.
showTestOutput() { th_showOutput "${SHUNIT_FALSE}" "${stdoutF}" "${stderrF}"; }
# wasAssertGenerated returns true if an ASSERT was generated to STDOUT.
wasAssertGenerated() { grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null; }
# Disable output coloring as it breaks the tests.
SHUNIT_COLOR='none'; export SHUNIT_COLOR
# Load and run shUnit2.
# shellcheck disable=SC2034
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT="$0"
. "${TH_SHUNIT}"

View File

@ -0,0 +1,292 @@
#! /bin/sh
# vim:et:ft=sh:sts=2:sw=2
#
# shUnit2 unit tests of miscellaneous things
#
# Copyright 2008-2021 Kate Ward. All Rights Reserved.
# Released under the Apache 2.0 license.
# http://www.apache.org/licenses/LICENSE-2.0
#
# Author: kate.ward@forestent.com (Kate Ward)
# https://github.com/kward/shunit2
#
# Allow usage of legacy backticked `...` notation instead of $(...).
# shellcheck disable=SC2006
# Disable source following.
# shellcheck disable=SC1090,SC1091
# These variables will be overridden by the test helpers.
stdoutF="${TMPDIR:-/tmp}/STDOUT"
stderrF="${TMPDIR:-/tmp}/STDERR"
# Load test helpers.
. ./shunit2_test_helpers
# Note: the test script is prefixed with '#' chars so that shUnit2 does not
# incorrectly interpret the embedded functions as real functions.
testUnboundVariable() {
unittestF="${SHUNIT_TMPDIR}/unittest"
sed 's/^#//' >"${unittestF}" <<EOF
## Treat unset variables as an error when performing parameter expansion.
#set -u
#
#boom() { x=\$1; } # This function goes boom if no parameters are passed!
#test_boom() {
# assertEquals 1 1
# boom # No parameter given
# assertEquals 0 \$?
#}
#SHUNIT_COLOR='none'
#. ${TH_SHUNIT}
EOF
if ( exec "${SHELL:-sh}" "${unittestF}" >"${stdoutF}" 2>"${stderrF}" ); then
fail 'expected a non-zero exit value'
fi
if ! grep '^ASSERT:unknown failure' "${stdoutF}" >/dev/null; then
fail 'assert message was not generated'
fi
if ! grep '^Ran [0-9]* test' "${stdoutF}" >/dev/null; then
fail 'test count message was not generated'
fi
if ! grep '^FAILED' "${stdoutF}" >/dev/null; then
fail 'failure message was not generated'
fi
}
# assertEquals repeats message argument.
# https://github.com/kward/shunit2/issues/7
testIssue7() {
# Disable coloring so 'ASSERT:' lines can be matched correctly.
_shunit_configureColor 'none'
# Ignoring errors with `|| :` as we only care about the message in this test.
( assertEquals 'Some message.' 1 2 >"${stdoutF}" 2>"${stderrF}" ) || :
diff "${stdoutF}" - >/dev/null <<EOF
ASSERT:Some message. expected:<1> but was:<2>
EOF
rtrn=$?
assertEquals "${SHUNIT_TRUE}" "${rtrn}"
[ "${rtrn}" -eq "${SHUNIT_TRUE}" ] || cat "${stderrF}" >&2
}
# Support prefixes on test output.
# https://github.com/kward/shunit2/issues/29
testIssue29() {
unittestF="${SHUNIT_TMPDIR}/unittest"
sed 's/^#//' >"${unittestF}" <<EOF
## Support test prefixes.
#test_assert() { assertTrue ${SHUNIT_TRUE}; }
#SHUNIT_COLOR='none'
#SHUNIT_TEST_PREFIX='--- '
#. ${TH_SHUNIT}
EOF
( exec "${SHELL:-sh}" "${unittestF}" >"${stdoutF}" 2>"${stderrF}" )
grep '^--- test_assert' "${stdoutF}" >/dev/null
rtrn=$?
assertEquals "${SHUNIT_TRUE}" "${rtrn}"
[ "${rtrn}" -eq "${SHUNIT_TRUE}" ] || cat "${stdoutF}" >&2
}
# Test that certain external commands sometimes "stubbed" by users are escaped.
testIssue54() {
for c in mkdir rm cat chmod sed; do
if grep "^[^#]*${c} " "${TH_SHUNIT}" | grep -qv "command ${c}"; then
fail "external call to ${c} not protected somewhere"
fi
done
# shellcheck disable=2016
if grep '^[^#]*[^ ] *\[' "${TH_SHUNIT}" | grep -qv '${__SHUNIT_BUILTIN} \['; then
fail 'call to [ not protected somewhere'
fi
# shellcheck disable=2016
if grep '^[^#]* *\.' "${TH_SHUNIT}" | grep -qv '${__SHUNIT_BUILTIN} \.'; then
fail 'call to . not protected somewhere'
fi
}
# shUnit2 should not exit with 0 when it has syntax errors.
# https://github.com/kward/shunit2/issues/69
testIssue69() {
unittestF="${SHUNIT_TMPDIR}/unittest"
# Note: assertNull not tested as zero arguments == null, which is valid.
for t in Equals NotEquals NotNull Same NotSame True False; do
assert="assert${t}"
sed 's/^#//' >"${unittestF}" <<EOF
## Asserts with invalid argument counts should be counted as failures.
#test_assert() { ${assert}; }
#SHUNIT_COLOR='none'
#. ${TH_SHUNIT}
EOF
# Ignoring errors with `|| :` as we only care about `FAILED` in the output.
( exec "${SHELL:-sh}" "${unittestF}" >"${stdoutF}" 2>"${stderrF}" ) || :
grep '^FAILED' "${stdoutF}" >/dev/null
assertTrue "failure message for ${assert} was not generated" $?
done
}
# Ensure that test fails if setup/teardown functions fail.
testIssue77() {
unittestF="${SHUNIT_TMPDIR}/unittest"
for func in oneTimeSetUp setUp tearDown oneTimeTearDown; do
sed 's/^#//' >"${unittestF}" <<EOF
## Environment failure should end test.
#${func}() { return ${SHUNIT_FALSE}; }
#test_true() { assertTrue ${SHUNIT_TRUE}; }
#SHUNIT_COLOR='none'
#. ${TH_SHUNIT}
EOF
# Ignoring errors with `|| :` as we only care about `FAILED` in the output.
( exec "${SHELL:-sh}" "${unittestF}" ) >"${stdoutF}" 2>"${stderrF}" || :
grep '^FAILED' "${stdoutF}" >/dev/null
assertTrue "failure of ${func}() did not end test" $?
done
}
# Ensure a test failure is recorded for code containing syntax errors.
# https://github.com/kward/shunit2/issues/84
testIssue84() {
unittestF="${SHUNIT_TMPDIR}/unittest"
sed 's/^#//' >"${unittestF}" <<\EOF
## Function with syntax error.
#syntax_error() { ${!#3442} -334 a$@2[1]; }
#test_syntax_error() {
# syntax_error
# assertTrue ${SHUNIT_TRUE}
#}
#SHUNIT_COLOR='none'
#SHUNIT_TEST_PREFIX='--- '
#. ${TH_SHUNIT}
EOF
# Ignoring errors with `|| :` as we only care about `FAILED` in the output.
( exec "${SHELL:-sh}" "${unittestF}" >"${stdoutF}" 2>"${stderrF}" ) || :
if ! grep '^FAILED' "${stdoutF}" >/dev/null; then
fail 'failure message was not generated'
fi
}
# Demonstrate that asserts are no longer executed in subshells.
# https://github.com/kward/shunit2/issues/123
#
# NOTE: this test only works if the `${BASH_SUBSHELL}` variable is present.
testIssue123() {
if [ -z "${BASH_SUBSHELL:-}" ]; then
# shellcheck disable=SC2016
startSkipping 'The ${BASH_SUBSHELL} variable is unavailable in this shell.'
fi
# shellcheck disable=SC2016
assertTrue 'not in subshell' '[[ ${BASH_SUBSHELL} -eq 0 ]]'
}
testPrepForSourcing() {
assertEquals '/abc' "`_shunit_prepForSourcing '/abc'`"
assertEquals './abc' "`_shunit_prepForSourcing './abc'`"
assertEquals './abc' "`_shunit_prepForSourcing 'abc'`"
}
# Test the various ways of declaring functions.
#
# Prefixing (then stripping) with comment symbol so these functions aren't
# treated as real functions by shUnit2.
testExtractTestFunctions() {
f="${SHUNIT_TMPDIR}/extract_test_functions"
sed 's/^#//' <<EOF >"${f}"
## Function on a single line.
#testABC() { echo 'ABC'; }
## Multi-line function with '{' on next line.
#test_def()
# {
# echo 'def'
#}
## Multi-line function with '{' on first line.
#testG3 () {
# echo 'G3'
#}
## Function with numerical values in name.
#function test4() { echo '4'; }
## Leading space in front of function.
# test5() { echo '5'; }
## Function with '_' chars in name.
#some_test_function() { echo 'some func'; }
## Function that sets variables.
#func_with_test_vars() {
# testVariable=1234
#}
## Function with keyword but no parenthesis
#function test6 { echo '6'; }
## Function with keyword but no parenthesis, multi-line
#function test7 {
# echo '7';
#}
## Function with no parenthesis, '{' on next line
#function test8
#{
# echo '8'
#}
## Function with hyphenated name
#test-9() {
# echo '9';
#}
## Function without parenthesis or keyword
#test_foobar { echo 'hello world'; }
## Function with multiple function keywords
#function function test_test_test() { echo 'lorem'; }
EOF
actual=`_shunit_extractTestFunctions "${f}"`
assertEquals 'testABC test_def testG3 test4 test5 test6 test7 test8 test-9' "${actual}"
}
testColors() {
while read -r cmd colors desc; do
SHUNIT_CMD_TPUT=${cmd}
want=${colors} got=`_shunit_colors`
assertEquals "${desc}: incorrect number of colors;" \
"${got}" "${want}"
done <<'EOF'
missing_tput 16 missing tput command
mock_tput 256 mock tput command
EOF
}
testColorsWitoutTERM() {
SHUNIT_CMD_TPUT='mock_tput'
got=`TERM='' _shunit_colors`
want=16
assertEquals "${got}" "${want}"
}
mock_tput() {
if [ -z "${TERM}" ]; then
# shellcheck disable=SC2016
echo 'tput: No value for $TERM and no -T specified'
return 2
fi
if [ "$1" = 'colors' ]; then
echo 256
return 0
fi
return 1
}
setUp() {
for f in "${stdoutF}" "${stderrF}"; do
cp /dev/null "${f}"
done
# Reconfigure coloring as some tests override default behavior.
_shunit_configureColor "${SHUNIT_COLOR_DEFAULT}"
# shellcheck disable=SC2034,SC2153
SHUNIT_CMD_TPUT=${__SHUNIT_CMD_TPUT}
}
oneTimeSetUp() {
SHUNIT_COLOR_DEFAULT="${SHUNIT_COLOR}"
th_oneTimeSetUp
}
# Load and run shUnit2.
# shellcheck disable=SC2034
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
. "${TH_SHUNIT}"

View File

@ -0,0 +1,70 @@
#! /bin/sh
# vim:et:ft=sh:sts=2:sw=2
#
# shUnit2 unit tests for `shopt` support.
#
# Copyright 2008-2021 Kate Ward. All Rights Reserved.
# Released under the Apache 2.0 license.
# http://www.apache.org/licenses/LICENSE-2.0
#
# Author: kate.ward@forestent.com (Kate Ward)
# https://github.com/kward/shunit2
#
# Disable source following.
# shellcheck disable=SC1090,SC1091
# Load test helpers.
. ./shunit2_test_helpers
# Call shopt from a variable so it can be mocked if it doesn't work.
SHOPT_CMD='shopt'
testNullglob() {
isShoptWorking || startSkipping
nullglob=$(${SHOPT_CMD} nullglob |cut -f2)
# Test without nullglob.
${SHOPT_CMD} -u nullglob
assertEquals 'test without nullglob' 0 0
# Test with nullglob.
${SHOPT_CMD} -s nullglob
assertEquals 'test with nullglob' 1 1
# Reset nullglob.
if [ "${nullglob}" = "on" ]; then
${SHOPT_CMD} -s nullglob
else
${SHOPT_CMD} -u nullglob
fi
unset nullglob
}
oneTimeSetUp() {
th_oneTimeSetUp
if ! isShoptWorking; then
SHOPT_CMD='mock_shopt'
fi
}
# isShoptWorking returns true if the `shopt` shell command is available.
# NOTE: `shopt` is not defined as part of the POSIX standard.
isShoptWorking() {
# shellcheck disable=SC2039,SC3044
( shopt >/dev/null 2>&1 );
}
mock_shopt() {
if [ $# -eq 0 ]; then
echo "nullglob off"
fi
return
}
# Load and run shUnit2.
# shellcheck disable=SC2034
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT="$0"
. "${TH_SHUNIT}"

View File

@ -0,0 +1,36 @@
#! /bin/sh
# vim:et:ft=sh:sts=2:sw=2
#
# shUnit2 unit test for standalone operation.
#
# Copyright 2008-2021 Kate Ward. All Rights Reserved.
# Released under the Apache 2.0 license.
# http://www.apache.org/licenses/LICENSE-2.0
#
# Author: kate.ward@forestent.com (Kate Ward)
# https://github.com/kward/shunit2
#
# This unit test is purely to test that calling shunit2 directly, while passing
# the name of a unit test script, works. When run, this script determines if it
# is running as a standalone program, and calls main() if it is.
#
# Disable source following.
# shellcheck disable=SC1090,SC1091
ARGV0=$(basename "$0")
# Load test helpers.
. ./shunit2_test_helpers
testStandalone() {
assertTrue "${SHUNIT_TRUE}"
}
main() {
${TH_SHUNIT} "${ARGV0}"
}
# Run main() if are running as a standalone script.
if [ "${ARGV0}" = 'shunit2_standalone_test.sh' ]; then
main "$@"
fi

View File

@ -1,27 +1,37 @@
# $Id$
# vim:et:ft=sh:sts=2:sw=2
#
# Copyright 2008 Kate Ward. All Rights Reserved.
# Released under the LGPL (GNU Lesser General Public License)
# shUnit2 unit test common functions
#
# Copyright 2008-2021 Kate Ward. All Rights Reserved.
# Released under the Apache 2.0 license.
# http://www.apache.org/licenses/LICENSE-2.0
#
# Author: kate.ward@forestent.com (Kate Ward)
# https://github.com/kward/shunit2
#
# shUnit2 unit test common functions
### ShellCheck (http://www.shellcheck.net/)
# expr may be antiquated, but it is the only solution in some cases.
# shellcheck disable=SC2003
# $() are not fully portable (POSIX != portable).
# shellcheck disable=SC2006
# treat unset variables as an error when performing parameter expansion
# Exit immediately if a simple command exits with a non-zero status.
set -e
# Treat unset variables as an error when performing parameter expansion.
set -u
# set shwordsplit for zsh
# Set shwordsplit for zsh.
[ -n "${ZSH_VERSION:-}" ] && setopt shwordsplit
#
# constants
# Constants.
#
# path to shUnit2 library. can be overridden by setting SHUNIT_INC
TH_SHUNIT=${SHUNIT_INC:-./shunit2}
# Path to shUnit2 library. Can be overridden by setting SHUNIT_INC.
TH_SHUNIT=${SHUNIT_INC:-./shunit2}; export TH_SHUNIT
# configure debugging. set the DEBUG environment variable to any
# Configure debugging. Set the DEBUG environment variable to any
# non-empty value to enable debug output, or TRACE to enable trace
# output.
TRACE=${TRACE:+'th_trace '}
@ -32,49 +42,50 @@ DEBUG=${DEBUG:+'th_debug '}
[ -z "${DEBUG}" ] && DEBUG=':'
#
# variables
# Variables.
#
th_RANDOM=0
#
# functions
# Functions.
#
# message functions
th_trace() { echo "${MY_NAME}:TRACE $@" >&2; }
th_debug() { echo "${MY_NAME}:DEBUG $@" >&2; }
th_info() { echo "${MY_NAME}:INFO $@" >&2; }
th_warn() { echo "${MY_NAME}:WARN $@" >&2; }
th_error() { echo "${MY_NAME}:ERROR $@" >&2; }
th_fatal() { echo "${MY_NAME}:FATAL $@" >&2; }
# Logging functions.
th_trace() { echo "test:TRACE $*" >&2; }
th_debug() { echo "test:DEBUG $*" >&2; }
th_info() { echo "test:INFO $*" >&2; }
th_warn() { echo "test:WARN $*" >&2; }
th_error() { echo "test:ERROR $*" >&2; }
th_fatal() { echo "test:FATAL $*" >&2; }
# output subtest name
th_subtest() { echo " $@" >&2; }
# Output subtest name.
th_subtest() { echo " $*" >&2; }
th_oneTimeSetUp()
{
# these files will be cleaned up automatically by shUnit2
th_oneTimeSetUp() {
# These files will be cleaned up automatically by shUnit2.
stdoutF="${SHUNIT_TMPDIR}/stdout"
stderrF="${SHUNIT_TMPDIR}/stderr"
returnF="${SHUNIT_TMPDIR}/return"
expectedF="${SHUNIT_TMPDIR}/expected"
export stdoutF stderrF returnF expectedF
}
# generate a random number
th_generateRandom()
{
# Generate a random number.
th_generateRandom() {
tfgr_random=${th_RANDOM}
while [ "${tfgr_random}" = "${th_RANDOM}" ]; do
# shellcheck disable=SC2039
if [ -n "${RANDOM:-}" ]; then
# $RANDOM works
# shellcheck disable=SC2039
tfgr_random=${RANDOM}${RANDOM}${RANDOM}$$
elif [ -r '/dev/urandom' ]; then
tfgr_random=`od -vAn -N4 -tu4 </dev/urandom |sed 's/^[^0-9]*//'`
else
tfgr_date=`date '+%H%M%S'`
tfgr_random=`expr ${tfgr_date} \* $$`
tfgr_random=`expr "${tfgr_date}" \* $$`
unset tfgr_date
fi
[ "${tfgr_random}" = "${th_RANDOM}" ] && sleep 1
@ -84,21 +95,20 @@ th_generateRandom()
unset tfgr_random
}
# this section returns the data section from the specified section of a file. a
# datasection is defined by a [header], one or more lines of data, and then a
# This section returns the data section from the specified section of a file. A
# data section is defined by a [header], one or more lines of data, and then a
# blank line.
th_getDataSect()
{
th_getDataSect() {
th_sgrep "\\[$1\\]" "$2" |sed '1d'
}
# this function greps a section from a file. a section is defined as a group of
# lines preceeded and followed by blank lines.
th_sgrep()
{
# This function greps a section from a file. a section is defined as a group of
# lines preceded and followed by blank lines..
th_sgrep() {
th_pattern_=$1
shift
# shellcheck disable=SC2068
sed -e '/./{H;$!d;}' -e "x;/${th_pattern_}/"'!d;' $@ |sed '1d'
unset th_pattern_
@ -113,19 +123,19 @@ th_sgrep()
# th_rtrn_: integer: the return value of the subtest performed
# th_stdout_: string: filename where stdout was redirected to
# th_stderr_: string: filename where stderr was redirected to
th_assertTrueWithNoOutput()
{
th_assertTrueWithNoOutput() {
th_test_=$1
th_rtrn_=$2
th_stdout_=$3
th_stderr_=$4
assertTrue "${th_test_}; expected return value of zero" ${th_rtrn_}
[ ${th_rtrn_} -ne ${SHUNIT_TRUE} ] && cat "${th_stderr_}"
assertFalse "${th_test_}; expected no output to STDOUT" \
"[ -s '${th_stdout_}' ]"
assertFalse "${th_test_}; expected no output to STDERR" \
"[ -s '${th_stderr_}' ]"
assertEquals "${th_test_}: expected return value of true" "${SHUNIT_TRUE}" "${th_rtrn_}"
assertFalse "${th_test_}: expected no output to STDOUT" "[ -s '${th_stdout_}' ]"
assertFalse "${th_test_}: expected no output to STDERR" "[ -s '${th_stderr_}' ]"
# shellcheck disable=SC2166
if [ -s "${th_stdout_}" -o -s "${th_stderr_}" ]; then
_th_showOutput "${SHUNIT_FALSE}" "${th_stdout_}" "${th_stderr_}"
fi
unset th_test_ th_rtrn_ th_stdout_ th_stderr_
}
@ -145,13 +155,13 @@ th_assertFalseWithOutput()
th_stdout_=$3
th_stderr_=$4
assertFalse "${th_test_}; expected non-zero return value" ${th_rtrn_}
assertTrue "${th_test_}; expected output to STDOUT" \
"[ -s '${th_stdout_}' ]"
assertFalse "${th_test_}; expected no output to STDERR" \
"[ -s '${th_stderr_}' ]"
[ -s "${th_stdout_}" -a ! -s "${th_stderr_}" ] || \
_th_showOutput ${SHUNIT_FALSE} "${th_stdout_}" "${th_stderr_}"
assertNotEquals "${th_test_}: expected non-true return value" "${SHUNIT_TRUE}" "${th_rtrn_}"
assertTrue "${th_test_}: expected output to STDOUT" "[ -s '${th_stdout_}' ]"
assertFalse "${th_test_}: expected no output to STDERR" "[ -s '${th_stderr_}' ]"
# shellcheck disable=SC2166
if ! [ -s "${th_stdout_}" -a ! -s "${th_stderr_}" ]; then
_th_showOutput "${SHUNIT_FALSE}" "${th_stdout_}" "${th_stderr_}"
fi
unset th_test_ th_rtrn_ th_stdout_ th_stderr_
}
@ -164,20 +174,19 @@ th_assertFalseWithOutput()
# th_rtrn_: integer: the return value of the subtest performed
# th_stdout_: string: filename where stdout was redirected to
# th_stderr_: string: filename where stderr was redirected to
th_assertFalseWithError()
{
th_assertFalseWithError() {
th_test_=$1
th_rtrn_=$2
th_stdout_=$3
th_stderr_=$4
assertFalse "${th_test_}; expected non-zero return value" ${th_rtrn_}
assertFalse "${th_test_}; expected no output to STDOUT" \
"[ -s '${th_stdout_}' ]"
assertTrue "${th_test_}; expected output to STDERR" \
"[ -s '${th_stderr_}' ]"
[ ! -s "${th_stdout_}" -a -s "${th_stderr_}" ] || \
_th_showOutput ${SHUNIT_FALSE} "${th_stdout_}" "${th_stderr_}"
assertFalse "${th_test_}: expected non-zero return value" "${th_rtrn_}"
assertFalse "${th_test_}: expected no output to STDOUT" "[ -s '${th_stdout_}' ]"
assertTrue "${th_test_}: expected output to STDERR" "[ -s '${th_stderr_}' ]"
# shellcheck disable=SC2166
if ! [ ! -s "${th_stdout_}" -a -s "${th_stderr_}" ]; then
_th_showOutput "${SHUNIT_FALSE}" "${th_stdout_}" "${th_stderr_}"
fi
unset th_test_ th_rtrn_ th_stdout_ th_stderr_
}
@ -186,35 +195,38 @@ th_assertFalseWithError()
# when a non-zero return value is encountered. To properly catch these values,
# they are either written to disk, or recognized as an error the file is empty.
th_clearReturn() { cp /dev/null "${returnF}"; }
th_queryReturn()
{
th_queryReturn() {
if [ -s "${returnF}" ]; then
th_return=`cat "${returnF}"`
else
th_return=${SHUNIT_ERROR}
fi
export th_return
}
# Providing external and internal calls to the showOutput helper function.
th_showOutput() { _th_showOutput $@; }
_th_showOutput()
{
_th_return_=$1
_th_stdout_=$2
_th_stderr_=$3
th_showOutput() { _th_showOutput "$@"; }
_th_showOutput() {
if isSkipping; then
return
fi
isSkipping
if [ $? -eq ${SHUNIT_FALSE} -a ${_th_return_} != ${SHUNIT_TRUE} ]; then
_th_return_="${1:-${returnF}}"
_th_stdout_="${2:-${stdoutF}}"
_th_stderr_="${3:-${stderrF}}"
if [ "${_th_return_}" != "${SHUNIT_TRUE}" ]; then
# shellcheck disable=SC2166
if [ -n "${_th_stdout_}" -a -s "${_th_stdout_}" ]; then
echo '>>> STDOUT' >&2
cat "${_th_stdout_}" >&2
echo '<<< STDOUT' >&2
fi
# shellcheck disable=SC2166
if [ -n "${_th_stderr_}" -a -s "${_th_stderr_}" ]; then
echo '>>> STDERR' >&2
cat "${_th_stderr_}" >&2
fi
if [ -n "${_th_stdout_}" -o -n "${_th_stderr_}" ]; then
echo '<<< end output' >&2
echo '<<< STDERR' >&2
fi
fi
@ -222,7 +234,7 @@ _th_showOutput()
}
#
# main
# Main.
#
${TRACE} 'trace output enabled'

191
dev/tests/shunit2/test_runner Executable file
View File

@ -0,0 +1,191 @@
#! /bin/sh
# vim:et:ft=sh:sts=2:sw=2
#
# Unit test suite runner.
#
# Copyright 2008-2020 Kate Ward. All Rights Reserved.
# Released under the Apache 2.0 license.
#
# Author: kate.ward@forestent.com (Kate Ward)
# https://github.com/kward/shlib
#
# This script runs all the unit tests that can be found, and generates a nice
# report of the tests.
#
### Sample usage:
#
# Run all tests for all shells.
# $ ./test_runner
#
# Run all tests for single shell.
# $ ./test_runner -s /bin/bash
#
# Run single test for all shells.
# $ ./test_runner -t shunit_asserts_test.sh
#
# Run single test for single shell.
# $ ./test_runner -s /bin/bash -t shunit_asserts_test.sh
#
### ShellCheck (http://www.shellcheck.net/)
# Disable source following.
# shellcheck disable=SC1090,SC1091
# expr may be antiquated, but it is the only solution in some cases.
# shellcheck disable=SC2003
# $() are not fully portable (POSIX != portable).
# shellcheck disable=SC2006
# Return if test_runner already loaded.
[ -z "${RUNNER_LOADED:-}" ] || return 0
RUNNER_LOADED=0
RUNNER_ARGV0=`basename "$0"`
RUNNER_SHELLS='/bin/sh ash /bin/bash /bin/dash /bin/ksh /bin/mksh /bin/zsh'
RUNNER_TEST_SUFFIX='_test.sh'
true; RUNNER_TRUE=$?
false; RUNNER_FALSE=$?
runner_warn() { echo "runner:WARN $*" >&2; }
runner_error() { echo "runner:ERROR $*" >&2; }
runner_fatal() { echo "runner:FATAL $*" >&2; exit 1; }
runner_usage() {
echo "usage: ${RUNNER_ARGV0} [-e key=val ...] [-s shell(s)] [-t test(s)]"
}
_runner_tests() { echo ./*${RUNNER_TEST_SUFFIX} |sed 's#\./##g'; }
_runner_testName() {
# shellcheck disable=SC1117
_runner_testName_=`expr "${1:-}" : "\(.*\)${RUNNER_TEST_SUFFIX}"`
if [ -n "${_runner_testName_}" ]; then
echo "${_runner_testName_}"
else
echo 'unknown'
fi
unset _runner_testName_
}
main() {
# Find and load versions library.
for _runner_dir_ in . ${LIB_DIR:-lib}; do
if [ -r "${_runner_dir_}/versions" ]; then
_runner_lib_dir_="${_runner_dir_}"
break
fi
done
[ -n "${_runner_lib_dir_}" ] || runner_fatal 'Unable to find versions library.'
. "${_runner_lib_dir_}/versions" || runner_fatal 'Unable to load versions library.'
unset _runner_dir_ _runner_lib_dir_
# Process command line flags.
env=''
while getopts 'e:hs:t:' opt; do
case ${opt} in
e) # set an environment variable
key=`expr "${OPTARG}" : '\([^=]*\)='`
val=`expr "${OPTARG}" : '[^=]*=\(.*\)'`
# shellcheck disable=SC2166
if [ -z "${key}" -o -z "${val}" ]; then
runner_usage
exit 1
fi
eval "${key}='${val}'"
eval "export ${key}"
env="${env:+${env} }${key}"
;;
h) runner_usage; exit 0 ;; # help output
s) shells=${OPTARG} ;; # list of shells to run
t) tests=${OPTARG} ;; # list of tests to run
*) runner_usage; exit 1 ;;
esac
done
shift "`expr ${OPTIND} - 1`"
# Fill shells and/or tests.
shells=${shells:-${RUNNER_SHELLS}}
[ -z "${tests}" ] && tests=`_runner_tests`
# Error checking.
if [ -z "${tests}" ]; then
runner_error 'no tests found to run; exiting'
exit 1
fi
cat <<EOF
#------------------------------------------------------------------------------
# System data.
#
$ uname -mprsv
`uname -mprsv`
OS Name: `versions_osName`
OS Version: `versions_osVersion`
### Test run info.
shells: ${shells}
tests: ${tests}
EOF
for key in ${env}; do
eval "echo \"${key}=\$${key}\""
done
# Run tests.
runner_passing_=${RUNNER_TRUE}
for shell in ${shells}; do
echo
cat <<EOF
#------------------------------------------------------------------------------
# Running the test suite with ${shell}.
#
EOF
# Check for existence of shell.
shell_bin=${shell}
shell_name=''
shell_present=${RUNNER_FALSE}
case ${shell} in
ash)
shell_bin=`command -v busybox`
[ $? -eq "${RUNNER_TRUE}" ] && shell_present="${RUNNER_TRUE}"
shell_bin="${shell_bin:+${shell_bin} }ash"
shell_name=${shell}
;;
*)
[ -x "${shell_bin}" ] && shell_present="${RUNNER_TRUE}"
shell_name=`basename "${shell}"`
;;
esac
if [ "${shell_present}" -eq "${RUNNER_FALSE}" ]; then
runner_warn "unable to run tests with the ${shell_name} shell"
continue
fi
shell_version=`versions_shellVersion "${shell}"`
echo "shell name: ${shell_name}"
echo "shell version: ${shell_version}"
# Execute the tests.
for t in ${tests}; do
echo
echo "--- Executing the '`_runner_testName "${t}"`' test suite. ---"
# ${shell_bin} needs word splitting.
# shellcheck disable=SC2086
( exec ${shell_bin} "./${t}" 2>&1; )
shell_passing=$?
if [ "${shell_passing}" -ne "${RUNNER_TRUE}" ]; then
runner_warn "${shell_bin} not passing"
fi
test "${runner_passing_}" -eq ${RUNNER_TRUE} -a ${shell_passing} -eq ${RUNNER_TRUE}
runner_passing_=$?
done
done
return ${runner_passing_}
}
# Execute main() if this is run in standalone mode (i.e. not from a unit test).
if [ -z "${SHUNIT_VERSION}" ]; then
main "$@"
fi

159
dev/tests/sudo_prep.sh Executable file
View File

@ -0,0 +1,159 @@
#!/usr/bin/env bash
testUser=osyncsudo
testUserHome=/home/osyncsudo
function CreateUser {
local remoteUser"${1}"
local homedir="${2}"
if type getent > /dev/null 2>&1; then
if ! getent passwd | grep "$remoteUser" > /dev/null; then
echo "Manual creation of $remoteUser with homedir $homedir"
if type adduser >/dev/null 2>&1; then
adduser "$remoteUser"
else
echo "Cannot create user $remoteUser. Don't know what tool to use !"
fi
else
echo "It seems that $remoteUser already exists"
fi
elif type dscl > /dev/null 2>&1; then
if ! dscl . -search /Users name $remoteUser | grep "$remoteUser" > /dev/null; then
echo "Manual creation of $remoteUser with homedir $homedir"
dscl . -create /Users/$remoteUser
else
echo "It seems that $remoteUser already exists"
fi
else
echo "Well, I don't know what tool to use to create that user for you"
fi
}
function SetupSSH {
local remoteUser="${1}"
local homedir="${2}"
if [ ! -d "$homedir/.ssh" ]; then
mkdir "$homedir/.ssh"
if [ $? != 0 ]; then
echo "Cannot create [$homedir/.ssh]."
exit 1
fi
fi
chmod 700 "$homedir/.ssh"
if [ $? != 0 ]; then
echo "Cannot chmod [$homedir/.ssh]."
exit 1
fi
chown $remoteUser "$homedir/.ssh"
if [ $? != 0 ]; then
echo "Cannot chown [$homedir/.ssh]."
exit 1
fi
echo -e 'y\n'| ssh-keygen -t rsa -b 2048 -N "" -f "$homedir/.ssh/id_rsa_local"
if ! grep "$(cat $homedir/.ssh/id_rsa_local.pub)" "$homedir/.ssh/authorized_keys"; then
cat "$homedir/.ssh/id_rsa_local.pub" >> "$homedir/.ssh/authorized_keys"
fi
chmod 600 "$homedir/.ssh/authorized_keys"
chown $remoteUser "$homedir/.ssh/authorized_keys"
chown $remoteUser "$homedir/.ssh/id_rsa_local"
chown $remoteUser "$homedir/.ssh/id_rsa_local.pub"
# Add localhost to known hosts so self connect works
if [ -z "$(ssh-keygen -F localhost)" ]; then
ssh-keyscan -H localhost >> "$homedir/.ssh/known_hosts"
fi
if [ -f "$homedir/.ssh/known_hosts" ]; then
chown $remoteUser "$homedir/.ssh/known_hosts"
fi
}
function PrepareSudoers {
local remoteUser="${1}"
local bashPath
local rsyncPath
if ! type bash > /dev/null 2>&1; then
echo "No bash available"
exit 1
else
bashPath=$(type -p bash)
fi
if ! type rsync > /dev/null 2>&1; then
echo "No rsync available"
exit 1
else
rsyncPath=$(type -p rsync)
fi
RemoveSudoers $remoteUser
if [ -f "/etc/sudoers" ]; then
echo "$remoteUser ALL=NOPASSWD:SETENV:$rsyncPath,$bashPath" >> "/etc/sudoers"
echo "Defaults:$remoteUser !requiretty" >> "/etc/sudoers"
elif [ -f "/usr/local/etc/sudoers" ]; then
echo "$remoteUser ALL=NOPASSWD:SETENV:$rsyncPath,$bashPath" >> "/usr/local/etc/sudoers"
echo "Defaults:$remoteUser !requiretty" >> "usr/local/etc/sudoers"
else
echo "No sudoers file found."
echo "copy the following lines to /etc/sudoers (or /usr/local/etc/sudoers) and adjust /usr/bin path to the target system"
echo "$remoteUser ALL=NOPASSWD:SETENV:$rsyncPath,$bashPath"
echo "Defaults:$remoteUser !requiretty"
fi
}
function RemoveUser {
local remoteUser="${1}"
if type rmuser > /dev/null 2>&1; then
rmuser -y $remoteUser
elif type userdel > /dev/null 2>&1; then
userdel -fr $remoteUser
elif type dscl > /dev/null 2>&1; then
dscl . -delete "Users/$remoteUser"
else
echo "Please remove $remoteUser manually"
fi
}
function RemoveSudoers {
local remoteUser="${1}"
if [ -f "/etc/sudoers" ]; then
cp "/etc/sudoers" "/etc/sudoers.old"
grep -v "$remoteUser" "/etc/sudoers.old" > "/etc/sudoers"
elif [ -f "/usr/local/etc/sudoers" ]; then
cp "/usr/local/etc/sudoers" "/usr/local/etc/sudoers.old"
grep -v "$remoteUser" "/usr/local/etc/sudoers.old" > "/usr/local/etc/sudoers"
else
echo "Please remove lines containing $remoteUser from sudoers file manualle"
fi
}
if [ "$1" == "set" ]; then
CreateUser "$testUser" "$testUserHome"
SetupSSH "$testUser" "$testUserHome"
PrepareSudoers "$testUser"
echo ""
echo "Now feel free to run osync sudo test with"
echo "su osyncsudo"
echo "SUDO_EXEC=yes osync.sh --initiator=/home/osyncsudo --target=ssh://osyncsudo@localhost:22//root/osync-tests --rsakey=/home/osyncsudo/.ssh/id_rsa_local"
echo "Don't forget to run $0 unset later"
elif [ "$1" == "unset" ]; then
RemoveUser "$testUser"
RemoveSudoers "$testUser"
else
echo "usage: $0 [set] [unset]"
fi

9
dev/uninterruptible.c Normal file
View File

@ -0,0 +1,9 @@
# Create a process in uninterruptible sleep state that forks a child process.
# Killing child process will change childs's state to zombie.
# Useful for WaitforTaskCompletion tests
int main() {
vfork();
sleep(180);
return 0;
}

1152
install.sh

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +1,23 @@
#!/usr/bin/env bash
SUBPROGRAM=osync
PROGRAM="$SUBPROGRAM-batch" # Batch program to run osync / obackup instances sequentially and rerun failed ones
AUTHOR="(L) 2013-2016 by Orsiris de Jong"
AUTHOR="(L) 2013-2020 by Orsiris de Jong"
CONTACT="http://www.netpower.fr - ozy@netpower.fr"
PROGRAM_BUILD=2016052501
PROGRAM_BUILD=2020031502
## Runs an osync /obackup instance for every conf file found
## If an instance fails, run it again if time permits
## Configuration file path. The path where all the osync / obackup conf files are, usually /etc/osync or /etc/obackup
CONF_FILE_PATH=/etc/$SUBPROGRAM
if ! type "$BASH" > /dev/null; then
echo "Please run this script only with bash shell. Tested on bash >= 3.2"
exit 127
fi
## If maximum execution time is not reached, failed instances will be rerun. Max exec time is in seconds. Example is set to 10 hours.
MAX_EXECUTION_TIME=36000
## Specifies the number of reruns an instance may get
MAX_RERUNS=3
## Specifies the number of total runs an instance may get
MAX_RUNS=3
## Log file path
if [ -w /var/log ]; then
@ -24,37 +26,218 @@ else
LOG_FILE=./$SUBPROGRAM-batch.log
fi
## Default directory where to store temporary run files
if [ -w /tmp ]; then
RUN_DIR=/tmp
elif [ -w /var/tmp ]; then
RUN_DIR=/var/tmp
else
RUN_DIR=.
fi
# No need to edit under this line ##############################################################
function _logger {
local value="${1}" # What to log
echo -e "$value" >> "$LOG_FILE"
#### RemoteLogger SUBSET ####
# Array to string converter, see http://stackoverflow.com/questions/1527049/bash-join-elements-of-an-array
# usage: joinString separaratorChar Array
function joinString {
local IFS="$1"; shift; echo "$*";
}
function Logger {
local value="${1}" # What to log
local level="${2}" # Log level: DEBUG, NOTICE, WARN, ERROR, CRITIAL
# Sub function of Logger
function _Logger {
local logValue="${1}" # Log to file
local stdValue="${2}" # Log to screeen
local toStdErr="${3:-false}" # Log to stderr instead of stdout
prefix="$(date) - "
if [ "$logValue" != "" ]; then
echo -e "$logValue" >> "$LOG_FILE"
if [ "$level" == "CRITICAL" ]; then
_logger "$prefix\e[41m$value\e[0m"
elif [ "$level" == "ERROR" ]; then
_logger "$prefix\e[91m$value\e[0m"
elif [ "$level" == "WARN" ]; then
_logger "$prefix\e[93m$value\e[0m"
elif [ "$level" == "NOTICE" ]; then
_logger "$prefix$value"
elif [ "$level" == "DEBUG" ]; then
if [ "$DEBUG" == "yes" ]; then
_logger "$prefix$value"
# Build current log file for alerts if we have a sufficient environment
if [ "$_LOGGER_WRITE_PARTIAL_LOGS" == true ] && [ "$RUN_DIR/$PROGRAM" != "/" ]; then
echo -e "$logValue" >> "$RUN_DIR/$PROGRAM._Logger.$SCRIPT_PID.$TSTAMP"
fi
fi
if [ "$stdValue" != "" ] && [ "$_LOGGER_SILENT" != true ]; then
if [ $toStdErr == true ]; then
# Force stderr color in subshell
(>&2 echo -e "$stdValue")
else
echo -e "$stdValue"
fi
else
_logger "\e[41mLogger function called without proper loglevel.\e[0m"
_logger "$prefix$value"
fi
}
# Remote logger similar to below Logger, without log to file and alert flags
function RemoteLogger {
local value="${1}" # Sentence to log (in double quotes)
local level="${2}" # Log level
local retval="${3:-undef}" # optional return value of command
local prefix
if [ "$_LOGGER_PREFIX" == "time" ]; then
prefix="RTIME: $SECONDS - "
elif [ "$_LOGGER_PREFIX" == "date" ]; then
prefix="R $(date) - "
else
prefix=""
fi
if [ "$level" == "CRITICAL" ]; then
_Logger "" "$prefix\e[1;33;41m$value\e[0m" true
if [ "$_DEBUG" == true ]; then
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
fi
return
elif [ "$level" == "ERROR" ]; then
_Logger "" "$prefix\e[31m$value\e[0m" true
if [ "$_DEBUG" == true ]; then
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
fi
return
elif [ "$level" == "WARN" ]; then
_Logger "" "$prefix\e[33m$value\e[0m" true
if [ "$_DEBUG" == true ]; then
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
fi
return
elif [ "$level" == "NOTICE" ]; then
if [ "$_LOGGER_ERR_ONLY" != true ]; then
_Logger "" "$prefix$value"
fi
return
elif [ "$level" == "VERBOSE" ]; then
if [ "$_LOGGER_VERBOSE" == true ]; then
_Logger "" "$prefix$value"
fi
return
elif [ "$level" == "ALWAYS" ]; then
_Logger "" "$prefix$value"
return
elif [ "$level" == "DEBUG" ]; then
if [ "$_DEBUG" == true ]; then
_Logger "" "$prefix$value"
return
fi
else
_Logger "" "\e[41mLogger function called without proper loglevel [$level].\e[0m" true
_Logger "" "Value was: $prefix$value" true
fi
}
#### RemoteLogger SUBSET END ####
# General log function with log levels:
# Environment variables
# _LOGGER_SILENT: Disables any output to stdout & stderr
# _LOGGER_ERR_ONLY: Disables any output to stdout except for ALWAYS loglevel
# _LOGGER_VERBOSE: Allows VERBOSE loglevel messages to be sent to stdout
# Loglevels
# Except for VERBOSE, all loglevels are ALWAYS sent to log file
# CRITICAL, ERROR, WARN sent to stderr, color depending on level, level also logged
# NOTICE sent to stdout
# VERBOSE sent to stdout if _LOGGER_VERBOSE=true
# ALWAYS is sent to stdout unless _LOGGER_SILENT=true
# DEBUG & PARANOIA_DEBUG are only sent to stdout if _DEBUG=true
function Logger {
local value="${1}" # Sentence to log (in double quotes)
local level="${2}" # Log level
local retval="${3:-undef}" # optional return value of command
local prefix
if [ "$_LOGGER_PREFIX" == "time" ]; then
prefix="TIME: $SECONDS - "
elif [ "$_LOGGER_PREFIX" == "date" ]; then
prefix="$(date '+%Y-%m-%d %H:%M:%S') - "
else
prefix=""
fi
## Obfuscate _REMOTE_TOKEN in logs (for ssh_filter usage only in osync and obackup)
value="${value/env _REMOTE_TOKEN=$_REMOTE_TOKEN/env _REMOTE_TOKEN=__o_O__}"
value="${value/env _REMOTE_TOKEN=\$_REMOTE_TOKEN/env _REMOTE_TOKEN=__o_O__}"
if [ "$level" == "CRITICAL" ]; then
_Logger "$prefix($level):$value" "$prefix\e[1;33;41m$value\e[0m" true
ERROR_ALERT=true
# ERROR_ALERT / WARN_ALERT is not set in main when Logger is called from a subprocess. We need to create these flag files for ERROR_ALERT / WARN_ALERT to be picked up by Alert
echo -e "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$\n$prefix($level):$value" >> "$RUN_DIR/$PROGRAM.ERROR_ALERT.$SCRIPT_PID.$TSTAMP"
return
elif [ "$level" == "ERROR" ]; then
_Logger "$prefix($level):$value" "$prefix\e[91m$value\e[0m" true
ERROR_ALERT=true
echo -e "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$\n$prefix($level):$value" >> "$RUN_DIR/$PROGRAM.ERROR_ALERT.$SCRIPT_PID.$TSTAMP"
return
elif [ "$level" == "WARN" ]; then
_Logger "$prefix($level):$value" "$prefix\e[33m$value\e[0m" true
WARN_ALERT=true
echo -e "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$\n$prefix($level):$value" >> "$RUN_DIR/$PROGRAM.WARN_ALERT.$SCRIPT_PID.$TSTAMP"
return
elif [ "$level" == "NOTICE" ]; then
if [ "$_LOGGER_ERR_ONLY" != true ]; then
_Logger "$prefix$value" "$prefix$value"
fi
return
elif [ "$level" == "VERBOSE" ]; then
if [ "$_LOGGER_VERBOSE" == true ]; then
_Logger "$prefix($level):$value" "$prefix$value"
fi
return
elif [ "$level" == "ALWAYS" ]; then
_Logger "$prefix$value" "$prefix$value"
return
elif [ "$level" == "DEBUG" ]; then
if [ "$_DEBUG" == true ]; then
_Logger "$prefix$value" "$prefix$value"
return
fi
else
_Logger "\e[41mLogger function called without proper loglevel [$level].\e[0m" "\e[41mLogger function called without proper loglevel [$level].\e[0m" true
_Logger "Value was: $prefix$value" "Value was: $prefix$value" true
fi
}
function CleanUp {
# Exit controlmaster before the socket gets deleted
if [ "$SSH_CONTROLMASTER" == true ] && [ "$SSH_CMD" != "" ]; then
$SSH_CMD -O exit
fi
if [ "$_DEBUG" != true ]; then
# Removing optional remote $RUN_DIR that goes into local $RUN_DIR
if [ -d "$RUN_DIR/$PROGRAM.remote.$SCRIPT_PID.$TSTAMP" ]; then
rm -rf "$RUN_DIR/$PROGRAM.remote.$SCRIPT_PID.$TSTAMP"
fi
# Removing all temporary run files
rm -f "$RUN_DIR/$PROGRAM."*".$SCRIPT_PID.$TSTAMP"
# Fix for sed -i requiring backup extension for BSD & Mac (see all sed -i statements)
rm -f "$RUN_DIR/$PROGRAM."*".$SCRIPT_PID.$TSTAMP.tmp"
fi
}
function GenericTrapQuit {
local exitcode=0
# Get ERROR / WARN alert flags from subprocesses that call Logger
if [ -f "$RUN_DIR/$PROGRAM.WARN_ALERT.$SCRIPT_PID.$TSTAMP" ]; then
WARN_ALERT=true
exitcode=2
fi
if [ -f "$RUN_DIR/$PROGRAM.ERROR_ALERT.$SCRIPT_PID.$TSTAMP" ]; then
ERROR_ALERT=true
exitcode=1
fi
CleanUp
exit $exitcode
}
function CheckEnvironment {
## osync / obackup executable full path can be set here if it cannot be found on the system
if ! type $SUBPROGRAM.sh > /dev/null 2>&1
@ -63,96 +246,97 @@ function CheckEnvironment {
then
SUBPROGRAM_EXECUTABLE=/usr/local/bin/$SUBPROGRAM.sh
else
Logger "Could not find $SUBPROGRAM.sh" "CRITICAL"
Logger "Could not find [/usr/local/bin/$SUBPROGRAM.sh]" "CRITICAL"
( >&2 echo "Could not find [/usr/local/bin/$SUBPROGRAM.sh]" )
exit 1
fi
else
SUBPROGRAM_EXECUTABLE=$(type -p $SUBPROGRAM.sh)
fi
## Check for CONF_FILE_PATH
if [ ! -d "$CONF_FILE_PATH" ]; then
Logger "Cannot find conf file path $CONF_FILE_PATH" "CRITICAL"
if [ "$CONF_FILE_PATH" == "" ]; then
Usage
fi
}
function Batch {
## Get list of .conf files
for i in $CONF_FILE_PATH/*.conf
do
if [ "$RUN" == "" ]; then
RUN="$i"
else
RUN=$RUN" $i"
fi
done
local runs=1 # Number of batch runs
local runList # Actual conf file list to run
local runAgainList # List of failed conf files sto run again
RERUNS=0
while ([ $MAX_EXECUTION_TIME -gt $SECONDS ] || [ $MAX_EXECUTION_TIME -eq 0 ]) && [ "$RUN" != "" ] && [ $MAX_RERUNS -gt $RERUNS ]
do
Logger "$SUBPROGRAM instances will be run for: $RUN" "NOTICE"
for i in $RUN
do
$SUBPROGRAM_EXECUTABLE "$i" $opts &
wait $!
if [ $? != 0 ]; then
Logger "Run instance $(basename $i) failed" "ERROR"
if [ "$RUN_AGAIN" == "" ]; then
RUN_AGAIN="$i"
local confFile
local result
local i
# Using -e because find will accept directories or files
if [ ! -e "$CONF_FILE_PATH" ]; then
Logger "Cannot find conf file path [$CONF_FILE_PATH]." "CRITICAL"
Usage
else
# Ugly hack to read files into an array while preserving special characters
runList=()
while IFS= read -d $'\0' -r file; do runList+=("$file"); done < <(find "$CONF_FILE_PATH" -maxdepth 1 -iname "*.conf" -print0)
while ([ $MAX_EXECUTION_TIME -gt $SECONDS ] || [ $MAX_EXECUTION_TIME -eq 0 ]) && [ "${#runList[@]}" -gt 0 ] && [ $runs -le $MAX_RUNS ]; do
runAgainList=()
Logger "Sequential run n°$runs of $SUBPROGRAM instances for:" "NOTICE"
for confFile in "${runList[@]}"; do
Logger "$(basename $confFile)" "NOTICE"
done
for confFile in "${runList[@]}"; do
$SUBPROGRAM_EXECUTABLE "$confFile" --silent $opts &
wait $!
result=$?
if [ $result != 0 ]; then
if [ $result == 1 ] || [ $result == 128 ]; then # Do not handle exit code 128 because it is already handled here
Logger "Instance $(basename $confFile) failed with exit code [$result]." "ERROR"
runAgainList+=("$confFile")
elif [ $result == 2 ]; then
Logger "Instance $(basename $confFile) finished with warnings." "WARN"
fi
else
RUN_AGAIN=$RUN_AGAIN" $i"
Logger "Instance $(basename $confFile) succeed." "NOTICE"
fi
else
Logger "Run instance $(basename $i) succeed." "NOTICE"
fi
done
runList=("${runAgainList[@]}")
runs=$((runs + 1))
done
RUN="$RUN_AGAIN"
RUN_AGAIN=""
RERUNS=$(($RERUNS + 1))
done
fi
}
function Usage {
echo "$PROGRAM $PROGRAM_BUILD"
echo $AUTHOR
echo $CONTACT
echo "$AUTHOR"
echo "$CONTACT"
echo ""
echo "Batch script to sequentially run osync or obackup instances and rerun failed ones."
echo "Usage: $SUBPROGRAM-batch.sh [OPTIONS]"
echo "Usage: $PROGRAM.sh [OPTIONS] [$SUBPROGRAM OPTIONS]"
echo ""
echo "[OPTIONS]"
echo "--path=/path/to/conf Path to osync / obackup conf files, defaults to /etc/osync or /etc/obackup"
echo "--max-reruns=X Number of runs max for failed instances, (defaults to 3)"
echo "--max-exec-time=X Retry failed instances only if max execution time not reached (defaults to 36000 seconds). Set to 0 to bypass execution time check."
echo "--no-maxtime Run osync / obackup without honoring conf file defined timeouts"
echo "--dry Will run osync / obackup without actually doing anything; just testing"
echo "--silent Will run osync / obackup without any output to stdout, used for cron jobs"
echo "--verbose Increases output"
echo "--max-runs=X Number of max runs per instance, (defaults to 3)"
echo "--max-exec-time=X Retry failed instances only if max execution time not reached (defaults to 36000 seconds). Set to 0 to bypass execution time check"
echo "[$SUBPROGRAM OPTIONS]"
echo "Specify whatever options $PROGRAM accepts. Example"
echo "$PROGRAM.sh --path=/etc/$SUBPROGRAM --no-maxtime"
echo ""
echo "No output will be written to stdout/stderr."
echo "Verify log file in [$LOG_FILE]."
exit 128
}
trap GenericTrapQuit TERM EXIT HUP QUIT
opts=""
for i in "$@"
do
case $i in
--silent)
opts=$opts" --silent"
;;
--dry)
opts=$opts" --dry"
;;
--verbose)
opts=$opts" --verbose"
;;
--no-maxtime)
opts=$opts" --no-maxtime"
;;
--path=*)
CONF_FILE_PATH=${i##*=}
;;
--max-reruns=*)
MAX_RERUNS=${i##*=}
--max-runs=*)
MAX_RUNS=${i##*=}
;;
--max-exec-time=*)
MAX_EXECUTION_TIME=${i##*=}
@ -161,8 +345,7 @@ do
Usage
;;
*)
Logger "Unknown param '$i'" "CRITICAL"
Usage
opts="$opts$i "
;;
esac
done

View File

@ -36,17 +36,17 @@ if [ ! -w $(dirname $pidfile) ]; then
fi
start() {
if [ ! -f $confdir/*.conf ]; then
if ! ls "$confdir/"*.conf > /dev/null 2>&1; then
echo "Cannot find any configuration files in $confdir."
exit 1
fi
errno=0
for cfgfile in $confdir/*.conf
for cfgfile in "$confdir/"*.conf
do
if [ -f $progpath/$progexec ]; then
$progpath/$progexec $cfgfile --on-changes > /dev/null 2>&1 &
$progpath/$progexec $cfgfile --on-changes --errors-only > /dev/null 2>&1 &
else
echo "Cannot find $prog executable in $progpath"
exit 1
@ -60,7 +60,7 @@ start() {
echo "$prog successfully started for configuration file $cfgfile"
else
echo "Cannot start $prog for configuration file $cfgfile"
$errno = 1
errno=1
fi
done
@ -106,7 +106,7 @@ status() {
echo "$prog instance $(basename $pfile) is running (pid $(cat $pfile))"
else
echo "$prog instance $pfile (pid $(cat $pfile)) is dead but pidfile exists."
$errno=1
errno=1
fi
done

53
osync-srv-openrc Executable file
View File

@ -0,0 +1,53 @@
#!/sbin/openrc-run
#
# PROGRAM="osync-srv"
# SCRIPT_BUILD=2018051701
# Script written by Brian Evans (grknight@gentoo.org) in 2018
# How to use:
#
# 0) Rename this to osync-srv, and place it in /etc/init.d.
# 1) Ensure that your config is located in /etc/osync, under some name with a
# .conf extension.
# 2) Ensure that osync.sh can be found in /usr/local/bin.
# 3) Ensure that you have rsync and inotify-tools installed.
# 4) Symlink this to a name with an extension equal to the basename of your
# config file.
# 5) Add to the default runlevel under the symlinked name.
#
# Example:
#
# Suppose the config is located at /etc/osync/documents.conf. You then want to
# symlink as follows:
#
# # ln -s /etc/init.d/osync-srv /etc/init.d/osync-srv.documents
#
# Then you can start the service as normal:
#
# # rc-update add osync-srv.documents default
depend() {
use localmount chrony ntp-client
}
description="Two way directory sync daemon"
command=/usr/local/bin/osync.sh
conffile="${RC_SVCNAME#*.}.conf"
cfgfile="/etc/osync/${conffile}"
command_args="${cfgfile} --on-changes --errors-only"
command_background="yes"
pidfile="/var/run/${RC_SVCNAME}"
stopsig=TERM
start_pre() {
if [ "${conffile}" = ".conf" ]; then
eerror "${RC_SVCNAME} cannot be started directly. You must create"
eerror "symbolic links to it for the configuration you want to start"
eerror "osync on and add those to the appropriate runlevels."
return 1
fi
if ! [ -f "${cfgfile}" ]; then
eerror "Cannot find configuration file ${cfgfile}."
return 1
fi
}

View File

@ -6,7 +6,8 @@ Wants=network-online.target
[Service]
Type=simple
ExecStart=/usr/local/bin/osync.sh /etc/osync/%i --on-changes --silent
ExecStart=/usr/local/bin/osync.sh /etc/osync/%i --on-changes --errors-only
SuccessExitStatus=0 2
[Install]
WantedBy=multi-user.target

View File

@ -6,6 +6,6 @@ Wants=network-online.target
[Service]
Type=simple
ExecStart=/usr/local/bin/osync.sh /etc/osync/%i --on-changes --silent
SuccessExitStatus=0 2
[Install]
WantedBy=multi-user.target

139
osync-target-helper-srv Executable file
View File

@ -0,0 +1,139 @@
#!/usr/bin/env bash
#
# osync-srv Two way directory sync daemon
#
# chkconfig: - 90 99
# description: monitors a local directory and syncs to a local or remote \
# directory on file changes
# processname: /usr/local/bin/osync.sh
# config: /etc/osync/*.conf
# pidfile: /var/run/osync
### BEGIN INIT INFO
# Provides: osync-target-helper-srv
# Required-Start: $local_fs $time
# Required-Stop: $local_fs $time
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: osync-target-helpder daemon
# Description: Two way directory sync daemon
### END INIT INFO
prog=osync
progexec=osync.sh
progpath=/usr/local/bin
confdir=/etc/osync
pidfile=/var/run/$prog-target-helper
SCRIPT_BUILD=2018100101
if [ ! -f $progpath/$progexec ] && [ ! -f $progexec ]; then
echo "Cannot find $prog executable in $progpath nor in local path."
exit 1
fi
if [ ! -w $(dirname $pidfile) ]; then
pidfile=./$prog
fi
start() {
if ! ls "$confdir/"*.conf > /dev/null 2>&1; then
echo "Cannot find any configuration files in $confdir."
exit 1
fi
errno=0
for cfgfile in "$confdir/"*.conf
do
if [ -f $progpath/$progexec ]; then
$progpath/$progexec $cfgfile --on-changes-target --errors-only > /dev/null 2>&1 &
else
echo "Cannot find $prog executable in $progpath"
exit 1
fi
pid=$!
retval=$?
if [ $? == 0 ]; then
echo $pid > "$pidfile-$(basename $cfgfile)"
echo "$prog successfully started for configuration file $cfgfile"
else
echo "Cannot start $prog for configuration file $cfgfile"
errno=1
fi
done
exit $errno
}
stop() {
if [ ! -f $pidfile-* ]; then
echo "No running $prog instances found."
exit 1
fi
for pfile in $pidfile-*
do
if ps -p$(cat $pfile) > /dev/null 2>&1
then
kill -TERM $(cat $pfile)
if [ $? == 0 ]; then
rm -f $pfile
echo "$prog instance $(basename $pfile) stopped."
else
echo "Cannot stop $prog instance $(basename $pfile)"
fi
else
rm -f $pfile
echo "$prog instance $pfile (pid $(cat $pfile)) is dead but pidfile exists."
fi
done
}
status() {
if [ ! -f $pidfile-* ]; then
echo "Cannot find any running $prog instance."
exit 1
fi
errno=0
for pfile in $pidfile-*
do
if ps -p$(cat $pfile) > /dev/null 2>&1
then
echo "$prog instance $(basename $pfile) is running (pid $(cat $pfile))"
else
echo "$prog instance $pfile (pid $(cat $pfile)) is dead but pidfile exists."
errno=1
fi
done
exit $errno
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
condrestart|try-restart)
status || exit 0
restart
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
;;
esac
exit 0

View File

@ -0,0 +1,13 @@
[Unit]
Description=osync - Target helper service
After=time-sync.target local-fs.target network-online.target
Requires=time-sync.target local-fs.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=/usr/local/bin/osync.sh /etc/osync/%i --on-changes-target --errors-only
SuccessExitStatus=0 2
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,11 @@
[Unit]
Description=A robust two way (bidirectional) file sync script based on rsync with fault tolerance
After=time-sync.target local-fs.target network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=/usr/local/bin/osync.sh /etc/osync/%i --on-changes-target --silent
SuccessExitStatus=0 2
[Install]
WantedBy=multi-user.target

7627
osync.sh

File diff suppressed because it is too large Load Diff

279
packaging/ARCH/mksrcinfo Executable file
View File

@ -0,0 +1,279 @@
#!/bin/bash
shopt -s extglob
array_build() {
local dest=$1 src=$2 i keys values
# it's an error to try to copy a value which doesn't exist.
declare -p "$2" &>/dev/null || return 1
# Build an array of the indicies of the source array.
eval "keys=(\"\${!$2[@]}\")"
# Clear the destination array
eval "$dest=()"
# Read values indirectly via their index. This approach gives us support
# for associative arrays, sparse arrays, and empty strings as elements.
for i in "${keys[@]}"; do
values+=("printf -v '$dest[$i]' %s \"\${$src[$i]}\";")
done
eval "${values[*]}"
}
funcgrep() {
{ declare -f "$1" || declare -f package; } 2>/dev/null | grep -E "$2"
}
# extract_global_var function compatible with bash 4.2
extract_global_var() {
# $1: variable name
# $2: multivalued
# $3: name of output var
local attr=$1 isarray=$2 outputvar=$3 ref
if (( isarray )); then
array_build ref "$attr"
[[ ${ref[@]} ]] && array_build "$outputvar" "$attr"
else
[[ ${!attr} ]] && printf -v "$outputvar" %s "${!attr}"
fi
}
# extract global_var function compatible with bash 4.3+
old_extract_global_var() {
# $1: variable name
# $2: multivalued
# $3: name of output var
local attr=$1 isarray=$2 outputvar=$3
if (( isarray )); then
declare -n ref=$attr
# Still need to use array_build here because we can't handle the scoping
# semantics that would be included with the use of 'declare -n'.
[[ ${ref[@]} ]] && array_build "$outputvar" "$attr"
else
[[ ${!attr} ]] && printf -v "$outputvar" %s "${!attr}"
fi
}
extract_function_var() {
# $1: function name
# $2: variable name
# $3: multivalued
# $4: name of output var
local funcname=$1 attr=$2 isarray=$3 outputvar=$4 attr_regex= decl= r=1
if (( isarray )); then
printf -v attr_regex '^[[:space:]]* %s\+?=\(' "$2"
else
printf -v attr_regex '^[[:space:]]* %s\+?=[^(]' "$2"
fi
while read -r; do
# strip leading whitespace and any usage of declare
decl=${REPLY##*([[:space:]])}
eval "${decl/#$attr/$outputvar}"
# entering this loop at all means we found a match, so notify the caller.
r=0
done < <(funcgrep "$funcname" "$attr_regex")
return $r
}
pkgbuild_get_attribute() {
# $1: package name
# $2: attribute name
# $3: multivalued
# $4: name of output var
local pkgname=$1 attrname=$2 isarray=$3 outputvar=$4
printf -v "$outputvar" %s ''
if [[ $pkgname ]]; then
extract_global_var "$attrname" "$isarray" "$outputvar"
extract_function_var "package_$pkgname" "$attrname" "$isarray" "$outputvar"
else
extract_global_var "$attrname" "$isarray" "$outputvar"
fi
}
srcinfo_open_section() {
printf '%s = %s\n' "$1" "$2"
}
srcinfo_close_section() {
echo
}
srcinfo_write_attr() {
# $1: attr name
# $2: attr values
local attrname=$1 attrvalues=("${@:2}")
# normalize whitespace, strip leading and trailing
attrvalues=("${attrvalues[@]//+([[:space:]])/ }")
attrvalues=("${attrvalues[@]#[[:space:]]}")
attrvalues=("${attrvalues[@]%[[:space:]]}")
printf "\t$attrname = %s\n" "${attrvalues[@]}"
}
pkgbuild_extract_to_srcinfo() {
# $1: pkgname
# $2: attr name
# $3: multivalued
local pkgname=$1 attrname=$2 isarray=$3 outvalue=
if pkgbuild_get_attribute "$pkgname" "$attrname" "$isarray" 'outvalue'; then
srcinfo_write_attr "$attrname" "${outvalue[@]}"
fi
}
srcinfo_write_section_details() {
local attr package_arch a
local multivalued_arch_attrs=(source provides conflicts depends replaces
optdepends makedepends checkdepends
{md5,sha{1,224,256,384,512}}sums)
for attr in "${singlevalued[@]}"; do
pkgbuild_extract_to_srcinfo "$1" "$attr" 0
done
for attr in "${multivalued[@]}"; do
pkgbuild_extract_to_srcinfo "$1" "$attr" 1
done
pkgbuild_get_attribute "$1" 'arch' 1 'package_arch'
for a in "${package_arch[@]}"; do
# 'any' is special. there's no support for, e.g. depends_any.
[[ $a = any ]] && continue
for attr in "${multivalued_arch_attrs[@]}"; do
pkgbuild_extract_to_srcinfo "$1" "${attr}_$a" 1
done
done
}
srcinfo_write_global() {
local singlevalued=(pkgdesc pkgver pkgrel epoch url install changelog)
local multivalued=(arch groups license checkdepends makedepends
depends optdepends provides conflicts replaces
noextract options backup
source {md5,sha{1,224,256,384,512}}sums)
srcinfo_open_section 'pkgbase' "${pkgbase:-$pkgname}"
srcinfo_write_section_details ''
srcinfo_close_section
}
srcinfo_write_package() {
local singlevalued=(pkgdesc url install changelog)
local multivalued=(arch groups license checkdepends depends optdepends
provides conflicts replaces options backup)
srcinfo_open_section 'pkgname' "$1"
srcinfo_write_section_details "$1"
srcinfo_close_section
}
srcinfo_write() {
local pkg
srcinfo_write_global
for pkg in "${pkgname[@]}"; do
srcinfo_write_package "$pkg"
done
}
clear_environment() {
local environ
mapfile -t environ < <(compgen -A variable |
grep -xvF "$(printf '%s\n' "$@")")
# expect that some variables marked read only will complain here
unset -v "${environ[@]}" 2>/dev/null
}
srcinfo_write_from_pkgbuild() {(
clear_environment PATH
shopt -u extglob
. "$1" || exit 1
shopt -s extglob
srcinfo_write
)}
usage() {
printf '%s\n' \
'mksrcinfo v8' \
'' \
'mksrcinfo reads the target PKGBUILD and writes an equivalent .SRCINFO.' \
'Without passing any arguments, mksrcinfo will read from $PWD/PKGBUILD' \
'and write to $PWD/.SRCINFO.' \
'' \
'Usage: mksrcinfo [/path/to/pkgbuild]' \
' -h display this help message and exit' \
' -o <file> write output to <file>'
}
error() {
printf "==> ERROR: $1\n" "${@:2}" >&2
}
die() {
error "$@"
exit 1
}
write_srcinfo_header() {
local timefmt='%a %b %e %H:%M:%S %Z %Y'
# fiddle with the environment to ensure we get the a consistent language and
# timezone.
TZ=UTC LC_TIME=C \
printf "# Generated by mksrcinfo %s\n# %($timefmt)T\n" 'v8' -1
}
srcinfo_dest=$PWD/.SRCINFO
while getopts ':o:h' flag; do
case $flag in
o)
srcinfo_dest=$OPTARG
;;
:)
die "option '-%s' requires an argument" "$OPTARG"
;;
h)
usage
exit 0
;;
\?)
die "invalid option -- '-%s' (use -h for help)" "$OPTARG"
;;
esac
done
shift $(( OPTIND - 1 ))
[[ -f PKGBUILD ]] || die 'PKGBUILD not found in current directory'
# TODO: replace this with 'makepkg --printsrcinfo' once makepkg>=4.3 is released.
{
write_srcinfo_header
srcinfo_write_from_pkgbuild "${1:-$PWD/PKGBUILD}"
} >"$srcinfo_dest"
# vim: set et ts=2 sw=2:

View File

@ -0,0 +1,113 @@
#!/bin/bash
HELPTEXT=\
"Usage: $0 [OPTIONS]\n"\
"Automatically updates the osync version in the AUR.\n"\
"\n"\
"-y, --yes Do not prompt before committing\n"\
"-n, --name=USERNAME Username to use with git in case no global username is set\n"\
"-e, --email=EMAIL Email address to use with git in case no global email is set"
function cleanup {
echo "Cleanup..."
cd ..
rm -rf osync.aur
}
# Check getopt compatibility
getopt --test > /dev/null
if [[ $? -ne 4 ]]; then
echo "You don't seem to have the GNU-enhanced getopt available. That shouldn't happen on a modern system with bash installed."
exit 38
fi
# Parse command line arguments
OPTIONS=hyn:e:
LONGOPTIONS=help,yes,name:,email:
PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTIONS --name "$0" -- "$@")
if [[ $? -ne 0 ]]; then
exit 22
fi
eval set -- "$PARSED"
while true; do
case "$1" in
-h|--help)
echo -e "$HELPTEXT"
exit 0
;;
-y|--yes)
yes="y"
shift
;;
-n|--name)
name="$2"
shift 2
;;
-e|--email)
email="$2"
shift 2
;;
--)
shift
break
;;
*)
echo "Programming error" > /dev/stderr
exit 131
;;
esac
done
if [[ -z $name ]];then
name=$(git config --global user.name)
if [[ -z $name ]]; then
echo "Please specify a username for the git commit with the -n|--name option or set it globally with 'git config --global user.name USERNAME"
exit 22
fi
fi
if [[ -z $email ]];then
email=$(git config --global user.email)
if [[ -z $email ]]; then
echo "Please specify an e-mail for the git commit with the -e|--email option or set it globally with 'git config --global user.email EMAIL"
exit 22
fi
fi
### Main ###
echo "Cloning AUR package..."
if ! git clone -q git+ssh://aur@aur.archlinux.org/osync.git osync.aur || ! cd osync.aur; then
exit 1
fi
git config user.name "$name"
git config user.email "$email"
echo "Cloning most recent stable version of osync..." &&
git clone -qb stable https://github.com/deajan/osync.git > /dev/null &&
echo "Fetching version..." &&
cd osync &&
pkgversion="$(git describe --tags --long | sed 's/\([^-]*-\)g/r\1/;s/-/./g')" &&
cd .. &&
echo "Updating version..." &&
sed -i "s/pkgver=.*/pkgver=${pkgversion}/g" "PKGBUILD" &&
../mksrcinfo &&
rm -rf "osync" &&
[[ ! -z $yes ]] || (read -p "About to commit changes to AUR. Are you sure? (y/n) " -n 1 -r && echo "" &&
[[ $REPLY =~ ^[Yy]$ ]]) &&
echo "Committing changes to AUR..." &&
git add PKGBUILD .SRCINFO &&
git commit -qm "Updated version to ${pkgversion}" &&
git push -q origin master &&
cleanup &&
echo "Package updated successfully to version ${pkgversion}" || cleanup
exit 0

78
packaging/RHEL/osync.spec Normal file
View File

@ -0,0 +1,78 @@
%define name osync
%define version 1.2
%define gitsource https://github.com/deajan/%{name}/archive/v%{version}.zip
%define use_systemd 1
%{?el5:%define use_systemd 0}
%{?el6:%define use_systemd 0}
Name: %{name}
Version: %{version}
Release: 1%{?dist}
Summary: robust file synchronization tool
Group: Applications/File
License: BSD
URL: https://www.netpower.fr/osync
Source0: %{gitsource}
BuildRequires: wget
Requires: rsync openssh-server bash wget inotify-tools
BuildArch: noarch
%description
A robust two way (bidirectional) file sync script based on rsync with fault tolerance, time control and ACL synchronization.
#%prep
#%setup -q
#%build
#%configure
%install
wget --no-check-certificate --timeout=5 -O %{_sourcedir}/%{name}-%{version}.zip %{gitsource}
( cd %{_sourcedir} && unzip -o %{_sourcedir}/%{name}-%{version}.zip )
rm -rf ${RPM_BUILD_ROOT}
mkdir -p ${RPM_BUILD_ROOT}%{_bindir}
mkdir -p ${RPM_BUILD_ROOT}%{_unitdir}
install -m 755 %{_sourcedir}/%{name}-%{version}/osync.sh ${RPM_BUILD_ROOT}%{_bindir}
install -m 755 %{_sourcedir}/%{name}-%{version}/osync-batch.sh ${RPM_BUILD_ROOT}%{_bindir}
install -m 0755 -d ${RPM_BUILD_ROOT}/etc/osync
install -m 0644 %{_sourcedir}/%{name}-%{version}/sync.conf.example ${RPM_BUILD_ROOT}/etc/osync
%if %use_systemd
sed -i 's#/usr/local/bin#%{_bindir}#' %{_sourcedir}/%{name}-%{version}/osync-srv@.service
install -m 0755 %{_sourcedir}/%{name}-%{version}/osync-srv@.service ${RPM_BUILD_ROOT}%{_unitdir}
%else
sed -i 's#/usr/local/bin#%{_bindir}#' %{_sourcedir}/%{name}-%{version}/osync-srv
install -m 0755 %{_sourcedir}/%{name}-%{version}/osync-srv ${RPM_BUILD_ROOT}/etc/init.d
%endif
%files
%defattr(-,root,root)
%attr(755,root,root) %{_bindir}/osync.sh
%attr(755,root,root) %{_bindir}/osync-batch.sh
%attr(644,root,root) /etc/osync/sync.conf.example
%if %use_systemd
%attr(755,root,root) %{_unitdir}/osync-srv@.service
%else
%attr(755,root,root) /etc/init.d/osync-srv
%endif
%doc
%changelog
* Tue Mar 14 2017 Orsiris de Jong <ozy@netpower.fr>
- On the fly update binary path from /usr/local/bin to %{_bindir} in source service files for RPM usage
- Allow unzip to overwrite existing source files
* Wed Feb 15 2017 Richard Grainger <grainger@gmail.com>
- Update version
- Download source archive based on version
- Add inotify-tools as dependency
* Sun Dec 18 2016 Orsiris de Jong <ozy@netpower.fr>
- Add systemd / initV differentiation
- Make source autodownload work
- Disable all macros except install
* Tue Aug 30 2016 Orsiris de Jong <ozy@netpower.fr>
- Initial spec file

View File

@ -5,102 +5,49 @@
##### It will filter the commands that can be run remotely via ssh.
##### Please chmod 755 and chown root:root this file
##### Obackup needed commands: rsync find du mysql mysqldump (sudo)
##### Osync needed commands: rsync find du echo mkdir rm if df (sudo)
SCRIPT_BUILD=2016031401
##### Any command that has env _REMOTE_TOKEN= with the corresponding token in it will be run
##### Any other command will return a "syntax error"
##### For details, see ssh_filter.log
## If enabled, execution of "sudo" command will be allowed.
SUDO_EXEC=yes
## Paranoia option. Don't change this unless you read the documentation and still feel concerned about security issues.
RSYNC_EXECUTABLE=rsync
## Enable other commands, useful for remote execution hooks like remotely creating snapshots.
CMD1=""
CMD2=""
CMD3=""
# BUILD=2017020802
LOG_FILE=~/.ssh/ssh_filter.log
## Allow sudo
SUDO_EXEC=true
## Log all valid commands too
_DEBUG=false
## Set remote token in authorized_keys
if [ "$1" != "" ]; then
_REMOTE_TOKEN="${1}"
fi
LOG_FILE="${HOME}/.ssh/ssh_filter.log"
function Log {
DATE=$(date)
echo "$DATE - $1" >> $LOG_FILE
DATE="$(date)"
echo "$DATE - $1" >> "$LOG_FILE"
}
function Go {
if [ "$_DEBUG" == true ]; then
Log "Executing [$SSH_ORIGINAL_COMMAND]."
fi
eval "$SSH_ORIGINAL_COMMAND"
}
case ${SSH_ORIGINAL_COMMAND%% *} in
"$RSYNC_EXECUTABLE")
Go ;;
"echo")
Go ;;
"find")
Go ;;
"du")
Go ;;
"mkdir")
Go ;;
"rm")
Go ;;
"df")
Go ;;
"mv")
Go ;;
"$CMD1")
if [ "$CMD1" != "" ]; then
Go
fi
;;
"$CMD2")
if [ "$CMD2" != "" ]; then
Go
fi
;;
"$CMD3")
if [ "$CMD3" != "" ]; then
Go
fi
;;
"sudo")
if [ "$SUDO_EXEC" == "yes" ]; then
if [[ "$SSH_ORIGINAL_COMMAND" == "sudo $RSYNC_EXECUTABLE"* ]]; then
Go
elif [[ "$SSH_ORIGINAL_COMMAND" == "sudo du"* ]]; then
Go
elif [[ "$SSH_ORIGINAL_COMMAND" == "sudo find"* ]]; then
Go
elif [[ "$SSH_ORIGINAL_COMMAND" == "sudo mkdir"* ]]; then
Go
elif [[ "$SSH_ORIGINAL_COMMAND" == "sudo rm"* ]]; then
Go
elif [[ "$SSH_ORIGINAL_COMMAND" == "sudo echo"* ]]; then
Go
elif [[ "$SSH_ORIGINAL_COMMAND" == "sudo df"* ]]; then
Go
elif [[ "$SSH_ORIGINAL_COMMAND" == "sudo mv"* ]]; then
Go
elif [[ "$SSH_ORIGINAL_COMMAND" == "sudo $CMD1"* ]]; then
if [ "$CMD1" != "" ]; then
Go
fi
elif [[ "$SSH_ORIGINAL_COMMAND" == "sudo $CMD2"* ]]; then
if [ "$CMD2" != "" ]; then
Go
fi
elif [[ "$SSH_ORIGINAL_COMMAND" == "sudo $CMD3"* ]]; then
if [ "$CMD3" != "" ]; then
Go
fi
else
Log "Command [$SSH_ORIGINAL_COMMAND] not allowed."
case "${SSH_ORIGINAL_COMMAND}" in
*"env _REMOTE_TOKEN=$_REMOTE_TOKEN"*)
if [ "$SUDO_EXEC" != true ] && [[ $SSH_ORIGINAL_COMMAND == *"sudo "* ]]; then
Log "Command [$SSH_ORIGINAL_COMMAND] contains sudo which is not allowed."
echo "Syntax error unexpected end of file"
exit 1
fi
else
Log "Command [$SSH_ORIGINAL_COMMAND] not allowed. sudo not enabled."
exit 1
fi
Go
;;
*)
Log "Command [$SSH_ORIGINAL_COMMAND] not allowed."
echo "Syntax error near unexpected token"
exit 1
;;
esac

233
sync.conf.example Normal file
View File

@ -0,0 +1,233 @@
###### osync - Rsync based two way sync engine with fault tolerance
###### (C) 2013-2023 by Orsiris de Jong (www.netpower.fr)
[GENERAL]
CONFIG_FILE_REVISION=1.3.0
## Sync job identification
INSTANCE_ID="sync_test"
## Directories to synchronize.
## Initiator is the system osync runs on. The initiator directory must be a local path.
INITIATOR_SYNC_DIR="/home/git/osync/dir1"
## Target is the system osync synchronizes to (can be the same system as the initiator in case of local sync tasks). The target directory can be a local or remote path.
TARGET_SYNC_DIR="/home/git/osync/dir2"
#TARGET_SYNC_DIR="ssh://backupuser@yourhost.old:22//home/git/osync/dir2"
## If the target system is remote, you can specify a RSA key (please use full path). If not defined, the default ~/.ssh/id_rsa will be used. See documentation for further information.
SSH_RSA_PRIVATE_KEY="/home/backupuser/.ssh/id_rsa"
## Alternatively, you may specify an SSH password file (less secure). Needs sshpass utility installed.
SSH_PASSWORD_FILE=""
## use the KRB5 credential cache to access SSH or rsync
#KRB5=true
## When using ssh filter, you must specify a remote token matching the one setup in authorized_keys
_REMOTE_TOKEN=SomeAlphaNumericToken9
## Create sync directories if they do not exist (true/false)
CREATE_DIRS=true
## Log file location. Leaving this empty will create a logfile at /var/log/osync_version_SYNC_ID.log (or current directory if /var/log doesn't exist)
LOGFILE=""
## Generate an alert if initiator or target replicas have less free space than given value in KB. Set this to zero to skip disk space tests.
MINIMUM_SPACE=10240
## Bandwidth limit Kbytes / second. Leave 0 to disable limitation
BANDWIDTH=0
## If enabled, synchronization on remote system will be processed as superuser. See documentation for /etc/sudoers file configuration.
SUDO_EXEC=false
## Paranoia option. Don't change this unless you read the documentation.
RSYNC_EXECUTABLE=rsync
## Remote rsync executable path. Leave this empty in most cases
RSYNC_REMOTE_PATH=""
## Rsync exclude / include order (the option set here will be set first, eg: include will make include then exclude patterns)
RSYNC_PATTERN_FIRST=include
## List of files / directories to incldue / exclude from sync on both sides (see rsync patterns, wildcards work).
## Paths are relative to sync dirs. List elements are separated by a semicolon.
RSYNC_INCLUDE_PATTERN=""
RSYNC_EXCLUDE_PATTERN=""
#RSYNC_EXCLUDE_PATTERN="tmp;archives"
## Files that contains lists of files / directories to include / exclude from sync on both sides. Leave this empty if you don't want to use an exclusion file.
## This file has to be in the same directory as the config file
## Paths are relative to sync dirs. One element per line.
RSYNC_INCLUDE_FROM=""
RSYNC_EXCLUDE_FROM=""
#RSYNC_EXCLUDE_FROM="exclude.list"
## List elements separator char. You may set an alternative separator char for your directories lists above.
PATH_SEPARATOR_CHAR=";"
## By default, osync stores its state into the replica_path/.osync_workdir/state
## This behavior can be changed for initiator or slave by overriding the following with an absolute path to a statedir, ex /opt/osync_state/initiator
## If osync runs locally, initiator and target state dirs **must** be different
INITIATOR_CUSTOM_STATE_DIR=""
TARGET_CUSTOM_STATE_DIR=""
[REMOTE_OPTIONS]
## ssh compression should be used on WAN links, unless your remote connection is good enough (LAN), in which case it would slow down things
SSH_COMPRESSION=false
## Optional ssh options. Example to lower CPU usage on ssh compression, one can specify '-T -c arcfour -o Compression=no -x'
## -T = turn off pseudo-tty, -c arcfour = weakest but fasted ssh encryption (destination must accept "Ciphers arcfour" in sshd_config), -x turns off X11 forwarding
## arcfour isn't accepted on most newer systems, you may then prefer any AES encryption if processor has aes-ni hardware acceleration
## If the system does not provide hardware assisted acceleration, chacha20-poly1305@openssh.com is a good cipher to select
## See: https://wiki.csnu.org/index.php/SSH_ciphers_speed_comparison
## -o Compression=no is already handled by SSH_COMPRESSION option
## Uncomment the following line to use those optimizations, on secured links only
#SSH_OPTIONAL_ARGS="-T -c aes128-ctr -x"
#SSH_OPTIONAL_ARGS="-T -c chacha20-poly1305@openssh.com -x"
## Ignore ssh known hosts. DANGER WILL ROBINSON DANGER ! This can lead to security issues. Only enable this if you know what you're doing.
SSH_IGNORE_KNOWN_HOSTS=false
## Use a single TCP connection for all SSH calls. Will make remote sync faster, but may work less good on lossy links.
SSH_CONTROLMASTER=false
## Check for connectivity to remote host before launching remote sync task. Be sure the hosts responds to ping. Failing to ping will stop sync.
REMOTE_HOST_PING=false
## Check for internet access by pinging one or more 3rd party hosts before remote sync task. Leave empty if you don't want this check to be be performed. Failing to ping will stop sync.
## If you use this function, you should set more than one 3rd party host, and be sure you can ping them.
## Be aware some DNS like opendns redirect false hostnames. Also, this adds an extra execution time of a bit less than a minute.
REMOTE_3RD_PARTY_HOSTS="www.kernel.org www.google.com"
[MISC_OPTIONS]
## Optional arguments passed to rsync executable. The following are already managed by the program and shoul never be passed here
## -r -l -p -t -g -o -D -E - u- i- n --executability -A -X -L -K -H -8 --zz -skip-compress -checksum -bwlimit -partial -partial-dir -no-whole-file -whole-file -backup -backup-dir -suffix
## --exclude --exclude-from --include --include-from --list-only --stats
## When dealing with different filesystems for sync, or using SMB mountpoints, try adding --modify-window=2 --omit-dir-times as optional arguments.
RSYNC_OPTIONAL_ARGS=""
## Preserve basic linux permissions
PRESERVE_PERMISSIONS=true
PRESERVE_OWNER=true
PRESERVE_GROUP=true
## On MACOS X, does not work and will be ignored
PRESERVE_EXECUTABILITY=true
## Preserve ACLS. Make sure source and target FS can handle ACL. Disabled on Mac OSX.
PRESERVE_ACL=false
## Preserve Xattr. Make sure source and target FS can manage identical XATTRS. Disabled on Mac OSX. Apparently, prior to rsync v3.1.2 there are some performance caveats with transferring XATTRS.
PRESERVE_XATTR=false
## Transforms symlinks into referent files/dirs. Be careful as symlinks without referrent will break sync as if standard files could not be copied.
COPY_SYMLINKS=false
## Treat symlinked dirs as dirs. CAUTION: This also follows symlinks outside of the replica root.
KEEP_DIRLINKS=false
## Preserve hard links. Make sure source and target FS can manage hard links or you will lose them.
PRESERVE_HARDLINKS=false
## Do a full checksum on all files that have identical sizes, they are checksummed to see if they actually are identical. This can take a long time.
CHECKSUM=false
## Let RSYNC compress file transfers. Do not use this if both initator and target replicas are on local system. Also, do not use this if you already enabled SSH compression.
RSYNC_COMPRESS=true
## Maximum execution time (in seconds) for sync process. Set these values zero will disable max execution times.
## Soft exec time only generates a warning. Hard exec time will generate a warning and stop sync process.
SOFT_MAX_EXEC_TIME=7200
HARD_MAX_EXEC_TIME=10600
## Log a message every KEEP_LOGGING seconds just to know the task is still alive
KEEP_LOGGING=1801
## Minimum time (in seconds) in file monitor /daemon mode between modification detection and sync task in order to let copy operations finish.
MIN_WAIT=60
## Maximum time (in seconds) waiting in file monitor / daemon mode. After this time, sync is run.
## Use 0 to wait indefinitely.
MAX_WAIT=7200
[BACKUP_DELETE_OPTIONS]
## Log a list of conflictual files (EXPERIMENTAL)
LOG_CONFLICTS=false
## Send an email when conflictual files are found (implies LOG_CONFLICTS)
ALERT_CONFLICTS=false
## Enabling this option will keep a backup of a file on the target replica if it gets updated from the source replica. Backups will be made to .osync_workdir/backups
CONFLICT_BACKUP=true
## Keep multiple backup versions of the same file. Warning, This can be very space consuming.
CONFLICT_BACKUP_MULTIPLE=false
## Osync will clean backup files after a given number of days. Setting this to 0 will disable cleaning and keep backups forever. Warning: This can be very space consuming.
CONFLICT_BACKUP_DAYS=30
## If the same file exists on both replicas, newer version will be synced. However, if both files have the same timestamp but differ, CONFILCT_PREVALANCE sets winner replica.
CONFLICT_PREVALANCE=initiator
## On deletion propagation to the target replica, a backup of the deleted files can be kept. Deletions will be kept in .osync_workdir/deleted
SOFT_DELETE=true
## Osync will clean deleted files after a given number of days. Setting this to 0 will disable cleaning and keep deleted files forever. Warning: This can be very space consuming.
SOFT_DELETE_DAYS=30
## Optional deletion skip on replicas. Valid values are "initiator", "target", or "initiator,target"
SKIP_DELETION=
## Optional sync type. By default, osync is bidirectional. You may want to use osync as unidirectional sync in some circumstances. Valid values are "initiator2target" or "target2initiator"
SYNC_TYPE=
[RESUME_OPTIONS]
## Try to resume an aborted sync task
RESUME_SYNC=true
## Number maximum resume tries before initiating a fresh sync.
RESUME_TRY=2
## When a pidlock exists on slave replica that does not correspond to the initiator's instance-id, force pidlock removal. Be careful with this option if you have multiple initiators.
FORCE_STRANGER_LOCK_RESUME=false
## Keep partial uploads that can be resumed on next run, experimental feature
PARTIAL=false
## Use delta copy algortithm (usefull when local paths are network drives), defaults to true
DELTA_COPIES=true
[ALERT_OPTIONS]
## List of alert mails separated by spaces
## Most Unix systems (including Win10 bash) have mail support out of the box
## Just make sure that the current user has enough privileges to use mail / mutt / sendmail and that the mail system is configured to allow outgoing mails
## on pfSense platform, smtp support needs to be configured in System > Advanced > Notifications
DESTINATION_MAILS="your@alert.tld"
## By default, only sync warnings / errors are sent by mail. This default behavior can be overrided here
ALWAYS_SEND_MAILS=false
## Optional change of mail body encoding (using iconv)
## By default, all mails are sent in UTF-8 format without header (because of maximum compatibility of all platforms)
## You may specify an optional encoding here (like "ISO-8859-1" or whatever iconv can handle)
MAIL_BODY_CHARSET=""
## Additional mail parameters needed for Android / Busybox / Cygwin / MSYS
## Android & Busybox use sendmail (and openssl if encryption is needed)
## MSYS & Cygwin Windows mail support relies on mailsend.exe from muquit, http://github.com/muquit/mailsend which needs to be in %PATH% environment variable
SENDER_MAIL="alert@your.system.tld"
SMTP_SERVER=smtp.your.isp.tld
SMTP_PORT=25
# encryption can be tls, ssl or none
SMTP_ENCRYPTION=none
SMTP_USER=
SMTP_PASSWORD=
[EXECUTION_HOOKS]
## Commands can will be run before and / or after sync process
LOCAL_RUN_BEFORE_CMD=""
LOCAL_RUN_AFTER_CMD=""
REMOTE_RUN_BEFORE_CMD=""
REMOTE_RUN_AFTER_CMD=""
## Max execution time of commands before they get force killed. Leave 0 if you don't wan't this to happen. Time is specified in seconds.
MAX_EXEC_TIME_PER_CMD_BEFORE=0
MAX_EXEC_TIME_PER_CMD_AFTER=0
## Stops osync execution if one of the above before commands fail
STOP_ON_CMD_ERROR=true
## Run local and remote after sync commands even on failure
RUN_AFTER_CMD_ON_ERROR=false

102
target-helper.conf.example Normal file
View File

@ -0,0 +1,102 @@
#!/usr/bin/env bash
###### osync - Rsync based two way sync engine with fault tolerance
###### (C) 2013-2020 by Orsiris de Jong (www.netpower.fr)
[GENERAL]
CONFIG_FILE_REVISION=1.3.0
## Sync job identification
INSTANCE_ID="target_test"
## Directories to synchronize.
## Initiator is the system osync runs on. The initiator directory must be a local path.
INITIATOR_SYNC_DIR="/home/git/osync/dir1"
#INITIATOR_SYNC_DIR="ssh://backupuser@yourhost.old:22//home/git/osync/dir1"
## Target is the system osync synchronizes to (can be the same system as the initiator in case of local sync tasks). The target directory can be a local or remote path.
TARGET_SYNC_DIR="/home/git/osync/dir2"
## If the target system is remote, you can specify a RSA key (please use full path). If not defined, the default ~/.ssh/id_rsa will be used. See documentation for further information.
SSH_RSA_PRIVATE_KEY="/home/backupuser/.ssh/id_rsa"
## Alternatively, you may specify an SSH password file (less secure). Needs sshpass utility installed.
SSH_PASSWORD_FILE=""
## When using ssh filter, you must specify a remote token matching the one setup in authorized_keys
_REMOTE_TOKEN=SomeAlphaNumericToken9
## Log file location. Leaving this empty will create a logfile at /var/log/osync_version_SYNC_ID.log (or current directory if /var/log doesn't exist)
LOGFILE=""
## If enabled, synchronization on remote system will be processed as superuser. See documentation for /etc/sudoers file configuration.
SUDO_EXEC=false
## ---------- REMOTE SYNC OPTIONS
## ssh compression should be used unless your remote connection is good enough (LAN)
SSH_COMPRESSION=true
## Ignore ssh known hosts. DANGER WILL ROBINSON DANGER ! This can lead to security issues. Only enable this if you know what you're doing.
SSH_IGNORE_KNOWN_HOSTS=false
## Check for connectivity to remote host before launching remote sync task. Be sure the hosts responds to ping. Failing to ping will stop sync.
REMOTE_HOST_PING=false
## Check for internet access by pinging one or more 3rd party hosts before remote sync task. Leave empty if you don't want this check to be be performed. Failing to ping will stop sync.
## If you use this function, you should set more than one 3rd party host, and be sure you can ping them.
## Be aware some DNS like opendns redirect false hostnames. Also, this adds an extra execution time of a bit less than a minute.
REMOTE_3RD_PARTY_HOSTS="www.kernel.org www.google.com"
## Log a message every KEEP_LOGGING seconds just to know the task is still alive
KEEP_LOGGING=1801
## Minimum time (in seconds) in file monitor /daemon mode between modification detection and sync task in order to let copy operations finish.
MIN_WAIT=60
## Maximum time (in seconds) waiting in file monitor / daemon mode. After this time, sync is run.
## Use 0 to wait indefinitely.
MAX_WAIT=7200
[ALERT_OPTIONS]
## List of alert mails separated by spaces
## Most Unix systems (including Win10 bash) have mail support out of the box
## Just make sure that the current user has enough privileges to use mail / mutt / sendmail and that the mail system is configured to allow outgoing mails
## on pfSense platform, smtp support needs to be configured in System > Advanced > Notifications
DESTINATION_MAILS="your@alert.tld"
## Optional change of mail body encoding (using iconv)
## By default, all mails are sent in UTF-8 format without header (because of maximum compatibility of all platforms)
## You may specify an optional encoding here (like "ISO-8859-1" or whatever iconv can handle)
MAIL_BODY_CHARSET=""
## Additional mail parameters needed for Android / Busybox / Cygwin / MSYS
## Android & Busybox use sendmail (and openssl if encryption is needed)
## MSYS & Cygwin Windows mail support relies on mailsend.exe from muquit, http://github.com/muquit/mailsend which needs to be in %PATH% environment variable
SENDER_MAIL="alert@your.system.tld"
SMTP_SERVER=smtp.your.isp.tld
SMTP_PORT=25
# encryption can be tls, ssl or none
SMTP_ENCRYPTION=none
SMTP_USER=
SMTP_PASSWORD=
[EXECUTION_HOOKS]
## Commands can will be run before and / or after sync process (remote execution will only happen if REMOTE_OPERATION is set).
LOCAL_RUN_BEFORE_CMD=""
LOCAL_RUN_AFTER_CMD=""
REMOTE_RUN_BEFORE_CMD=""
REMOTE_RUN_AFTER_CMD=""
## Max execution time of commands before they get force killed. Leave 0 if you don't wan't this to happen. Time is specified in seconds.
MAX_EXEC_TIME_PER_CMD_BEFORE=0
MAX_EXEC_TIME_PER_CMD_AFTER=0
## Stops osync execution if one of the above commands fail
STOP_ON_CMD_ERROR=true
## Run local and remote after sync commands even on failure
RUN_AFTER_CMD_ON_ERROR=false

View File

@ -1,143 +0,0 @@
#!/usr/bin/env bash
###### Osync - Rsync based two way sync engine with fault tolerance
###### (L) 2013-2014 by Orsiris "Ozy" de Jong (www.netpower.fr)
###### Config file rev 2611201401
## ---------- GENERAL OPTIONS
## Sync job identification
SYNC_ID="sync_test"
## Directories to synchronize. Master must be on the system Osync runs on. Slave can be either a local directory, or a remote one.
MASTER_SYNC_DIR="master"
SLAVE_SYNC_DIR="ssh://localhost//tmp/osync_tests/remote/slave"
#SLAVE_SYNC_DIR="ssh://backupuser@yourhost.old:22//home/git/osync/dir2"
## If slave replica is a remote directory, you must specify a RSA key (please use full path). Please see documentation for further information.
#SSH_RSA_PRIVATE_KEY="/home/backupuser/.ssh/id_rsa"
## Create sync directories if they do not exist
CREATE_DIRS=yes
## Log file location. Leaving this empty will create a logfile at /var/log/osync_version_SYNC_ID.log (or current directory if /var/log doesn't exist)
LOGFILE=""
## List of directories to exclude from sync on both sides (rsync patterns, wildcards work).
## Paths are relative to sync dirs. List elements are separated by a semicolon.
RSYNC_EXCLUDE_PATTERN=""
#RSYNC_EXCLUDE_PATTERN="tmp;archives"
## File that contains the list of directories or files to exclude from sync on both sides. Leave this empty if you don't want to use an exclusion file.
## This file has to be in the same directory as the config file
## Paths are relative to sync dirs. One element per line.
RSYNC_EXCLUDE_FROM=""
#RSYNC_EXCLUDE_FROM="exclude.list"
## List elements separator char. You may set an alternative separator char for your directories lists above.
PATH_SEPARATOR_CHAR=";"
## Generate an alert if master or slave replicas have less free space than given value in KB.
MINIMUM_SPACE=10240
## Bandwidth limit Kbytes / second. Leave 0 to disable limitation
BANDWIDTH=0
## If enabled, synchronization on remote system will be processed as superuser. See documentation for /etc/sudoers file configuration.
SUDO_EXEC=no
## Paranoia option. Don't change this unless you read the documentation.
RSYNC_EXECUTABLE=rsync
## ---------- REMOTE SYNC OPTIONS
## ssh compression should be used unless your remote connection is good enough (LAN)
SSH_COMPRESSION=yes
## Check for connectivity to remote host before launching remote sync task. Be sure the hosts responds to ping. Failing to ping will stop sync.
REMOTE_HOST_PING=no
## Check for internet access by pinging one or more 3rd party hosts before remote sync task. Leave empty if you don't want this check to be be performed. Failing to ping will stop sync.
## If you use this function, you should set more than one 3rd party host, and be sure you can ping them.
## Be aware some DNS like opendns redirect false hostnames. Also, this adds an extra execution time of a bit less than a minute.
REMOTE_3RD_PARTY_HOSTS=""
## Remote rsync executable path. Leave this empty in most cases
RSYNC_REMOTE_PATH=""
## ---------- MISC OPTIONS
## Preserve ACLS. Make sure source and target FS can manage same ACLs or you'll get loads of errors.
PRESERVE_ACL=no
## Preserve Xattr. Make sure source and target FS can manage same Xattrs or you'll get loads of errors.
PRESERVE_XATTR=no
## Transforms symlinks into referent files/dirs
COPY_SYMLINKS=no
## Treat symlinked dirs as dirs. CAUTION: This also follows symlinks outside of the replica root.
KEEP_DIRLINKS=no
## Preserve hard links. Make sure source and target FS can manage hard links or you will lose them.
PRESERVE_HARDLINKS=no
## Let RSYNC compress file transfers. Do not use this if both master and slave replicas are on local system. Also, do not use this if you already enabled SSH compression.
RSYNC_COMPRESS=yes
## Maximum execution time (in seconds) for sync process. Soft exec time only generates a warning. Hard exec time will generate a warning and stop sync process.
SOFT_MAX_EXEC_TIME=7200
HARD_MAX_EXEC_TIME=10600
## Minimum time (in seconds) in file monitor /daemon mode between modification detection and sync task in order to let copy operations finish.
MIN_WAIT=60
## ---------- BACKUP AND DELETION OPTIONS
## Enabling this option will keep a backup of a file on the target replica if it gets updated from the source replica. Backups will be made to .osync_workdir/backups
CONFLICT_BACKUP=yes
## Keep multiple backup versions of the same file. Warning, This can be very space consuming.
CONFLICT_BACKUP_MULTIPLE=no
## Osync will clean backup files after a given number of days. Setting this to 0 will disable cleaning and keep backups forever. Warning: This can be very space consuming.
CONFLICT_BACKUP_DAYS=30
## If the same file exists on both replicas, newer version will be synced. However, if both files have the same timestamp but differ, CONFILCT_PREVALANCE sets winner replica.
CONFLICT_PREVALANCE=master
## On deletion propagation to the target replica, a backup of the deleted files can be kept. Deletions will be kept in .osync_workdir/deleted
SOFT_DELETE=yes
## Osync will clean deleted files after a given number of days. Setting this to 0 will disable cleaning and keep deleted files forever. Warning: This can be very space consuming.
SOFT_DELETE_DAYS=30
## ---------- RESUME OPTIONS
## Try to resume an aborted sync task
RESUME_SYNC=yes
## Number maximum resume tries before initiating a fresh sync.
RESUME_TRY=2
## When a pidlock exists on slave replica that does not correspond to master's sync-id, force pidlock removal. Be careful with this option if you have multiple masters.
FORCE_STRANGER_LOCK_RESUME=no
## Keep partial uploads that can be resumed on next run, experimental feature
PARTIAL=no
## ---------- ALERT OPTIONS
## List of alert mails separated by spaces
DESTINATION_MAILS="your@alert.tld"
## Windows (MSYS environment) only mail options (used with sendemail.exe from Brandon Zehm)
SENDER_MAIL="alert@your.system.tld"
SMTP_SERVER=smtp.your.isp.tld
SMTP_USER=
SMTP_PASSWORD=
## ---------- EXECUTION HOOKS
## Commands can will be run before and / or after sync process (remote execution will only happen if REMOTE_SYNC is set).
LOCAL_RUN_BEFORE_CMD=""
LOCAL_RUN_AFTER_CMD=""
REMOTE_RUN_BEFORE_CMD=""
REMOTE_RUN_AFTER_CMD=""
## Max execution time of commands before they get force killed. Leave 0 if you don't wan't this to happen. Time is specified in seconds.
MAX_EXEC_TIME_PER_CMD_BEFORE=0
MAX_EXEC_TIME_PER_CMD_AFTER=0
## Stops Osync execution if one of the above commands fail
STOP_ON_CMD_ERROR=yes

View File

@ -1,345 +0,0 @@
#!/usr/bin/env bash
# Test dir
TMP="/tmp/osync_tests"
# SSH port used for remote tests
SSH_PORT=49999
# Get dir the tests are stored in
TEST_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd "$TEST_DIR"
OSYNC_EXECUTABLE="$(dirname $TEST_DIR)//osync.sh"
declare -A sandbox_osync
#sandbox_osync[quickLocal]="--master=master --slave=slave"
#sandbox_osync[quickRemote]="--master=master --slave=ssh://localhost//tmp/osync_tests/quickRemote/slave"
#sandbox_osync[local]="conf/local.conf"
#sandbox_osync[remote]="conf/remote.conf"
oneTimeSetUp()
{
for i in "${!sandbox_osync[@]}"
do
prepareSandbox "$i"
done
}
oneTimeTearDown()
{
rm -rf "$TMP"
}
prepareSandbox()
{
rm -rf "$TMP/$1"
mkdir -p "$TMP/$1"
pushd "$TMP/$1" >/dev/null
mkdir master
mkdir slave
mkdir expected
popd >/dev/null
}
compareSandbox()
{
diff -aurx .osync_workdir master slave
assertEquals 0 $?
diff -aurx .osync_workdir master expected
assertEquals 0 $?
diff -aurx .osync_workdir slave expected
assertEquals 0 $?
}
syncSandbox()
{
$OSYNC_EXECUTABLE ${sandbox_osync[$1]} >/dev/null
assertEquals 0 $?
}
runSandbox()
{
syncSandbox "$1"
compareSandbox
}
joinSandbox()
{
cd "$TMP/$1"
}
### Tests ###
# One empty file
_testOneEmptyFile()
{
joinSandbox "$1"
# Add one empty file
touch "$2/testOneEmpty"
touch expected/testOneEmpty
runSandbox "$1"
# Change one empty file
echo "Test" > "$2/testOneEmpty"
cp "$2/testOneEmpty" expected/testOneEmpty
runSandbox "$1"
# Empty one file
echo -n "" > "$2/testOneEmpty"
cp "$2/testOneEmpty" expected/testOneEmpty
runSandbox "$1"
# Delete one empty file
cp "$2/testOneEmpty" testOneEmpty
rm "$2/testOneEmpty"
rm expected/testOneEmpty
runSandbox "$1"
# Backup check
if [ "$2" == "master" ]
then
diff -aur slave/.osync_workdir/deleted/testOneEmpty testOneEmpty
else
diff -aur master/.osync_workdir/deleted/testOneEmpty testOneEmpty
fi
assertEquals 0 $?
}
testQuickLocalMasterOneEmptyFile()
{
_testOneEmptyFile quickLocal master
}
testQuickLocalSlaveOneEmptyFile()
{
_testOneEmptyFile quickLocal slave
}
testQuickRemoteMasterOneEmptyFile()
{
_testOneEmptyFile quickRemote master
}
testQuickRemoteSlaveOneEmptyFile()
{
_testOneEmptyFile quickRemote slave
}
testLocalMasterOneEmptyFile()
{
_testOneEmptyFile local master
}
testLocalSlaveOneEmptyFile()
{
_testOneEmptyFile local slave
}
testRemoteMasterOneEmptyFile()
{
_testOneEmptyFile remote master
}
testRemoteSlaveOneEmptyFile()
{
_testOneEmptyFile remote slave
}
# One file
_testOneFile()
{
joinSandbox "$1"
# Add one file
echo "Test" > "$2/testOne"
cp "$2/testOne" expected/testOne
runSandbox "$1"
# Change one file
echo "Test2" > "$2/testOne"
cp "$2/testOne" expected/testOne
runSandbox "$1"
# Delete one file
cp "$2/testOne" testOne
rm "$2/testOne"
rm expected/testOne
runSandbox "$1"
# Backup check
if [ "$2" == "master" ]
then
diff -aur slave/.osync_workdir/deleted/testOne testOne
else
diff -aur master/.osync_workdir/deleted/testOne testOne
fi
assertEquals 0 $?
}
testQuickLocalMasterOneFile()
{
_testOneFile quickLocal master
}
testQuickLocalSlaveOneFile()
{
_testOneFile quickLocal slave
}
testQuickRemoteMasterOneFile()
{
_testOneFile quickRemote master
}
testQuickRemoteSlaveOneFile()
{
_testOneFile quickRemote slave
}
testLocalMasterOneFile()
{
_testOneFile local master
}
testLocalSlaveOneFile()
{
_testOneFile local slave
}
testRemoteMasterOneFile()
{
_testOneFile remote master
}
testRemoteSlaveOneFile()
{
_testOneFile remote slave
}
# Distinct
_testDistinct()
{
joinSandbox "$1"
# Generate files in master
for i in testDistinctM1 testDistinctM2 testDistinctM3
do
mkdir "master/$i"
mkdir "expected/$i"
for j in m1 m2 m3 ; do
echo "$i/$j" > "master/$i/$j"
cp "master/$i/$j" "expected/$i/$j"
done
done
# Generate files in slave
for i in testDistinctS1 testDistinctS2 testDistinctS3
do
mkdir "slave/$i"
mkdir "expected/$i"
for j in s1 s2 s3 ; do
echo "$i/$j" > "slave/$i/$j"
cp "slave/$i/$j" "expected/$i/$j"
done
done
# Generate files in same directories for master and slave
for i in testDistinctMS1 testDistinctMS2 testDistinctMS3
do
mkdir "master/$i"
mkdir "slave/$i"
mkdir "expected/$i"
for j in ms1 ms2 ms3 ; do
echo "$i/$j" > "master/$i/m-$j"
cp "master/$i/m-$j" "expected/$i/m-$j"
echo "$i/$j" > "slave/$i/s-$j"
cp "slave/$i/s-$j" "expected/$i/s-$j"
done
done
runSandbox "$1"
}
testQuickLocalDistinct()
{
_testDistinct quickLocal
}
testQuickRemoteDistinct()
{
_testDistinct quickRemote
}
testLocalDistinct()
{
_testDistinct local
}
testRemoteDistinct()
{
_testDistinct remote
}
# Collision
_testCollision()
{
joinSandbox "$1"
# Slave precedence
echo "Test1" > master/testCollision1
echo "Test2" > slave/testCollision1
touch -d "2004-02-29 16:21:41" master/testCollision1
touch -d "2004-02-29 16:21:42" slave/testCollision1
cp slave/testCollision1 expected/testCollision1
cp master/testCollision1 testCollision1
runSandbox "$1"
# Backup check
diff -aur master/.osync_workdir/backups/testCollision1 testCollision1
assertEquals 0 $?
# Master precedence
echo "Test1" > master/testCollision2
echo "Test2" > slave/testCollision2
touch -d "2004-02-29 16:21:42" master/testCollision2
touch -d "2004-02-29 16:21:41" slave/testCollision2
cp master/testCollision2 expected/testCollision2
cp slave/testCollision2 testCollision2
runSandbox "$1"
# Backup check
diff -aur slave/.osync_workdir/backups/testCollision2 testCollision2
assertEquals 0 $?
# ??
# echo "Test1" > master/testCollision3
# echo "Test2" > slave/testCollision3
# touch -d "2004-02-29 16:21:42" master/testCollision3
# touch -d "2004-02-29 16:21:42" slave/testCollision3
# cp slave/testCollision3 expected/testCollision3
# runSandbox "$1"
}
testQuickLocalCollision()
{
_testCollision quickLocal
}
testQuickRemoteCollision()
{
_testCollision quickRemote
}
testLocalCollision()
{
_testCollision local
}
testRemoteCollision()
{
_testCollision remote
}
#suite()
#{
# suite_addTest "testQuickRemoteMasterOneEmptyFile"
#}
. shunit2/shunit2

File diff suppressed because it is too large Load Diff

View File

@ -1,124 +0,0 @@
#! /bin/sh
# $Id$
# vim:et:ft=sh:sts=2:sw=2
#
# Copyright 2008 Kate Ward. All Rights Reserved.
# Released under the LGPL (GNU Lesser General Public License)
# Author: kate.ward@forestent.com (Kate Ward)
#
# shUnit2 unit test suite runner.
#
# This script runs all the unit tests that can be found, and generates a nice
# report of the tests.
MY_NAME=`basename $0`
MY_PATH=`dirname $0`
PREFIX='shunit2_test_'
SHELLS='/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh'
TESTS=''
for test in ${PREFIX}[a-z]*.sh; do
TESTS="${TESTS} ${test}"
done
# load common unit test functions
. ../lib/versions
. ./shunit2_test_helpers
usage()
{
echo "usage: ${MY_NAME} [-e key=val ...] [-s shell(s)] [-t test(s)]"
}
env=''
# process command line flags
while getopts 'e:hs:t:' opt; do
case ${opt} in
e) # set an environment variable
key=`expr "${OPTARG}" : '\([^=]*\)='`
val=`expr "${OPTARG}" : '[^=]*=\(.*\)'`
if [ -z "${key}" -o -z "${val}" ]; then
usage
exit 1
fi
eval "${key}='${val}'"
export ${key}
env="${env:+${env} }${key}"
;;
h) usage; exit 0 ;; # output help
s) shells=${OPTARG} ;; # list of shells to run
t) tests=${OPTARG} ;; # list of tests to run
*) usage; exit 1 ;;
esac
done
shift `expr ${OPTIND} - 1`
# fill shells and/or tests
shells=${shells:-${SHELLS}}
tests=${tests:-${TESTS}}
# error checking
if [ -z "${tests}" ]; then
th_error 'no tests found to run; exiting'
exit 1
fi
cat <<EOF
#------------------------------------------------------------------------------
# System data
#
# test run info
shells: ${shells}
tests: ${tests}
EOF
for key in ${env}; do
eval "echo \"${key}=\$${key}\""
done
echo
# output system data
echo "# system info"
echo "$ date"
date
echo
echo "$ uname -mprsv"
uname -mprsv
#
# run tests
#
for shell in ${shells}; do
echo
# check for existance of shell
if [ ! -x ${shell} ]; then
th_warn "unable to run tests with the ${shell} shell"
continue
fi
cat <<EOF
#------------------------------------------------------------------------------
# Running the test suite with ${shell}
#
EOF
SHUNIT_SHELL=${shell} # pass shell onto tests
shell_name=`basename ${shell}`
shell_version=`versions_shellVersion "${shell}"`
echo "shell name: ${shell_name}"
echo "shell version: ${shell_version}"
# execute the tests
for suite in ${tests}; do
suiteName=`expr "${suite}" : "${PREFIX}\(.*\).sh"`
echo
echo "--- Executing the '${suiteName}' test suite ---"
( exec ${shell} ./${suite} 2>&1; )
done
done

View File

@ -1,206 +0,0 @@
#! /bin/sh
# $Id$
# vim:et:ft=sh:sts=2:sw=2
#
# Copyright 2008 Kate Ward. All Rights Reserved.
# Released under the LGPL (GNU Lesser General Public License)
#
# Author: kate.ward@forestent.com (Kate Ward)
#
# shUnit2 unit test for assert functions
# load test helpers
. ./shunit2_test_helpers
#------------------------------------------------------------------------------
# suite tests
#
commonEqualsSame()
{
fn=$1
( ${fn} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
th_assertTrueWithNoOutput 'equal' $? "${stdoutF}" "${stderrF}"
( ${fn} "${MSG}" 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
th_assertTrueWithNoOutput 'equal; with msg' $? "${stdoutF}" "${stderrF}"
( ${fn} 'abc def' 'abc def' >"${stdoutF}" 2>"${stderrF}" )
th_assertTrueWithNoOutput 'equal with spaces' $? "${stdoutF}" "${stderrF}"
( ${fn} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'not equal' $? "${stdoutF}" "${stderrF}"
( ${fn} '' '' >"${stdoutF}" 2>"${stderrF}" )
th_assertTrueWithNoOutput 'null values' $? "${stdoutF}" "${stderrF}"
( ${fn} arg1 >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}"
( ${fn} arg1 arg2 arg3 arg4 >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
}
commonNotEqualsSame()
{
fn=$1
( ${fn} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
th_assertTrueWithNoOutput 'not same' $? "${stdoutF}" "${stderrF}"
( ${fn} "${MSG}" 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
th_assertTrueWithNoOutput 'not same, with msg' $? "${stdoutF}" "${stderrF}"
( ${fn} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'same' $? "${stdoutF}" "${stderrF}"
( ${fn} '' '' >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'null values' $? "${stdoutF}" "${stderrF}"
( ${fn} arg1 >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}"
( ${fn} arg1 arg2 arg3 arg4 >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
}
testAssertEquals()
{
commonEqualsSame 'assertEquals'
}
testAssertNotEquals()
{
commonNotEqualsSame 'assertNotEquals'
}
testAssertSame()
{
commonEqualsSame 'assertSame'
}
testAssertNotSame()
{
commonNotEqualsSame 'assertNotSame'
}
testAssertNull()
{
( assertNull '' >"${stdoutF}" 2>"${stderrF}" )
th_assertTrueWithNoOutput 'null' $? "${stdoutF}" "${stderrF}"
( assertNull "${MSG}" '' >"${stdoutF}" 2>"${stderrF}" )
th_assertTrueWithNoOutput 'null, with msg' $? "${stdoutF}" "${stderrF}"
( assertNull 'x' >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'not null' $? "${stdoutF}" "${stderrF}"
( assertNull >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}"
( assertNull arg1 arg2 arg3 >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
}
testAssertNotNull()
{
( assertNotNull 'x' >"${stdoutF}" 2>"${stderrF}" )
th_assertTrueWithNoOutput 'not null' $? "${stdoutF}" "${stderrF}"
( assertNotNull "${MSG}" 'x' >"${stdoutF}" 2>"${stderrF}" )
th_assertTrueWithNoOutput 'not null, with msg' $? "${stdoutF}" "${stderrF}"
( assertNotNull 'x"b' >"${stdoutF}" 2>"${stderrF}" )
th_assertTrueWithNoOutput 'not null, with double-quote' $? \
"${stdoutF}" "${stderrF}"
( assertNotNull "x'b" >"${stdoutF}" 2>"${stderrF}" )
th_assertTrueWithNoOutput 'not null, with single-quote' $? \
"${stdoutF}" "${stderrF}"
( assertNotNull 'x$b' >"${stdoutF}" 2>"${stderrF}" )
th_assertTrueWithNoOutput 'not null, with dollar' $? \
"${stdoutF}" "${stderrF}"
( assertNotNull 'x`b' >"${stdoutF}" 2>"${stderrF}" )
th_assertTrueWithNoOutput 'not null, with backtick' $? \
"${stdoutF}" "${stderrF}"
( assertNotNull '' >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'null' $? "${stdoutF}" "${stderrF}"
# there is no test for too few arguments as $1 might actually be null
( assertNotNull arg1 arg2 arg3 >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
}
testAssertTrue()
{
( assertTrue 0 >"${stdoutF}" 2>"${stderrF}" )
th_assertTrueWithNoOutput 'true' $? "${stdoutF}" "${stderrF}"
( assertTrue "${MSG}" 0 >"${stdoutF}" 2>"${stderrF}" )
th_assertTrueWithNoOutput 'true, with msg' $? "${stdoutF}" "${stderrF}"
( assertTrue '[ 0 -eq 0 ]' >"${stdoutF}" 2>"${stderrF}" )
th_assertTrueWithNoOutput 'true condition' $? "${stdoutF}" "${stderrF}"
( assertTrue 1 >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'false' $? "${stdoutF}" "${stderrF}"
( assertTrue '[ 0 -eq 1 ]' >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'false condition' $? "${stdoutF}" "${stderrF}"
( assertTrue '' >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'null' $? "${stdoutF}" "${stderrF}"
( assertTrue >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}"
( assertTrue arg1 arg2 arg3 >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
}
testAssertFalse()
{
( assertFalse 1 >"${stdoutF}" 2>"${stderrF}" )
th_assertTrueWithNoOutput 'false' $? "${stdoutF}" "${stderrF}"
( assertFalse "${MSG}" 1 >"${stdoutF}" 2>"${stderrF}" )
th_assertTrueWithNoOutput 'false, with msg' $? "${stdoutF}" "${stderrF}"
( assertFalse '[ 0 -eq 1 ]' >"${stdoutF}" 2>"${stderrF}" )
th_assertTrueWithNoOutput 'false condition' $? "${stdoutF}" "${stderrF}"
( assertFalse 0 >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'true' $? "${stdoutF}" "${stderrF}"
( assertFalse '[ 0 -eq 0 ]' >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'true condition' $? "${stdoutF}" "${stderrF}"
( assertFalse '' >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'true condition' $? "${stdoutF}" "${stderrF}"
( assertFalse >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}"
( assertFalse arg1 arg2 arg3 >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
}
#------------------------------------------------------------------------------
# suite functions
#
oneTimeSetUp()
{
th_oneTimeSetUp
MSG='This is a test message'
}
# load and run shUnit2
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
. ${TH_SHUNIT}

View File

@ -1,86 +0,0 @@
#! /bin/sh
# $Id$
# vim:et:ft=sh:sts=2:sw=2
#
# Copyright 2008 Kate Ward. All Rights Reserved.
# Released under the LGPL (GNU Lesser General Public License)
#
# Author: kate.ward@forestent.com (Kate Ward)
#
# shUnit2 unit test for failure functions
# load common unit-test functions
. ./shunit2_test_helpers
#-----------------------------------------------------------------------------
# suite tests
#
testFail()
{
( fail >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'fail' $? "${stdoutF}" "${stderrF}"
( fail "${MSG}" >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'fail with msg' $? "${stdoutF}" "${stderrF}"
( fail arg1 >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'too many arguments' $? "${stdoutF}" "${stderrF}"
}
testFailNotEquals()
{
( failNotEquals 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'same' $? "${stdoutF}" "${stderrF}"
( failNotEquals "${MSG}" 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'same with msg' $? "${stdoutF}" "${stderrF}"
( failNotEquals 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'not same' $? "${stdoutF}" "${stderrF}"
( failNotEquals '' '' >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'null values' $? "${stdoutF}" "${stderrF}"
( failNotEquals >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}"
( failNotEquals arg1 arg2 arg3 arg4 >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
}
testFailSame()
{
( failSame 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'same' $? "${stdoutF}" "${stderrF}"
( failSame "${MSG}" 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'same with msg' $? "${stdoutF}" "${stderrF}"
( failSame 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'not same' $? "${stdoutF}" "${stderrF}"
( failSame '' '' >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithOutput 'null values' $? "${stdoutF}" "${stderrF}"
( failSame >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}"
( failSame arg1 arg2 arg3 arg4 >"${stdoutF}" 2>"${stderrF}" )
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
}
#-----------------------------------------------------------------------------
# suite functions
#
oneTimeSetUp()
{
th_oneTimeSetUp
MSG='This is a test message'
}
# load and run shUnit2
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
. ${TH_SHUNIT}

View File

@ -1,246 +0,0 @@
#! /bin/sh
# $Id$
# vim:et:ft=sh:sts=2:sw=2
#
# Copyright 2008 Kate Ward. All Rights Reserved.
# Released under the LGPL (GNU Lesser General Public License)
# Author: kate.ward@forestent.com (Kate Ward)
#
# shUnit2 unit test for macros.
# load test helpers
. ./shunit2_test_helpers
#------------------------------------------------------------------------------
# suite tests
#
testAssertEquals()
{
# start skipping if LINENO not available
[ -z "${LINENO:-}" ] && startSkipping
( ${_ASSERT_EQUALS_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_ASSERT_EQUALS_ failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
( ${_ASSERT_EQUALS_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_ASSERT_EQUALS_ w/ msg failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
}
testAssertNotEquals()
{
# start skipping if LINENO not available
[ -z "${LINENO:-}" ] && startSkipping
( ${_ASSERT_NOT_EQUALS_} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_ASSERT_NOT_EQUALS_ failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
( ${_ASSERT_NOT_EQUALS_} '"some msg"' 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_ASSERT_NOT_EQUALS_ w/ msg failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
}
testSame()
{
# start skipping if LINENO not available
[ -z "${LINENO:-}" ] && startSkipping
( ${_ASSERT_SAME_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_ASSERT_SAME_ failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
( ${_ASSERT_SAME_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_ASSERT_SAME_ w/ msg failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
}
testNotSame()
{
# start skipping if LINENO not available
[ -z "${LINENO:-}" ] && startSkipping
( ${_ASSERT_NOT_SAME_} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_ASSERT_NOT_SAME_ failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
( ${_ASSERT_NOT_SAME_} '"some msg"' 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_ASSERT_NOT_SAME_ w/ msg failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
}
testNull()
{
# start skipping if LINENO not available
[ -z "${LINENO:-}" ] && startSkipping
( ${_ASSERT_NULL_} 'x' >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_ASSERT_NULL_ failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
( ${_ASSERT_NULL_} '"some msg"' 'x' >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_ASSERT_NULL_ w/ msg failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
}
testNotNull()
{
# start skipping if LINENO not available
[ -z "${LINENO:-}" ] && startSkipping
( ${_ASSERT_NOT_NULL_} '' >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_ASSERT_NOT_NULL_ failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
( ${_ASSERT_NOT_NULL_} '"some msg"' '""' >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_ASSERT_NOT_NULL_ w/ msg failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stdoutF}" "${stderrF}" >&2
}
testAssertTrue()
{
# start skipping if LINENO not available
[ -z "${LINENO:-}" ] && startSkipping
( ${_ASSERT_TRUE_} ${SHUNIT_FALSE} >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_ASSERT_TRUE_ failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
( ${_ASSERT_TRUE_} '"some msg"' ${SHUNIT_FALSE} >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_ASSERT_TRUE_ w/ msg failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
}
testAssertFalse()
{
# start skipping if LINENO not available
[ -z "${LINENO:-}" ] && startSkipping
( ${_ASSERT_FALSE_} ${SHUNIT_TRUE} >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_ASSERT_FALSE_ failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
( ${_ASSERT_FALSE_} '"some msg"' ${SHUNIT_TRUE} >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_ASSERT_FALSE_ w/ msg failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
}
testFail()
{
# start skipping if LINENO not available
[ -z "${LINENO:-}" ] && startSkipping
( ${_FAIL_} >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_FAIL_ failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
( ${_FAIL_} '"some msg"' >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_FAIL_ w/ msg failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
}
testFailNotEquals()
{
# start skipping if LINENO not available
[ -z "${LINENO:-}" ] && startSkipping
( ${_FAIL_NOT_EQUALS_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_FAIL_NOT_EQUALS_ failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
( ${_FAIL_NOT_EQUALS_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_FAIL_NOT_EQUALS_ w/ msg failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
}
testFailSame()
{
# start skipping if LINENO not available
[ -z "${LINENO:-}" ] && startSkipping
( ${_FAIL_SAME_} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_FAIL_SAME_ failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
( ${_FAIL_SAME_} '"some msg"' 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_FAIL_SAME_ w/ msg failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
}
testFailNotSame()
{
# start skipping if LINENO not available
[ -z "${LINENO:-}" ] && startSkipping
( ${_FAIL_NOT_SAME_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_FAIL_NOT_SAME_ failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
( ${_FAIL_NOT_SAME_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
rtrn=$?
assertTrue '_FAIL_NOT_SAME_ w/ msg failure' ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
}
#------------------------------------------------------------------------------
# suite functions
#
oneTimeSetUp()
{
th_oneTimeSetUp
}
# load and run shUnit2
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
. ${TH_SHUNIT}

View File

@ -1,160 +0,0 @@
#! /bin/sh
# $Id$
# vim:et:ft=sh:sts=2:sw=2
#
# Copyright 2008 Kate Ward. All Rights Reserved.
# Released under the LGPL (GNU Lesser General Public License)
#
# Author: kate.ward@forestent.com (Kate Ward)
#
# shUnit2 unit tests of miscellaneous things
# load test helpers
. ./shunit2_test_helpers
#------------------------------------------------------------------------------
# suite tests
#
# Note: the test script is prefixed with '#' chars so that shUnit2 does not
# incorrectly interpret the embedded functions as real functions.
testUnboundVariable()
{
unittestF="${SHUNIT_TMPDIR}/unittest"
sed 's/^#//' >"${unittestF}" <<EOF
## treat unset variables as an error when performing parameter expansion
#set -u
#
#boom() { x=\$1; } # this function goes boom if no parameters are passed!
#test_boom()
#{
# assertEquals 1 1
# boom # No parameter given
# assertEquals 0 \$?
#}
#. ${TH_SHUNIT}
EOF
( exec ${SHUNIT_SHELL:-sh} "${unittestF}" >"${stdoutF}" 2>"${stderrF}" )
assertFalse 'expected a non-zero exit value' $?
grep '^ASSERT:Unknown failure' "${stdoutF}" >/dev/null
assertTrue 'assert message was not generated' $?
grep '^Ran [0-9]* test' "${stdoutF}" >/dev/null
assertTrue 'test count message was not generated' $?
grep '^FAILED' "${stdoutF}" >/dev/null
assertTrue 'failure message was not generated' $?
}
testIssue7()
{
( assertEquals 'Some message.' 1 2 >"${stdoutF}" 2>"${stderrF}" )
diff "${stdoutF}" - >/dev/null <<EOF
ASSERT:Some message. expected:<1> but was:<2>
EOF
rtrn=$?
assertEquals ${SHUNIT_TRUE} ${rtrn}
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
}
testPrepForSourcing()
{
assertEquals '/abc' `_shunit_prepForSourcing '/abc'`
assertEquals './abc' `_shunit_prepForSourcing './abc'`
assertEquals './abc' `_shunit_prepForSourcing 'abc'`
}
testEscapeCharInStr()
{
actual=`_shunit_escapeCharInStr '\' ''`
assertEquals '' "${actual}"
assertEquals 'abc\\' `_shunit_escapeCharInStr '\' 'abc\'`
assertEquals 'abc\\def' `_shunit_escapeCharInStr '\' 'abc\def'`
assertEquals '\\def' `_shunit_escapeCharInStr '\' '\def'`
actual=`_shunit_escapeCharInStr '"' ''`
assertEquals '' "${actual}"
assertEquals 'abc\"' `_shunit_escapeCharInStr '"' 'abc"'`
assertEquals 'abc\"def' `_shunit_escapeCharInStr '"' 'abc"def'`
assertEquals '\"def' `_shunit_escapeCharInStr '"' '"def'`
actual=`_shunit_escapeCharInStr '$' ''`
assertEquals '' "${actual}"
assertEquals 'abc\$' `_shunit_escapeCharInStr '$' 'abc$'`
assertEquals 'abc\$def' `_shunit_escapeCharInStr '$' 'abc$def'`
assertEquals '\$def' `_shunit_escapeCharInStr '$' '$def'`
# actual=`_shunit_escapeCharInStr "'" ''`
# assertEquals '' "${actual}"
# assertEquals "abc\\'" `_shunit_escapeCharInStr "'" "abc'"`
# assertEquals "abc\\'def" `_shunit_escapeCharInStr "'" "abc'def"`
# assertEquals "\\'def" `_shunit_escapeCharInStr "'" "'def"`
# # must put the backtick in a variable so the shell doesn't misinterpret it
# # while inside a backticked sequence (e.g. `echo '`'` would fail).
# backtick='`'
# actual=`_shunit_escapeCharInStr ${backtick} ''`
# assertEquals '' "${actual}"
# assertEquals '\`abc' \
# `_shunit_escapeCharInStr "${backtick}" ${backtick}'abc'`
# assertEquals 'abc\`' \
# `_shunit_escapeCharInStr "${backtick}" 'abc'${backtick}`
# assertEquals 'abc\`def' \
# `_shunit_escapeCharInStr "${backtick}" 'abc'${backtick}'def'`
}
testEscapeCharInStr_specialChars()
{
# make sure our forward slash doesn't upset sed
assertEquals '/' `_shunit_escapeCharInStr '\' '/'`
# some shells escape these differently
#assertEquals '\\a' `_shunit_escapeCharInStr '\' '\a'`
#assertEquals '\\b' `_shunit_escapeCharInStr '\' '\b'`
}
# Test the various ways of declaring functions.
#
# Prefixing (then stripping) with comment symbol so these functions aren't
# treated as real functions by shUnit2.
testExtractTestFunctions()
{
f="${SHUNIT_TMPDIR}/extract_test_functions"
sed 's/^#//' <<EOF >"${f}"
#testABC() { echo 'ABC'; }
#test_def() {
# echo 'def'
#}
#testG3 ()
#{
# echo 'G3'
#}
#function test4() { echo '4'; }
# test5() { echo '5'; }
#some_test_function() { echo 'some func'; }
#func_with_test_vars() {
# testVariable=1234
#}
EOF
actual=`_shunit_extractTestFunctions "${f}"`
assertEquals 'testABC test_def testG3 test4 test5' "${actual}"
}
#------------------------------------------------------------------------------
# suite functions
#
setUp()
{
for f in ${expectedF} ${stdoutF} ${stderrF}; do
cp /dev/null ${f}
done
}
oneTimeSetUp()
{
th_oneTimeSetUp
}
# load and run shUnit2
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
. ${TH_SHUNIT}

View File

@ -1,41 +0,0 @@
#! /bin/sh
# $Id$
# vim:et:ft=sh:sts=2:sw=2
#
# Copyright 2010 Kate Ward. All Rights Reserved.
# Released under the LGPL (GNU Lesser General Public License)
# Author: kate.ward@forestent.com (Kate Ward)
#
# shUnit2 unit test for standalone operation.
#
# This unit test is purely to test that calling shunit2 directly, while passing
# the name of a unit test script, works. When run, this script determines if it
# is running as a standalone program, and calls main() if it is.
ARGV0=`basename "$0"`
# load test helpers
. ./shunit2_test_helpers
#------------------------------------------------------------------------------
# suite tests
#
testStandalone()
{
assertTrue ${SHUNIT_TRUE}
}
#------------------------------------------------------------------------------
# main
#
main()
{
${TH_SHUNIT} "${ARGV0}"
}
# are we running as a standalone?
if [ "${ARGV0}" = 'shunit2_test_standalone.sh' ]; then
if [ $# -gt 0 ]; then main "$@"; else main; fi
fi

View File

@ -1,415 +0,0 @@
#!/usr/bin/env bash
PROGRAM="osync instance upgrade script"
SUBPROGRAM="osync"
AUTHOR="(C) 2015 by Orsiris \"Ozy\" de Jong"
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
OLD_PROGRAM_VERSION="1.0x"
NEW_PROGRAM_VERSION="v1.1x"
PROGRAM_BUILD=2016041301
## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode
if ! type "$BASH" > /dev/null; then
echo "Please run this script only with bash shell. Tested on bash >= 3.2"
exit 127
fi
function Init {
OSYNC_DIR=".osync_workdir"
STATE_DIR="state"
TREE_CURRENT_FILENAME="-tree-current-$SYNC_ID"
TREE_AFTER_FILENAME="-tree-after-$SYNC_ID"
TREE_AFTER_FILENAME_NO_SUFFIX="-tree-after-$SYNC_ID"
DELETED_LIST_FILENAME="-deleted-list-$SYNC_ID"
FAILED_DELETE_LIST_FILENAME="-failed-delete-$SYNC_ID"
if [ "${SLAVE_SYNC_DIR:0:6}" == "ssh://" ]; then
REMOTE_SYNC="yes"
# remove leadng 'ssh://'
uri=${SLAVE_SYNC_DIR#ssh://*}
if [[ "$uri" == *"@"* ]]; then
# remove everything after '@'
REMOTE_USER=${uri%@*}
else
REMOTE_USER=$LOCAL_USER
fi
if [ "$SSH_RSA_PRIVATE_KEY" == "" ]; then
SSH_RSA_PRIVATE_KEY=~/.ssh/id_rsa
fi
# remove everything before '@'
_hosturiandpath=${uri#*@}
# remove everything after first '/'
_hosturi=${_hosturiandpath%%/*}
if [[ "$_hosturi" == *":"* ]]; then
REMOTE_PORT=${_hosturi##*:}
else
REMOTE_PORT=22
fi
REMOTE_HOST=${_hosturi%%:*}
# remove everything before first '/'
SLAVE_SYNC_DIR=${_hosturiandpath#*/}
fi
SSH_CMD="$(type -p ssh) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY $REMOTE_USER@$REMOTE_HOST -p $REMOTE_PORT"
}
function Usage {
echo "$PROGRAM $PROGRAM_BUILD"
echo $AUTHOR
echo $CONTACT
echo ""
echo "This script migrates osync $OLD_PROGRAM_VERSION setups to $NEW_PROGRAM_VERSION by updating state filenames and config files."
echo ""
echo "Usage: $0 /path/to/config_file.conf"
echo "Usage: $0 --master=/path/to/master/replica --slave=/path/to/local/slave/replica --sync-id=existing_id"
echo "Usage: $0 --master=/path/to/master/replica --slave=ssh://[backupuser]@remotehost.com[:portnumber]//path/to/slave/replica --sync-id=existing_id --rsakey=/path/to/rsa/key"
echo ""
echo "If config file is provided, the config file itself and both replicas from config file will be updated. Please make sure the config file is writable."
echo "If no config file provided, assume you run the update script just like any other quicksync task."
echo "If sync-id is not specified, it will assume handling a quicksync task."
exit 128
}
function CheckEnvironment {
if [ "$REMOTE_SYNC" == "yes" ]; then
if ! type -p ssh > /dev/null 2>&1
then
Logger "ssh not present. Cannot start sync." "CRITICAL"
return 1
fi
fi
if ! type -p rsync > /dev/null 2>&1
then
Logger "rsync not present. Sync cannot start." "CRITICAL"
return 1
fi
}
function LoadConfigFile {
local config_file="${1}"
if [ ! -f "$config_file" ]; then
echo "Cannot load configuration file [$config_file]. Sync cannot start."
exit 1
elif [[ "$1" != *".conf" ]]; then
echo "Wrong configuration file supplied [$config_file]. Sync cannot start."
exit 1
else
egrep '^#|^[^ ]*=[^;&]*' "$config_file" > "./$SUBPROGRAM.$FUNCNAME.$$"
# Shellcheck source=./sync.conf
source "./$SUBPROGRAM.$FUNCNAME.$$"
rm -f "./$SUBPROGRAM.$FUNCNAME.$$"
fi
}
function _RenameStateFilesLocal {
local state_dir="${1}" # Absolute path to statedir
local rewrite=false
echo "Rewriting state files in [$state_dir]."
# Make sure there is no ending slash
state_dir="${state_dir%/}/"
if [ -f "$state_dir""master"$TREE_CURRENT_FILENAME ]; then
mv -f "$state_dir""master"$TREE_CURRENT_FILENAME "$state_dir""initiator"$TREE_CURRENT_FILENAME
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir"master"$TREE_CURRENT_FILENAME
else
rewrite=true
fi
fi
if [ -f "$state_dir""master"$TREE_AFTER_FILENAME ]; then
mv -f "$state_dir""master"$TREE_AFTER_FILENAME "$state_dir""initiator"$TREE_AFTER_FILENAME
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir"master"$TREE_AFTER_FILENAME
else
rewrite=true
fi
fi
if [ -f "$state_dir""master"$DELETED_LIST_FILENAME ]; then
mv -f "$state_dir""master"$DELETED_LIST_FILENAME "$state_dir""initiator"$DELETED_LIST_FILENAME
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir"master"$DELETED_LIST_FILENAME
else
rewrite=true
fi
rewrite=true
fi
if [ -f "$state_dir""master"$FAILED_DELETE_LIST_FILENAME ]; then
mv -f "$state_dir""master"$FAILED_DELETE_LIST_FILENAME "$state_dir""initiator"$FAILED_DELETE_LIST_FILENAME
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir"master"$FAILED_DELETE_LIST_FILENAME
else
rewrite=true
fi
fi
if [ -f "$state_dir""master"$TREE_CURRENT_FILENAME"-dry" ]; then
mv -f "$state_dir""master"$TREE_CURRENT_FILENAME"-dry" "$state_dir""initiator"$TREE_CURRENT_FILENAME"-dry"
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir"master"$TREE_CURRENT_FILENAME"-dry"
else
rewrite=true
fi
fi
if [ -f "$state_dir""master"$TREE_AFTER_FILENAME"-dry" ]; then
mv -f "$state_dir""master"$TREE_AFTER_FILENAME"-dry" "$state_dir""initiator"$TREE_AFTER_FILENAME"-dry"
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir""master"$TREE_AFTER_FILENAME"
else
rewrite=true
fi
fi
if [ -f "$state_dir""master"$DELETED_LIST_FILENAME"-dry" ]; then
mv -f "$state_dir""master"$DELETED_LIST_FILENAME"-dry" "$state_dir""initiator"$DELETED_LIST_FILENAME"-dry"
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir"master"$DELETED_LIST_FILENAME"-dry"
else
rewrite=true
fi
fi
if [ -f "$state_dir""master"$FAILED_DELETE_LIST_FILENAME"-dry" ]; then
mv -f "$state_dir""master"$FAILED_DELETE_LIST_FILENAME"-dry" "$state_dir""initiator"$FAILED_DELETE_LIST_FILENAME"-dry"
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir"master"$FAILED_DELETE_LIST_FILENAME"-dry"
else
rewrite=true
fi
fi
if [ -f "$state_dir""slave"$TREE_CURRENT_FILENAME ]; then
mv -f "$state_dir""slave"$TREE_CURRENT_FILENAME "$state_dir""target"$TREE_CURRENT_FILENAME
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir"slave"$TREE_CURRENT_FILENAME
else
rewrite=true
fi
fi
if [ -f "$state_dir""slave"$TREE_AFTER_FILENAME ]; then
mv -f "$state_dir""slave"$TREE_AFTER_FILENAME "$state_dir""target"$TREE_AFTER_FILENAME
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir"slave"$TREE_AFTER_FILENAME
else
rewrite=true
fi
fi
if [ -f "$state_dir""slave"$DELETED_LIST_FILENAME ]; then
mv -f "$state_dir""slave"$DELETED_LIST_FILENAME "$state_dir""target"$DELETED_LIST_FILENAME
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir"slave"$DELETED_LIST_FILENAME
else
rewrite=true
fi
fi
if [ -f "$state_dir""slave"$FAILED_DELETE_LIST_FILENAME ]; then
mv -f "$state_dir""slave"$FAILED_DELETE_LIST_FILENAME "$state_dir""target"$FAILED_DELETE_LIST_FILENAME
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir"slave"$FAILED_DELETE_LIST_FILENAME
else
rewrite=true
fi
fi
if [ -f "$state_dir""slave"$TREE_CURRENT_FILENAME"-dry" ]; then
mv -f "$state_dir""slave"$TREE_CURRENT_FILENAME"-dry" "$state_dir""target"$TREE_CURRENT_FILENAME"-dry"
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir"slave"$TREE_CURRENT_FILENAME"-dry"
else
rewrite=true
fi
fi
if [ -f "$state_dir""slave"$TREE_AFTER_FILENAME"-dry" ]; then
mv -f "$state_dir""slave"$TREE_AFTER_FILENAME"-dry" "$state_dir""target"$TREE_AFTER_FILENAME"-dry"
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir"slave"$TREE_AFTER_FILENAME"-dry"
else
rewrite=true
fi
fi
if [ -f "$state_dir""slave"$DELETED_LIST_FILENAME"-dry" ]; then
mv -f "$state_dir""slave"$DELETED_LIST_FILENAME"-dry" "$state_dir""target"$DELETED_LIST_FILENAME"-dry"
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir"slave"$DELETED_LIST_FILENAME"-dry"
else
rewrite=true
fi
fi
if [ -f "$state_dir""slave"$FAILED_DELETE_LIST_FILENAME"-dry" ]; then
mv -f "$state_dir""slave"$FAILED_DELETE_LIST_FILENAME"-dry" "$state_dir""target"$FAILED_DELETE_LIST_FILENAME"-dry"
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir"slave"$FAILED_DELETE_LIST_FILENAME"-dry"
else
rewrite=true
fi
fi
if [ $rewrite == true ]; then
echo "State dir rewritten."
else
echo "Nothing rewritten in state dir."
fi
}
function _RenameStateFilesRemote {
echo "Connecting remotely to rewrite state files in [$1]."
$SSH_CMD state_dir="${1}" DELETED_LIST_FILENAME="$DELETED_LIST_FILENAME" FAILED_DELETE_LIST_FILENAME="$FAILED_DELETE_LIST_FILENAME" 'bash -s' << 'ENDSSH'
# Make sure there is no ending slash
state_dir="${state_dir%/}/"
rewrite=false
if [ -f "$state_dir""master"$DELETED_LIST_FILENAME ]; then
mv -f "$state_dir""master"$DELETED_LIST_FILENAME "$state_dir""initiator"$DELETED_LIST_FILENAME
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir"master"$DELETED_LIST_FILENAME
else
rewrite=true
fi
fi
if [ -f "$state_dir""master"$FAILED_DELETE_LIST_FILENAME ]; then
mv -f "$state_dir""master"$FAILED_DELETE_LIST_FILENAME "$state_dir""initiator"$FAILED_DELETE_LIST_FILENAME
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir"master"$FAILED_DELETE_LIST_FILENAME
else
rewrite=true
fi
fi
if [ -f "$state_dir""master"$FAILED_DELETE_LIST_FILENAME"-dry" ]; then
mv -f "$state_dir""master"$FAILED_DELETE_LIST_FILENAME"-dry" "$state_dir""initiator"$FAILED_DELETE_LIST_FILENAME"-dry"
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir"master"$FAILED_DELETE_LIST_FILENAME"-dry"
else
rewrite=true
fi
fi
if [ $rewrite == true ]; then
echo "State dir rewritten."
else
echo "Nothing rewritten in state dir."
fi
ENDSSH
}
function RenameStateFiles {
_RenameStateFilesLocal "$MASTER_SYNC_DIR/$OSYNC_DIR/$STATE_DIR"
if [ "$REMOTE_SYNC" != "yes" ]; then
_RenameStateFilesLocal "$SLAVE_SYNC_DIR/$OSYNC_DIR/$STATE_DIR"
else
_RenameStateFilesRemote "$SLAVE_SYNC_DIR/$OSYNC_DIR/$STATE_DIR"
fi
}
function RewriteConfigFiles {
local config_file="${1}"
if ((! grep "MASTER_SYNC_DIR=" "$config_file" > /dev/null) && (! grep "INITIATOR_SYNC_DIR=" "$config_file" > /dev/null)); then
echo "Config file [$config_file] does not seem to be an osync v1.0x or v1.1-dev file."
exit 1
fi
echo "Backing up [$config_file] as [$config_file.save]"
cp -p "$config_file" "$config_file.save"
if [ $? != 0 ]; then
echo "Cannot backup config file."
exit 1
fi
echo "Rewriting config file $config_file"
#TODO: exclude occurences between doublequotes
sed -i'.tmp' 's/^MASTER_SYNC_DIR/INITIATOR_SYNC_DIR/g' "$config_file"
sed -i'.tmp' 's/^SLAVE_SYNC_DIR/TARGET_SYNC_DIR/g' "$config_file"
sed -i'.tmp' 's/^CONFLICT_PREVALANCE=master/CONFLICT_PREVALANCE=initiator/g' "$config_file"
sed -i'.tmp' 's/^CONFLICT_PREVALANCE=slave/CONFLICT_PREVALANCE=target/g' "$config_file"
sed -i'.tmp' 's/^SYNC_ID=/INSTANCE_ID=/g' "$config_file"
# Add new config file values from v1.1x
if ! grep "^RSYNC_PATTERN_FIRST=" "$config_file" > /dev/null; then
sed -i'.tmp' '/^LOGFILE=*/a\'$'\n''RSYNC_PATTERN_FIRST=include\'$'\n''' "$config_file"
fi
if ! grep "^SSH_IGNORE_KNOWN_HOSTS=" "$config_file" > /dev/null; then
sed -i'.tmp' '/^SSH_COMPRESSION=*/a\'$'\n''SSH_IGNORE_KNOWN_HOSTS=no\'$'\n''' "$config_file"
fi
if ! grep "^RSYNC_INCLUDE_PATTERN=" "$config_file" > /dev/null; then
sed -i'.tmp' '/^RSYNC_EXCLUDE_PATTERN=*/a\'$'\n''RSYNC_INCLUDE_PATTERN=""\'$'\n''' "$config_file"
fi
if ! grep "^RSYNC_INCLUDE_FROM=" "$config_file" > /dev/null; then
sed -i'.tmp' '/^RSYNC_EXCLUDE_FROM=*/a\'$'\n''RSYNC_INCLUDE_FROM=""\'$'\n''' "$config_file"
fi
if ! grep "^CHECKSUM=" "$config_file" > /dev/null; then
sed -i'.tmp' '/^PRESERVE_HARDLINKS=*/a\'$'\n''CHECKSUM=no\'$'\n''' "$config_file"
fi
if ! grep "^MAX_WAIT=" "$config_file" > /dev/null; then
sed -i'.tmp' '/^MIN_WAIT=*/a\'$'\n''MAX_WAIT=300\'$'\n''' "$config_file"
fi
if ! grep "^PARTIAL=" "$config_file" > /dev/null; then
sed -i'.tmp' '/^FORCE_STRANGER_LOCK_RESUME=*/a\'$'\n''PARTIAL=no\'$'\n''' "$config_file"
fi
if ! grep "^DELTA_COPIES=" "$config_file" > /dev/null; then
sed -i'.tmp' '/^PARTIAL=*/a\'$'\n''DELTA_COPIES=yes\'$'\n''' "$config_file"
fi
if ! grep "^RUN_AFTER_CMD_ON_ERROR=" "$config_file" > /dev/null; then
sed -i'.tmp' '/^STOP_ON_CMD_ERROR=*/a\'$'\n''RUN_AFTER_CMD_ON_ERROR=no\'$'\n''' "$config_file"
fi
rm -f "$config_file.tmp"
}
_QUICKSYNC=0
for i in "$@"
do
case $i in
--master=*)
no_maxtime=1
MASTER_SYNC_DIR=${i##*=}
QUICK_SYNC=$(($_QUICKSYNC + 1))
;;
--slave=*)
SLAVE_SYNC_DIR=${i##*=}
QUICK_SYNC=$(($_QUICKSYNC + 1))
;;
--rsakey=*)
SSH_RSA_PRIVATE_KEY=${i##*=}
;;
--sync-id=*)
SYNC_ID=${i##*=}
;;
esac
done
if [ $_QUICKSYNC -eq 2 ]; then
Init
REPLICA_DIR=${i##*=}
RenameStateFiles
elif [ "$1" != "" ] && [ -f "$1" ] && [ -w "$1" ]; then
CONF_FILE="$1"
# Make sure there is no ending slash
CONF_FILE="${CONF_FILE%/}"
LoadConfigFile "$CONF_FILE"
Init
RewriteConfigFiles "$CONF_FILE"
RenameStateFiles
else
Usage
fi

605
upgrade-v1.0x-v1.3x.sh Executable file
View File

@ -0,0 +1,605 @@
#!/usr/bin/env bash
PROGRAM="osync instance upgrade script"
SUBPROGRAM="osync"
AUTHOR="(C) 2016-2020 by Orsiris de Jong"
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
OLD_PROGRAM_VERSION="v1.0x-v1.2x"
NEW_PROGRAM_VERSION="v1.3x"
CONFIG_FILE_REVISION=1.3.0
PROGRAM_BUILD=2020012201
## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode
if ! type "$BASH" > /dev/null; then
echo "Please run this script only with bash shell. Tested on bash >= 3.2"
exit 127
fi
# Defines all keywords / value sets in osync configuration files
# bash does not support two dimensional arrays, so we declare two arrays:
# ${KEYWORDS[index]}=${VALUES[index]}
KEYWORDS=(
INSTANCE_ID
INITIATOR_SYNC_DIR
TARGET_SYNC_DIR
SSH_RSA_PRIVATE_KEY
SSH_PASSWORD_FILE
_REMOTE_TOKEN
CREATE_DIRS
LOGFILE
MINIMUM_SPACE
BANDWIDTH
SUDO_EXEC
RSYNC_EXECUTABLE
RSYNC_REMOTE_PATH
RSYNC_PATTERN_FIRST
RSYNC_INCLUDE_PATTERN
RSYNC_EXCLUDE_PATTERN
RSYNC_INCLUDE_FROM
RSYNC_EXCLUDE_FROM
PATH_SEPARATOR_CHAR
SSH_COMPRESSION
SSH_IGNORE_KNOWN_HOSTS
SSH_CONTROLMASTER
REMOTE_HOST_PING
REMOTE_3RD_PARTY_HOSTS
RSYNC_OPTIONAL_ARGS
PRESERVE_PERMISSIONS
PRESERVE_OWNER
PRESERVE_GROUP
PRESERVE_EXECUTABILITY
PRESERVE_ACL
PRESERVE_XATTR
COPY_SYMLINKS
KEEP_DIRLINKS
PRESERVE_HARDLINKS
CHECKSUM
RSYNC_COMPRESS
SOFT_MAX_EXEC_TIME
HARD_MAX_EXEC_TIME
KEEP_LOGGING
MIN_WAIT
MAX_WAIT
LOG_CONFLICTS
ALERT_CONFLICTS
CONFLICT_BACKUP
CONFLICT_BACKUP_MULTIPLE
CONFLICT_BACKUP_DAYS
CONFLICT_PREVALANCE
SOFT_DELETE
SOFT_DELETE_DAYS
SKIP_DELETION
SYNC_TYPE
RESUME_SYNC
RESUME_TRY
FORCE_STRANGER_LOCK_RESUME
PARTIAL
DELTA_COPIES
DESTINATION_MAILS
MAIL_BODY_CHARSET
SENDER_MAIL
SMTP_SERVER
SMTP_PORT
SMTP_ENCRYPTION
SMTP_USER
SMTP_PASSWORD
LOCAL_RUN_BEFORE_CMD
LOCAL_RUN_AFTER_CMD
REMOTE_RUN_BEFORE_CMD
REMOTE_RUN_AFTER_CMD
MAX_EXEC_TIME_PER_CMD_BEFORE
MAX_EXEC_TIME_PER_CMD_AFTER
STOP_ON_CMD_ERROR
RUN_AFTER_CMD_ON_ERROR
)
VALUES=(
sync-test
''
''
${HOME}/backupuser/.ssh/id_rsa
''
SomeAlphaNumericToken9
false
''
10240
0
false
rsync
''
include
''
''
''
''
\;
true
false
false
false
'www.kernel.org www.google.com'
''
true
true
true
true
false
false
false
false
false
false
true
7200
10600
1801
60
7200
false
false
true
false
30
initiator
true
30
''
''
true
2
false
false
true
''
''
alert@your.system.tld
smtp.your.isp.tld
25
none
''
''
''
''
''
''
0
0
true
false
)
function Init {
OSYNC_DIR=".osync_workdir"
STATE_DIR="state"
TREE_CURRENT_FILENAME="-tree-current-$SYNC_ID"
TREE_AFTER_FILENAME="-tree-after-$SYNC_ID"
DELETED_LIST_FILENAME="-deleted-list-$SYNC_ID"
FAILED_DELETE_LIST_FILENAME="-failed-delete-$SYNC_ID"
if [ "${SLAVE_SYNC_DIR:0:6}" == "ssh://" ]; then
# Might also exist from old config file as REMOTE_OPERATION=yes
REMOTE_OPERATION=true
# remove leadng 'ssh://'
uri=${SLAVE_SYNC_DIR#ssh://*}
if [[ "$uri" == *"@"* ]]; then
# remove everything after '@'
REMOTE_USER=${uri%@*}
else
REMOTE_USER=$LOCAL_USER
fi
if [ "$SSH_RSA_PRIVATE_KEY" == "" ]; then
SSH_RSA_PRIVATE_KEY=~/.ssh/id_rsa
fi
# remove everything before '@'
_hosturiandpath=${uri#*@}
# remove everything after first '/'
_hosturi=${_hosturiandpath%%/*}
if [[ "$_hosturi" == *":"* ]]; then
REMOTE_PORT=${_hosturi##*:}
else
REMOTE_PORT=22
fi
REMOTE_HOST=${_hosturi%%:*}
# remove everything before first '/'
SLAVE_SYNC_DIR=${_hosturiandpath#*/}
fi
SSH_CMD="$(type -p ssh) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY $REMOTE_USER@$REMOTE_HOST -p $REMOTE_PORT"
}
function Usage {
echo "$PROGRAM $PROGRAM_BUILD"
echo $AUTHOR
echo $CONTACT
echo ""
echo "This script migrates osync $OLD_PROGRAM_VERSION setups to $NEW_PROGRAM_VERSION by updating state filenames and config files."
echo ""
echo "Usage: $0 /path/to/config_file.conf"
echo "Usage: $0 --master=/path/to/master/replica --slave=/path/to/local/slave/replica --sync-id=existing_id"
echo "Usage: $0 --master=/path/to/master/replica --slave=ssh://[backupuser]@remotehost.com[:portnumber]//path/to/slave/replica --sync-id=existing_id --rsakey=/path/to/rsa/key"
echo ""
echo "If config file is provided, the config file itself and both replicas from config file will be updated. Please make sure the config file is writable."
echo "If no config file provided, assume you run the update script just like any other quicksync task."
echo "If sync-id is not specified, it will assume handling a quicksync task."
exit 128
}
function LoadConfigFile {
local config_file="${1}"
if [ ! -f "$config_file" ]; then
echo "Cannot load configuration file [$config_file]. Sync cannot start."
exit 1
elif [[ "$1" != *".conf" ]]; then
echo "Wrong configuration file supplied [$config_file]. Sync cannot start."
exit 1
else
egrep '^#|^[^ ]*=[^;&]*' "$config_file" > "./$SUBPROGRAM.${FUNCNAME[0]}.$$"
# Shellcheck source=./sync.conf
source "./$SUBPROGRAM.${FUNCNAME[0]}.$$"
rm -f "./$SUBPROGRAM.${FUNCNAME[0]}.$$"
fi
}
function _RenameStateFilesLocal {
local state_dir="${1}" # Absolute path to statedir
local rewrite=false
echo "Rewriting state files in [$state_dir]."
# Make sure there is no ending slash
state_dir="${state_dir%/}/"
if [ -f "${state_dir}master${TREE_CURRENT_FILENAME}" ]; then
mv -f "${state_dir}master${TREE_CURRENT_FILENAME}" "${state_dir}initiator${TREE_CURRENT_FILENAME}"
if [ $? != 0 ]; then
echo "Error while rewriting ${state_dir}master${TREE_CURRENT_FILENAME}"
else
rewrite=true
fi
fi
if [ -f "${state_dir}master${TREE_AFTER_FILENAME}" ]; then
mv -f "${state_dir}master${TREE_AFTER_FILENAME}" "${state_dir}initiator${TREE_AFTER_FILENAME}"
if [ $? != 0 ]; then
echo "Error while rewriting ${state_dir}master${TREE_AFTER_FILENAME}"
else
rewrite=true
fi
fi
if [ -f "${state_dir}master${DELETED_LIST_FILENAME}" ]; then
mv -f "${state_dir}master${DELETED_LIST_FILENAME}" "${state_dir}initiator${DELETED_LIST_FILENAME}"
if [ $? != 0 ]; then
echo "Error while rewriting ${state_dir}master${DELETED_LIST_FILENAME}"
else
rewrite=true
fi
rewrite=true
fi
if [ -f "${state_dir}master${FAILED_DELETE_LIST_FILENAME}" ]; then
mv -f "${state_dir}master${FAILED_DELETE_LIST_FILENAME}" "${state_dir}initiator${FAILED_DELETE_LIST_FILENAME}"
if [ $? != 0 ]; then
echo "Error while rewriting ${state_dir}master${FAILED_DELETE_LIST_FILENAME}"
else
rewrite=true
fi
fi
if [ -f "${state_dir}master${TREE_CURRENT_FILENAME}-dry" ]; then
mv -f "${state_dir}master${TREE_CURRENT_FILENAME}-dry" "${state_dir}initiator${TREE_CURRENT_FILENAME}-dry"
if [ $? != 0 ]; then
echo "Error while rewriting ${state_dir}master${TREE_CURRENT_FILENAME}-dry"
else
rewrite=true
fi
fi
if [ -f "${state_dir}master${TREE_AFTER_FILENAME}-dry" ]; then
mv -f "${state_dir}master${TREE_AFTER_FILENAME}-dry" "${state_dir}initiator${TREE_AFTER_FILENAME}-dry"
if [ $? != 0 ]; then
echo "Error while rewriting ${state_dir}master${TREE_AFTER_FILENAME}-dry"
else
rewrite=true
fi
fi
if [ -f "${state_dir}master${DELETED_LIST_FILENAME}-dry" ]; then
mv -f "${state_dir}master${DELETED_LIST_FILENAME}-dry" "${state_dir}initiator${DELETED_LIST_FILENAME}-dry"
if [ $? != 0 ]; then
echo "Error while rewriting ${state_dir}master${DELETED_LIST_FILENAME}-dry"
else
rewrite=true
fi
fi
if [ -f "${state_dir}master${FAILED_DELETE_LIST_FILENAME}-dry" ]; then
mv -f "${state_dir}master${FAILED_DELETE_LIST_FILENAME}-dry" "${state_dir}initiator${FAILED_DELETE_LIST_FILENAME}-dry"
if [ $? != 0 ]; then
echo "Error while rewriting ${state_dir}master${FAILED_DELETE_LIST_FILENAME}-dry"
else
rewrite=true
fi
fi
if [ -f "${state_dir}slave${TREE_CURRENT_FILENAME}" ]; then
mv -f "${state_dir}slave${TREE_CURRENT_FILENAME}" "${state_dir}target${TREE_CURRENT_FILENAME}"
if [ $? != 0 ]; then
echo "Error while rewriting ${state_dir}slave${TREE_CURRENT_FILENAME}"
else
rewrite=true
fi
fi
if [ -f "${state_dir}slave${TREE_AFTER_FILENAME}" ]; then
mv -f "${state_dir}slave${TREE_AFTER_FILENAME}" "${state_dir}target${TREE_AFTER_FILENAME}"
if [ $? != 0 ]; then
echo "Error while rewriting ${state_dir}slave${TREE_AFTER_FILENAME}"
else
rewrite=true
fi
fi
if [ -f "${state_dir}slave${DELETED_LIST_FILENAME}" ]; then
mv -f "${state_dir}slave${DELETED_LIST_FILENAME}" "${state_dir}target${DELETED_LIST_FILENAME}"
if [ $? != 0 ]; then
echo "Error while rewriting ${state_dir}slave${DELETED_LIST_FILENAME}"
else
rewrite=true
fi
fi
if [ -f "${state_dir}slave${FAILED_DELETE_LIST_FILENAME}" ]; then
mv -f "${state_dir}slave${FAILED_DELETE_LIST_FILENAME}" "${state_dir}target${FAILED_DELETE_LIST_FILENAME}"
if [ $? != 0 ]; then
echo "Error while rewriting ${state_dir}slave${FAILED_DELETE_LIST_FILENAME}"
else
rewrite=true
fi
fi
if [ -f "${state_dir}slave${TREE_CURRENT_FILENAME}-dry" ]; then
mv -f "${state_dir}slave${TREE_CURRENT_FILENAME}-dry" "${state_dir}target${TREE_CURRENT_FILENAME}-dry"
if [ $? != 0 ]; then
echo "Error while rewriting ${state_dir}slave${TREE_CURRENT_FILENAME}-dry"
else
rewrite=true
fi
fi
if [ -f "${state_dir}slave${TREE_AFTER_FILENAME}-dry" ]; then
mv -f "${state_dir}slave${TREE_AFTER_FILENAME}-dry" "${state_dir}target${TREE_AFTER_FILENAME}-dry"
if [ $? != 0 ]; then
echo "Error while rewriting ${state_dir}slave${TREE_AFTER_FILENAME}-dry"
else
rewrite=true
fi
fi
if [ -f "${state_dir}slave${DELETED_LIST_FILENAME}-dry" ]; then
mv -f "${state_dir}slave${DELETED_LIST_FILENAME}-dry" "${state_dir}target${DELETED_LIST_FILENAME}-dry"
if [ $? != 0 ]; then
echo "Error while rewriting ${state_dir}slave${DELETED_LIST_FILENAME}-dry"
else
rewrite=true
fi
fi
if [ -f "${state_dir}slave${FAILED_DELETE_LIST_FILENAME}-dry" ]; then
mv -f "${state_dir}slave${FAILED_DELETE_LIST_FILENAME}-dry" "${state_dir}target${FAILED_DELETE_LIST_FILENAME}-dry"
if [ $? != 0 ]; then
echo "Error while rewriting ${state_dir}slave${FAILED_DELETE_LIST_FILENAME}-dry"
else
rewrite=true
fi
fi
if [ $rewrite == true ]; then
echo "State dir rewritten."
else
echo "Nothing rewritten in state dir."
fi
}
function _RenameStateFilesRemote {
echo "Connecting remotely to rewrite state files in [$1]."
$SSH_CMD state_dir="${1}" DELETED_LIST_FILENAME="$DELETED_LIST_FILENAME" FAILED_DELETE_LIST_FILENAME="$FAILED_DELETE_LIST_FILENAME" 'bash -s' << 'ENDSSH'
# Make sure there is no ending slash
state_dir="${state_dir%/}/"
rewrite=false
if [ -f "${state_dir}master${DELETED_LIST_FILENAME}" ]; then
mv -f "${state_dir}master${DELETED_LIST_FILENAME}" "${state_dir}initiator${DELETED_LIST_FILENAME}"
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir"master"$DELETED_LIST_FILENAME
else
rewrite=true
fi
fi
if [ -f "${state_dir}master${FAILED_DELETE_LIST_FILENAME}" ]; then
mv -f "${state_dir}master${FAILED_DELETE_LIST_FILENAME}" "${state_dir}initiator${FAILED_DELETE_LIST_FILENAME}"
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir"master"$FAILED_DELETE_LIST_FILENAME
else
rewrite=true
fi
fi
if [ -f "${state_dir}master${FAILED_DELETE_LIST_FILENAME}-dry" ]; then
mv -f "${state_dir}master${FAILED_DELETE_LIST_FILENAME}-dry" "${state_dir}initiator${FAILED_DELETE_LIST_FILENAME}-dry"
if [ $? != 0 ]; then
echo "Error while rewriting "$state_dir"master"$FAILED_DELETE_LIST_FILENAME"-dry"
else
rewrite=true
fi
fi
if [ $rewrite == true ]; then
echo "State dir rewritten."
else
echo "Nothing rewritten in state dir."
fi
ENDSSH
}
function RenameStateFiles {
_RenameStateFilesLocal "$MASTER_SYNC_DIR/$OSYNC_DIR/$STATE_DIR"
if [ "$REMOTE_OPERATION" != "yes" ] || "$REMOTE_OPERATION" == true ]; then
_RenameStateFilesLocal "$SLAVE_SYNC_DIR/$OSYNC_DIR/$STATE_DIR"
else
_RenameStateFilesRemote "$SLAVE_SYNC_DIR/$OSYNC_DIR/$STATE_DIR"
fi
}
function CheckAndBackup {
local config_file="${1}"
if ! grep "MASTER_SYNC_DIR=" "$config_file" > /dev/null && ! grep "INITIATOR_SYNC_DIR=" "$config_file" > /dev/null; then
echo "Config file [$config_file] does not seem to be an osync v1.0x or v1.1x file."
exit 1
fi
echo "Backing up [$config_file] as [$config_file.save]"
cp -p "$config_file" "$config_file.save"
if [ $? != 0 ]; then
echo "Cannot backup config file."
exit 1
fi
}
function RewriteOldConfigFiles {
local config_file="${1}"
echo "Rewriting config file $config_file"
#TODO: exclude occurences between doublequotes
sed -i'.tmp' 's/^MASTER_SYNC_DIR/INITIATOR_SYNC_DIR/g' "$config_file"
sed -i'.tmp' 's/^SLAVE_SYNC_DIR/TARGET_SYNC_DIR/g' "$config_file"
sed -i'.tmp' 's/^CONFLICT_PREVALANCE=master/CONFLICT_PREVALANCE=initiator/g' "$config_file"
sed -i'.tmp' 's/^CONFLICT_PREVALANCE=slave/CONFLICT_PREVALANCE=target/g' "$config_file"
sed -i'.tmp' 's/^SYNC_ID=/INSTANCE_ID=/g' "$config_file"
sed -i'.tmp' 's/^REMOTE_SYNC=.*//g' "$config_file"
rm -f "$config_file.tmp"
}
function AddMissingConfigOptionsAndFixBooleans {
local config_file="${1}"
local counter=0
while [ $counter -lt ${#KEYWORDS[@]} ]; do
if ! grep "^${KEYWORDS[$counter]}=" > /dev/null "$config_file"; then
echo "${KEYWORDS[$counter]} not found"
if [ $counter -gt 0 ]; then
if [ "${VALUES[$counter]}" == true ] || [ "${VALUES[$counter]}" == false ]; then
sed -i'.tmp' '/^'${KEYWORDS[$((counter-1))]}'=*/a\'$'\n'${KEYWORDS[$counter]}'='"${VALUES[$counter]}"'\'$'\n''' "$config_file"
else
sed -i'.tmp' '/^'${KEYWORDS[$((counter-1))]}'=*/a\'$'\n'${KEYWORDS[$counter]}'="'"${VALUES[$counter]}"'"\'$'\n''' "$config_file"
fi
if [ $? -ne 0 ]; then
echo "Cannot add missing ${[KEYWORDS[$counter]}."
exit 1
fi
else
if [ "${VALUES[$counter]}" == true ] || [ "${VALUES[$counter]}" == false ]; then
sed -i'.tmp' '/[GENERAL\]$//a\'$'\n'${KEYWORDS[$counter]}'='"${VALUES[$counter]}"'\'$'\n''' "$config_file"
else
sed -i'.tmp' '/[GENERAL\]$//a\'$'\n'${KEYWORDS[$counter]}'="'"${VALUES[$counter]}"'"\'$'\n''' "$config_file"
fi
fi
echo "Added missing ${KEYWORDS[$counter]} config option with default option [${VALUES[$counter]}]"
else
# Not the most elegant but the quickest way :)
if grep "^${KEYWORDS[$counter]}=yes$" > /dev/null "$config_file"; then
sed -i'.tmp' 's/^'${KEYWORDS[$counter]}'=.*/'${KEYWORDS[$counter]}'=true/g' "$config_file"
if [ $? -ne 0 ]; then
echo "Cannot rewrite ${[KEYWORDS[$counter]} boolean to true."
exit 1
fi
elif grep "^${KEYWORDS[$counter]}=no$" > /dev/null "$config_file"; then
sed -i'.tmp' 's/^'${KEYWORDS[$counter]}'=.*/'${KEYWORDS[$counter]}'=false/g' "$config_file"
if [ $? -ne 0 ]; then
echo "Cannot rewrite ${[KEYWORDS[$counter]} boolean to false."
exit 1
fi
fi
fi
counter=$((counter+1))
done
}
function RewriteSections {
local config_file="${1}"
sed -i'.tmp' 's/## ---------- GENERAL OPTIONS/[GENERAL]/g' "$config_file"
sed -i'.tmp' 's/## ---------- REMOTE OPTIONS/[REMOTE_OPTIONS]/g' "$config_file"
sed -i'.tmp' 's/## ---------- REMOTE SYNC OPTIONS/[REMOTE_OPTIONS]/g' "$config_file"
sed -i'.tmp' 's/## ---------- MISC OPTIONS/[MISC_OPTIONS]/g' "$config_file"
sed -i'.tmp' 's/## ---------- BACKUP AND DELETION OPTIONS/[BACKUP_DELETE_OPTIONS]/g' "$config_file"
sed -i'.tmp' 's/## ---------- BACKUP AND TRASH OPTIONS/[BACKUP_DELETE_OPTIONS]/g' "$config_file"
sed -i'.tmp' 's/## ---------- RESUME OPTIONS/[RESUME_OPTIONS]/g' "$config_file"
sed -i'.tmp' 's/## ---------- ALERT OPTIONS/[ALERT_OPTIONS]/g' "$config_file"
sed -i'.tmp' 's/## ---------- EXECUTION HOOKS/[EXECUTION_HOOKS]/g' "$config_file"
}
function UpdateConfigHeader {
local config_file="${1}"
if ! grep "^CONFIG_FILE_REVISION=" > /dev/null "$config_file"; then
if grep "\[GENERAL\]" > /dev/null "$config_file"; then
sed -i'.tmp' '/^\[GENERAL\]$/a\'$'\n'CONFIG_FILE_REVISION=$CONFIG_FILE_REVISION$'\n''' "$config_file"
else
sed -i'.tmp' '/.*onfig file rev.*/a\'$'\n'CONFIG_FILE_REVISION=$CONFIG_FILE_REVISION$'\n''' "$config_file"
fi
# "onfig file rev" to deal with earlier variants of the file where c was lower or uppercase
sed -i'.tmp' 's/.*onfig file rev.*//' "$config_file"
fi
}
_QUICK_SYNC=0
for i in "$@"
do
case $i in
--master=*)
MASTER_SYNC_DIR=${i##*=}
_QUICK_SYNC=$((_QUICK_SYNC + 1))
;;
--slave=*)
SLAVE_SYNC_DIR=${i##*=}
_QUICK_SYNC=$((_QUICK_SYNC + 1))
;;
--rsakey=*)
SSH_RSA_PRIVATE_KEY=${i##*=}
;;
--sync-id=*)
SYNC_ID=${i##*=}
;;
esac
done
if [ $_QUICK_SYNC -eq 2 ]; then
Init
RenameStateFiles "$MASTER_SYNC_DIR"
RenameStateFiles "$SLAVE_SYNC_DIR"
elif [ "$1" != "" ] && [ -f "$1" ] && [ -w "$1" ]; then
CONF_FILE="$1"
# Make sure there is no ending slash
CONF_FILE="${CONF_FILE%/}"
LoadConfigFile "$CONF_FILE"
Init
CheckAndBackup "$CONF_FILE"
RewriteSections "$CONF_FILE"
RewriteOldConfigFiles "$CONF_FILE"
AddMissingConfigOptionsAndFixBooleans "$CONF_FILE"
UpdateConfigHeader "$CONF_FILE"
if [ -d "$MASTER_SYNC_DIR" ]; then
RenameStateFiles "$MASTER_SYNC_DIR"
fi
if [ -d "$SLAVE_SYNC_DIR" ]; then
RenameStateFiles "$SLAVE_SYNC_DIR"
fi
rm -f "$CONF_FILE.tmp"
echo "Configuration file upgrade finished."
else
Usage
fi