Compare commits

...

280 Commits

Author SHA1 Message Date
Daniel Hansson
3821efb21c
Update README.md
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2024-07-12 18:13:33 +02:00
Daniel Hansson
d6e260ebfd fix README
Signed-off-by: Daniel Hansson <your.name@domain.com>
2024-05-07 18:55:10 +02:00
Daniel Hansson
4d9b13d7e9 remove unessecary files and folders
Signed-off-by: Daniel Hansson <your.name@domain.com>
2024-05-07 18:54:04 +02:00
Daniel Hansson
fa26666385
branch change
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2024-05-07 18:49:49 +02:00
Daniel Hansson
9a6904d98e
update Ubuntu OS versions
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2024-05-07 18:36:40 +02:00
Daniel Hansson
b53b1441c0
Upgrade OS --> 24.04 (#2623) 2024-05-07 18:32:08 +02:00
Daniel Hansson
fba7709068
remove 'version' from docker yml
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2024-05-05 00:05:44 +02:00
Daniel Hansson
28b4b2036e
fix #2619 (#2620)
* part fix #2619

make sure the bin is exceutable

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>

* one solution for all files

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>

* Update nextcloud_update.sh

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>

* Update nextcloud_update.sh

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>

* tested and works

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>

---------

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-04-15 21:49:53 +02:00
Daniel Hansson
e7d5e7ffd2
update spamhaus urls (#2621)
fix #2616

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2024-04-02 21:06:48 +02:00
Robrecht Cannoodt
920f638942
Fix typo (#2618)
Signed-off-by: Robrecht Cannoodt <rcannood@gmail.com>
2024-03-21 23:38:50 +01:00
Daniel Hansson
669164ac7b
add --type=boolean
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2024-03-01 09:10:22 +01:00
Simon L
bf372334d1
fix pi-hole script (#2612)
Signed-off-by: Simon L <szaimen@e.mail.de>
2024-01-24 22:35:50 +01:00
Daniel Hansson
3149aad664
don't wait for virus scan to finish (#2536)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2024-01-15 19:57:20 +01:00
Patrick Robertson
c3f1e0db0e
Add comment/documentation on why .bash_history is cleared by default (#2604)
* Update history.sh

Add comment/documentation on why .bash_history is cleared

Signed-off-by: Patrick Robertson <robertson.patrick@gmail.com>

* Add comment about history.sh to bash_profile as well (#1)

Signed-off-by: Patrick Robertson <robertson.patrick@gmail.com>

---------

Signed-off-by: Patrick Robertson <robertson.patrick@gmail.com>
Co-authored-by: Daniel Hansson <mailto@danielhansson.nu>
2024-01-15 19:45:05 +01:00
Simon L
36be44643b
btrfs mounts should not fail the initial startup (#2611)
Signed-off-by: Simon L <szaimen@e.mail.de>
Co-authored-by: Daniel Hansson <mailto@danielhansson.nu>
2024-01-14 11:54:35 +01:00
Simon L
82c47946d7
update geoblock database (#2610)
Signed-off-by: Simon L <szaimen@e.mail.de>
2024-01-13 18:54:40 +01:00
Daniel Hansson
b2f3f2d3d7
happy new year! (#2609) 2024-01-13 01:48:25 +01:00
Daniel Hansson
386118f3ba
Part fix for #2603
https://github.com/nextcloud/vm/issues/2603

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-12-20 19:07:03 +01:00
Daniel Hansson
1f5340d666
Get the latest version again (#2602)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-12-17 18:13:03 +01:00
Daniel Hansson
1a8408e6cb
upgrade RAM info
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-12-13 21:23:32 +01:00
Daniel Hansson
972695b487
typo
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-12-03 19:58:11 +01:00
Daniel Hansson
ba6711e866
add migration step from nc_fts
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-12-03 19:54:34 +01:00
Patrick Robertson
3e3e64ed54
Check for empty $INFECTED_FILES (#2594)
* Check for empty $INFECTED_FILES

Fixes #2593

Signed-off-by: Patrick Robertson <robertson.patrick@gmail.com>

* remove undeeded ;

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>

---------

Signed-off-by: Patrick Robertson <robertson.patrick@gmail.com>
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
Co-authored-by: Daniel Hansson <mailto@danielhansson.nu>
2023-11-20 10:42:36 +01:00
Daniel Hansson
e5210c7549
whiptail is needed before everything else
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-11-11 21:23:13 +01:00
Daniel Hansson
0e87ec8dc4
Install sqlite for Collectives (#2590)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-11-10 20:12:59 +01:00
pq2
b23be733d1
Fix typo in borgbackup.sh (#2591)
Signed-off-by: pq2 <github@nhelmschmidt.de>
2023-11-10 00:26:10 +01:00
Daniel Hansson
70bdcfae8f
update comment
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-10-13 12:24:41 +02:00
Daniel Hansson
53dc94791f
Fix DIG bug
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-10-04 10:44:43 +02:00
Daniel Hansson
afd13db5c5
Add DIG variable (#2576)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-10-03 15:20:36 +02:00
Daniel Hansson
70755f416b
Fix self-signed cert for SMTP servers (#2574)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-09-30 20:39:42 +02:00
Daniel Hansson
4038aa55e1
remove applied patch (#2573) 2023-09-29 17:19:32 +02:00
Daniel Hansson
83d790a5af
remove live service before dropping index
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-09-29 14:51:46 +02:00
Daniel Hansson
7ddca4a71d
apply patch and expect values for removing index (#2572) 2023-09-29 14:19:31 +02:00
Daniel Hansson
dc7017891a
make git_apply_patch work for apps as well (#2570) 2023-09-29 14:12:10 +02:00
Daniel Hansson
9f58a31495
docker prune update (#2569) 2023-09-27 17:30:25 +02:00
Daniel Hansson
9c619703ef
-return-size
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-09-27 16:04:37 +02:00
Simon L
cc78021d64
update geoblock database (#2568)
Signed-off-by: Simon L <szaimen@e.mail.de>
2023-09-25 17:53:35 +02:00
Daniel Hansson
b512bea2db
also make sure to remove network
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-09-24 18:48:29 +02:00
Daniel Hansson
9e1e289891
fix bug with removing old opensearch
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-09-24 18:43:51 +02:00
Daniel Hansson
df6bda0ff0
remove live service
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-09-23 10:43:39 +02:00
Daniel Hansson
d4ae98d67a
change comment
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-09-22 18:17:30 +02:00
Daniel Hansson
a7527896f2
raise minimum RAM
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-09-22 18:16:53 +02:00
Daniel Hansson
6dba16c10a
SC
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-09-22 18:14:55 +02:00
Daniel Hansson
d68324ec44
Check for version tag before install
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-09-22 13:36:13 +02:00
Daniel Hansson
ecf78fc036
only update if version tag is available (#2567)
* only update if version tag is available

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>

* Update nextcloud_update.sh

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>

---------

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-09-21 23:13:19 +02:00
Daniel Hansson
54472c771c
remove double info
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-09-21 14:53:35 +02:00
Daniel Hansson
fa31478346
FTS doesn't support latest tag (erm kind of...) (#2566) 2023-09-21 14:46:01 +02:00
Daniel Hansson
586c140952
add live index service (#2565) 2023-09-21 13:29:07 +02:00
Daniel Hansson
da5faca354
update dav adressbook (#2564)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-09-21 12:56:45 +02:00
Daniel Hansson
fc1363713d
Change to latest tag for Full Text Search (#2563) 2023-09-21 12:31:45 +02:00
Daniel Hansson
7059ae3663
H1 report (#2562)
cc @AndyScherzinger

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-09-11 19:05:00 +02:00
dependabot[bot]
5c90c10e2d
Bump actions/checkout from 3 to 4 (#2561)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-11 07:33:11 +02:00
Daniel Hansson
c236be9484
SC
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-09-08 10:21:14 +02:00
Daniel Hansson
d60cb8f4f0
turn off swap
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-09-08 10:17:56 +02:00
Daniel Hansson
6c20e0208a
set hard limit for Java in ES
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-09-08 09:55:43 +02:00
Daniel Hansson
db30875f01
switch place of removal
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-31 15:24:24 +02:00
Daniel Hansson
ec60a73474
add check
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-31 15:23:14 +02:00
Daniel Hansson
1ea3d93ee5
don't use nextcloud_occ during install
Fix https://github.com/nextcloud/vm/issues/2542

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-31 14:53:00 +02:00
Daniel Hansson
f3b8122e23
SC
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-27 21:50:06 +02:00
Daniel Hansson
764f541d96
improve the https check (#2555) 2023-08-27 21:27:46 +02:00
Daniel Hansson
0b8c0abf36
Change to better compression for ZFS (#2554) 2023-08-27 12:40:27 +02:00
Daniel Hansson
0cb6c24e2a
also post cli ouput in terminal
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-27 12:30:32 +02:00
Daniel Hansson
7ca3d4767d
Fix bug in PHP (#2553)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-27 12:04:12 +02:00
Daniel Hansson
2a839cfeec
stay truthful
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-27 12:03:30 +02:00
Daniel Hansson
b62609234b
only post info if new FTS are installed
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-27 11:49:14 +02:00
Daniel Hansson
98d9cf0b37
typo
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-27 02:28:43 +02:00
Daniel Hansson
5a245496ce
docker compose already included
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-25 19:28:40 +02:00
Daniel Hansson
223a2f06de
silent output from grep
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-25 15:23:46 +02:00
Daniel Hansson
4018629160
details
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-25 15:19:53 +02:00
Daniel Hansson
3acd78906a
Only set preview concurency if imaginary is installed (#2552)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-25 13:41:56 +02:00
Daniel Hansson
493ac11f5a
more fixes to redis
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-25 12:32:19 +02:00
Daniel Hansson
de42d1e3a5
rearrange redis
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-25 11:42:11 +02:00
Daniel Hansson
414baf425a
raise timeout and add more info
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-25 10:47:14 +02:00
Daniel Hansson
3f16f77cd3
rearrange install script (#2551) 2023-08-25 10:32:27 +02:00
Daniel Hansson
fd92b6ed24
SC
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-24 09:15:54 +02:00
Daniel Hansson
09bd223ad3
upgrade to nextcloud_occ commands instead for Redis
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-22 15:18:25 +02:00
Daniel Hansson
c894b69f6c
upgrade ES01 to latest maintenance release
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-21 10:46:13 +02:00
Daniel Hansson
904f81a2c9
docker update (#2547) 2023-08-21 10:45:11 +02:00
Daniel Hansson
ffb2a1786e
Upgrades ElasticSearch to 8.9
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-21 10:29:27 +02:00
Daniel Hansson
eedfc57160
use variable for name
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-18 12:12:00 +02:00
Daniel Hansson
c67f7b9023
check if it exists before removal
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-18 12:10:55 +02:00
Daniel Hansson
e04636765e
also remove the network
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-18 12:08:20 +02:00
Daniel Hansson
fd9254b1c9
lower cpu check
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-17 11:48:40 +02:00
Daniel Hansson
5a310e4222
make talk recording default
and the resource check higher

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-17 11:33:28 +02:00
Simon L
295c91d5c1
talk-recording - change tag from beta to latest (#2546)
Signed-off-by: Simon L <szaimen@e.mail.de>
2023-08-17 11:28:44 +02:00
Daniel Hansson
cfac66cd15
smaller fixes for FTS (#2545)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-14 15:37:33 +02:00
Daniel Hansson
7b8dddd85d
add back needed function
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-14 14:01:40 +02:00
Daniel Hansson
9e081a9f4c
Change to ElasticSearch for FTS (#2541) 2023-08-14 13:57:06 +02:00
Daniel Hansson
b50a04c0a8
only restart docker if changed
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-14 13:04:44 +02:00
Daniel Hansson
b99e6ac7dc
don't set /standalone-signaling
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-14 08:01:46 +02:00
Daniel Hansson
3bf4b1f2d9
fix the missing piece
use beta, and not latest

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-13 16:44:07 +02:00
Daniel Hansson
461a2354e7
fix whole name
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-13 16:39:33 +02:00
Daniel Hansson
80b655ed6d
fix some SC
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-11 20:35:01 +02:00
Daniel Hansson
cbfdd7b84b
install needrestart if not existing (#2543)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-11 16:54:22 +02:00
Daniel Hansson
8bab391237
fix intention
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-10 18:37:29 +02:00
Daniel Hansson
de0b5f24b0
change to beta
@szaimen I hope the tag is correct?

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-10 18:18:55 +02:00
Daniel Hansson
9b605630b4
move extend LVM to the top
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-10 15:54:52 +02:00
Daniel Hansson
f791c536a3
opcache_interned_strings_buffer_value (#2540) 2023-08-09 17:45:50 +02:00
Daniel Hansson
82f8b91736
Remove annoying message on every update (#2539)
even though FTS isn't installed.

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-09 15:58:53 +02:00
Daniel Hansson
bf25e292aa
fix integer bug
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-08-04 16:26:42 +02:00
Daniel Hansson
b98e350bae
fix maintenance:mode (#2535)
@cc @szaimen

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-31 08:44:26 +02:00
Daniel Hansson
5cfb0444b1
add check_command to regular nextcloud_occ
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-30 20:39:21 +02:00
Daniel Hansson
9afdf04d20
move install check
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-30 20:34:06 +02:00
Daniel Hansson
1118b09372
Shellcheck (#2533) 2023-07-28 20:07:57 +02:00
Daniel Hansson
661c8e6c4a
hide output from maintenance mode
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-28 18:54:14 +02:00
Daniel Hansson
dea4242e88
don't use function in upgrade script for ǹextcloud_occ`
fixes the issue where it calls itself, resulting in enabling maintenance mode even if there's no reason for it

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-28 18:50:35 +02:00
Daniel Hansson
219a049c65
add back actual function
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-28 18:14:17 +02:00
Daniel Hansson
4716b601c8
commit lost commit
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-28 17:51:00 +02:00
Daniel Hansson
532932688c
improve nextcloud_occ maintainance_check (#2532)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-28 17:49:38 +02:00
Daniel Hansson
a1fdaf06ff
disable maintenance mode for no_check as well
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-28 12:03:30 +02:00
Daniel Hansson
b844a7523b
don't upgrade FTS (#2531) 2023-07-28 11:59:12 +02:00
Daniel Hansson
1cce2cdcd0
Disable maintenance mode if active during occ (#2530)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-28 11:49:41 +02:00
Daniel Hansson
4ca9ad9370
:(
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-28 11:48:45 +02:00
Daniel Hansson
23499b77d5
typo
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-21 12:26:56 +02:00
Daniel Hansson
341f5f9a23
Improve PHP-FPM + add maintenance:mode (#2526)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-20 22:50:51 +02:00
Daniel Hansson
92cfd4292d
Update nextcloud_install_production.sh
It is the legacy way of running PHP based applications as opposed to the newer PHP-FPM

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-20 22:42:21 +02:00
Daniel Hansson
174c05f488
PHP-FPM mpm_event (#2525) 2023-07-20 20:03:30 +02:00
Daniel Hansson
0fbfbd926d
add name for CPU check
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-20 16:43:34 +02:00
Daniel Hansson
839bf49f02
fix bug when removing
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-20 16:39:25 +02:00
Daniel Hansson
c91ef70f5f
change logging
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-20 16:23:31 +02:00
Daniel Hansson
b117d87a0b
add HPB domain
@szaimen This is what I mean, I would need the `HPB_DOMAIN` in your docker.

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-20 16:03:18 +02:00
Daniel Hansson
963c144b27
update domain (#2524) 2023-07-20 15:36:47 +02:00
Daniel Hansson
551ba820bd
change log path
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-20 14:31:19 +02:00
Daniel Hansson
0cacf3bdfe
change var name
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-20 13:49:11 +02:00
Daniel Hansson
2b06221c8c
update check
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-20 13:32:34 +02:00
Daniel Hansson
7e4f9f2e65
more minor changes to talk-recording (#2523) 2023-07-20 13:23:57 +02:00
Daniel Hansson
0e57d3ecb5
actually prune the old container
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-20 11:00:26 +02:00
Daniel Hansson
4bfc3debb3
talk-recoding fixes (#2521) 2023-07-20 10:56:10 +02:00
Daniel Hansson
70095884dc
typo
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-20 10:00:01 +02:00
Daniel Hansson
dcef8d8050
add keyboard-configuration to dependecies
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-20 09:53:14 +02:00
Daniel Hansson
86e8266f26
Implement Talk recording (#2520) 2023-07-20 09:07:53 +02:00
Daniel Hansson
f9ada6d342
Use Stuttgart mirrors for DE servers (#2509)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-16 21:22:25 +02:00
Simon L
5e46ba61d4
adjust av_max_file_size (#2515)
Signed-off-by: Simon L <szaimen@e.mail.de>
2023-07-11 12:47:00 +02:00
Daniel Hansson
367f088701
change min cpu and ram
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-07-04 22:56:40 +02:00
Daniel Hansson
bafbcdd5f9
fix password prompt for psql
fail if it prompts

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-06-23 15:33:42 +02:00
Daniel Hansson
6cc7c2d284
print in text instead of box
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-06-23 14:34:19 +02:00
Daniel Hansson
1f40673d33
wait for cronjob
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-06-23 14:24:41 +02:00
Simon L
ab47c78f81
fix vgs free space check (#2510)
Signed-off-by: Simon L <szaimen@e.mail.de>
Co-authored-by: Daniel Hansson <mailto@danielhansson.nu>
2023-06-23 12:12:21 +02:00
Daniel Hansson
cd48cd8d83
remove adminer.conf in sites-enabled
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-06-23 11:05:26 +02:00
Daniel Hansson
909949a67f
add option fix for apt
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-06-22 12:49:03 +02:00
Daniel Hansson
e0f7e27797
27.0.0 (#2506) 2023-06-17 18:29:15 +02:00
Daniel Hansson
b5ed8b8e4a
change shorted links (#2505)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-06-17 17:42:34 +02:00
Daniel Hansson
bb2f6ee8ab
add CURRENTMAJOR (#2503) 2023-06-14 14:07:28 +02:00
Daniel Hansson
138dbbfd88
use fullchain instead of cert
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-06-14 12:15:24 +02:00
Daniel Hansson
82a1eb8631
change paatebin tool
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-06-12 15:20:51 +02:00
Daniel Hansson
101c5e2cd3
use function instead (#2502) 2023-06-02 14:43:26 +02:00
Daniel Hansson
cf130f4d79
stop any running indexing
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-05-30 09:20:57 +02:00
Simon L
f47f31fc9f
pi-hole - keep host headers (#2501)
Signed-off-by: Simon L <szaimen@e.mail.de>
Co-authored-by: Daniel Hansson <mailto@danielhansson.nu>
2023-05-28 11:35:18 +02:00
Simon L
3426336462
remotedesktop - remove gnome-shell-extensions which seem to be removed (#2499)
Signed-off-by: Simon L <szaimen@e.mail.de>
Co-authored-by: Daniel Hansson <mailto@danielhansson.nu>
2023-05-28 11:34:32 +02:00
Simon L
f0fc252e54
give plex user a fixed uid and gid (#2498)
Signed-off-by: Simon L <szaimen@e.mail.de>
2023-05-28 11:33:46 +02:00
Simon L
616e1422f2
fix onlyoffice setting jwt_secret (#2496)
Signed-off-by: Simon L <szaimen@e.mail.de>
2023-05-27 18:08:52 +02:00
Daniel Hansson
57cf42fe5c
update version after upgrade
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-05-26 16:21:46 +02:00
Daniel Hansson
511b5b2a39
Improve solvable_files.sh from Nextcloud GmbH (#2487) 2023-05-05 22:17:05 +02:00
Daniel Hansson
2e02b2104b
Fix PECL XML
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-05-05 11:45:12 +02:00
Simon L
8bf2fa47de
update the geoblock database (#2486)
Signed-off-by: Simon L <szaimen@e.mail.de>
2023-05-04 06:57:06 +02:00
Daniel Hansson
5808d439fa
set FQDN and not conf name
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-05-02 21:51:08 +02:00
Daniel Hansson
daaa114f83
cleanup apache2 configs (#2485) 2023-05-02 21:38:14 +02:00
Daniel Hansson
db8004ee8b
fix " " misstake (#2484) 2023-05-02 21:12:32 +02:00
Daniel Hansson
0a7a9979fc
add script for trusted domains (#2482) 2023-05-02 19:17:21 +02:00
Daniel Hansson
34272bd7bd
fix Apache rules (#2483) 2023-05-02 19:16:59 +02:00
Daniel Hansson
6772a66940
Update Imaginary values (#2479) 2023-04-27 20:13:11 +02:00
Daniel Hansson
4e8e79c83b
Trusted domains (#2477) 2023-04-25 20:31:49 +02:00
Daniel Hansson
8be4b40f50
Add PDF to imaginary
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-25 19:58:58 +02:00
Daniel Hansson
303e0870be
remove legacy DB variables
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-25 10:52:32 +02:00
Simon L
b4be930948
automatically reboot server if ncvm-snapshot could not get removed (#2476)
* automatically reboot server if ncvm-snapshot could not get removed

Signed-off-by: Simon L <szaimen@e.mail.de>

* use countdown instead

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>

---------

Signed-off-by: Simon L <szaimen@e.mail.de>
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
Co-authored-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-24 13:40:17 +02:00
Daniel Hansson
62ea0e09ad
reuse html path
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-24 12:43:31 +02:00
Daniel Hansson
1727783b98
revert last change
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-21 11:40:55 +02:00
Daniel Hansson
c9e49ff412
allow 18.04
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-21 11:31:59 +02:00
Daniel Hansson
2ef2f78b81
don't fail if previewgenerator isn't installed
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-13 22:27:02 +02:00
Daniel Hansson
0794cddf40
Not needed anymore
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-12 14:27:54 +02:00
Daniel Hansson
a95ccf2120
check fro cronjob instead of enabled
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-11 17:03:55 +02:00
Daniel Hansson
f1ff45f0e2
backup the original file just in case
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-07 17:13:25 +02:00
Daniel Hansson
84ed27c155
Fix PostgreSQL bug (regression) (#2471) 2023-04-07 16:39:41 +02:00
Daniel Hansson
6a5b85fddd
remove whitespace
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-06 23:53:15 +02:00
Daniel Hansson
603b99c1e0
inform about restarting webserver
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-06 23:50:55 +02:00
Daniel Hansson
419239be98
fix msg_box to show correct path in menu script
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-06 23:06:38 +02:00
Daniel Hansson
bab1a907dc
Wording
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-06 22:33:19 +02:00
Daniel Hansson
bb4554a654
Install imaginary during first setup instead (#2469) 2023-04-06 17:40:27 +02:00
Daniel Hansson
476c0bce1e
stealth!
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-06 17:40:09 +02:00
Daniel Hansson
e26123b56e
NC 26.0.0
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-06 15:12:59 +02:00
Daniel Hansson
468665c7f2
wording
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-02 20:36:57 +02:00
Daniel Hansson
c08b28e7a4
Hide output from apt-hold
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-02 20:17:37 +02:00
Daniel Hansson
905765a44c
fix SC
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-02 20:12:35 +02:00
Daniel Hansson
fc88cc8f95
update CPU cores during first setup + fix SC (#2468) 2023-04-02 18:35:47 +02:00
Daniel Hansson
618509895c
Calculate CPU cores
It's already done in Nextcloud core code, but we want another default

cc @szaimen 

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-02 18:27:00 +02:00
Daniel Hansson
123e1516ec
default to 2 cpu cores since that's what the VM is released with
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-02 17:28:55 +02:00
Daniel Hansson
949872cfca
Install Imaginary by default (#2467) 2023-04-02 17:19:51 +02:00
Daniel Hansson
8f797d5f74
remove imagick even if it's held
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-02 02:46:46 +02:00
Daniel Hansson
197e233b1c
Change Updatenotification (#2461) 2023-04-02 01:52:46 +02:00
Daniel Hansson
c57ab7eb9d
add more nono ports
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-01 23:33:25 +02:00
Daniel Hansson
d748335f1a
Fix SC
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-01 23:29:36 +02:00
Daniel Hansson
fe9b3ffdc2
typo
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-01 23:18:05 +02:00
Daniel Hansson
234f1e6985
fix menu for apps (#2466) 2023-04-01 23:14:54 +02:00
Daniel Hansson
64b69c9097
Add Imaginary Docker for previews (#2464) 2023-04-01 23:07:56 +02:00
Daniel Hansson
d5aa43c6f0
improve docker-compose down function
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-04-01 20:51:38 +02:00
Daniel Hansson
c14adf47a7
fix check for face recognition
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-31 21:44:24 +02:00
Daniel Hansson
d696ab2598
Add some more checks (#2462)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-31 21:42:23 +02:00
Daniel Hansson
47e91252ff
final fix for check
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-31 21:12:04 +02:00
Daniel Hansson
d15b85aac7
exit if no
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-31 20:59:42 +02:00
Daniel Hansson
1224348439
typo
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-31 20:53:17 +02:00
Daniel Hansson
1ab04a2306
don't stop on failure
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-31 20:47:35 +02:00
Daniel Hansson
2811c4fc11
move app check
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-31 20:38:07 +02:00
Daniel Hansson
26bdbf51f5
check php before restaring webserver
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-31 20:27:08 +02:00
Daniel Hansson
87249678db
inform about new major release
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-31 13:48:39 +02:00
Daniel Hansson
7c7b5f5947
updates once per month is enough
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-31 12:33:31 +02:00
Daniel Hansson
0e6a86a4ab
Check if Suspicious Login are installed
and ask to remove.

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-31 10:46:38 +02:00
Daniel Hansson
33ff2d6288
automatically restart services (#2459)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-24 11:38:21 +01:00
Daniel Hansson
c6701426fc
Update recognize.sh
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-22 14:03:27 +01:00
Daniel Hansson
2b93764531
Fix OnlyOffice websockets (#2457) 2023-03-21 21:38:05 +01:00
Daniel Hansson
209ab35698
advice to reinstall
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-21 17:45:56 +01:00
Daniel Hansson
6a72e2edee
make Talk default during first setup
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-21 17:29:12 +01:00
Daniel Hansson
033aa2c00a
move CPU / RAM check
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-20 12:31:36 +01:00
Daniel Hansson
4aa578fbb4
lower CPU check
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-20 12:30:59 +01:00
Daniel Hansson
9d12d1a6b1
cleanup on uninstall/reinstall
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-20 12:27:20 +01:00
Daniel Hansson
743272b350
NC 26 prep (#2454) 2023-03-16 11:03:10 +01:00
Daniel Hansson
d39421fbc5
remove instructions on how to bypass ram check (#2455)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-14 16:24:44 +01:00
Simon L
854deb3184
enforce https for get.docker.com (#2453)
Signed-off-by: Simon L <szaimen@e.mail.de>
2023-03-13 22:34:29 +01:00
Daniel Hansson
f18ab5f139
memory tuning for imagick (#2451) 2023-03-12 20:50:41 +01:00
Daniel Hansson
698f155443
SC
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-12 20:10:22 +01:00
Daniel Hansson
7acd3569a1
install libimagiccore depending on OS
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-12 20:02:57 +01:00
Daniel Hansson
6e4849aa41
SC
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-12 19:23:03 +01:00
Daniel Hansson
b1d24ff3b5
Add error message if it fails
If the Mount ID changed, then it will fail. Notify about this error.

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-12 12:30:58 +01:00
Daniel Hansson
7080236e06
update inotify script (#2449) 2023-03-12 12:03:03 +01:00
Daniel Hansson
461cefa098
remove noauto
messes up mounting on certain SMB shares

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-10 14:17:20 +01:00
Daniel Hansson
de04591d66
upgrade apps a second time (#2447)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-05 10:42:14 +01:00
Daniel Hansson
a14cbeb11f
issuetemplate no longer seems to be maintained
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-02 14:03:34 +01:00
Daniel Hansson
624c6e9e78
better intendation
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-02 13:51:35 +01:00
Daniel Hansson
64500e0cdc
better detect nvme
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-02 13:50:12 +01:00
Daniel Hansson
23ff1c141d
update home/sme/server
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-03-02 13:40:22 +01:00
Daniel Hansson
70e919a53a
remove log find
It's an old fix, and if you haven't updated in the past 3 years, then you probably don't care anyway.

Fix https://github.com/nextcloud/vm/issues/2445

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-02-26 19:35:44 +01:00
Daniel Hansson
8168d605c1
enterprise (#2443)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-02-17 14:48:20 +01:00
Daniel Hansson
79533967cb
add new firmware to asusnuc (#2442)
* add new firmware to asusnuc

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>

* update version

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>

---------

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-02-10 12:30:28 +01:00
Daniel Hansson
d7692d523e
change to the new standard dhparam
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-02-10 12:18:44 +01:00
Daniel Hansson
cf9150218a
SC
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-02-06 16:26:20 +01:00
Daniel Hansson
804f316043
cat the trackers file instead
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-02-06 16:14:45 +01:00
Daniel Hansson
5e62bd846a
remove leading -t
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-02-06 15:53:36 +01:00
Daniel Hansson
37e184df1e
cat the whole file instead
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-02-06 15:36:07 +01:00
Daniel Hansson
3e62fca7d6
add -t in front of all trackers
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-02-06 15:27:30 +01:00
Daniel Hansson
e6eed5af3c
remvove dummytracker
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-02-06 15:13:54 +01:00
Daniel Hansson
8cb0b6395d
add dummyline
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-02-06 15:12:05 +01:00
Daniel Hansson
cbf686a5c0
remove newline
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-02-06 15:07:45 +01:00
Daniel Hansson
9638dead12
remove plain IP adresses from trackers.txt
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-02-06 15:07:12 +01:00
Daniel Hansson
28d0525dee
increase memory (#2439) 2023-02-06 14:57:19 +01:00
Daniel Hansson
fb8b702416
remove unvalid tracker
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-02-06 13:52:15 +01:00
Daniel Hansson
a62724b302
Create torrent (#2438) 2023-02-06 13:44:28 +01:00
Daniel Hansson
2025411b1f
Onlyffice fixes
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-02-03 12:44:59 +01:00
Daniel Hansson
6c9613ec21
allow local access
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-02-02 17:22:38 +01:00
Daniel Hansson
d2a3586007
add some more scripts to leftover removal
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-01-26 15:46:34 +01:00
Daniel Hansson
6a7f5f50a5
check distro, install current PHPVER lib
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-01-20 14:20:23 +01:00
Daniel Hansson
3c49dcda17
improve the function also check distro
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-01-20 13:37:28 +01:00
Daniel Hansson
ed5c5e2627
check PHP Version instead of distro
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-01-20 13:26:49 +01:00
Daniel Hansson
d37a2917fa
happy new year! (#2431)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-01-20 13:21:59 +01:00
Daniel Hansson
55838d129f
add nextcloud_occ
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-01-20 12:53:39 +01:00
Daniel Hansson
50511a0331
add auth.log if not existing (#2430)
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-01-20 10:58:52 +01:00
Simon L
ec8310b7b7
remove snapshots dir from valid repository paths (#2428)
Signed-off-by: Simon L <szaimen@e.mail.de>

Signed-off-by: Simon L <szaimen@e.mail.de>
2023-01-18 10:07:09 +01:00
Florian Helmschmidt
3b4cf721df
Update system-restore.sh and backup-viewer.sh (#2426)
* Update system-restore.sh

Fixed issue with inconsistent quotes related to ENCRYPTION_KEY
Compare https://github.com/nextcloud/vm/blob/master/not-supported/daily-backup-wizard.sh#L437

Signed-off-by: Florian Helmschmidt <github@nhelmschmidt.de>

* fix getting the encryption_key

Signed-off-by: Simon L. <szaimen@e.mail.de>

* fix it in backup-viewer as well

Signed-off-by: Simon L <szaimen@e.mail.de>

Signed-off-by: Florian Helmschmidt <github@nhelmschmidt.de>
Signed-off-by: Simon L. <szaimen@e.mail.de>
Signed-off-by: Simon L <szaimen@e.mail.de>
Co-authored-by: Simon L <szaimen@e.mail.de>
2023-01-16 22:09:49 +01:00
Simon L
9422e742a2
update geoblock database (#2425)
Signed-off-by: Simon L <szaimen@e.mail.de>

Signed-off-by: Simon L <szaimen@e.mail.de>
2023-01-12 02:26:07 +01:00
Daniel Hansson
e84262e982
128 MB shoulod be enough
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2023-01-08 11:24:23 +01:00
Daniel Hansson
a637b51282
raise memory to generate more prevews
Defaults to 50 MB and that's not enough.

https://help.nextcloud.com/t/no-previews-on-photos-8mb-smaller-files-are-fine/144265

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2022-12-30 11:23:26 +01:00
Daniel Hansson
72011c0b36
fix typos (#2423) 2022-12-28 21:42:25 +01:00
Daniel Hansson
3a7e04aa03
prep for app subdomain
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2022-12-28 14:26:32 +01:00
Daniel Hansson
a87cf8be11
check for subdomain directly in the script
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2022-12-28 11:15:26 +01:00
Daniel Hansson
ab123163e1
export the final domain
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2022-12-28 10:54:46 +01:00
Daniel Hansson
101b82c578
fix SC
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2022-12-27 20:34:02 +01:00
Daniel Hansson
9b4c2342fd
Upgrade repository for Talk (#2420)
* Upgrade repository for Talk

Fix for https://github.com/nextcloud/vm/issues/2392

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>

* check for package, not for app

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2022-12-27 19:51:37 +01:00
Daniel Hansson
1090f491bf
change place for spaces warning, and remove..
.. legacy notification

Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2022-12-27 19:35:01 +01:00
Simon L
4327d2b098
move the notify-crontab to its own script (#2391) 2022-12-27 12:25:49 +01:00
Daniel Hansson
4fd6eae0b0
spaces are OK in NC 25
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2022-12-26 21:08:02 +01:00
Daniel Hansson
b24ef5191f
fix SC (#2418) 2022-12-25 18:39:43 +01:00
Daniel Hansson
c01ca31e4c
fix SC (#2418) 2022-12-25 18:32:29 +01:00
Daniel Hansson
294ed9ac5c
escape proxy settings
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2022-12-23 12:51:46 +01:00
Daniel Hansson
6b3491f758
9.010.01
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2022-12-17 01:01:45 +01:00
Daniel Hansson
e15a8192f8
r8125-9.010.01.tar.bz2
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2022-12-17 01:00:21 +01:00
Daniel Hansson
8e880a71f1
add python2
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2022-12-16 16:24:56 +01:00
Daniel Hansson
a82dea8859
add new dependencies
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2022-12-16 14:25:53 +01:00
Daniel Hansson
ebb7026f6e
remove untrusted repo
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2022-12-16 14:16:25 +01:00
Daniel Hansson
a1ad096ae7
Upgrade Webmin for failed installs
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2022-12-16 14:10:40 +01:00
Daniel Hansson
852dda0673
change reboot command
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2022-12-15 09:27:23 +01:00
Daniel Hansson
bd8ffe2385
fix versions
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2022-12-10 01:32:57 +01:00
Daniel Hansson
99d13f077b
25.0.2
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
2022-12-09 14:28:19 +01:00
144 changed files with 1194 additions and 13995 deletions

View File

@ -38,7 +38,7 @@ body:
id: screenshots
attributes:
label: Screenshots, Videos, or Pastebins
description: If applicable, add screenshots and/or a short video to help explain your problem. You can use https://0bin.net for long error messages or logs.
description: If applicable, add screenshots and/or a short video to help explain your problem. You can use https://paste.sh for long error messages or logs.
- type: textarea
id: additional-context
attributes:

View File

@ -10,7 +10,7 @@ jobs:
name: Github Actions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Run Shellcheck
uses: ludeeus/action-shellcheck@master
with:

View File

@ -11,7 +11,7 @@ jobs:
name: Shellcheck testing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: shellcheck
uses: reviewdog/action-shellcheck@v1
with:
@ -25,7 +25,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: spelling or typos
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: misspell
uses: reviewdog/action-misspell@v1
with:

View File

@ -1,450 +0,0 @@
### Download can be found here: https://www.hanssonit.se/nextcloud-vm/
**Please note that BOTH disks need to be imported for the VM to function properly.**
- Check the latest commits here: https://github.com/nextcloud/vm/commits/master
- Documentation can be found here: https://docs.hanssonit.se/s/W6fMouPiqQz3_Mog/virtual-machines-vm/d/W7Du9uPiqQz3_Mr1/nextcloud-vm-machine-configuration
PR's are more than welcome. Happy Nextclouding!
### Different versions
If you run Hyper-V or want 500 GB, 1 TB or 2 TB VM you can download it from [T&M Hansson IT's shop](https://shop.hanssonit.se/product-category/virtual-machine/nextcloud/).
## 24.0.5
### Small changelog:
- Update Fail2ban with a better regex
- Fix FTS, and make sure it's gone when removed (even DB)
- Make Talk installable again by fixing source-repos and some tweaks to the script
- Fix dependencies for Bitwarden
- Improve the port checking function (for checking open ports)
- Allow `NCDATA` to be other than default when checking for Nextcloud version (`lowest_compatible_version()`)
- Upgrade Realtek firmware drivers for the Home/SME Nextcloud server
- Add Googles DNS as an option (user request)
- Always recover old Nextcloud apps, even if app store is broken
- Remove some legacy code
- Improve backup scripts and other stuff in the `not-supported` folder
- Ubuntu 22.04 reached its first maintenance release, consider it 100% stable.
- And more...
### Full changelog:
- [https://github.com/nextcloud/vm/compare/24.0.1..24.0.5](https://github.com/nextcloud/vm/compare/24.0.1..24.0.5)
- [https://nextcloud.com/changelog/#latest24](https://nextcloud.com/changelog/#latest24)
## 24.0.1
This release is quite huge, including Ubuntu 22.04 (minimal), PHP-FPM 8.1, and PosgreSQL 14.
### Small changelog:
- Prefer use of local lib file
- Add `addons/fix_invalid_modification_time.sh`
- Use minimal OS, instead of full blown. Install only needed dependecies.
- Deprecate Ubuntu 18.04
- Upgrade to Ubuntu 22.04
- Upgrade to PHP 8.1
- Upgrade to PostgreSQL 14
- Upgrade Documentserver scripts to work with the new Docker images
- Deprectae `apt-key` and introduce a new and better way for adding keys
- Make the menu update option default. It first upgrades minor, then asks for major if applicable
- Only clean disk if it's 70% full and/or less than 100 GB left
- Remove legacy code
- Make it possible to add your own DNS servers during installation (not setup)
- Do not ask for password change if it differs from default, since that means you probably already set your own password
- Make it possible to add your own GUI user during installation
- Change DH-param instead of DSA-param
- Make Talk a bit safer
- Minor bugfixes and improvements
- Updated geoblock database
- Fixed a few backup related details
- And more...
### Full changelog:
- https://github.com/nextcloud/vm/compare/23.0.2..24.0.1
- https://nextcloud.com/changelog/#latest24
## 24.0.0.1
### This is a pre-release. Available as a VM, but only the free 40 GB version.
### Full changelog:
- https://github.com/nextcloud/vm/compare/24.0.0..24.0.0.1
- https://nextcloud.com/changelog/#latest24
## 24.0.0
### This is a pre-release. Only available in master.
### Full changelog:
- https://github.com/nextcloud/vm/compare/23.0.2..24.0.0
- https://nextcloud.com/changelog/#latest24
## 23.0.2
### Small changelog:
- Change to another Full Text Search implementation
- Improve deSEC functions
- Minor bugfixes and improvements
- And more...
### Full changelog:
- https://github.com/nextcloud/vm/compare/23.0.1..23.0.2
- https://nextcloud.com/changelog/#latest23
## 23.0.1
### Small changelog:
- Fixed all the bugs with the old release (23.0.0)
- Minor bugfixes and improvements
- And more...
### Full changelog:
- https://github.com/nextcloud/vm/compare/23.0.0..23.0.1
- https://nextcloud.com/changelog/#latest23
## 23.0.0
### Small changelog:
- Change from lool to cool for Collabora
- Make it possible to ugrade NIC-firmware from all old releases ([Home/SME server](https://shop.hanssonit.se/product-category/nextcloud/home-sme-server/))
- Minor bugfixes and improvements
- And more...
### Full changelog:
- https://github.com/nextcloud/vm/compare/22.2.2..23.0.0
- https://nextcloud.com/changelog/#latest23
## 22.2.2
### Small changelog:
- Change to AllowOverride None for Apache and include .htaccess instead (speeds up I/O)
- Change IPv4 check (WANIP4)
- Set productname
- Minor bugfixes and improvements
- And more...
### Full changelog:
- https://github.com/nextcloud/vm/compare/22.2.0..22.2.2
- https://nextcloud.com/changelog/#latest22
## 22.2.0
### Small changelog:
- Upgrade Home/SME server NIC firmware
- Add NVMe to format disk
- Change keyserver
- Minor bugfixes and improvements
- And more...
### Full changelog:
- https://github.com/nextcloud/vm/compare/22.1.1..22.2.0
- https://nextcloud.com/changelog/#latest22
## 22.1.1
### Small changelog:
- Remove Group Folders in the standard installation
- Improved deSEC and added support for existing accounts
- Improved SPAMHAUS rules and script
- Show the hostname when notifying - better if you run multiple servers
- Only update update script if it's older than 120 days
- Changed to EDCSA for certbot (TLS)
- Add script for removal or deSEC + subdomain
- Make deSEC a menu instead
- Crucial fixes for the new PN51 network drivers
- Update script - only update the updatenotification script if a new Nextcloud update is available
- Updated and renamed Bitwarden RS to Vaultwarden
- Updated geoblock database - August 2021
- Update script - don't execute the update before all cronjobs are finished
- Always create a backup before updating
- Minor bugfixes and improvements
- And more...
### Full changelog:
- https://github.com/nextcloud/vm/compare/22.0.0..22.1.1
- https://nextcloud.com/changelog/#latest22
## 22.0.0
### Small changelog:
- Add SMTP2GO to SMTP-Relay
- Remove APCu and replace with Redis instead
- Made it possible to add subdomains to deSEC
- Improved spinner_loading
- Added dates to automatic updates log
- Added regular ZFS snapshot prune
- Added retention for Nextclouds user activities
- Previewgenerator - allow to clear all previews
- Update script - update Nextclouds mimetype list
- Moved mimteype update to nextcloud_configuration menu
- Reworked office scripts
- Update script - change crontab on all installations to 5 minutes
- Fixed a bug with Netdata
- Geoblock - updated link to csv file
- Refactored the bitwarden_mailconfig script
- Added more functionality to curl_to_dir
- Docker documentserver - don't restart docker daemon upon installation
- Restart notify push in some situations
- Make sure sudo and software-properties-common is installed
- Fixed password generation in edge cases
- Reworked the cookielifetime script
- Updated geoblock database - June 2021
- Added option to check for 0-byte files
- Changed from apt to apt-get
- Simplified ClamAV notifications and small fix to fail2ban notification
- Harden-SSH script - allow to set up 2FA authentication
- SMB-server - added option to automatically empty recylce bins
- SMB-server - added option to empty all recycle bins
- SMB-server - Create the files directory for new users directly during the user creation
- Reworked system-restore
- Minor bugfixes and improvements
- And more...
### Full changelog:
- https://github.com/nextcloud/vm/compare/21.0.2..22.0.0
- https://nextcloud.com/changelog/#latest22
## 21.0.2
### Small changelog:
- Make it possible to choose port for public access in the deSEC setup (only when you choose TLS)
- Fix bugs with the deSEC script
- Avoid ending up in a loop in the deSEC script
- It's now possible to check for NONO ports with a function
- Loop port selection in the Talk script
- Move backups location to /mnt/NCBACKUPS and delete backups from last year
- Tune chunking in GUI uploads
- Clean up some more scripts in the end of each setup
- Add the Azure kernel for Hyper-V VMs
- Shorten the time files are stored in trashbin (can still be configured)
- Escape all Apache Log dirs correctly
- Made some enhancements to scripts in the [not-supported folder](https://github.com/nextcloud/vm/tree/master/not-supported)
- Minor bugfixes and improvements
- And more...
### Full changelog:
- https://github.com/nextcloud/vm/compare/21.0.1..21.0.2
- https://nextcloud.com/changelog/#latest21
## 21.0.1
### Small changelog:
- Add TLS with DNS and deSEC. It's now possible to get DNS from a local machine without any open ports!
- ClamAV - give the daemon more time to start
- SMB-server - completely rework how directories get mounted to Nextcloud
- SMTP-mail - add providers
- Create a script for the Pico CMS Nextcloud app
- Add a Firewall script to the not-supported folder
- Add SSH hardening
- Add deSEC magic
- S.M.A.R.T. Monitoring - test drives directly
- Add a script for the Facerecognition Nextcloud app
- ClamAV - improve weekly full-scan tremendously
- Update geoblock database - april
- Speed up the network check if the network already works
- Made some enhancements to scripts in the [not-supported folder](https://github.com/nextcloud/vm/tree/master/not-supported)
- Minor bugfixes and improvements
### Full changelog:
- https://github.com/nextcloud/vm/compare/21.0.0..21.0.1
- https://nextcloud.com/changelog/#latest21
## 21.0.0
### Small changelog:
- Added Push Notifications for Nextcloud (`High Performance Backend for Nextcloud files`)
- Added Whiteboard for Nextcloud (`New in Nextcloud 21`)
- Moved Extract for Nextcloud to its own script
- Add phone region (new in 21)
- Made sure that all docker containers only listen on localhost
- Improve Strict Transport Security in TLS
- DDclient - added No-IP
- Updated geoblock database files
- Avoid double crontabs when reexecuting some scripts
- Don't enable disabled apps after update
- Geoblock - allow some IP-addresses by default
- Fix watchtower updates
- Geoblock - add Let's Encrypt advice
- Fix upgrade.disable-web
- Don't break update when enabling app
- Fix not enabled PECL extensions
- Prevent apps from breaking the update due to incompatibility
- Made some enhancements to scripts in the [not-supported folder](https://github.com/nextcloud/vm/tree/master/not-supported)
- Minor bugfixes and improvements
### Full changelog:
- https://github.com/nextcloud/vm/compare/20.0.7..21.0.0
- https://nextcloud.com/changelog/#latest21
## 20.0.7
### Small changelog:
- Ask to get the latest `update.sh` script when running updates from `menu.sh`
- Allow to reinstall Bitwarden RS also if local files are present
- Updated geoblock database files
- Made some enhancements to scripts in the [not-supported folder](https://github.com/nextcloud/vm/tree/master/not-supported)
- Minor bugfixes and improvements
### Full changelog:
- https://github.com/nextcloud/vm/compare/20.0.5..20.0.7
- https://nextcloud.com/changelog/#latest20
## 20.0.5
### Small changelog:
- Minor bugfixes and improvements
### Full changelog:
- https://github.com/nextcloud/vm/compare/20.0.4..20.0.5
- https://nextcloud.com/changelog/#latest20
## 20.0.4
### Major changes:
- We upgraded the compatibility for VMware. More info [here](https://docs.hanssonit.se/s/W6fMouPiqQz3_Mog/virtual-machines-vm/d/W7Du9uPiqQz3_Mr1/nextcloud-vm-machine-configuration). Changes are based on [this](https://github.com/nextcloud/vm/issues/1358) issue.
### Small changelog:
- Happy new year!
- Add ban notifications to Fail2ban
- Remove unattended upgrades to improve stability (we have our own auto updater)
- Fixes to the SMB Mount script
- Fixes to DDclient
- Minor bugfixes and improvements
### Full changelog:
- https://github.com/nextcloud/vm/compare/20.0.3..20.0.4
- https://nextcloud.com/changelog/#latest20
## 20.0.3
### Small changelog:
- Allow to choose between latest version or not
- Always run the permissions script
- Don't allow MariaDB specifically
- Fix PHP error message from Redis
- Fix grammar and spelling
- Update geoblock files
- Minor bugfixes and improvements
### Full changelog:
- https://github.com/nextcloud/vm/compare/20.0.2..20.0.3
- https://nextcloud.com/changelog/#latest20
## 20.0.2
### Small changelog:
- Fixed bugs with the `--provisioning` flag
- Updated geoblock.sh to get rid of jq
- Added a script-explainer to nextcloud_install_production.sh
- ClamAV - added a mechanism to inform about found files
- Fixed a bug in midnight-commander.sh
- Created smart-monitoring.sh to allow continuously smart checking
- Switched from Travis to Github Actions
- Added Reviewdog
- Improved previewgenerator
- Made some SC rules global
- Fixed some problems with wrong ownership of /mnt/ncdata
- Fixed link in startup-script
- Fixed ClamAV-Fullscan
- Added apt over https
- Further improved ClamAV
- Allow to reinstall automatic updates
- Improved partition check during the install-script
- Fixed some typo's
- Added more options to the [not-supported folder](https://github.com/nextcloud/vm/tree/master/not-supported) and made some enhancements
- Minor bugfixes and improvements
### Full changelog:
- https://github.com/nextcloud/vm/compare/20.0.1..20.0.2
- https://nextcloud.com/changelog/#latest20
## 20.0.1
### Small changelog:
- Made the setup of SMTP-mail more reliable
- Added a switch to the install-script to enable automatic provisioning of new releases
- Changed occ_command to nextcloud_occ to simplify copy and paste between scripts and CLI
- Improved the logging for SMTP-mail
- Added deSEC to DDclient-configuration
- Implemented an option to create LVM snapshots during the update script for certain instances
- Don't clear the CLI history anymore to simplify debugging
- Created geblock.sh in order to allow access from configured countries and/or continents
- Made it more clear that a Nextcloud update started
- Added DuckDNS to DDclient-configuration
- Fixed an incorrect OnlyOffice-URL
- Improved the guidance how to control whiptails
- Added some popups that explain the Additional Apps Menu and Server Configuration Menu during the startup script
- Switched to TLS1.3 for new website-configurations on Ubuntu 20.04
- Added a mechanism to update geoblock database file and added the geoblockdat folder to the repository
- SMTP-mail: allow to cancel the removal of configurations and packets if the testmail fails in order to simplify debugging
- Made BPYTOP its own script
- Standardized the usage of the word CLI
- Made Midnight Commander its own script
- Updated all app scripts with a new function for reinstalling
- Renamed the talk-signaling script to talk and deleted the old talk script
- Use start_if_stopped everywhere it fits
- Updatenotification: added an advice for Major Nextcloud updates
- Improved previewgenerator
- Fixed problems with static-ip
- Added Docker migrate script
- Fixed and issue with ClamAV
- Added more options to the [not-supported folder](https://github.com/nextcloud/vm/tree/master/not-supported) and made some enhancements
- Minor bugfixes and improvements
### Full changelog:
- https://github.com/nextcloud/vm/compare/20.0.0..20.0.1
- https://nextcloud.com/changelog/#latest20
## 20.0.0
### Small changelog:
- Add SMTP email relay to be able to send emails directly from the OS (Ubuntu)
- Make it possible to open ports with UPNP
- Update notify_admin_gui to cache all found admin users (tested with 500 users, and it's MUCH faster now)
- Disable hibernation (Ubuntu)
- Set archive.ubuntu.com as default Repo (Ubuntu)
- Standardize whiptails even more
- Improve fetch_lib
- Use fetch_lib in all scripts to prefer local library instead of hammering Github with requests in every script
- Update all Docker containers one by one when the update script is run due to compatibility issues with Bitwarden Password manager
- Improve the way passwords are set during the initial setup
- SMBmount: Introduce the option to customize the mount before adding as external storage to Nextcloud
- SMBmount: Add the option to utilize inotify to actively watch over externally changed files and folders
- Repository: cleanup by removing duplicate scripts and not-needed functions
- Repository: added the [not-supported folder](https://github.com/nextcloud/vm/tree/master/not-supported) with additional options like creating a SMB-server
- Minor bugfixes and improvements
### Full changelog:
- https://github.com/nextcloud/vm/compare/19.0.3..20.0.0
- https://nextcloud.com/changelog/#latest20
## 19.0.3
### Small changelog:
- Standardize input_box flow
- Automatically rewrite Webmin to HTTPS
- Add default dark mode theme to Adminer
- Make Adminer work on HTTP/2
- Introduce fetch_lib and chain libaries - this is now the new way of fetching the libs
- Add more menu scripts
- Add more Yes/No boxes and fix occurrences where the text wasn't shown due to print_text_in_color
- Standardize Whiptails even more
- Change to TLS1.2 all over
- Make functions out of all special variables
- Create a new (smart) startup script with basic server settings
- Automatically get the main domain for all scripts with built in proxies
- Minor bugfixes and improvements
### Full changelog:
- https://github.com/nextcloud/vm/compare/19.0.2..19.0.3
- https://nextcloud.com/changelog/#latest19
### Known errors:
- N/A

121
README.md
View File

@ -1,122 +1,5 @@
Nextcloud VM Appliance
============
Server installation. Simplified. :cloud:
--------------------------------
#### Interactive Guidance
> **The Nextcloud VM**_(aka **N**ext**c**loud **V**irtual **M**achine_ or _**NcVM**)_ — helps you create a personal or corporate [Nextcloud Server] _faster_ and _easier._ Fundamentally, NcVM is a carefully crafted _family_ of [\*nix] scripts which interactively guide you through a quality-controlled installation to obtain an [A+ security-rated] Nextcloud instance.
#### Curated Extras
> The Nextcloud [app store] extends core features by allowing you to enable a multitude of free one-click apps. However, _integration apps_ there like [Collabora Online] and [ONLYOFFICE] are solely _bridges_ to Nextcloud. Youre still required to install those services _separately_, which can be complex. NcVM provides optional _**full installation of select curated apps**_, including those and others. Monitor and manage your cloud using any web browser with NcVMs hand-picked collection of power utilities featuring stunning, modern UIs.
#### All Systems Go
> NcVM can check for and install _stable_ updates to keep things current, smooth, and secure.
--------------------
## Dependencies:
(Ubuntu Server 22.04 LTS *minimal* 64-bit)
<br>
(Linux Kernel: 5.15)
- Apache 2.4
- PostgreSQL 14
- PHP-FPM 8.1
- Redis Memcache (latest stable version from PECL)
- PHP-igbinary (latest stable version from PECL
- PHP-smbclient (latest stable version from PECL)
- Nextcloud Server Latest
## Support the development
* [Create a PR](https://help.github.com/articles/creating-a-pull-request/) and improve the code
* Report [your issue](https://github.com/nextcloud/vm/issues/new)
* Help us with [existing issues](https://github.com/nextcloud/vm/issues)
* Test what's not yet released into the stable VM. Please have a look at [this subfolder](https://github.com/nextcloud/vm/tree/master/not-supported) for further information.
* Write scripts so that the release process becomes automated with [Vagrant](https://www.vagrantup.com/docs/getting-started/), [Terraform](https://www.terraform.io/) or similar
* **[Donate](https://shop.hanssonit.se/product-category/donate/) or buy our [pre-configured VMs](https://shop.hanssonit.se/product-category/virtual-machine/): 500 GB, 1 TB, 2TB for both VMware, Hyper-V and [more](https://docs.hanssonit.se/s/W6fMouPiqQz3_Mog/virtual-machines-vm/d/W7Du9uPiqQz3_Mr1/nextcloud-vm-machine-configuration?currentPageId=bls17dahv0jgrltpif20)**
**FYI**
Developed by [Daniel Hansson](https://github.com/enoch85) and the Nextcloud community. Nextcloud GmbH does not offer support for the VM in the [master branch](https://github.com/nextcloud/vm/tree/master) (full-version), as we only support manual tarball/zip-package installations. You can download the official Nextcloud VM appliance ([also from this repo](https://github.com/nextcloud/vm/tree/official-basic-vm)) from [our website](https://download.nextcloud.com/vm/Official-Nextcloud-VM.zip) to get a stripped down version for testing if you rather want to skip all the manual steps in our documentation.
If you want support regarding the full-version VM in master, please contact our partner [Hansson IT](https://www.hanssonit.se/nextcloud-vm).
## Full documentation
* [VM](https://docs.hanssonit.se/s/W6fMouPiqQz3_Mog/virtual-machines-vm/d/W6fMquPiqQz3_Moi/nextcloud-vm) (the easiest option)
* [Install with scripts](https://docs.hanssonit.se/s/bj0vl1ihv0jgrmfm08j0/build-your-own/d/bj0vl4ahv0jgrmfm0950/nextcloud-vm) (if you feel brave)
* [FAQ](https://docs.hanssonit.se/s/bj101nihv0jgrmfm09f0/faq/d/bj101pihv0jgrmfm0a10/nextcloud-vm?currentPageId=bj101sqhv0jgrmfm0a1g) (Frequently Asked Questions)
* [Machine configuration](https://docs.hanssonit.se/s/W6fMouPiqQz3_Mog/virtual-machines-vm/d/W7Du9uPiqQz3_Mr1/machine-setup-nextcloud-vm) (of the released version)
## I want to test a Release Candidate (RC), or Beta!
No problem, brave explorer! We made it simple.
In some cases we do pre-releases of the VM as well. Those can be found in the [TESTING](https://download.kafit.se/s/dnkWptz8AK4JZDM?path=%2FTESTING) folder on the download server.
If you want to try the latest version yourself, there are two variables that you could use:
1. For latest **beta** or **RC** version: `sudo bash /var/scripts/update.sh beta`
2. For specific **RC** version: `sudo bash /var/scripts/update.sh 23.0.1rc2`
Please keep in mind that this is only intended for testing and might crash your Nextcloud. Please keep backups!
## Vagrant example (Beta)
The `nextcloud_install_production.sh` script can be run as part of Vagrant provisioning.
See [this subrepo](https://github.com/nextcloud/vm/tree/master/vagrant) for more information.
Please report any issues you can find. Improvements are welcome!
## First look
#### Nextcloud
![alt tag](https://github.com/nextcloud/nextcloud.com/blob/master/assets/img/features/VMwelcome.png)
#### Adminer (Database Administration) *not default*
![alt tag](https://i.imgur.com/tiF4chg.png)
#### Webmin (Server Administration GUI) *not default*
![alt tag](https://i.imgur.com/hLkmA1D.png)
#### TLS rating
![alt tag](https://i.imgur.com/nBEvczb.png)
## The usual tags
**Downloads from Github (not the main downloads location):**
<br>
![Downloads](https://img.shields.io/github/downloads/nextcloud/vm/total.svg)
<br>
**Downloads from main server:**
<br>
~100 per day since 2016
<br>
**Build Status:**
<br>
[![Check-code-with-shellcheck Actions status](https://github.com/nextcloud/vm/workflows/check-code-with-shellcheck/badge.svg)](https://github.com/nextcloud/vm/actions)
<br>
[![Reviewdog Actions status](https://github.com/nextcloud/vm/workflows/reviewdog/badge.svg)](https://github.com/nextcloud/vm/actions)
<br>
**Stability Status:**
<br>
![Stability Status](https://img.shields.io/badge/stability-stable-brightgreen.svg)
## Current [maintainers](https://github.com/nextcloud/vm/graphs/contributors)
(Most of the commit history is gone, since Github decided to remove it when an account email address is removed.)
* [Daniel Hanson](https://github.com/enoch85) @ [T&M Hansson IT AB](https://www.hanssonit.se)
* [szaimen](https://github.com/szaimen)
* You? :)
## Special thanks to
* [Ezra Holm](https://github.com/ezraholm50) @ [Tech and Me](https://www.techandme.se)
* [Luis Guzman](https://github.com/Ark74) @ [SwITNet](https://switnet.net)
* [Stefan Heitmüller](https://github.com/morph027) @ [morph027's Blog](https://morph027.gitlab.io/)
* [Lorenzo Faleschini](https://github.com/penzoiders)
* [Georg Großmann](https://github.com/ggeorgg)
* [liao20081228](https://github.com/liao20081228)
* [aaaskew](https://github.com/aaaskew)
[Nextcloud Server]: https://bit.ly/2CHIUkA
[app store]: https://bit.ly/2HUy4v9
[\*nix]: https://bit.ly/2UaCC7b
[A+ security-rated]: https://bit.ly/2mvlyJ3
[Collabora Online]: https://bit.ly/2WjVVZ8
[ONLYOFFICE]: https://bit.ly/2FA0TKj
THIS REPO IS ONLY HERE FOR BACKWARDS COMPATIBILITY, USE THE `MAIN` BRANCH INSTEAD.
============

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Check for 0-Byte files"
# shellcheck source=lib.sh

View File

@ -1,12 +1,12 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Automatic Updates"
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
SCRIPT_EXPLAINER="This option will update your server every week on Saturdays at $AUT_UPDATES_TIME:00.
SCRIPT_EXPLAINER="This option will update your server once every month on Saturdays at $AUT_UPDATES_TIME:00.
The update will run the built in script '$SCRIPTS/update.sh' which will update both the server packages and Nextcloud itself.\n
You can read more about it here: https://www.techandme.se/nextcloud-update-is-now-fully-automated/
Please keep in mind that automatic updates might fail, which is why it's \
@ -39,7 +39,7 @@ fi
# Install automatic updates
mkdir -p "$VMLOGS"/updates
crontab -u root -l | { cat; echo "0 $AUT_UPDATES_TIME * * 6 $SCRIPTS/update.sh minor >> $VMLOGS/updates/update-\$(date +\%Y-\%m-\%d_\%H:\%M).log 2>&1"; } | crontab -u root -
crontab -u root -l | { cat; echo "0 $AUT_UPDATES_TIME * 1-12 6 $SCRIPTS/update.sh minor >> $VMLOGS/updates/update-\$(date +\%Y-\%m-\%d_\%H:\%M).log 2>&1"; } | crontab -u root -
if yesno_box_yes "Do you want to reboot your server after every update? *recommended*"
then
sed -i "s|exit|/sbin/shutdown -r +1|g" "$SCRIPTS"/update.sh

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Set Cookie Lifetime"

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="deSEC Registration"
@ -140,9 +140,9 @@ then
# Add DNS renewals with the deSEC hoock script
print_text_in_color "$ICyan" "Preparing for DNS-renewals..."
mkdir -p "$SCRIPTS"/deSEC
curl_to_dir "https://raw.githubusercontent.com/nextcloud/vm/master/addons/deSEC" "hook.sh" "$SCRIPTS"/deSEC
curl_to_dir "https://raw.githubusercontent.com/nextcloud/vm/main/addons/deSEC" "hook.sh" "$SCRIPTS"/deSEC
chmod +x "$SCRIPTS"/deSEC/hook.sh
curl_to_dir "https://raw.githubusercontent.com/nextcloud/vm/master/addons/deSEC" ".dedynauth" "$SCRIPTS"/deSEC
curl_to_dir "https://raw.githubusercontent.com/nextcloud/vm/main/addons/deSEC" ".dedynauth" "$SCRIPTS"/deSEC
check_command sed -i "s|DEDYN_TOKEN=.*|DEDYN_TOKEN=$DEDYNAUTHTOKEN|g" "$SCRIPTS"/deSEC/.dedynauth
check_command sed -i "s|DEDYN_NAME=.*|DEDYN_NAME=$DEDYNDOMAIN|g" "$SCRIPTS"/deSEC/.dedynauth
msg_box "DNS updates for deSEC are now set. This means you don't have to open any ports (80|443) for the renewal process since deSEC TLS renewals will be run with a built in hook. \
@ -150,7 +150,7 @@ The hook files will end up in $SCRIPTS/deSEC, please don't touch that folder unl
You can read more about it here: https://github.com/desec-io/desec-certbot-hook
Please remember that you still need to open the port you choose to make your server publicly available.
You can read more about that here: https://goo.gl/iUGE2U"
You can read more about that here: http://shortio.hanssonit.se/ffOQOXS6Kh"
# Run the TLS script
run_script LETS_ENC activate-tls

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="deSEC Subdomain"
@ -29,11 +29,16 @@ fi
while :
do
# Ask for subdomain
SUBDOMAIN=$(input_box_flow "Please enter the subdomain you want to add or delete, e.g: yoursubdomain")
# Check if subdomain contains a dot
if echo "$SUBDOMAIN" | grep '\.' >/dev/null 2>&1
if [ -z "$SUBDOMAIN" ]
then
msg_box "Please *only* enter the subomain name like 'yoursubdomain', not 'yoursubdomain.yourdomain.io'."
SUBDOMAIN=$(input_box_flow "Please enter the subdomain you want to add or delete, e.g: yoursubdomain")
# Check if subdomain contains a dot
if echo "$SUBDOMAIN" | grep '\.' >/dev/null 2>&1
then
msg_box "Please *only* enter the subomain name like 'yoursubdomain', not 'yoursubdomain.yourdomain.io'."
else
break
fi
else
break
fi

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="deSEC Removal"

View File

@ -1,6 +1,7 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Based on: https://raw.githubusercontent.com/nextcloud-gmbh/mtime_fixer_tool_kit/main/solvable_files.sh
true
SCRIPT_NAME="Fix 'Could not update metadata due to invalid modified time'."
@ -24,9 +25,6 @@ msg_box "OK, let's go!
Please note, this script might take several hours to run, depening on the size of your datadir. Don't abort it!"
# Download the script
curl_to_dir https://raw.githubusercontent.com/nextcloud-gmbh/mtime_fixer_tool_kit/master solvable_files.sh $NCPATH
# Run all the needed variables
ncdb
@ -38,8 +36,7 @@ fi
# Run the script and remove it
print_text_in_color "$ICyan" "Running the scan and fixing broken files..."
bash "$NCPATH"/solvable_files.sh "$NCDATA" "$NCDBTYPE" "$NCDBHOST" "$NCDBUSER" "$NCDBPASS" "$NCDB" fix use_birthday verbose
rm "$NCPATH"/solvable_files.sh
run_script ADDONS solvable_files
# Scan all files
nextcloud_occ files:scan --all

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Locales"
@ -30,6 +30,14 @@ then
elif [ "$KEYBOARD_LAYOUT" = "de" ]
then
sudo locale-gen "de_DE.UTF-8" && sudo dpkg-reconfigure --frontend=noninteractive locales
# Set a better mirror (only for German servers)
if grep -r archive.ubuntu.com /etc/apt/sources.list
then
sed -i "s|http://archive.ubuntu.com|https://ftp.uni-stuttgart.de|g" /etc/apt/sources.list
elif grep -r de.archive.ubuntu.com /etc/apt/sources.list
then
sed -i "s|http://de.archive.ubuntu.com|https://ftp.uni-stuttgart.de|g" /etc/apt/sources.list
fi
elif [ "$KEYBOARD_LAYOUT" = "fr" ]
then
sudo locale-gen "fr_FR.UTF-8" && sudo dpkg-reconfigure --frontend=noninteractive locales

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Locate Mirror"

28
addons/notify-crontab.sh Normal file
View File

@ -0,0 +1,28 @@
#!/bin/bash
true
SCRIPT_NAME="Notify Crontab Script"
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode
# Must be root
root_check
MOUNT_ID="$1"
if nextcloud_occ files_external:list | grep "$MOUNT_ID"
then
# Start the iNotify for this external storage
countdown "iNotify starts in 120 seconds" "120" >> "$VMLOGS"/files_inotify.log
nextcloud_occ files_external:notify -v "$MOUNT_ID" >> "$VMLOGS"/files_inotify.log
else
notify_admin_gui \
"Files iNotify Failed!" \
"There seems to be an issue with iNofity. Please check the Mount ID (nextcloud_occ files_external:list) and change the crontab accordingly."
fi

View File

@ -4,7 +4,7 @@ SCRIPT_NAME="Redis Server Ubuntu"
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Check for errors + debug code and abort if something isn't right
# 1 = ON
@ -16,9 +16,9 @@ debug_mode
root_check
# Check Ubuntu version
if ! version 18.04 "$DISTRO" 22.04.10
if ! version 18.04 "$DISTRO" 24.04.10
then
msg_box "Your current Ubuntu version is $DISTRO but must be between 18.04 - 22.04.10 to run this script."
msg_box "Your current Ubuntu version is $DISTRO but must be between 18.04 - 24.04.10 to run this script."
msg_box "Please contact us to get support for upgrading your server:
https://www.hanssonit.se/#contact
https://shop.hanssonit.se/"
@ -34,15 +34,40 @@ fi
# Check the current PHPVER
check_php
if is_this_installed redis-server
then
print_text_in_color "$ICyan" "Removing old Redis server installation..."
if nextcloud_occ_no_check -V
then
# Remove the config from Nextclouds config.php
nextcloud_occ config:system:delete memcache.local
nextcloud_occ config:system:delete memcache.distributed
nextcloud_occ config:system:delete filelocking.enabled
nextcloud_occ config:system:delete memcache.locking
nextcloud_occ config:system:delete redis password
nextcloud_occ config:system:delete redis
# Check that everything is functioning
nextcloud_occ -V
fi
if pecl list | grep -q redis
then
pecl uninstall redis
fi
apt-get purge redis-server -y
apt-get autoremove -y
apt-get autoclean
fi
# Install Redis
print_text_in_color "$ICyan" "Installing Redis server..."
install_if_not php"$PHPVER"-dev
pecl channel-update pecl.php.net
if ! yes no | pecl install -Z redis
then
msg_box "PHP module installation failed"
msg_box "Redis PHP module installation failed"
exit 1
else
printf "${IGreen}\nPHP module installation OK!${Color_Off}\n"
print_text_in_color "$IGreen" "Redis PHP module installation OK!"
fi
if [ ! -f $PHP_MODS_DIR/redis.ini ]
then
@ -56,26 +81,6 @@ then
fi
install_if_not redis-server
# Prepare for adding redis configuration
sed -i "s|);||g" $NCPATH/config/config.php
# Add the needed config to Nextclouds config.php
cat <<ADD_TO_CONFIG >> $NCPATH/config/config.php
'memcache.local' => '\\OC\\Memcache\\Redis',
'filelocking.enabled' => true,
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' =>
array (
'host' => '$REDIS_SOCK',
'port' => 0,
'timeout' => 0.5,
'dbindex' => 0,
'password' => '$REDIS_PASS',
),
);
ADD_TO_CONFIG
## Redis performance tweaks ##
if ! grep -Fxq "vm.overcommit_memory = 1" /etc/sysctl.conf
then
@ -95,19 +100,31 @@ fi
# sysctl -w net.core.somaxconn=512
# echo "net.core.somaxconn = 512" >> /etc/sysctl.conf
#fi
# Set redis options
sed -i "s|# unixsocket .*|unixsocket $REDIS_SOCK|g" $REDIS_CONF
sed -i "s|# unixsocketperm .*|unixsocketperm 777|g" $REDIS_CONF
sed -i "s|^port.*|port 0|" $REDIS_CONF
sed -i "s|# requirepass .*|requirepass $REDIS_PASS|g" $REDIS_CONF
sed -i 's|# rename-command CONFIG ""|rename-command CONFIG ""|' $REDIS_CONF
redis-cli SHUTDOWN
systemctl restart redis-server
# Add the needed config to Nextclouds config.php
# Redis needs to be set first for the connection, else it will fail.
nextcloud_occ config:system:set redis host --value="$REDIS_SOCK"
nextcloud_occ config:system:set redis port --value=0
nextcloud_occ config:system:set redis dbindex --value=0
nextcloud_occ config:system:set redis timeout --value=0.5
nextcloud_occ config:system:set memcache.local --value='\OC\Memcache\Redis'
nextcloud_occ config:system:set filelocking.enabled --value='true'
nextcloud_occ config:system:set memcache.distributed --value='\OC\Memcache\Redis'
nextcloud_occ config:system:set memcache.locking --value='\OC\Memcache\Redis'
# Secure Redis
chown redis:root /etc/redis/redis.conf
chmod 600 /etc/redis/redis.conf
apt-get update -q4 & spinner_loading
apt-get autoremove -y
apt-get autoclean
exit
# Set password
sed -i "s|# requirepass .*|requirepass $REDIS_PASS|g" $REDIS_CONF
nextcloud_occ config:system:set redis password --value="$REDIS_PASS"
systemctl restart redis-server

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Extra Security"

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true
@ -148,6 +148,17 @@ fi
# Enter the recipient
RECIPIENT=$(input_box_flow "Please enter the recipient email address that shall receive all mails.\nE.g. recipient@mail.com")
# Check if the server use self-signed certificates
if yesno_box_no "Does the SMTP-server use self-signed certificates?"
then
SELF_SIGNED_CERT=yes
nextcloud_occ config:system:set mail_smtpstreamoptions ssl allow_self_signed --value=true --type=boolean
nextcloud_occ config:system:set mail_smtpstreamoptions ssl verify_peer --value=false --type=boolean
nextcloud_occ config:system:set mail_smtpstreamoptions ssl verify_peer_name --value=false --type=boolean
else
SELF_SIGNED_CERT=no
fi
# Present what we gathered, if everything okay, write to files
msg_box "These are the settings that will be used. Please check that everything seems correct.
@ -156,11 +167,13 @@ Encryption=$PROTOCOL
SMTP Port=$SMTP_PORT
SMTP Username=$MAIL_USERNAME
SMTP Password=$MAIL_PASSWORD
Recipient=$RECIPIENT"
Recipient=$RECIPIENT
Self-signed TLS/SSL certificate=$SELF_SIGNED_CERT"
# Ask if everything is okay
if ! yesno_box_yes "Does everything look correct?"
then
msg_box "OK, please start over by running this script again."
exit
fi

99
addons/solvable_files.sh Normal file
View File

@ -0,0 +1,99 @@
#!/bin/bash
# Based on: https://raw.githubusercontent.com/nextcloud-gmbh/mtime_fixer_tool_kit/main/solvable_files.sh
true
SCRIPT_NAME="Fix 'Could not update metadata due to invalid modified time'."
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
# Get needed variables for database management
ncdb
# Check if root
root_check
#2023-05-04 Customized the original script to fit the Nextcloud VM users setup. Also fixed some shellcheck issues.
data_dir="$(realpath "$NCDATA")"
export data_dir
export db_type=$NCDBTYPE
export db_host=$NCDBHOST
export db_user=$NCDBUSER
export db_pwd=$NCDBPASS
export db_name=$NCDB
export action=fix
export scan_action=noscan
export use_birthday=use_birthday
export verbose=verbose
# In case you're using a different database table prefix, set this to your config's `dbtableprefix` value.
export dbtableprefix="oc_"
# 1. Return if fs mtime <= 86400
# 2. Compute username from filepath
# 3. Query mtime from the database with the filename and the username
# 4. Return if mtime_on_fs != mtime_in_db
# 5. Correct the fs mtime with touch (optionally using the files change date/timestamp)
correct_mtime() {
filepath=$NCDATA
if [ ! -e "$filepath" ]
then
echo "File or directory $filepath does not exist. Skipping."
return
fi
relative_filepath="${filepath/#$data_dir\//}"
mtime_on_fs="$(stat -c '%Y' "$filepath")"
username=$relative_filepath
while [ "$(dirname "$username")" != "." ]
do
username=$(dirname "$username")
done
relative_filepath_without_username="${relative_filepath/#$username\//}"
base64_relative_filepath="$(printf '%s' "$relative_filepath" | base64)"
base64_relative_filepath_without_username="$(printf '%s' "$relative_filepath_without_username" | base64)"
if [ "$username" == "__groupfolders" ]
then
mtime_in_db=$(sudo -u postgres psql nextcloud_db --tuples-only --no-align -c "SELECT mtime FROM ${dbtableprefix}storages JOIN ${dbtableprefix}filecache ON ${dbtableprefix}storages.numeric_id = ${dbtableprefix}filecache.storage WHERE ${dbtableprefix}storages.id='local::$data_dir/' AND ${dbtableprefix}filecache.path=CONVERT_FROM(DECODE('$base64_relative_filepath', 'base64'), 'UTF-8')")
else
mtime_in_db=$(sudo -u postgres psql nextcloud_db --tuples-only --no-align -c "SELECT mtime FROM ${dbtableprefix}storages JOIN ${dbtableprefix}filecache ON ${dbtableprefix}storages.numeric_id = ${dbtableprefix}filecache.storage WHERE ${dbtableprefix}storages.id='home::$username' AND ${dbtableprefix}filecache.path=CONVERT_FROM(DECODE('$base64_relative_filepath_without_username', 'base64'), 'UTF-8')")
fi
if [ "$mtime_in_db" == "" ]
then
echo "No mtime in database. File not indexed. Skipping $filepath"
return
fi
if [ "$mtime_in_db" != "$mtime_on_fs" ]
then
echo "mtime in database do not match fs mtime (fs: $mtime_on_fs, db: $mtime_in_db). Skipping $filepath"
return
fi
if [ -e "$filepath" ]
then
newdate=$(stat -c "%w" "$filepath")
if [ "$newdate" == "-" ]
then
newdate=$(stat -c "%z" "$filepath")
touch -c -d "$newdate" "$filepath"
else
touch -c "$filepath"
fi
echo mtime for "$filepath" updated to "$(stat -c "%y" "$filepath")"
elif [ ! -e "$filepath" ]
then
echo "File or directory $filepath does not exist. Skipping."
return
fi
}
export -f correct_mtime
find "$data_dir" -type f ! -newermt "@86400" -exec bash -c 'correct_mtime "$0"' {} \;

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Adminer"
@ -28,6 +28,7 @@ else
# Removal
check_external_ip # Check that the script can see the external IP (apache fails otherwise)
a2disconf adminer.conf
restart_webserver
rm -f $ADMINER_CONF
rm -rf $ADMINERDIR
check_command apt-get purge adminer -y
@ -52,11 +53,11 @@ a2enmod ssl
apt-get update -q4 & spinner_loading
install_if_not adminer
curl_to_dir "http://www.adminer.org" "latest.php" "$ADMINERDIR"
curl_to_dir "https://raw.githubusercontent.com/Niyko/Hydra-Dark-Theme-for-Adminer/master" "adminer.css" "$ADMINERDIR"
curl_to_dir "https://raw.githubusercontent.com/Niyko/Hydra-Dark-Theme-for-Adminer/main" "adminer.css" "$ADMINERDIR"
ln -s "$ADMINERDIR"/latest.php "$ADMINERDIR"/adminer.php
# Only add TLS 1.3 on Ubuntu later than 20.04
if version 20.04 "$DISTRO" 22.04.10
# Only add TLS 1.3 on Ubuntu later than 22.04
if version 22.04 "$DISTRO" 24.04.10
then
TLS13="+TLSv1.3"
fi
@ -129,6 +130,11 @@ then
The script will exit."
exit 1
else
# Allow local access:
check_command sed -i "s|local all postgres peer|local all postgres md5|g" /etc/postgresql/*/main/pg_hba.conf
restart_webserver
msg_box "Adminer was successfully installed and can be reached here:
https://$ADDRESS:9443
@ -146,5 +152,3 @@ $(grep dbname $NCPATH/config/config.php)
In case you try to access Adminer and get 'Forbidden' you need to change the IP in:
$ADMINER_CONF"
fi
exit

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Bitwarden Mail Configuration"

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Bitwarden Registration"

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="BPYTOP"

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="ClamAV"
@ -101,7 +101,7 @@ install_and_enable_app files_antivirus
nextcloud_occ config:app:set files_antivirus av_mode --value="socket"
nextcloud_occ config:app:set files_antivirus av_socket --value="/var/run/clamav/clamd.ctl"
nextcloud_occ config:app:set files_antivirus av_stream_max_length --value="1048576000"
nextcloud_occ config:app:set files_antivirus av_max_file_size --value="-1"
nextcloud_occ config:app:set files_antivirus av_max_file_size --value="1048576000"
nextcloud_occ config:app:set files_antivirus av_infected_action --value="only_log"
# Create av notification script
@ -198,7 +198,7 @@ esac
cat << CLAMAV_REPORT > "$SCRIPTS"/clamav-fullscan.sh
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
source /var/scripts/fetch_lib.sh
@ -246,6 +246,11 @@ fi
INFECTED_FILES_LOG="\$(sed -n '/----------- SCAN SUMMARY -----------/,\$p' $VMLOGS/clamav-fullscan.log)"
INFECTED_FILES="\$(grep 'FOUND$' $VMLOGS/clamav-fullscan.log)"
if [ -z "$INFECTED_FILES" ]
then
INFECTED_FILES="No infected files found"
fi
# Send notification
if ! send_mail "Your weekly full-scan ClamAV report" "\$INFECTED_FILES_LOG\n
\$INFECTED_FILES"

View File

@ -1,12 +1,12 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Collabora (Docker)"
SCRIPT_EXPLAINER="This script will install the Collabora Office Server bundled with Docker"
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh)
source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/main/lib.sh)
# To work with https://github.com/nextcloud/richdocuments/pull/2235
# Check for errors + debug code and abort if something isn't right
@ -57,7 +57,7 @@ NCDOMAIN=$(nextcloud_occ_no_check config:system:get overwrite.cli.url | sed 's|h
# Curl the library another time to get the correct https_conf
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh)
source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/main/lib.sh)
# Get all needed variables from the library
nc_update
@ -135,8 +135,8 @@ a2enmod proxy_http
a2enmod ssl
a2enmod headers
# Only add TLS 1.3 on Ubuntu later than 20.04
if version 20.04 "$DISTRO" 22.04.10
# Only add TLS 1.3 on Ubuntu later than 22.04
if version 22.04 "$DISTRO" 24.04.10
then
TLS13="+TLSv1.3"
fi

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Collabora (Integrated)"

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true

View File

@ -1,11 +1,9 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Face Recognition"
SCRIPT_EXPLAINER="The $SCRIPT_NAME app allows to automatically scan for faces inside your Nextcloud."
SCRIPT_NAME="Redirect to Recognize"
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
@ -15,170 +13,10 @@ source /var/scripts/fetch_lib.sh
DEBUG=0
debug_mode
# Check if root
# Must be root
root_check
# Check compatibility
check_distro_version
check_php
if [[ "$PHPVER" != "8.1" ]] && [[ "$PHPVER" != "7.4" ]]
then
msg_box "Currently only PHP 7.4 and PHP 8.1 is supported by this script."
exit 1
fi
# This is because we move the old script to old, and replaced it with this instead.
run_script APP recognize
# Encryption may not be enabled
if is_app_enabled encryption || is_app_enabled end_to_end_encryption
then
msg_box "It seems like you have encryption enabled which is unsupported by the $SCRIPT_NAME app!"
exit 1
fi
# Compatible with NC21 and above
lowest_compatible_nc 21
# Hardware requirements
# https://github.com/matiasdelellis/facerecognition/wiki/Requirements-and-Limitations#hardware-requirements
# https://github.com/matiasdelellis/facerecognition/wiki/Models#model-3
ram_check 2
cpu_check 2
# Check if facerecognition is already installed
if ! is_app_installed facerecognition && ! is_this_installed php7.4-pdlib && ! is_this_installed php8.1-pdli
then
# Ask for installing
install_popup "$SCRIPT_NAME"
else
# Ask for removal or reinstallation
reinstall_remove_menu "$SCRIPT_NAME"
# Removal
if is_this_installed php7.4-pdlib
then
apt-get purge php7.4-pdlib -y
rm -f /etc/apt/sources.list.d/20-pdlib.list
apt-get update -q4 & spinner_loading
apt-get autoremove -y
rm -f /etc/apt/trusted.gpg.d/facerecognition.gpg
elif is_this_installed php8.1-pdlib
then
apt-get purge php8.1-pdlib -y
rm -f /etc/apt/sources.list.d/facerecognition-pdlib.list
apt-get update -q4 & spinner_loading
apt-get autoremove -y
rm -f /etc/apt/keyrings/repo.gpg.key
fi
crontab -u www-data -l | grep -v "face_background_job.log" | crontab -u www-data -
crontab -u www-data -l | grep -v "face:background_job" | crontab -u www-data -
if is_app_enabled facerecognition
then
if yesno_box_no "Do you want to reset all face data?
The background scanner will then have to rescan all files for faces when you install the app again."
then
echo y | nextcloud_occ face:reset --all
fi
nextcloud_occ config:app:set facerecognition handle_external_files --value false
nextcloud_occ config:app:set facerecognition handle_group_files --value false
nextcloud_occ config:app:set facerecognition handle_shared_files --value false
fi
if is_app_installed facerecognition
then
nextcloud_occ app:remove facerecognition
fi
rm -f "$VMLOGS"/face_background_job.log
# Show successful uninstall if applicable
removal_popup "$SCRIPT_NAME"
fi
# Inform about dependencies
msg_box "Please note that the $SCRIPT_NAME app needs an additional PHP dependency \
to work which will need to be installed from an external repository.
This can set your server under risk."
if ! yesno_box_yes "Do you want to install the required dependency?
If you choose 'No', the installation will be aborted."
then
exit 1
fi
# Install requirements
if version 20.04 "$DISTRO" 20.04.10
then
# https://github.com/matiasdelellis/facerecognition/wiki/PDlib-Installation#ubuntu-focal
add_trusted_key_and_repo "repo.gpg.key" \
"https://repo.delellis.com.ar" \
"https://repo.delellis.com.ar" \
"focal focal" \
"facerecognition-pdlib.list"
install_if_not php7.4-pdlib
elif version 22.04 "$DISTRO" 22.04.10
then
# https://github.com/matiasdelellis/facerecognition/wiki/PDlib-Installation#ubuntu-jammy
add_trusted_key_and_repo "repo.gpg.key" \
"https://repo.delellis.com.ar" \
"https://repo.delellis.com.ar" \
"$CODENAME $CODENAME" \
"facerecognition-pdlib.list"
install_if_not php8.1-pdlib
fi
# Install the app
install_and_enable_app facerecognition
if ! is_app_enabled facerecognition
then
msg_box "Could not install the $SCRIPT_NAME app. Cannot proceed."
exit 1
fi
# Set up face model and max memory usage
# https://github.com/matiasdelellis/facerecognition/wiki/Models#comparison
# https://github.com/matiasdelellis/facerecognition/tree/master#initial-setup
nextcloud_occ face:setup --memory 2GB
nextcloud_occ face:setup --model 3
# Set temporary files size
nextcloud_occ config:app:set facerecognition analysis_image_area --value="4320000"
# Additional settings
# https://github.com/matiasdelellis/facerecognition/wiki/Settings#hidden-settings
if yesno_box_no "Do you want the $SCRIPT_NAME app to scan external storages?
This is currently highly inefficient since it will scan all external storges multiple times (once for each user) \
and can produce a lot of network traffic.
(The scan will need to access all files, also if they are stored externally.)
Hence, you should only enable this option if you are only using local external storage \
or if you don't use the external storage app at all."
then
nextcloud_occ config:app:set facerecognition handle_external_files --value true
fi
if yesno_box_no "Do you want the $SCRIPT_NAME app to scan groupfolders?
This is currently highly inefficient since it will scan all groupfolders multiple times (once for each user)."
then
nextcloud_occ config:app:set facerecognition handle_group_files --value true
fi
if yesno_box_no "Do you want the $SCRIPT_NAME app to scan shared folders/files?
This is currently highly inefficient since it will scan all shared folders/files multiple times (once for each user)."
then
nextcloud_occ config:app:set facerecognition handle_shared_files --value true
fi
# Allow the background scanner to scan the files for each user again and enable face scanning for all users
# https://github.com/matiasdelellis/facerecognition/wiki/Settings#notes
NC_USERS_NEW=$(nextcloud_occ_no_check user:list | sed 's|^ - ||g' | sed 's|:.*||')
mapfile -t NC_USERS_NEW <<< "$NC_USERS_NEW"
for user in "${NC_USERS_NEW[@]}"
do
nextcloud_occ user:setting "$user" facerecognition full_image_scan_done false
nextcloud_occ user:setting "$user" facerecognition enabled true
done
# Make sure that the logfile doesn't get crazy big.
crontab -u www-data -l | grep -v "face_background_job.log" | crontab -u www-data -
crontab -u www-data -l | { cat; echo "@daily rm -f $VMLOGS/face_background_job.log"; } | crontab -u www-data -
# Schedule background scan
# https://github.com/matiasdelellis/facerecognition/wiki/Schedule-Background-Task#cron
crontab -u www-data -l | grep -v "face:background_job" | crontab -u www-data -
crontab -u www-data -l | { cat; echo "*/30 * * * * php -f $NCPATH/occ \
face:background_job -t 900 --defer-clustering >> $VMLOGS/face_background_job.log"; } | crontab -u www-data -
msg_box "Congratulations, $SCRIPT_NAME was successfully installed!
You just need to wait now and let the background job do its work.
After a while, you should see more and more faces that were found in your Nextcloud."
exit

View File

@ -1,7 +1,7 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# Inspired by https://github.com/nextcloud/nextcloudpi/blob/master/etc/nextcloudpi-config.d/fail2ban.sh
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Inspired by https://github.com/nextcloud/nextcloudpi/blob/main/etc/nextcloudpi-config.d/fail2ban.sh
true
SCRIPT_NAME="Fail2ban"
@ -118,6 +118,12 @@ install_if_not iptables
# remove ncdata, else it will be used
rm -f "$NCDATA"/nextcloud.log
# Add auth.log just in case it's not created
if ! [ -f /var/log/auth.log ]
then
touch /var/log/auth.log
fi
# time to ban an IP that exceeded attempts
BANTIME_=1209600
# cooldown time for incorrect passwords
@ -215,7 +221,7 @@ fi
# Create Fail2ban report script
cat << FAIL2BAN_REPORT > "$SCRIPTS/daily_fail2ban_report.sh"
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Look for ip addresses
BANNED_IPS=\$(grep "Ban " /var/log/fail2ban.log | grep "\$(date +%Y-%m-%d)" \

View File

@ -1,19 +1,18 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# SwITNet Ltd © - 2022, https://switnet.net/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# SwITNet Ltd © - 2024, https://switnet.net/
true
SCRIPT_NAME="Full Text Search"
SCRIPT_EXPLAINER="Full Text Search provides OpenSearch for Nextcloud, which makes it possible to search for text inside files."
SCRIPT_EXPLAINER="Full Text Search provides ElastichSearch for Nextcloud, which makes it possible to search for text inside files."
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
# Get all needed variables from the library
ncdb
nc_update
opensearch_install
ncdomain
ncdb
fulltextsearch_install
# Check for errors + debug code and abort if something isn't right
# 1 = ON
@ -24,24 +23,41 @@ debug_mode
# Must be root
root_check
# Nextcloud 21 is required.
lowest_compatible_nc 21
# Nextcloud 26 is required.
lowest_compatible_nc 26
# Check if Full Text Search is already installed
if ! does_this_docker_exist "$nc_fts" && ! does_this_docker_exist "$opens_fts" && ! is_app_installed fulltextsearch
if ! does_this_docker_exist docker.elastic.co/elasticsearch/elasticsearch && ! is_app_installed fulltextsearch
then
# Ask for installing
install_popup "$SCRIPT_NAME"
else
# Ask for removal or reinstallation
reinstall_remove_menu "$SCRIPT_NAME"
# Remove live service
systemctl stop "$FULLTEXTSEARCH_SERVICE"
systemctl disable "$FULLTEXTSEARCH_SERVICE"
rm -f "$FULLTEXTSEARCH_SERVICE"
# Reset Full Text Search to be able to index again, and also remove the app to be able to install it again
nextcloud_occ_no_check fulltextsearch:reset
nextcloud_occ_no_check fulltextsearch:stop
install_if_not expect
REMOVE_FTS_INDEX=$(expect -c "
set timeout 3
spawn sudo -u www-data php $NCPATH/occ fulltextsearch:reset
expect \"Do you really want to reset your indexed documents ? (y/N)\"
send \"y\r\"
expect \"Please confirm this destructive operation by typing 'reset ALL ALL':\"
send \"reset ALL ALL\r\"
expect eof
")
echo "$REMOVE_FTS_INDEX"
apt -y purge expect
# Drop database tables
sudo -Hiu postgres psql "$NCDB" -c "DROP TABLE oc_fulltextsearch_ticks;"
sudo -Hiu postgres psql "$NCDB" -c "DROP TABLE oc_fulltextsearch_index;"
sudo -Hiu postgres psql "$NCDB" -c "DELETE FROM oc_migrations WHERE app='fulltextsearch';"
sudo -Hiu postgres psql "$NCDB" -c "DELETE FROM oc_preferences WHERE appid='fulltextsearch';"
# Remove apps
APPS=(fulltextsearch fulltextsearch_elasticsearch files_fulltextsearch)
for app in "${APPS[@]}"
do
@ -50,20 +66,26 @@ else
nextcloud_occ app:remove "$app"
fi
done
# Removal Docker image
docker_prune_this "$nc_fts"
docker_prune_volume "esdata"
docker-compose_down "$OPNSDIR/docker-compose.yml"
# Remove configuration files
rm -rf "$RORDIR"
rm -rf "$OPNSDIR"
# Removal Elastichsearch Docker image
docker_prune_this "docker.elastic.co/elasticsearch/elasticsearch"
if docker network ls | grep "$FULLTEXTSEARCH_IMAGE_NAME"-network
then
docker network rm "$FULLTEXTSEARCH_IMAGE_NAME"-network
fi
rm -rf "$FULLTEXTSEARCH_DIR"
# Show successful uninstall if applicable
removal_popup "$SCRIPT_NAME"
apt-get purge docker-compose -y
fi
# Test RAM size (4GB min) + CPUs (min 2)
ram_check 4 FullTextSearch
# Check if version tag is available
if [ -z "$FULLTEXTSEARCH_IMAGE_NAME_LATEST_TAG" ]
then
msg_box "The Elasticsearch version tag is not available, please report this to $ISSUES"
exit 1
fi
# Test RAM size (6GB min) + CPUs (min 2)
ram_check 6 FullTextSearch
cpu_check 2 FullTextSearch
# Make sure there is an Nextcloud installation
@ -89,6 +111,23 @@ then
deluser --group solr
fi
# Removal Opensearch Docker image
if does_this_docker_exist "$nc_fts" || does_this_docker_exist "$opens_fts"
then
docker_prune_this "$nc_fts"
docker_prune_this "$opens_fts"
docker_prune_volume "esdata"
nextcloud_occ fulltextsearch:migration:24
if docker network ls | grep opensearch_fts_os-net
then
docker network rm opensearch_fts_os-net
fi
# Remove configuration files
rm -rf "$RORDIR"
rm -rf "$OPNSDIR"
apt-get purge docker-compose -y
fi
# Check if the app is compatible with the current Nextcloud version
if ! install_and_enable_app fulltextsearch
then
@ -97,98 +136,23 @@ fi
# Check & install docker
install_docker
install_if_not docker-compose
set_max_count
mkdir -p "$OPNSDIR"
docker pull "$opens_fts"
BCRYPT_HASH="$(docker run --rm -it $opens_fts \
bash -c "plugins/opensearch-security/tools/hash.sh -p $OPNSREST | tr -d ':\n' ")"
# Create configurations YML
# opensearch.yml
cat << YML_OPENSEARCH > $OPNSDIR/opensearch.yml
cluster.name: docker-cluster
# Avoid Docker assigning IP.
network.host: 0.0.0.0
# Declaring single node cluster.
discovery.type: single-node
######## Start Security Configuration ########
plugins.security.ssl.transport.pemcert_filepath: node.pem
plugins.security.ssl.transport.pemkey_filepath: node-key.pem
plugins.security.ssl.transport.pemtrustedcas_filepath: root-ca.pem
plugins.security.ssl.transport.enforce_hostname_verification: false
# Disable ssl at REST as Fulltextsearch can't accept self-signed CA certs.
plugins.security.ssl.http.enabled: false
#plugins.security.ssl.http.pemcert_filepath: node.pem
#plugins.security.ssl.http.pemkey_filepath: node-key.pem
#plugins.security.ssl.http.pemtrustedcas_filepath: root-ca.pem
plugins.security.allow_unsafe_democertificates: false
plugins.security.allow_default_init_securityindex: true
plugins.security.authcz.admin_dn:
- 'CN=admin,OU=FTS,O=OPENSEARCH,L=VM,ST=NEXTCLOUD,C=CA'
plugins.security.nodes_dn:
- 'CN=${NCDOMAIN},OU=FTS,O=OPENSEARCH,L=VM,ST=NEXTCLOUD,C=CA'
plugins.security.audit.type: internal_opensearch
plugins.security.enable_snapshot_restore_privilege: true
plugins.security.check_snapshot_restore_write_privileges: true
plugins.security.restapi.roles_enabled: ["all_access", "security_rest_api_access"]
plugins.security.system_indices.enabled: true
plugins.security.system_indices.indices: [".opendistro-alerting-config", ".opendistro-alerting-alert*", ".opendistro-anomaly-results*", ".opendistro-anomaly-detector*", ".opendistro-anomaly-checkpoints", ".opendistro-anomaly-detection-state", ".opendistro-reports-*", ".opendistro-notifications-*", ".opendistro-notebooks", ".opensearch-observability", ".opendistro-asynchronous-search-response*", ".replication-metadata-store"]
node.max_local_storage_nodes: 1
######## End Security Configuration ########
YML_OPENSEARCH
# internal_users.yml
cat << YML_INTERNAL_USERS > $OPNSDIR/internal_users.yml
_meta:
type: "internalusers"
config_version: 2
${INDEX_USER}:
hash: "${BCRYPT_HASH}"
reserved: true
backend_roles:
- "admin"
description: "admin user for fts at opensearch."
YML_INTERNAL_USERS
# roles_mapping.yml
cat << YML_ROLES_MAPPING > $OPNSDIR/roles_mapping.yml
_meta:
type: "rolesmapping"
config_version: 2
# Roles mapping
all_access:
reserved: false
backend_roles:
- "admin"
description: "Maps admin to all_access"
YML_ROLES_MAPPING
# docker-compose.yml
cat << YML_DOCKER_COMPOSE > $OPNSDIR/docker-compose.yml
version: '3'
mkdir -p "$FULLTEXTSEARCH_DIR"
cat << YML_DOCKER_COMPOSE > "$FULLTEXTSEARCH_DIR/docker-compose.yaml"
services:
fts_os-node:
image: opensearchproject/opensearch:1
container_name: fts_os-node
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:$FULLTEXTSEARCH_IMAGE_NAME_LATEST_TAG
container_name: $FULLTEXTSEARCH_IMAGE_NAME
restart: always
command:
- sh
- -c
- "/usr/share/opensearch/bin/opensearch-plugin list | grep -q ingest-attachment \
|| /usr/share/opensearch/bin/opensearch-plugin install --batch ingest-attachment ;
./opensearch-docker-entrypoint.sh"
ports:
- 127.0.0.1:9200:9200
environment:
- cluster.name=fts_os-cluster
- node.name=fts_os-node
- bootstrap.memory_lock=true
- "OPENSEARCH_JAVA_OPTS=-Xms1024M -Xmx1024M"
- discovery.type=single-node
- xpack.security.enabled=true
- xpack.security.http.ssl.enabled=false
- "ES_JAVA_OPTS=-Xms2g -Xmx2g"
- ELASTIC_PASSWORD=$ELASTIC_USER_PASSWORD
ulimits:
memlock:
soft: -1
@ -196,87 +160,81 @@ services:
nofile:
soft: 65536
hard: 65536
volumes:
- fts_os-data:/usr/share/opensearch/data
- $OPNSDIR/root-ca.pem:/usr/share/opensearch/config/root-ca.pem
- $OPNSDIR/node.pem:/usr/share/opensearch/config/node.pem
- $OPNSDIR/node-key.pem:/usr/share/opensearch/config/node-key.pem
- $OPNSDIR/admin.pem:/usr/share/opensearch/config/admin.pem
- $OPNSDIR/admin-key.pem:/usr/share/opensearch/config/admin-key.pem
- $OPNSDIR/opensearch.yml:/usr/share/opensearch/config/opensearch.yml
- $OPNSDIR/internal_users.yml:/usr/share/opensearch/plugins/opensearch-security/securityconfig/internal_users.yml
- $OPNSDIR/roles_mapping.yml:/usr/share/opensearch/plugins/opensearch-security/securityconfig/roles_mapping.yml
ports:
- 127.0.0.1:9200:9200
- 127.0.0.1:9600:9600 # Performance Analyzer [1]
networks:
- fts_os-net
- $FULLTEXTSEARCH_IMAGE_NAME-network
volumes:
fts_os-data:
$FULLTEXTSEARCH_IMAGE_NAME-data:
networks:
fts_os-net:
#[1] https://github.com/opensearch-project/performance-analyzer
$FULLTEXTSEARCH_IMAGE_NAME-network:
YML_DOCKER_COMPOSE
# Prepare certs
create_certs "$NCDOMAIN"
# Start the docker image
cd "$FULLTEXTSEARCH_DIR"
docker compose up -d
# Set permissions
chmod 744 -R $OPNSDIR
# Check if online
until curl -sS "http://elastic:$ELASTIC_USER_PASSWORD@localhost:9200/_cat/health?h=status" | grep -q "green\|yellow"
do
countdown "Waiting for ElasticSearch to come online, please don't abort..." "10"
done
# Launch docker-compose
cd $OPNSDIR
docker-compose up -d
# Check logs
print_text_in_color "$ICyan" "Checking logs..."
docker logs "$FULLTEXTSEARCH_IMAGE_NAME"
# Wait for bootstrapping
if [ "$(nproc)" -gt 2 ]
then
countdown "Waiting for Docker bootstrapping..." "60"
else
countdown "Waiting for Docker bootstrapping..." "120"
fi
# Make sure password setup is enforced.
docker-compose exec fts_os-node \
bash -c "cd \
plugins/opensearch-security/tools/ && \
bash securityadmin.sh -f \
../securityconfig/internal_users.yml \
-t internalusers \
-icl \
-nhnv \
-cacert ../../../config/root-ca.pem \
-cert ../../../config/admin.pem \
-key ../../../config/admin-key.pem && \
chmod 0600 ../../../config/root-ca.pem ../../../config/admin.pem ../../../config/admin-key.pem"
docker logs $fts_node
countdown "Waiting a bit more before testing..." "10"
# Get Full Text Search app for nextcloud
install_and_enable_app fulltextsearch
install_and_enable_app fulltextsearch_elasticsearch
install_and_enable_app files_fulltextsearch
chown -R www-data:www-data $NC_APPS_PATH
chown -R www-data:www-data "$NC_APPS_PATH"
# Final setup
nextcloud_occ fulltextsearch:configure '{"search_platform":"OCA\\FullTextSearch_Elasticsearch\\Platform\\ElasticSearchPlatform"}'
nextcloud_occ fulltextsearch_elasticsearch:configure "{\"elastic_host\":\"http://${INDEX_USER}:${OPNSREST}@localhost:9200\",\"elastic_index\":\"${INDEX_USER}-index\"}"
nextcloud_occ fulltextsearch_elasticsearch:configure "{\"elastic_host\":\"http://elastic:$ELASTIC_USER_PASSWORD@localhost:9200\",\"elastic_index\":\"${NEXTCLOUD_INDEX}\"}"
nextcloud_occ files_fulltextsearch:configure "{\"files_pdf\":\"1\",\"files_office\":\"1\"}"
# Add SystemD service for live indexing
cat << SYSTEMCTL_FTS > "/etc/systemd/system/$FULLTEXTSEARCH_SERVICE"
[Unit]
Description=Elasticsearch Worker for Nextcloud FullTextSearch
After=network.target
[Service]
User=www-data
Group=www-data
WorkingDirectory=$NCPATH
ExecStart=/usr/bin/php $NCPATH/occ fulltextsearch:live -q
ExecStop=/usr/bin/php $NCPATH/occ fulltextsearch:stop
Nice=19
Restart=always
[Install]
WantedBy=multi-user.target
SYSTEMCTL_FTS
# Wait further for cache for index to work
countdown "Waiting for a few seconds before indexing starts..." "10"
if nextcloud_occ fulltextsearch:test
then
# Turn off swap temporarily https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration-memory.html
print_text_in_color "Turning of swap temporarily..."
swapoff -a
if nextcloud_occ fulltextsearch:index < /dev/null
then
msg_box "Full Text Search was successfully installed!"
# Enable the live service
systemctl enable "$FULLTEXTSEARCH_SERVICE"
systemctl start "$FULLTEXTSEARCH_SERVICE"
fi
else
msg_box "There seems to be an issue with the Full Text Search test. Please report this to $ISSUES."
fi
# Turn on swap again
swapon -a
# Make sure the script exists
exit

167
apps/imaginary.sh Normal file
View File

@ -0,0 +1,167 @@
#!/bin/bash
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# GNU General Public License v3.0
# https://github.com/nextcloud/vm/blob/main/LICENSE
true
SCRIPT_NAME="Imaginary Docker"
SCRIPT_EXPLAINER="This script will install Imaginary which is a replacement for the less secure Imagick.
It can speedup the loading of previews in Nextcloud a lot."
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode
# Check if root
root_check
# Check recources
# If we can calculate the cpu and ram, then set it to the lowest possible, if not, then hardcode it to a recomended minimum.
if which nproc >/dev/null 2>&1
then
ram_check 2 Imaginary
cpu_check 2 Imaginary
else
ram_check 4 Imaginary
cpu_check 2 Imaginary
fi
# Compatible with NC24 and above
lowest_compatible_nc 26
# Check if Imaginary is already installed
if ! does_this_docker_exist nextcloud/aio-imaginary
then
# Ask for installing
install_popup "$SCRIPT_NAME"
else
# Ask for removal or reinstallation
reinstall_remove_menu "$SCRIPT_NAME"
# Removal
if yesno_box_yes "Do you want to remove the Imaginary and all it's settings?"
then
# Remove docker container
docker_prune_this 'nextcloud/aio-imaginary' 'imaginary'
# reset the preview formats
nextcloud_occ config:system:delete "preview_imaginary_url"
nextcloud_occ config:system:delete "enabledPreviewProviders"
nextcloud_occ config:system:delete "preview_max_x"
nextcloud_occ config:system:delete "preview_max_y"
nextcloud_occ config:system:delete "jpeg_quality"
nextcloud_occ config:system:delete "preview_max_memory"
nextcloud_occ config:system:delete "enable_previews"
nextcloud_occ config:system:delete "preview_concurrency_new"
nextcloud_occ config:system:delete "preview_concurrency_all"
# Remove FFMPEG
if is_this_installed ffmpeg && ! is_app_installed integration_whiteboard
then
apt-get purge ffmpeg -y
apt-get autoremove -y
fi
# Show successful uninstall if applicable
removal_popup "$SCRIPT_NAME"
fi
fi
# Remove everything that is related to previewgenerator
if crontab -u www-data -l | grep -q "preview:pre-generate"
then
if yesno_box_yes "We noticed that you have Preview Generator enabled. Imagniary replaces this, and the old app Preview Generator is now legacy.\nWe recommend you to remove it. Do you want to do that?"
then
# Remove the app
nextcloud_occ_no_check app:remove previewgenerator
# Remove the cronjob
crontab -u www-data -l | grep -v 'preview:pre-generate' | crontab -u www-data -
# Remove dependecies
DEPENDENCY=(php-imagick php"$PHPVER"-imagick libmagickcore-6.q16-3-extra imagemagick-6.q16-extra)
for installeddependency in "${DEPENDENCY[@]}"
do
if is_this_installed "$installeddependency"
then
# --allow-change-held-packages in case running on Ondrejs PPA and it's held
apt-get purge "$installeddependency" -y --allow-change-held-packages
fi
done
# Remove custom config
rm -rf /etc/ImageMagick-6
# Remove previews
if yesno_box_yes "Do you want to remove all previews that were generated until now?
This will most likely clear a lot of space! Also, pre-generated previews are not needed anymore once Imaginary are installed."
then
countdown "Removing the preview folder. This can take a while..." "5"
rm -rfv "$NCDATA"/appdata_*/preview/*
print_text_in_color "$ICyan" "Scanning Nextclouds appdata directory after removing all previews. \
This can take a while..."
# Don't execute the update before all cronjobs are finished
check_running_cronjobs
nextcloud_occ files:scan-app-data preview -vvv
print_text_in_color "$IGreen" "All previews were successfully removed."
fi
# Remove log
rm -f "$VMLOGS"/previewgenerator.log
fi
fi
# Install Docker
install_docker
# Pull and start
docker pull nextcloud/aio-imaginary:latest
docker run -t -d -p 127.0.0.1:9000:9000 --restart always --name imaginary nextcloud/aio-imaginary cap-add=sys_nice -concurrency 50 -enable-url-source -return-size -log-level debug
# Test if imaginary is working
countdown "Testing if it works in 3 sedonds" "3"
if curl -O "http://127.0.0.1:9000/crop?width=500&height=400&url=https://raw.githubusercontent.com/h2non/imaginary/master/testdata/large.jpg"
then
print_text_in_color "$IGreen" "imaginary seems to be working OK!"
rm -f large.jpg
else
msg_box "Test failed, please report this to: $ISSUES"
exit
fi
# Install dependencies
check_php
install_if_not php"$PHPVER"-sysvsem
install_if_not ffmpeg
# Calculate CPU cores
# https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#previews
if which nproc >/dev/null 2>&1
then
nextcloud_occ config:system:set preview_concurrency_new --value="$(nproc)"
nextcloud_occ config:system:set preview_concurrency_all --value="$(("$(nproc)"*2))"
else
nextcloud_occ config:system:set preview_concurrency_new --value="2"
nextcloud_occ config:system:set preview_concurrency_all --value="4"
fi
# Set providers (https://github.com/nextcloud/server/blob/master/lib/private/Preview/Imaginary.php#L60)
# https://github.com/nextcloud/vm/issues/2465
# Already enabled: https://github.com/nextcloud/server/blob/5e96228eb1f7999a327dacab22055ec2aa8e28a3/lib/private/Preview/Imaginary.php#L60
nextcloud_occ config:system:set enabledPreviewProviders 0 --value="OC\\Preview\\Imaginary"
nextcloud_occ config:system:set enabledPreviewProviders 1 --value="OC\\Preview\\Image"
nextcloud_occ config:system:set enabledPreviewProviders 2 --value="OC\\Preview\\MarkDown"
nextcloud_occ config:system:set enabledPreviewProviders 3 --value="OC\\Preview\\MP3"
nextcloud_occ config:system:set enabledPreviewProviders 4 --value="OC\\Preview\\TXT"
nextcloud_occ config:system:set enabledPreviewProviders 5 --value="OC\\Preview\\OpenDocument"
nextcloud_occ config:system:set enabledPreviewProviders 6 --value="OC\\Preview\\Movie"
nextcloud_occ config:system:set enabledPreviewProviders 7 --value="OC\\Preview\\Krita"
nextcloud_occ config:system:set preview_imaginary_url --value="http://127.0.0.1:9000"
# Set general values
nextcloud_occ config:system:set preview_max_x --value="2048"
nextcloud_occ config:system:set preview_max_y --value="2048"
nextcloud_occ config:system:set jpeg_quality --value="60"
nextcloud_occ config:system:set preview_max_memory --value="256"
if docker logs imaginary
then
msg_box "Imaginary was successfully installed!"
else
msg_box "It seems that something is wrong. Please post the full installation output to $ISSUES"
fi

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Netdata"

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true
@ -39,16 +39,14 @@ then
exit 1
fi
# Check TLS
NCDOMAIN=$(nextcloud_occ_no_check config:system:get overwrite.cli.url | sed 's|https://||;s|/||')
if ! curl -s https://"$NCDOMAIN"/status.php | grep -q 'installed":true'
check_nextcloud_https "Notify Push"
# Get the NCDOMAIN variable
if [ -z "$NCDOMAIN" ]
then
msg_box "It seems like Nextcloud is not installed or that you don't use https on:
$NCDOMAIN.
Please install Nextcloud and make sure your domain is reachable, or activate TLS
on your domain to be able to run this script.
If you use the Nextcloud VM you can use the Let's Encrypt script to get TLS and activate your Nextcloud domain."
exit 1
ncdomain
fi
# Check apache conf
if ! [ -f "$SITES_AVAILABLE/$NCDOMAIN.conf" ]
then

View File

@ -30,6 +30,9 @@ else
# Remove config.php value set when install was successful
nextcloud_occ config:system:delete allow_local_remote_servers
nextcloud_occ config:system:delete onlyoffice
nextcloud_occ config:system:delete onlyoffice jwt_secret
nextcloud_occ config:app:delete onlyoffice jwt_secret
nextcloud_occ config:system:delete onlyoffice jwt_header
# Show successful uninstall if applicable
removal_popup "$SCRIPT_NAME"
fi
@ -149,8 +152,8 @@ a2enmod proxy_http
a2enmod ssl
a2enmod headers
# Only add TLS 1.3 on Ubuntu later than 20.04
if version 20.04 "$DISTRO" 22.04.10
# Only add TLS 1.3 on Ubuntu later than 22.04
if version 22.04 "$DISTRO" 24.04.10
then
TLS13="+TLSv1.3"
fi
@ -205,9 +208,12 @@ then
# basic proxy settings
ProxyRequests off
ProxyPassMatch (.*)(\/websocket)$ "ws://127.0.0.3:9090/$1$2"
ProxyPass / "http://127.0.0.3:9090/"
ProxyPassReverse / "http://127.0.0.3:9090/"
RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://127.0.0.3:9090/" [P,L]
<Location />
ProxyPassReverse /
@ -257,6 +263,7 @@ then
# Allow remote servers with local addresses e.g. in federated shares, webcal services and more
nextcloud_occ config:system:set allow_local_remote_servers --value="true"
nextcloud_occ config:system:set onlyoffice jwt_secret --value="$ONLYOFFICE_SECRET"
nextcloud_occ config:app:set onlyoffice jwt_secret --value="$ONLYOFFICE_SECRET"
nextcloud_occ config:system:set onlyoffice jwt_header --value="AuthorizationJwt"
# Add prune command
add_dockerprune

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="OnlyOffice (Integrated)"
@ -89,7 +89,7 @@ sleep 2
if install_and_enable_app documentserver_community
then
chown -R www-data:www-data "$NC_APPS_PATH"
nextcloud_occ config:app:set onlyoffice DocumentServerUrl --value="$(nextcloud_occ_no_check config:system:get overwrite.cli.url)index.php/apps/documentserver_community/"
nextcloud_occ config:app:set onlyoffice DocumentServerUrl --value="$(nextcloud_occ_no_check config:system:get overwrite.cli.url)/index.php/apps/documentserver_community/"
msg_box "OnlyOffice was successfully installed."
else
msg_box "The documentserver_community app failed to install. Please try again later.

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true
@ -214,8 +214,8 @@ a2enmod proxy_http
a2enmod ssl
a2enmod headers
# Only add TLS 1.3 on Ubuntu later than 20.04
if version 20.04 "$DISTRO" 22.04.10
# Only add TLS 1.3 on Ubuntu later than 22.04
if version 22.04 "$DISTRO" 24.04.10
then
TLS13="+TLSv1.3"
fi

View File

@ -1,284 +0,0 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
true
SCRIPT_NAME="Preview Generator"
SCRIPT_EXPLAINER="This script will install the Preview Generator.
It can speedup the loading of previews in Nextcloud a lot."
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode
# Check if root
root_check
# PHP 7.x is needed
if is_this_installed php5.6-common || is_this_installed php5.5-common
then
msg_box "At least PHP 7.X is required, please upgrade your PHP version: \
https://shop.hanssonit.se/product/upgrade-php-version-including-dependencies/"
exit
fi
# Encryption may not be enabled
if is_app_enabled encryption || is_app_enabled end_to_end_encryption
then
msg_box "It seems like you have encryption enabled which is unsupported when using the Preview Generator"
exit
fi
# Check if previewgenerator is already installed
if ! is_app_installed previewgenerator
then
# Ask for installing
install_popup "$SCRIPT_NAME"
else
# Ask for removal or reinstallation
reinstall_remove_menu "$SCRIPT_NAME"
# Removal
nextcloud_occ app:remove previewgenerator
# reset the preview formats
nextcloud_occ_no_check config:system:delete "enabledPreviewProviders"
# reset the cronjob
crontab -u www-data -l | grep -v 'preview:pre-generate' | crontab -u www-data -
# Remove apps
APPS=(php-imagick libmagickcore-6.q16-3-extra)
for app in "${APPS[@]}"
do
if is_this_installed "$app"
then
apt-get purge "$app" -y
fi
done
if is_this_installed ffmpeg && ! is_app_installed integration_whiteboard
then
apt-get purge ffmpeg -y
fi
apt-get autoremove -y
if yesno_box_no "Do you want to remove all previews that were generated until now?
This will most likely clear a lot of space but your server will need to re-generate the previews \
if you should opt to re-enable previews again."
then
countdown "Removing the preview folder. This can take a while..." "5"
rm -rfv "$NCDATA"/appdata_*/preview
print_text_in_color "$ICyan" "Scanning Nextclouds appdata directory after removing all previews. \
This can take a while..."
nextcloud_occ files:scan-app-data -vvv
msg_box "All previews were successfully removed."
fi
# Show successful uninstall if applicable
removal_popup "$SCRIPT_NAME"
fi
# Install preview generator
install_and_enable_app previewgenerator
# check if the previewgenerator is installed and enabled
if is_app_enabled previewgenerator
then
# enable previews
nextcloud_occ config:system:set enable_previews --value=true --type=boolean
# install needed dependency for movies
install_if_not ffmpeg
else
exit
fi
msg_box "In the next step you can choose to install a package called imagick \
to speed up the generation of previews and add support for more filetypes.
The currently supported filetypes are:
* PNG
* JPEG
* GIF
* BMP
* MarkDown
* MP3
* TXT
* Movie
* Photoshop (needs imagick)
* SVG (needs imagick)
* TIFF (needs imagick)"
msg_box "IMPORTANT NOTE!!
Imagick will put your server at risk as it's is known to have several flaws.
You can check this issue to understand why: https://github.com/nextcloud/vm/issues/743
Please note: If you choose not to install imagick, it will get removed now."
if yesno_box_no "Do you want to install imagick?"
then
check_php
# Install imagick
install_if_not php"$PHPVER"-imagick
install_if_not libmagickcore-6.q16-3-extra
# Choose file formats fo the case when imagick is installed.
# for additional previews please look at the Nextcloud documentation. But these probably won't work.
choice=$(whiptail --title "$TITLE - Choose file formats" --checklist \
"Now you can choose for which file formats you would like to generate previews for
$CHECKLIST_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
"PNG" "" ON \
"JPEG" "" ON \
"GIF" "" ON \
"BMP" "" ON \
"MarkDown" "" ON \
"MP3" "" ON \
"TXT" "" ON \
"Movie" "" ON \
"Photoshop" "" ON \
"SVG" "" ON \
"TIFF" "" ON 3>&1 1>&2 2>&3)
case "$choice" in
*"PNG"*)
nextcloud_occ config:system:set enabledPreviewProviders 0 --value="OC\\Preview\\PNG"
;;&
*"JPEG"*)
nextcloud_occ config:system:set enabledPreviewProviders 1 --value="OC\\Preview\\JPEG"
;;&
*"GIF"*)
nextcloud_occ config:system:set enabledPreviewProviders 2 --value="OC\\Preview\\GIF"
;;&
*"BMP"*)
nextcloud_occ config:system:set enabledPreviewProviders 3 --value="OC\\Preview\\BMP"
;;&
*"MarkDown"*)
nextcloud_occ config:system:set enabledPreviewProviders 4 --value="OC\\Preview\\MarkDown"
;;&
*"MP3"*)
nextcloud_occ config:system:set enabledPreviewProviders 5 --value="OC\\Preview\\MP3"
;;&
*"TXT"*)
nextcloud_occ config:system:set enabledPreviewProviders 6 --value="OC\\Preview\\TXT"
;;&
*"Movie"*)
nextcloud_occ config:system:set enabledPreviewProviders 7 --value="OC\\Preview\\Movie"
;;&
*"Photoshop"*)
nextcloud_occ config:system:set enabledPreviewProviders 8 --value="OC\\Preview\\Photoshop"
;;&
*"SVG"*)
nextcloud_occ config:system:set enabledPreviewProviders 9 --value="OC\\Preview\\SVG"
;;&
*"TIFF"*)
nextcloud_occ config:system:set enabledPreviewProviders 10 --value="OC\\Preview\\TIFF"
;;&
*)
;;
esac
else
# check if imagick is installed and remove it
if is_this_installed php-imagick
then
apt-get purge php-imagick -y
elif is_this_installed php"$PHPVER"-imagick
then
apt-get purge php"$PHPVER"-imagick -y
fi
# check if libmagickcore is installed and remove it
if is_this_installed libmagickcore-6.q16-3-extra
then
apt-get purge libmagickcore-6.q16-3-extra -y
fi
# Choose file formats fo the case when imagick is not installed.
# for additional previews please look at the Nextcloud documentation. But these probably won't work.
choice=$(whiptail --title "$TITLE - Choose file formats" --checklist \
"Now you can choose for which file formats you would like to generate previews for
$CHECKLIST_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
"PNG" "" ON \
"JPEG" "" ON \
"GIF" "" ON \
"BMP" "" ON \
"MarkDown" "" ON \
"MP3" "" ON \
"TXT" "" ON \
"Movie" "" ON 3>&1 1>&2 2>&3)
case "$choice" in
*"PNG"*)
nextcloud_occ config:system:set enabledPreviewProviders 11 --value="OC\\Preview\\PNG"
;;&
*"JPEG"*)
nextcloud_occ config:system:set enabledPreviewProviders 12 --value="OC\\Preview\\JPEG"
;;&
*"GIF"*)
nextcloud_occ config:system:set enabledPreviewProviders 13 --value="OC\\Preview\\GIF"
;;&
*"BMP"*)
nextcloud_occ config:system:set enabledPreviewProviders 14 --value="OC\\Preview\\BMP"
;;&
*"MarkDown"*)
nextcloud_occ config:system:set enabledPreviewProviders 15 --value="OC\\Preview\\MarkDown"
;;&
*"MP3"*)
nextcloud_occ config:system:set enabledPreviewProviders 16 --value="OC\\Preview\\MP3"
;;&
*"TXT"*)
nextcloud_occ config:system:set enabledPreviewProviders 17 --value="OC\\Preview\\TXT"
;;&
*"Movie"*)
nextcloud_occ config:system:set enabledPreviewProviders 18 --value="OC\\Preview\\Movie"
;;&
*)
;;
esac
fi
# Set aspect ratio
nextcloud_occ config:app:set previewgenerator squareSizes --value="32 256"
nextcloud_occ config:app:set previewgenerator widthSizes --value="256 384"
nextcloud_occ config:app:set previewgenerator heightSizes --value="256"
nextcloud_occ config:system:set preview_max_x --value="2048"
nextcloud_occ config:system:set preview_max_y --value="2048"
nextcloud_occ config:system:set jpeg_quality --value="60"
nextcloud_occ config:app:set preview jpeg_quality --value="60"
# Add crontab for www-data
if ! crontab -u www-data -l | grep -q 'preview:pre-generate'
then
print_text_in_color "$ICyan" "Adding crontab for $SCRIPT_NAME"
crontab -u www-data -l | { cat; echo "*/10 * * * * php -f $NCPATH/occ preview:pre-generate >> $VMLOGS/previewgenerator.log"; } | crontab -u www-data -
touch "$VMLOGS"/previewgenerator.log
chown www-data:www-data "$VMLOGS"/previewgenerator.log
fi
msg_box "In the last step you can define a specific Nextcloud user for \
which will be the user that runs the Preview Generation.
The default behavior (just hit [ENTER]) is to run with the \
system user 'www-data' which will generate previews for all users.
If you on the other hand choose to use a specific user, previews will ONLY be generated for that specific user."
if ! yesno_box_no "Do you want to choose a specific Nextcloud user to generate previews?"
then
print_text_in_color "$ICyan" "Using www-data (all Nextcloud users) for generating previews..."
# Pre generate everything
nextcloud_occ preview:generate-all
else
while :
do
PREVIEW_USER=$(input_box "Enter the Nextcloud user for \
which you want to run the Preview Generation (as a scheduled task)")
if [ -z "$(nextcloud_occ user:list | grep "$PREVIEW_USER" | awk '{print $3}')" ]
then
msg_box "It seems like the user you entered ($PREVIEW_USER) doesn't exist, please try again."
else
break
fi
done
# Pre generate everything
nextcloud_occ preview:generate-all "$PREVIEW_USER"
fi
msg_box "Previewgenerator was successfully installed."

102
apps/recognize.sh Normal file
View File

@ -0,0 +1,102 @@
#!/bin/bash
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Recognize for Nextcloud"
SCRIPT_EXPLAINER="$SCRIPT_NAME enables [local] AI detection of photos in your Nextcloud. Recognize improves the Photos app."
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode
# Check if root
root_check
# Encryption may not be enabled
if is_app_enabled encryption || is_app_enabled end_to_end_encryption
then
msg_box "It seems like you have encryption enabled which is unsupported by the $SCRIPT_NAME app!"
exit 1
fi
# Compatible with NC26 and above
lowest_compatible_nc 26
# Check if suspicious_login are installed
# https://github.com/nextcloud/recognize/issues/676
if is_app_enabled suspicious_login
then
msg_box "Since you have the app Suspicious Login Detection installed, you can't install Recognize. The reason is that it will cause issues with cron.php.\nIf you choose 'No' the installer will exit"
if yesno_box_no "Do you want to disable Suspicious Login to be able to install Recognize?"
then
nextcloud_occ app:disable suspicious_login
if ! [ -f /etc/fail2ban/filter.d/nextcloud.conf ] || ! is_this_installed fail2ban
then
if yesno_box_yes "Do you want to install Fail2ban (IP blocking in Linux) instead?"
then
run_script APP fail2ban
fi
fi
else
exit
fi
fi
# Check if face-recognition is installed and ask to remove it
if is_app_installed facerecognition
then
msg_box "It seems like Face Recognition is installed. This app doesn't work with both installed at the same time. Please uninstall Face Recognition and try again:
1. Hit OK here.
2. Choose 'Uninstall'
3. Run sudo bash $SCRIPTS/menu.sh --> Additional Apps --> Recognize
4. Install
We will run the uninstaller for you now, then exit."
wget https://raw.githubusercontent.com/nextcloud/vm/main/old/face-recognition.sh && bash face-recognition.sh && rm -f face-recognition.sh
exit
fi
# Check if recognize is already installed
if ! is_app_installed recognize
then
# Ask for installing
install_popup "$SCRIPT_NAME"
else
# Ask for removal or reinstallation
reinstall_remove_menu "$SCRIPT_NAME"
# Removal
if yesno_box_no "Do you want to remove all facerecognitions and tags that were generated until now?"
then
print_text_in_color "$ICyan" "This will take some time..."
nextcloud_occ_no_check recognize:remove-legacy-tags
nextcloud_occ_no_check recognize:cleanup-tags
nextcloud_occ_no_check recognize:reset-face-clusters
nextcloud_occ_no_check recognize:reset-faces
nextcloud_occ_no_check recognize:reset-tags
fi
nextcloud_occ app:remove recognize
# Show successful uninstall if applicable
removal_popup "$SCRIPT_NAME"
fi
# Install recognize
# Enough recouces?
ram_check 8
cpu_check 4
install_and_enable_app recognize
nextcloud_occ recognize:download-models
# Check if it was installed
if is_app_enabled recognize
then
msg_box "$SCRIPT_NAME was successfully installed!"
else
msg_box "The installation wasn't successful. Please try again by running this script again!"
fi

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true
@ -77,7 +77,7 @@ then
msg_box "All $MAX_COUNT slots are occupied. No mounting slots available. Please delete one of the SMB-mounts.
If you really want to mount more, you can simply download the smb-mount script \
directly and edit the variable 'MAX_COUNT' to a higher value than $MAX_COUNT by running:
'curl -sLO https://raw.githubusercontent.com/nextcloud/vm/master/apps/smbmount.sh' # Download the script
'curl -sLO https://raw.githubusercontent.com/nextcloud/vm/main/apps/smbmount.sh' # Download the script
'nano smbmount.sh' # Edit MAX_COUNT=$MAX_COUNT to your likings and save the file
'sudo bash smbmount.sh' # Execute the script." "$SUBTITLE"
return
@ -147,7 +147,7 @@ $MENU_GUIDE\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
print_text_in_color "$ICyan" "Using for backups..."
umount "$SMBSHARES/$count"
sed -i "/$SMBSHARES_SED\/$count /d" /etc/fstab
echo "$SERVER_SHARE_NAME $SMBSHARES/$count cifs credentials=$SMB_CREDENTIALS/SMB$count,uid=root,gid=root,file_mode=0600,dir_mode=0600,nounix,noserverino,cache=none,nofail,noauto 0 0" >> /etc/fstab
echo "$SERVER_SHARE_NAME $SMBSHARES/$count cifs credentials=$SMB_CREDENTIALS/SMB$count,uid=root,gid=root,file_mode=0600,dir_mode=0600,nounix,noserverino,cache=none,nofail 0 0" >> /etc/fstab
unset SMB_USER && unset SMB_PASSWORD
sleep 1
msg_box "The backup mount was successfully created!"
@ -340,7 +340,7 @@ We please you to do the math yourself if the number is high enough for your setu
fi
# Install the inotify PHP extension
# https://github.com/icewind1991/files_inotify/blob/master/README.md
# https://github.com/icewind1991/files_inotify/blob/main/README.md
if ! pecl list | grep -q inotify
then
print_text_in_color "$ICyan" "Installing the PHP inotify extension..."
@ -408,9 +408,14 @@ files_inotify app and set up the cronjob for this external storage."
nextcloud_occ_no_check app:enable files_inotify
fi
# Add crontab for this external storage
# Download script
download_script ADDONS notify-crontab
chmod +x "$SCRIPTS"/notify-crontab.sh
chown root:root "$SCRIPTS"/notify-crontab.sh
# Add crontab
print_text_in_color "$ICyan" "Generating crontab..."
crontab -u www-data -l | { cat; echo "@reboot sleep 20 && php -f $NCPATH/occ files_external:notify -v $MOUNT_ID >> $VMLOGS/files_inotify.log"; } | crontab -u www-data -
crontab -u root -l | { cat; echo "@reboot $SCRIPTS/notify-crontab.sh $MOUNT_ID"; } | crontab -u root -
# Run the command in a subshell and don't exit if the smbmount script exits
nohup sudo -u www-data php "$NCPATH"/occ files_external:notify -v "$MOUNT_ID" >> $VMLOGS/files_inotify.log &

View File

@ -1,12 +1,15 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Nextcloud Talk"
SCRIPT_EXPLAINER="This script installs Nextcloud Talk and also offers the possibility \
to install the so-called High-Performance-Backend, which makes it possible to host more video calls than it would be with the standard Talk app. \
It's called 'Talk Signaling' and you will be offered to install it as part two of this script."
SCRIPT_EXPLAINER="This script installs Nextcloud Talk which is a replacement for Teams/Skype and similar.
You will also be offered the possibility to install the so-called High-Performance-Backend, which makes it possible to host more video calls than it would be with the standard Talk app.
It's called 'Talk Signaling' and you will be offered to install it as part two of this script.
And last but not least, Talk Recording is also offered to be installed. It enables recording of sessions in Talk and it's part three of this script."
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
@ -33,29 +36,43 @@ else
# Ask for removal or reinstallation
reinstall_remove_menu "$SCRIPT_NAME"
# Removal
if [ -f "$SIGNALING_SERVER_CONF" ]
then
SUBDOMAIN=$(input_box_flow "Please enter the subdomain you were using for Talk Signaling, e.g: talk.yourdomain.com. This will be removed.")
if [ -f "$CERTFILES/$SUBDOMAIN/cert.pem" ]
then
yes no | certbot revoke --cert-path "$CERTFILES/$SUBDOMAIN/cert.pem"
REMOVE_OLD="$(find "$LETSENCRYPTPATH/" -name "$SUBDOMAIN*")"
for remove in $REMOVE_OLD
do rm -rf "$remove"
done
fi
fi
sed "/# Talk Signaling Server/d" /etc/hosts >/dev/null 2>&1
sed "/127.0.1.1 $SUBDOMAIN/d" /etc/hosts >/dev/null 2>&1
nextcloud_occ_no_check config:app:delete spreed stun_servers
nextcloud_occ_no_check config:app:delete spreed turn_servers
nextcloud_occ_no_check config:app:delete spreed signaling_servers
nextcloud_occ_no_check config:app:delete spreed recording_servers
nextcloud_occ_no_check app:remove spreed
rm -rf \
"$TURN_CONF" \
"$SIGNALING_SERVER_CONF" \
/etc/signaling \
/etc/nats \
/etc/janus \
/etc/apt/trusted.gpg.d/morph027-janus.asc \
/etc/apt/trusted.gpg.d/morph027-nats-server.asc \
/etc/apt/trusted.gpg.d/morph027-nextcloud-spreed-signaling.asc \
/etc/apt/trusted.gpg.d/morph027-coturn.asc \
/etc/apt/keyrings/morph027-coturn.asc
/etc/apt/sources.list.d/morph027-nextcloud-spreed-signaling.list\
/etc/apt/keyrings/morph027-coturn.asc \
/etc/apt/sources.list.d/morph027-nextcloud-spreed-signaling.list \
/etc/apt/sources.list.d/morph027-janus.list \
/etc/apt/sources.list.d/morph027-nats-server.list \
/etc/apt/sources.list.d/morph027-coturn.list \
$VMLOGS/talk_apache_error.log \
$VMLOGS/talk_apache_access.log \
$VMLOGS/turnserver.log \
"$VMLOGS"/talk_apache_error.log \
"$VMLOGS"/talk_apache_access.log \
"$VMLOGS"/turnserver.log \
/var/www/html/error
APPS=(coturn nats-server janus nextcloud-spreed-signaling)
for app in "${APPS[@]}"
@ -66,21 +83,22 @@ else
fi
done
apt-get autoremove -y
docker_prune_this nextcloud/aio-talk-recording
# Show successful uninstall if applicable
removal_popup "$SCRIPT_NAME"
fi
# Must be 22.04
if ! version 20.04 "$DISTRO" 22.04.10
# Must be 24.04
if ! version 22.04 "$DISTRO" 24.04.10
then
msg_box "Your current Ubuntu version is $DISTRO but must be between 20.04 - 22.04.10 to install Talk"
msg_box "Your current Ubuntu version is $DISTRO but must be between 22.04 - 24.04.10 to install Talk"
msg_box "Please contact us to get support for upgrading your server:
https://www.hanssonit.se/#contact
https://shop.hanssonit.se/"
exit
fi
# Nextcloud 19 is required.
# Nextcloud 20 is required.
lowest_compatible_nc 20
####################### TALK (COTURN)
@ -215,7 +233,7 @@ msg_box "You will now be presented with the option to install the Talk Signaling
This aims to give you greater performance and ability to have more users in a call at the same time.
You can read more here:
https://github.com/strukturag/nextcloud-spreed-signaling/blob/master/README.md
https://github.com/strukturag/nextcloud-spreed-signaling/blob/main/README.md
We will use apt packages from https://gitlab.com/morph027 which is a trusted contributor to this repository.
@ -319,24 +337,34 @@ then
cat << SIGNALING_CONF_CREATE > "$SIGNALING_SERVER_CONF"
[http]
listen = 127.0.0.1:8081
[app]
debug = false
[sessions]
hashkey = $(openssl rand -hex 16)
blockkey = $(openssl rand -hex 16)
[clients]
internalsecret = $(openssl rand -hex 16)
internalsecret = ${TURN_INTERNAL_SECRET}
[backend]
allowed = ${TURN_DOMAIN}
backends = backend-1
allowall = false
secret = ${NC_SECRET}
timeout = 10
connectionsperhost = 8
[backend-1]
url = https://${TURN_DOMAIN}
secret = ${SIGNALING_SECRET}
[nats]
url = nats://localhost:4222
url = nats://127.0.0.1:4222
[mcu]
type = janus
url = ws://127.0.0.1:8188
[turn]
apikey = ${JANUS_API_KEY}
secret = ${TURN_SECRET}
@ -361,17 +389,17 @@ a2enmod headers
a2enmod remoteip
# Allow CustomLog
touch $VMLOGS/talk_apache_access.log
touch $VMLOGS/talk_apache_error.log
chown www-data:www-data $VMLOGS/talk_apache_error.log $VMLOGS/talk_apache_access.log
touch "$VMLOGS"/talk_apache_access.log
touch "$VMLOGS"/talk_apache_error.log
chown root:adm "$VMLOGS"/talk_apache_*
# Prep the error page
mkdir -p /var/www/html/error
echo "Hi there! :) If you see this page, the Apache2 proxy for $SCRIPT_NAME is up and running." > /var/www/html/error/404_proxy.html
chown -R www-data:www-data /var/www/html/error
# Only add TLS 1.3 on Ubuntu later than 20.04
if version 20.04 "$DISTRO" 22.04.10
# Only add TLS 1.3 on Ubuntu later than 22.04
if version 22.04 "$DISTRO" 24.04.10
then
TLS13="+TLSv1.3"
fi
@ -403,8 +431,8 @@ then
# Logs
LogLevel warn
CustomLog \${APACHE_LOG_DIR}/access.log combined
ErrorLog \${APACHE_LOG_DIR}/error.log
CustomLog $VMLOGS/talk_apache_access.log common
ErrorLog $VMLOGS/talk_apache_error.log
# Just in case - see below
SSLProxyEngine On
@ -467,7 +495,7 @@ else
fi
# Set signaling server strings
SIGNALING_SERVERS_STRING="{\"servers\":[{\"server\":\"https://$SUBDOMAIN/\",\"verify\":true}],\"secret\":\"$NC_SECRET\"}"
SIGNALING_SERVERS_STRING="{\"servers\":[{\"server\":\"https://$SUBDOMAIN/\",\"verify\":true}],\"secret\":\"$SIGNALING_SECRET\"}"
nextcloud_occ config:app:set spreed signaling_servers --value="$SIGNALING_SERVERS_STRING" --output json
# Add to /etc/hosts
@ -483,6 +511,51 @@ then
msg_box "Installation failed. :/\n\nPlease run this script again to uninstall if you want to clean the system, or choose to reinstall if you want to try again.\n\nLogging can be found by typing: journalctl -lfu signaling"
exit 1
else
msg_box "Congratulations, everything is working as intended! The installation succeeded.\n\nLogging can be found by typing: journalctl -lfu signaling"
exit 0
msg_box "Congratulations, everything is working as intended! The Talk Signaling installation succeeded.\n\nLogging can be found by typing: journalctl -lfu signaling"
fi
####### Talk recording
if ! yesno_box_yes "Do you want install Talk Recording to be able to record your calls?"
then
exit
fi
# Nextcloud 26 is required.
lowest_compatible_nc 26
# It's pretty recource intensive
cpu_check 4 "Talk Recording"
ram_check 4 "Talk Recording"
print_text_in_color "$ICyan" "Setting up Talk recording..."
# Pull and start
docker pull nextcloud/aio-talk-recording:latest
docker run -t -d -p "$TURN_RECORDING_HOST":"$TURN_RECORDING_HOST_PORT":"$TURN_RECORDING_HOST_PORT" \
--restart always \
--name talk-recording \
--shm-size=2GB \
-e NC_DOMAIN="${TURN_DOMAIN}" \
-e HPB_DOMAIN="${SUBDOMAIN}" \
-e HPB_PATH=/ \
-e TZ="$(cat /etc/timezone)" \
-e RECORDING_SECRET="${TURN_RECORDING_SECRET}" \
-e INTERNAL_SECRET="${TURN_INTERNAL_SECRET}" \
nextcloud/aio-talk-recording:latest
# Talk recording
if [ -d "$NCPATH/apps/spreed" ]
then
if does_this_docker_exist nextcloud/aio-talk-recording
then
install_if_not netcat
while ! nc -z "$TURN_RECORDING_HOST" "$TURN_RECORDING_HOST_PORT"
do
print_text_in_color "$ICyan" "Waiting for Talk Recording to become available..."
sleep 5
done
# Set values in Nextcloud
RECORDING_SERVERS_STRING="{\"servers\":[{\"server\":\"http://$TURN_RECORDING_HOST:$TURN_RECORDING_HOST_PORT/\",\"verify\":false}],\"secret\":\"$TURN_RECORDING_SECRET\"}"
nextcloud_occ_no_check config:app:set spreed recording_servers --value="$RECORDING_SERVERS_STRING" --output json
fi
fi

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Bitwarden"
@ -102,7 +102,6 @@ https://imgur.com/a/3ytwvp6"
# Install Docker
install_docker
install_if_not docker-compose
# Create bitwarden user
if ! id "$BITWARDEN_USER" >/dev/null 2>&1
@ -182,7 +181,7 @@ USERGROUPID=$(id -g $BITWARDEN_USER)
sed -i "s|database_docker_volume:.*|database_docker_volume: true|g" "$BITWARDEN_HOME"/bwdata/config.yml
sed -i "s|LOCAL_UID=.*|LOCAL_UID=$USERID|g" "$BITWARDEN_HOME"/bwdata/env/uid.env
sed -i "s|LOCAL_GID=.*|LOCAL_GID=$USERGROUPID|g" "$BITWARDEN_HOME"/bwdata/env/uid.env
# Get Subdomain from config.yml and change it to https
# Get subdomain from config.yml and change it to https
SUBDOMAIN=$(grep ^url "$BITWARDEN_HOME"/bwdata/config.yml)
SUBDOMAIN=${SUBDOMAIN##*url: http://}
sed -i "s|^url: .*|url: https://$SUBDOMAIN|g" "$BITWARDEN_HOME"/bwdata/config.yml
@ -241,8 +240,8 @@ a2enmod ssl
a2enmod headers
a2enmod remoteip
# Only add TLS 1.3 on Ubuntu later than 20.04
if version 20.04 "$DISTRO" 22.04.10
# Only add TLS 1.3 on Ubuntu later than 22.04
if version 22.04 "$DISTRO" 24.04.10
then
TLS13="+TLSv1.3"
fi

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Vaultwarden (formerly Bitwarden RS)"
@ -122,8 +122,8 @@ a2enmod ssl
a2enmod headers
a2enmod remoteip
# Only add TLS 1.3 on Ubuntu later than 20.04
if version 20.04 "$DISTRO" 22.04.10
# Only add TLS 1.3 on Ubuntu later than 22.04
if version 22.04 "$DISTRO" 24.04.10
then
TLS13="+TLSv1.3"
fi

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Vaultwarden (formerly Bitwarden RS) Admin Panel"

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Webmin"
@ -37,6 +37,8 @@ else
rm -f /etc/apt/trusted.gpg.d/webmin.gpg
rm -f /etc/apt/keyrings/jcameron-key.asc
sed -i '/webmin/d' /etc/apt/sources.list
apt-get clean all
apt-get update
# Show successful uninstall if applicable
removal_popup "$SCRIPT_NAME"
fi
@ -52,6 +54,7 @@ install_if_not libio-pty-perl
install_if_not apt-show-versions
install_if_not python2
install_if_not unzip
install_if_not shared-mime-info
install_if_not zip
# https://github.com/webmin/webmin/issues/1169
@ -79,8 +82,8 @@ install_if_not webmin
if ! dpkg-query -W -f='${Status}' "webmin" | grep -q "ok installed"
then
wget http://prdownloads.sourceforge.net/webadmin/webmin_1.991_all.deb
dpkg --install webmin_1.991_all.deb
wget http://prdownloads.sourceforge.net/webadmin/webmin_2.010_all.deb
dpkg --install webmin_2.010_all.deb
fi
print_text_in_color "$ICyan" "Configuring Webmin..."

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true

View File

@ -1,11 +1,11 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# https://wiki.archlinux.org/index.php/ZFS#Using_zfs-mount-generator
# Tested on Ubuntu 20.04
# Tested on Ubuntu 22.04
# This script came to life when we were having issues with importing the ZFS pool (ncdata) on Ubuntu 20.04.
# This script came to life when we were having issues with importing the ZFS pool (ncdata) on Ubuntu 22.04.
# After some forum reading and some digging on Github, this is the result.
# The intention here is to make the import process more robust, and less prune to fail
# Essentially, changing from 'zfs-mount.service' to 'zfs-mount-generator' which by many has been working better.
@ -18,12 +18,12 @@ source /var/scripts/fetch_lib.sh
# Check if root
root_check
# Needs to be Ubuntu 20.04 and Multiverse
# Needs to be Ubuntu 22.04 and Multiverse
check_distro_version
check_multiverse
# Import if missing and export again to import it with UUID
# https://github.com/nextcloud/vm/blob/master/lib.sh#L1233
# https://github.com/nextcloud/vm/blob/main/lib.sh#L1233
# Set a different name for the pool (if used outside of this repo)
# export POOLNAME=ncdata
zpool_import_if_missing

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Create daily ZFS prune script"

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Format Chosen Disk"
@ -10,7 +10,7 @@ source /var/scripts/fetch_lib.sh
# Check if root
root_check
# Needs to be Ubuntu 20.04 and Multiverse
# Needs to be Ubuntu 22.04 and Multiverse
check_distro_version
check_multiverse
@ -172,7 +172,7 @@ then
check_command zpool create -f -o ashift=12 "$POOLNAME" "$DISKTYPE"
check_command zpool set failmode=continue "$POOLNAME"
check_command zfs set mountpoint="$MOUNT_" "$POOLNAME"
check_command zfs set compression=lz4 "$POOLNAME"
check_command zfs set compression=zstd "$POOLNAME"
check_command zfs set sync=standard "$POOLNAME"
check_command zfs set xattr=sa "$POOLNAME"
check_command zfs set primarycache=all "$POOLNAME"

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Format sdb"
@ -10,7 +10,7 @@ source /var/scripts/fetch_lib.sh
# Check if root
root_check
# Needs to be Ubuntu 20.04 and Multiverse
# Needs to be Ubuntu 22.04 and Multiverse
check_distro_version
check_multiverse
@ -83,7 +83,7 @@ This script will now exit. Please add a second disk and start over."
fi
# Get the name of the drive
DISKTYPE=$(fdisk -l | grep $DEVTYPE | awk '{print $2}' | cut -d ":" -f1 | head -1)
DISKTYPE=$(fdisk -l | grep "$DEVTYPE" | awk '{print $2}' | cut -d ":" -f1 | head -1)
if [ "$DISKTYPE" != "/dev/$DEVTYPE" ]
then
msg_box "It seems like your $SYSNAME secondary volume (/dev/$DEVTYPE) does not exist.
@ -155,7 +155,7 @@ then
check_command zpool create -f -o ashift=12 "$POOLNAME" "$DISKTYPE"
check_command zpool set failmode=continue "$POOLNAME"
check_command zfs set mountpoint="$MOUNT_" "$POOLNAME"
check_command zfs set compression=lz4 "$POOLNAME"
check_command zfs set compression=zstd "$POOLNAME"
check_command zfs set sync=standard "$POOLNAME"
check_command zfs set xattr=sa "$POOLNAME"
check_command zfs set primarycache=all "$POOLNAME"
@ -180,7 +180,7 @@ format
# Do a backup of the ZFS mount
if is_this_installed libzfs4linux
then
if grep -r $POOLNAME /etc/mtab
if grep -r "$POOLNAME" /etc/mtab
then
install_if_not zfs-auto-snapshot
sed -i "s|date --utc|date|g" /usr/sbin/zfs-auto-snapshot
@ -191,8 +191,8 @@ fi
if zpool list -v | grep "$DEVTYPE"
then
check_command partprobe -s
zpool export $POOLNAME
zpool import -d /dev/disk/by-id $POOLNAME
zpool export "$POOLNAME"
zpool import -d /dev/disk/by-id "$POOLNAME"
fi
# Success!
@ -211,7 +211,7 @@ Manpage is here:
http://manpages.ubuntu.com/manpages/focal/man8/zfs-auto-snapshot.8.html
CURRENT STATUS:
$(zpool status $POOLNAME)
$(zpool status "$POOLNAME")
$(zpool list)"
fi

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Prune ZFS Snapshots"
@ -36,7 +36,7 @@ and avoid a fatal crash. Please check $VMLOGS/zfs_prune.log for the results."
# On screen information
msg_box "Your disk space is almost full (more than 70% or less than 100GB left).
To solve that, we will now delete ZFS snapshots older than 4 weeks
To solve that, we will now delete ZFS snapshots older than 2 days.
The script will also delete everything in trashbin for all users to free up some space."
countdown "To abort, please press CTRL+C within 10 seconds." 10
@ -59,7 +59,7 @@ The script will also delete everything in trashbin for all users to free up some
fi
# Prune snapshots
touch $VMLOGS/zfs_prune.log
./zfs-prune-snapshots.sh 2d ncdata >> $VMLOGS/zfs_prune.log
./zfs-prune-snapshots.sh 2d ncdata | tee -a $VMLOGS/zfs_prune.log
# Create daily prune to avoid disk being full again
if [ ! -f "$SCRIPTS/daily-zfs-prune.sh" ]
then

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true
@ -114,7 +114,7 @@ then
cat << SMART_NOTIFICATION > "$SCRIPTS/smart-notification.sh"
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true
@ -161,7 +161,7 @@ $SCRIPTS/smart-notification.sh -s (S/../.././01|L/../../6/02)" > /etc/smartd.con
cat << SMART_NOTIFICATION > "$SCRIPTS/smart-notification.sh"
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,5 @@
# What is this folder about?
This folder is only meant for storing GeoIP Legacy Databases which are used by the [geoip script](https://github.com/nextcloud/vm/blob/master/network/geoblock.sh).
This folder is only meant for storing GeoIP Legacy Databases which are used by the [geoip script](https://github.com/nextcloud/vm/blob/main/network/geoblock.sh).
All .dat files in this folder are from https://www.miyuru.lk/geoiplegacy and converted by Miyuru Sankalpa.

View File

@ -4,7 +4,7 @@ SCRIPT_NAME="Activate TLS"
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Check for errors + debug code and abort if something isn't right
# 1 = ON
@ -115,15 +115,15 @@ fi
# To get the correct version for the Apache conf file
check_php
# Only add TLS 1.3 on Ubuntu later than 20.04
if version 20.04 "$DISTRO" 22.04.10
# Only add TLS 1.3 on Ubuntu later than 22.04
if version 22.04 "$DISTRO" 24.04.10
then
TLS13="+TLSv1.3"
fi
# Fix zero file sizes
# See https://github.com/nextcloud/server/issues/3056
if version 22.04 "$DISTRO" 26.04.10
if version 24.04 "$DISTRO" 26.04.10
then
SETENVPROXY="SetEnv proxy-sendcl 1"
fi
@ -156,7 +156,7 @@ then
SSLEngine on
SSLCompression off
SSLProtocol -all +TLSv1.2 $TLS13
SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
SSLHonorCipherOrder off
SSLSessionTickets off
ServerSignature off
@ -166,33 +166,41 @@ then
CustomLog \${APACHE_LOG_DIR}/access.log combined
ErrorLog \${APACHE_LOG_DIR}/error.log
# Document root folder
DocumentRoot $NCPATH
# The Nextcloud folder
<Directory $NCPATH>
Options Indexes FollowSymLinks
AllowOverride None
### include all .htaccess
Include $NCPATH/.htaccess
Include $NCPATH/config/.htaccess
Include $NCDATA/.htaccess
###
Require all granted
Satisfy Any
# This is to include all the Nextcloud rules due to that we use PHP-FPM and .htaccess aren't read
Include $NCPATH/.htaccess
</Directory>
# Deny access to your data directory
<Directory $NCDATA>
Require all denied
</Directory>
# Deny access to the Nextcloud config folder
<Directory $NCPATH/config/>
Require all denied
</Directory>
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME $NCPATH
SetEnv HTTP_HOME $NCPATH
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
# The following lines prevent .htaccess and .htpasswd files from being viewed by Web clients.
<Files ".ht*">
Require all denied
</Files>
SetEnv HOME $NCPATH
SetEnv HTTP_HOME $NCPATH
# Disable HTTP TRACE method.
TraceEnable off
# Disable HTTP TRACK method.
@ -207,8 +215,8 @@ then
### LOCATION OF CERT FILES ###
SSLCertificateChainFile $CERTFILES/$TLSDOMAIN/chain.pem
SSLCertificateFile $CERTFILES/$TLSDOMAIN/cert.pem
# SSLCertificateChainFile $CERTFILES/$TLSDOMAIN/chain.pem
SSLCertificateFile $CERTFILES/$TLSDOMAIN/fullchain.pem
SSLCertificateKeyFile $CERTFILES/$TLSDOMAIN/privkey.pem
SSLOpenSSLConfCmd DHParameters $DHPARAMS_TLS
</VirtualHost>
@ -317,7 +325,7 @@ Please consider showing them your gratitude:
https://letsencrypt.org/become-a-sponsor/
If you want to contribute to these scripts, have a look here:
https://github.com/nextcloud/vm/tree/master/lets-encrypt"
https://github.com/nextcloud/vm/tree/main/lets-encrypt"
exit 0
fi
else

View File

@ -4,7 +4,7 @@ SCRIPT_NAME="Test New Configuration"
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Check for errors + debug code and abort if something isn't right
# 1 = ON
@ -34,8 +34,10 @@ then
sed -i "s|env\[HOSTNAME\] = .*|env[HOSTNAME] = $(hostname -f)|g" "$PHP_POOL_DIR"/nextcloud.conf
fi
# Set trusted domains
run_script NETWORK trusted
# Set the domain as trusted
add_to_trusted_domains "$FQDOMAIN"
nextcloud_occ config:system:set overwrite.cli.url --value="https://$FQDOMAIN"
nextcloud_occ maintenance:update:htaccess
# Add crontab
cat << CRONTAB > "$SCRIPTS/letsencryptrenew.sh"

300
lib.sh
View File

@ -1,40 +1,25 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# GNU General Public License v3.0
# https://github.com/nextcloud/vm/blob/master/LICENSE
# https://github.com/nextcloud/vm/blob/main/LICENSE
# shellcheck disable=SC2034
true
# see https://github.com/koalaman/shellcheck/wiki/Directive
##### LEGACY #####
## Remove 2022-09-01
NCPATH=/var/www/nextcloud
NCPASS=nextcloud
NCUSER=ncadmin
PGDB_USER=nextcloud_db_user
if [ -f "$NCPATH"/config/config.php ]
then
NCCONFIGDBPASS="$(grep 'dbpassword' "$NCPATH"/config/config.php | awk '{print $3}' | sed "s/[',]//g")"
NCCONFIGDB="$(grep 'dbname' "$NCPATH"/config/config.php | awk '{print $3}' | sed "s/[',]//g")"
fi
## VARIABLES
# Dirs
SCRIPTS=/var/scripts
NCPATH=/var/www/nextcloud
HTML=/var/www
NCPATH="$HTML"/nextcloud
POOLNAME=ncdata
NCDATA=/mnt/"$POOLNAME"
SNAPDIR=/var/snap/spreedme
GPGDIR=/tmp/gpg
SHA256_DIR=/tmp/sha256
BACKUP=/mnt/NCBACKUP
RORDIR=/opt/es/
OPNSDIR=/opt/opensearch
NC_APPS_PATH=$NCPATH/apps
VMLOGS=/var/log/nextcloud
@ -70,7 +55,8 @@ INTERNET_DNS="9.9.9.9"
# Default Quad9 DNS servers, overwritten by the systemd global DNS defined servers, if set
DNS1="9.9.9.9"
DNS2="149.112.112.112"
NONO_PORTS=(22 25 53 80 443 1024 3012 3306 5178 5179 5432 7867 7983 8983 10000 8081 8443 9443)
NONO_PORTS=(22 25 53 80 443 1024 3012 3306 5178 5179 5432 7867 7983 8983 10000 8081 8443 9443 9000 9980 9090 9200 9600 1234)
# 9000 9980 9090 9200 9600 1234 are local docker ports, don't remember if they are needed here or not.
use_global_systemd_dns() {
if [ -f "/etc/systemd/resolved.conf" ]
then
@ -101,7 +87,7 @@ Confirm by pressing [ENTER]. Cancel by pressing [ESC]."
MENU_GUIDE="Navigate with the [ARROW] keys and confirm by pressing [ENTER]. Cancel by pressing [ESC]."
RUN_LATER_GUIDE="You can view this script later by running 'sudo bash $SCRIPTS/menu.sh'."
# Repo
GITHUB_REPO="https://raw.githubusercontent.com/nextcloud/vm/master"
GITHUB_REPO="https://raw.githubusercontent.com/nextcloud/vm/main"
STATIC="$GITHUB_REPO/static"
LETS_ENC="$GITHUB_REPO/lets-encrypt"
APP="$GITHUB_REPO/apps"
@ -145,6 +131,7 @@ nc_update() {
NCVERSION=$(curl -s -m 900 $NCREPO/ | sed --silent 's/.*href="nextcloud-\([^"]\+\).zip.asc".*/\1/p' | sort --version-sort | tail -1)
STABLEVERSION="nextcloud-$NCVERSION"
NCMAJOR="${NCVERSION%%.*}"
CURRENTMAJOR="${CURRENTVERSION%%.*}"
NCBAD=$((NCMAJOR-2))
NCNEXT="$((${CURRENTVERSION%%.*}+1))"
}
@ -164,11 +151,12 @@ HTTP_CONF="nextcloud_http_domain_self_signed.conf"
HTTPS_CONF="$SITES_AVAILABLE/$SUBDOMAIN.conf"
HTTP2_CONF="/etc/apache2/mods-available/http2.conf"
# PHP-FPM
PHPVER=8.1
PHPVER=8.3
PHP_FPM_DIR=/etc/php/$PHPVER/fpm
PHP_INI=$PHP_FPM_DIR/php.ini
PHP_POOL_DIR=$PHP_FPM_DIR/pool.d
PHP_MODS_DIR=/etc/php/"$PHPVER"/mods-available
opcache_interned_strings_buffer_value=24
# Notify push
NOTIFY_PUSH_SERVICE_PATH="/etc/systemd/system/notify_push.service"
# Adminer
@ -183,21 +171,24 @@ SPAMHAUS=/etc/spamhaus.wl
ENVASIVE=/etc/apache2/mods-available/mod-evasive.load
APACHE2=/etc/apache2/apache2.conf
# Full text Search
opensearch_install() {
INDEX_USER=$(gen_passwd "$SHUF" '[:lower:]')
OPNSREST=$(gen_passwd "$SHUF" "A-Za-z0-9")
fulltextsearch_install() {
FULLTEXTSEARCH_DIR="$SCRIPTS"/fulltextsearch
NEXTCLOUD_INDEX=$(gen_passwd "$SHUF" '[:lower:]')
ELASTIC_USER_PASSWORD=$(gen_passwd "$SHUF" '[:lower:]')
FULLTEXTSEARCH_IMAGE_NAME=fulltextsearch_es01
FULLTEXTSEARCH_SERVICE=nextcloud-fulltext-elasticsearch-worker.service
# Supports 0-9.0-99.0-9. Max supprted version with this function is 9.99.9. When ES 10.0.0 is out we have a problem.
# Maybe "10\\.[[:digit:]][[:digit:]]\\.[[:digit:]]" will work?
FULLTEXTSEARCH_IMAGE_NAME_LATEST_TAG="$(curl -s -m 900 https://www.docker.elastic.co/r/elasticsearch | grep -Eo "[[:digit:]]\\.[[:digit:]][[:digit:]]\\.[[:digit:]]" | sort --version-sort | tail -1)"
# Legacy, changed 2023-09-21
DOCKER_IMAGE_NAME=es01
# Legacy, not used at all
RORDIR=/opt/es/
OPNSDIR=/opt/opensearch
nc_fts="ark74/nc_fts"
opens_fts="opensearchproject/opensearch:1"
opens_fts="opensearchproject/opensearch"
fts_node="fts_os-node"
}
create_certs(){
download_script APP opensearch_certs
check_command sed -i "s|__NCDOMAIN__|$1|" "$SCRIPTS"/opensearch_certs.sh
check_command mv "$SCRIPTS"/opensearch_certs.sh "$OPNSDIR"
check_command cd "$OPNSDIR"
check_command bash opensearch_certs.sh
rm -f "$OPNSDIR"/opensearch_certs.sh
}
# Name in trusted_config
ncdomain() {
NCDOMAIN=$(nextcloud_occ_no_check config:system:get overwrite.cli.url | sed 's|https://||;s|/||')
@ -208,10 +199,14 @@ turn_install() {
TURN_PORT=3478
TURN_DOMAIN=$(sudo -u www-data /var/www/nextcloud/occ config:system:get overwrite.cli.url | sed 's|https://||;s|/||')
SHUF=$(shuf -i 25-29 -n 1)
TURN_SECRET=$(gen_passwd "$SHUF" "a-zA-Z0-9@#*")
JANUS_API_KEY=$(gen_passwd "$SHUF" "a-zA-Z0-9@#*")
NC_SECRET=$(gen_passwd "$SHUF" "a-zA-Z0-9@#*")
TURN_SECRET=$(gen_passwd "$SHUF" "a-zA-Z0-9")
JANUS_API_KEY=$(gen_passwd "$SHUF" "a-zA-Z0-9")
SIGNALING_SECRET=$(gen_passwd "$SHUF" "a-zA-Z0-9")
SIGNALING_SERVER_CONF=/etc/signaling/server.conf
TURN_INTERNAL_SECRET=$(gen_passwd "$SHUF" "a-zA-Z0-9")
TURN_RECORDING_SECRET=$(gen_passwd "$SHUF" "a-zA-Z0-9")
TURN_RECORDING_HOST=127.0.0.1
TURN_RECORDING_HOST_PORT=1234
}
## FUNCTIONS
@ -392,7 +387,7 @@ something is wrong here. Please report this to $ISSUES"
# Used in geoblock.sh
get_newest_dat_files() {
# IPv4
IPV4_NAME=$(curl -s https://github.com/nextcloud/vm/tree/master/geoblockdat \
IPV4_NAME=$(curl -s https://github.com/nextcloud/vm/tree/main/geoblockdat \
| grep -oP '202[0-9]-[01][0-9]-Maxmind-Country-IPv4\.dat' | sort -r | head -1)
if [ -z "$IPV4_NAME" ]
then
@ -418,7 +413,7 @@ get_newest_dat_files() {
fi
fi
# IPv6
IPV6_NAME=$(curl -s https://github.com/nextcloud/vm/tree/master/geoblockdat \
IPV6_NAME=$(curl -s https://github.com/nextcloud/vm/tree/main/geoblockdat \
| grep -oP '202[0-9]-[01][0-9]-Maxmind-Country-IPv6\.dat' | sort -r | head -1)
if [ -z "$IPV6_NAME" ]
then
@ -466,7 +461,16 @@ done
check_running_cronjobs() {
while [ -n "$(pgrep -f nextcloud/cron.php)" ]
do
countdown "Waiting for the Nextcloud cronjob to finish..." "30"
# Check if virus scan is running, could take ages for it to finish...
if ! pgrep -f clamd
then
# If not running, then keep waiting
countdown "Waiting for the Nextcloud cronjob to finish..." "30"
else
# If virus scan is running, then wait a bit longer, and kill it to release cron.php
countdown "Waiting for the Nextcloud cronjob and virusscan to finish..." "120"
pkill -f clamd
fi
done
}
@ -503,7 +507,8 @@ You can use this site to check if the IP seems correct: https://www.whatsmydns.n
fi
# Is the DNS record same as the external IP address of the server?
if dig +short "${1}" @resolver1.opendns.com | grep -q "$WANIP4"
DIG="$(dig +short "${1}" @resolver1.opendns.com)"
if [ "$DIG" = "$WANIP4" ]
then
print_text_in_color "$IGreen" "DNS seems correct when checking with dig!"
else
@ -703,10 +708,10 @@ version(){
[[ $2 != "$h" && $2 != "$t" ]]
}
if ! version 20.04 "$DISTRO" 22.04.10
if ! version 22.04 "$DISTRO" 24.04.10
then
print_text_in_color "$IRed" "Your current Ubuntu version is $DISTRO but must be between \
20.04 - 22.04.10 to run this script."
22.04 - 24.04.10 to run this script."
print_text_in_color "$ICyan" "Please contact us for support upgrading your server:"
print_text_in_color "$ICyan" "https://www.hanssonit.se/#contact"
print_text_in_color "$ICyan" "https://shop.hanssonit.se/"
@ -758,22 +763,45 @@ fi
# Check if Nextcloud is installed with TLS
check_nextcloud_https() {
if ! nextcloud_occ_no_check config:system:get overwrite.cli.url | grep -q "https"
if ! nextcloud_occ_no_check config:system:get overwrite.cli.url | grep -q "https"
then
# Check if it's used by any of the Documentserver apps and adopt the message to that
if [ "$1" == 'Collabora (Docker)' ] || [ "$1" == 'OnlyOffice (Docker)' ]
then
msg_box "Sorry, but Nextcloud needs to be run on HTTPS.
ncdomain
if ! curl -s https://"$NCDOMAIN"/status.php | grep -q 'installed":true'
then
msg_box "Sorry, but Nextcloud needs to be run on HTTPS.
You can easily activate TLS (HTTPS) by running the Let's Encrypt script.
More info here: https://bit.ly/37wRCin
More info here: http://shortio.hanssonit.se/1EAgBmPyFc
To run this script again, just exectue 'sudo bash $SCRIPTS/menu.sh' and choose:
Additional Apps --> Documentserver --> $1."
exit
exit
fi
else
# Adopt the error message to anything else but the Documentserver apps
ncdomain
if ! curl -s https://"$NCDOMAIN"/status.php | grep -q 'installed":true'
then
msg_box "Sorry, but Nextcloud needs to be run on HTTPS.
You can easily activate TLS (HTTPS) by running the Let's Encrypt script.
More info here: http://shortio.hanssonit.se/1EAgBmPyFc
To run this script again, just exectue 'sudo bash $SCRIPTS/menu.sh' and choose:
Additional Apps --> $1."
exit
fi
fi
fi
}
restart_webserver() {
# https://github.com/nextcloud/vm/issues/2358
sleep 2
print_text_in_color "$ICyan" "Restarting Apache2 and PHP-FPM..."
check_command systemctl restart apache2.service
check_php
if is_this_installed php"$PHPVER"-fpm
then
check_command systemctl restart php"$PHPVER"-fpm.service
@ -884,7 +912,7 @@ then
# Generate DHparams cipher
if [ ! -f "$DHPARAMS_TLS" ]
then
openssl dhparam -dsaparam -out "$DHPARAMS_TLS" 4096
openssl dhparam -out "$DHPARAMS_TLS" 2048
fi
# Choose which port for public access
msg_box "You will now be able to choose which port you want to put your Nextcloud on for public access.\n
@ -1039,16 +1067,16 @@ remove_from_trusted_domains() {
}
check_distro_version() {
# Subṕport Ubuntu 22.0.4 jammy, and Ubuntu 20.04 focal.
# Support Ubuntu 22.04 jammy, and Ubuntu 24.04 noble.
# Check Ubuntu version
if [ "${CODENAME}" == "jammy" ] || [ "${CODENAME}" == "focal" ]
if [ "${CODENAME}" == "jammy" ] || [ "${CODENAME}" == "noble" ]
then
OS=1
elif lsb_release -i | grep -ic "Ubuntu" &> /dev/null
then
OS=1
elif uname -a | grep -ic "jammy" &> /dev/null || uname -a | grep -ic "focal" &> /dev/null
elif uname -a | grep -ic "jammy" &> /dev/null || uname -a | grep -ic "noble" &> /dev/null
then
OS=1
elif uname -v | grep -ic "Ubuntu" &> /dev/null
@ -1065,8 +1093,8 @@ You can find the download link here: https://www.ubuntu.com/download/server"
exit 1
fi
if ! version 20.04 "$DISTRO" 22.04.10; then
msg_box "Your current Ubuntu version is $DISTRO but must be between 20.04 - 22.04.10 to run this script."
if ! version 22.04 "$DISTRO" 24.04.10; then
msg_box "Your current Ubuntu version is $DISTRO but must be between 22.04 - 24.04.10 to run this script."
msg_box "Please contact us to get support for upgrading your server:
https://www.hanssonit.se/#contact
https://shop.hanssonit.se/product/upgrade-ubuntu-os-between-major-versions/"
@ -1097,6 +1125,12 @@ fi
install_if_not() {
if ! dpkg-query -W -f='${Status}' "${1}" | grep -q "ok installed"
then
# https://askubuntu.com/questions/1235914/hash-sum-mismatch-error-due-to-identical-sha1-and-md5-but-different-sha256#1242739
#if ! -f /etc/gcrypt/hwf.deny ]
#then
# mkdir -p /etc/gcrypt
# echo all > /etc/gcrypt/hwf.deny
#fi
apt-get update -q4 & spinner_loading && RUNLEVEL=1 apt-get install "${1}" -y
fi
}
@ -1125,10 +1159,7 @@ then
print_text_in_color "$IRed" "Error: ${1} GB RAM required to install ${2}!" >&2
print_text_in_color "$IRed" "Current RAM is: ($mem_available_gb GB)" >&2
sleep 3
msg_box "** Error: insufficient memory. ${mem_available_gb}GB RAM installed, ${1}GB required.
To bypass this check, comment out (add # before the line) 'ram_check X' in the script that you are trying to run.
Please note this may affect performance. USE AT YOUR OWN RISK!"
msg_box "** Error: insufficient memory. ${mem_available_gb}GB RAM installed, ${1}GB required."
exit 1
else
print_text_in_color "$IGreen" "RAM for ${2} OK! ($mem_available_gb GB)"
@ -1168,14 +1199,37 @@ $ISSUES and include the output of the error message. Thank you!" \
fi
}
# Example: nextcloud_occ 'maintenance:mode --on'
# Example: nextcloud_occ_no_check 'maintenance:mode --on'
nextcloud_occ() {
check_command sudo -u www-data php "$NCPATH"/occ "$@";
# Check it maintenance:mode is enabled
if sudo -u www-data php "$NCPATH"/occ maintenance:mode | grep -q enabled >/dev/null 2>&1
then
# Disable maintenance:mode
sudo -u www-data php "$NCPATH"/occ maintenance:mode --off >/dev/null 2>&1
# Run the actual command
check_command sudo -u www-data php "$NCPATH"/occ "$@";
# Enable maintenance:mode again
sudo -u www-data php "$NCPATH"/occ maintenance:mode --on >/dev/null 2>&1
else
check_command sudo -u www-data php "$NCPATH"/occ "$@";
fi
}
# Example: nextcloud_occ_no_check 'maintenance:mode --on'
nextcloud_occ_no_check() {
sudo -u www-data php "$NCPATH"/occ "$@";
# Check it maintenance:mode is enabled
if sudo -u www-data php "$NCPATH"/occ maintenance:mode | grep -q enabled >/dev/null 2>&1
then
# Disable maintenance:mode
sudo -u www-data php "$NCPATH"/occ maintenance:mode --off >/dev/null 2>&1
# Run the actual command
sudo -u www-data php "$NCPATH"/occ "$@";
# Enable maintenance:mode again
sudo -u www-data php "$NCPATH"/occ maintenance:mode --on >/dev/null 2>&1
else
sudo -u www-data php "$NCPATH"/occ "$@";
fi
}
# Backwards compatibility (2020-10-08)
@ -1199,7 +1253,7 @@ version(){
[[ $2 != "$h" && $2 != "$t" ]]
}
if version 20.04 "$DISTRO" 22.04.10
if version 22.04 "$DISTRO" 24.04.10
then
print_text_in_color "$ICyan" "Testing if network is OK..."
if site_200 github.com
@ -1224,7 +1278,7 @@ then
fi
fi
else
msg_box "Your current Ubuntu version is $DISTRO but must be between 20.04 - 22.04.10 to run this script."
msg_box "Your current Ubuntu version is $DISTRO but must be between 22.04 - 24.04.10 to run this script."
msg_box "Please contact us to get support for upgrading your server:
https://www.hanssonit.se/#contact
https://shop.hanssonit.se/"
@ -1396,7 +1450,7 @@ If it still fails, please report this issue to: $ISSUES."
fi
}
# Run any script in ../master
# Run any script in ../main
# call like: run_main_script name_of_script
run_main_script() {
run_script GITHUB_REPO "${1}"
@ -1488,7 +1542,7 @@ or experience other issues then please report this to $ISSUES"
# Download the latest updater
# cd $NCPATH
# curl sLO https://github.com/nextcloud/updater/archive/master.zip
# curl sLO https://github.com/nextcloud/updater/archive/main.zip
# install_if_not unzip
# unzip -q master.zip
# rm master.zip*
@ -1509,10 +1563,8 @@ fi
# Check new version
# shellcheck source=lib.sh
if [ -z "$NCVERSION" ]
then
nc_update
fi
source /var/scripts/fetch_lib.sh
nc_update
if [ "${CURRENTVERSION%%.*}" -ge "$1" ]
then
sleep 1
@ -1656,7 +1708,7 @@ is_image_present() {
}
# Check if old docker exists
# FULL NAME e.g. ark74/nc_fts or containrrr/watchtower or collabora/code
# FULL NAME e.g. ark74/nc_fts or containrrr/watchtower or collabora/code or 'nextcloud/aio-imaginary'
does_this_docker_exist() {
is_docker_running && is_image_present "$1";
}
@ -1669,7 +1721,7 @@ then
print_text_in_color "$ICyan" "Installing Docker CE..."
apt-get update -q4 & spinner_loading
install_if_not curl
curl -fsSL get.docker.com | sh
curl -fsSL https://get.docker.com | sh
fi
# Set overlay2
@ -1680,10 +1732,11 @@ then
"storage-driver": "overlay2"
}
OVERLAY2
fi
systemctl daemon-reload
systemctl restart docker.service
# Only restart if changed
systemctl daemon-reload
systemctl restart docker.service
fi
}
# Remove all dockers excluding one
@ -1693,30 +1746,40 @@ print_text_in_color "$ICyan" "Checking if there are any old images and removing
DOCKERPS=$(docker ps -a | grep -v "$1" | awk 'NR>1 {print $1}')
if [ "$DOCKERPS" != "" ]
then
msg_box "Removing old Docker instance(s)... ($DOCKERPS)
Please note that we will not remove $1 ($2).
You will be given the option to abort when you hit OK."
any_key "Press any key to continue. Press CTRL+C to abort"
docker stop "$(docker ps -a | grep -v "$1" | awk 'NR>1 {print $1}')"
docker container prune -f
docker image prune -a -f
docker volume prune -f
if yesno_box_yes "Do you want to remove old Docker instance(s)... ($DOCKERPS)? Please note that we will not remove $1 ($2)."
then
docker stop "$(docker ps -a | grep -v "$1" | awk 'NR>1 {print $1}')"
docker container prune -f
docker image prune -a -f
docker volume prune -f
else
msg_box "OK, this script will now exit, but there's still leftovers to cleanup. You can run it again at any time."
exit
fi
fi
}
# Remove selected Docker image
# docker_prune_this 'collabora/code' 'onlyoffice/documentserver' 'ark74/nc_fts'
# docker_prune_this 'collabora/code' 'onlyoffice/documentserver' 'ark74/nc_fts' 'imaginary'
docker_prune_this() {
if does_this_docker_exist "$1"
then
msg_box "Removing old Docker image: $1
You will be given the option to abort when you hit OK."
any_key "Press any key to continue. Press CTRL+C to abort"
docker stop "$(docker container ls -a | grep "$1" | awk '{print $1}' | tail -1)"
docker rm "$(docker container ls -a | grep "$1" | awk '{print $1}' | tail -1)" --volumes
docker image prune -a -f
if yesno_box_yes "Do you want to remove $1?"
then
CONTAINER="$(docker container ls -a | grep "$1" | awk '{print $1}' | tail -1)"
if [ -z "$CONTAINER" ]
then
# Special solution if the container name is scrambled, then search for the actual name instead
CONTAINER="$(docker container ls -a | grep "$2" | awk '{print $1}' | tail -1)"
fi
docker stop "$CONTAINER"
docker rm "$CONTAINER"
docker image prune -a -f
docker system prune -a -f
else
msg_box "OK, this script will now exit, but there's still leftovers to cleanup. You can run it again at any time."
exit
fi
fi
}
@ -1738,31 +1801,39 @@ docker-compose_down() {
if [ -f "$1" ]
then
cd "$(dirname "$1")"
docker-compose down --volume --rmi all
if is_this_installed docker-compose
then
docker-compose down --volumes --rmi all
else
docker compose down --volumes --rmi all
fi
# Remove leftovers
docker system prune -a -f
else
echo "Non-existing docker-compose file path, skipping..."
fi
}
# Update specific Docker image
# docker_update_specific 'vaultwarden' 'Vaultwarden' (docker conainter name = $1, the name in text = $2)
docker_update_specific() {
if is_docker_running && docker ps -a --format "{{.Names}}" | grep -q "^$1$"
then
docker run --rm --name temporary_watchtower -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --cleanup --run-once "$1"
print_text_in_color "$IGreen" "$2 docker image just got updated!"
echo "Docker image just got updated! We just updated $2 docker image automatically! $(date +%Y%m%d)" >> "$VMLOGS"/update.log
if docker run --rm --name temporary_watchtower -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --cleanup --run-once "$1"
then
print_text_in_color "$IGreen" "$2 docker image just got updated!"
echo "Docker image just got updated! We just updated $2 docker image automatically! $(date +%Y%m%d)" >> "$VMLOGS"/update.log
fi
fi
}
# docker-compose_update 'fts_os-node' 'Full Text Search' "$OPNSDIR"
# docker-compose_update 'fulltextsearch-elasticsearch' 'Full Text Search' "$FTSDIR"
# (docker conainter name = $1, the name in text = $2 , docker-compose directory = $3)
docker-compose_update() {
if is_docker_running && docker ps -a --format "{{.Names}}" | grep -q "^$1$"
then
cd "$3"
docker-compose pull
docker-compose up -d --remove-orphans
docker compose pull
docker compose up -d --remove-orphans
docker image prune -a -f
print_text_in_color "$IGreen" "$2 docker image just got updated!"
echo "Docker image just got updated! We just updated $2 docker image automatically! $(date +%Y%m%d)" >> "$VMLOGS"/update.log
@ -1785,10 +1856,14 @@ printf "%b%s%b\n" "$1" "$2" "$Color_Off"
}
# Apply patch
# git_apply_patch 15992 server 16.0.2
# App:
# git_apply_patch "319" "fulltextsearch_elasticsearch" "27.1.1" "$NCPATH/apps/fulltextsearch_elasticsearch"
# Server:
# git_apply_patch "15992" "server" "16.0.2" "$NCPATH"
# 1 = pull
# 2 = repository
# Nextcloud version
# 3 = Nextcloud version
# 4 = Folder on system
git_apply_patch() {
if [ -z "$NCVERSION" ]
then
@ -1798,7 +1873,7 @@ if [[ "$CURRENTVERSION" = "$3" ]]
then
curl_to_dir "https://patch-diff.githubusercontent.com/raw/nextcloud/${2}/pull" "${1}.patch" "/tmp"
install_if_not git
cd "$NCPATH"
cd "${4}"
if git apply --check /tmp/"${1}".patch >/dev/null 2>&1
then
print_text_in_color "$IGreen" "Applying patch https://github.com/nextcloud/${2}/pull/${1} ..."
@ -1816,11 +1891,14 @@ fi
home_sme_server() {
# OLD DISKS: "Samsung SSD 860" || ST5000LM000-2AN1 || ST5000LM015-2E81
# OLD MEMORY: BLS16G4 (Balistix Sport) || 18ASF2G72HZ (ECC)
if lshw -c system | grep -q "NUC8i3BEH\|NUC10i3FNH\|PN50\|PN51"
if lshw -c system | grep -q "NUC8i3BEH\|NUC10i3FNH\|PN50\|PN51\|PN52"
then
if lshw -c memory | grep -q "BLS16G4\|18ASF2G72HZ\|16ATF2G64HZ\|CT16G4SFD8266\|M471A4G43MB1\|9905744\|HMA82GS6JJR8N\|HMA82GS6CJR8N\|9905703-023"
if lshw -c memory | grep -q "BLS16G4\|18ASF2G72HZ\|16ATF2G64HZ\|CT16G4SFD8266\|M471A4G43MB1\|9905744\|HMA82GS6JJR8N\|HMA82GS6CJR8N\|9905703-023\|9905744-110"
then
if lshw -c disk | grep -q "ST2000LM015-2E81\|WDS400\|ST5000LM000-2AN1\|ST5000LM015-2E81\|Samsung SSD 860\|WDS500G1R0B"
then
NEXTCLOUDHOMESME=yes-this-is-the-home-sme-server
elif lshw -c storage | grep -q "SN700"
then
NEXTCLOUDHOMESME=yes-this-is-the-home-sme-server
fi
@ -1923,7 +2001,7 @@ zpool_import_if_missing() {
# ZFS needs to be installed
if ! is_this_installed zfsutils-linux
then
print_text_in_color "$IRed" "This function is only intened to be run if you have ZFS installed."
print_text_in_color "$IRed" "This function is only intended to be run if you have ZFS installed."
return 1
elif [ -z "$POOLNAME" ]
then
@ -1954,7 +2032,7 @@ fi
check_free_space() {
if vgs &>/dev/null
then
FREE_SPACE=$(vgs | grep ubuntu-vg | awk '{print $7}' | grep g | grep -oP "[0-9]+[\.,][0-9]" | sed 's|\.||')
FREE_SPACE=$(vgs | grep ubuntu-vg | awk '{print $7}' | grep g | grep -oP "[0-9]+[\.,][0-9]" | sed 's|[.,]||')
fi
if [ -z "$FREE_SPACE" ]
then
@ -2019,6 +2097,18 @@ then
elif grep 8.2 <<< "$GETPHP" >/dev/null 2>&1
then
export PHPVER=8.2
elif grep 8.3 <<< "$GETPHP" >/dev/null 2>&1
then
export PHPVER=8.3
elif grep 8.4 <<< "$GETPHP" >/dev/null 2>&1
then
export PHPVER=8.4
elif grep 8.5 <<< "$GETPHP" >/dev/null 2>&1
then
export PHPVER=8.5
elif grep 8.6 <<< "$GETPHP" >/dev/null 2>&1
then
export PHPVER=8.6
fi
# Export other PHP variables based on PHPVER
@ -2079,7 +2169,7 @@ add_trusted_key_and_repo() {
check_distro_version
# Do the magic
if version 22.04 "$DISTRO" 22.04.10
if version 22.04 "$DISTRO" 24.04.10
then
# New recommended way not using apt-key
print_text_in_color "$ICyan" "Adding trusted key in /etc/apt/keyrings/$1..."

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Additional Apps Menu"
@ -39,24 +39,24 @@ choice=$(whiptail --title "$TITLE" --checklist \
"Which apps do you want to install?\n\nAutomatically configure and install selected apps
$CHECKLIST_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
"Documentserver" "(OnlyOffice or Collabora - Docker or Integrated)" OFF \
"Bitwarden" "(External password manager)" OFF \
"Bitwarden" "(External password manager) [4GB RAM]" OFF \
"Fail2ban " "(Extra Bruteforce protection)" "$STARTUP_SWITCH" \
"PreviewGenerator" "(Pre-generate previews for Nextcloud)" OFF \
"Recognize" "(Use [local] AI on your photos in Nextcloud) [8GB RAM]" OFF \
"Imaginary" "(Generate image previews for Nextcloud) [4GB RAM]" "$STARTUP_SWITCH" \
"Webmin" "(Server GUI like Cpanel)" OFF \
"Talk" "(Video calls and chat for Nextcloud - requires port 3478)" "$STARTUP_SWITCH" \
"SMB-mount" "(Mount SMB-shares from your local network)" OFF \
"Adminer" "(PostgreSQL GUI)" OFF \
"LDAP" "(Windows Active directory for Nextcloud)" OFF \
"Notify Push" "(High Performance Files Backend for Nextcloud)" OFF \
"Talk" "(Video calls and chat for Nextcloud)" OFF \
"Netdata" "(Real-time server monitoring in Web GUI)" OFF \
"FullTextSearch" "(Search for text inside documents [4GB RAM])" OFF \
"FullTextSearch" "(Search for text inside documents [6GB RAM])" OFF \
"BPYTOP" "(Real-time server monitoring in CLI)" OFF \
"ClamAV" "(Antivirus for Nextcloud and files)" OFF \
"Midnight Commander" "(CLI file manager)" OFF \
"Pico CMS" "(Lightweight CMS integration in Nextcloud)" OFF \
"Whiteboard" "(Whiteboard for Nextcloud)" OFF \
"Extract" "(Archive extraction for Nextcloud)" OFF \
"Face Recognition" "(Scan your photos for faces in Nextcloud)" OFF \
"SMB-mount" "(Mount SMB-shares from your local network)" OFF \
"PDF Annotations" "(Annotate PDF files in Nextcloud)" OFF 3>&1 1>&2 2>&3)
case "$choice" in
@ -104,9 +104,9 @@ case "$choice" in
print_text_in_color "$ICyan" "Downloading the Pico CMS script..."
run_script APP pico_cms
;;&
*"PreviewGenerator"*)
print_text_in_color "$ICyan" "Downloading the PreviewGenerator script..."
run_script APP previewgenerator
*"Imaginary"*)
print_text_in_color "$ICyan" "Downloading the Imaginary script..."
run_script APP imaginary
;;&
*"Notify Push"*)
print_text_in_color "$ICyan" "Downloading the Notify Push script..."
@ -135,9 +135,9 @@ to finish the setup once this script is done." "$SUBTITLE"
print_text_in_color "$ICyan" "Downloading the Whiteboard script..."
run_script APP whiteboard
;;&
*"Face Recognition"*)
print_text_in_color "$ICyan" "Downloading the Face Recognition script..."
run_script APP face-recognition
*"Recognize"*)
print_text_in_color "$ICyan" "Downloading the Recognize script..."
run_script APP recognize
;;&
*"SMB-mount"*)
print_text_in_color "$ICyan" "Downloading the SMB-mount script..."

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Bitwarden Menu"

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="deSEC Menu"

View File

@ -1,9 +1,9 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Documentserver Menu"
SCRIPT_NAME="Documentserver menu"
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
@ -17,12 +17,12 @@ debug_mode
root_check
choice=$(whiptail --title "$TITLE" --menu \
"Which Documentserver do you want to install?\n\nAutomatically configure and install the selected Documentserver.
"Which Documentserver for online editing do you want to install?\n\nWe recomend Collabora with Docker. The subdomain could look like this:\noffice.your-nextcloud.tld\n\nAutomatically configure and install the selected Documentserver.
$MENU_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
"Collabora (Docker)" "(Online editing - Extra Subdomain required)" \
"Collabora (Integrated)" "(Online editing - No Subdomain required)" \
"OnlyOffice (Docker)" "(Online editing - Extra Subdomain required)" \
"OnlyOffice (Integrated)" "(Online editing - No Subdomain required)" 3>&1 1>&2 2>&3)
"Collabora (Docker)" "(Extra Subdomain required)" \
"Collabora (Integrated)" "(No Subdomain required)" \
"OnlyOffice (Docker)" "(Extra Subdomain required)" \
"OnlyOffice (Integrated)" "(No Subdomain required)" 3>&1 1>&2 2>&3)
case "$choice" in
"Collabora (Docker)")

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Fail2ban Menu"

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Main Menu"
@ -57,12 +57,15 @@ do_the_update() {
msg_box "Since you have automated updates enabled with the reboot option set, we won't run update script a second time to the latest version automatically.
To upgrade to the latest version, please run: 'sudo bash $SCRIPTS/update.sh' from your CLI."
else
if yesno_box_yes "We will now run the update script a second time to update to the latest major version ($NCVERSION). Do you want to continue?"
if version_gt "$NCVERSION" "$CURRENTVERSION"
then
# Check if it's an unsupported major version (will exit if it is)
major_versions_unsupported
# Do the upgrade if it's not
bash "$SCRIPTS"/update.sh
if yesno_box_yes "We will now run the update script a second time to update to the latest major version ($NCVERSION). Do you want to continue?"
then
# Check if it's an unsupported major version (will exit if it is)
major_versions_unsupported
# Do the upgrade if it's not
bash "$SCRIPTS"/update.sh
fi
fi
fi
fi
@ -72,7 +75,7 @@ To upgrade to the latest version, please run: 'sudo bash $SCRIPTS/update.sh' fro
# Check if automated updates are set
REBOOT_SET=$(grep -r "shutdown -r" "$SCRIPTS"/update.sh)
# Check if it's older than 60 days (60 seconds * 60 minutes * 24 hours * 60 days)
if [ "$(stat --format=%Y "$SCRIPTS"/update.sh)" -le "$(( $(date +%s) - ((60*60*24*60)) ))" ]
if [ "$(stat --format=%Y "$SCRIPTS"/update.sh)" -le "$(( $(date +%s) - (60*60*24*60) ))" ]
then
print_text_in_color "$ICyan" "Downloading the latest update script..."
download_script STATIC update

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Main Menu"

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Nextcloud Configuration Menu"

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Server Configuration Menu"

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Startup Configuration Menu"

View File

@ -1,53 +0,0 @@
//create folders
mkdir nc && cd nc
mkdir db
mkdir config
//if you are running postgresql < v13, upgrade the cluster to v13
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql-13
sudo pg_dropcluster 13 main --stop
sudo pg_upgradecluster -m upgrade 12 main
//copy db files
cp -r /var/lib/postgresql/13/main db
cp /etc/postgresql/13/main/pg_hba.conf db
cp /etc/postgresql/13/main/pg_ident.conf db
cp /etc/postgresql/13/main/postgresql.conf db
//patch postgres config file
patch db/postgresql.conf postgres.patch
//add authorization to pg-hba.conf file
echo "host all all all md5" >> db/pg_hba.conf
//copy nc config
cp -R /var/www/nextcloud/config/* config
/*copy configuration data in thes files:
nextcloud_admin_password.txt # put admin password to this file
nextcloud_admin_user.txt # put admin username to this file
postgres_db.txt # put postgresql db name to this file
postgres_password.txt # put postgresql password to this file
postgres_user.txt # put postgresql username to this file
*/
//patch nc config
patch config/config.php config.patch
//change config directory ownership if not already the case (tofind out the needed id: docker exec -it nc id www-data)
chown -R www-data:www-data *
docker-compose up -d
// /usr/bin/sed -i "/);/i 'installed' => true" /var/www/html/config/config.php

View File

@ -1,39 +0,0 @@
version: '3.2'
volumes:
nextcloud:
db:
services:
db:
image: postgres
container_name: db
restart: always
volumes:
- ./db:/var/lib/postgresql/data
environment:
- POSTGRES_DB_FILE=/run/secrets/postgres_db
- POSTGRES_USER_FILE=/run/secrets/postgres_user
- POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password
secrets:
- postgres_db
- postgres_password
- postgres_user
app:
image: nextcloud
container_name: nc
restart: always
ports:
- ${NC_PORT}:80
volumes:
- ./config:/var/www/html/config:rw
- ${NC_DATADIR}:/var/www/html/data
environment:
- POSTGRES_HOST=db
- POSTGRES_DB_FILE=${POSTGRES_DB}
- POSTGRES_USER_FILE=${POSTGRES_USER}
- POSTGRES_PASSWORD_FILE=${POSTGRES_PASSWORD}
- NEXTCLOUD_ADMIN_PASSWORD_FILE=${NEXTCLOUD_ADMIN_PASSWORD}
- NEXTCLOUD_ADMIN_USER_FILE=${NEXTCLOUD_ADMIN_USER}
depends_on:
- db

View File

@ -1,181 +0,0 @@
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
if [ $# -eq 0 ]
then
echo "No arguments supplied"
exit 0
elif [ $# -lt 4 ]; then
echo "Wrong number of arguments supplied"
exit 0
fi
echo "Using folder $1, and Nextcloud User $2"
DIR="$1"
NC_USER=$2
NC_PWD=$3
NC_PORT=$4
POSTGRESPATH="/etc/postgresql"
PSQLVERSION_DOCKER=13
CFG_VARS=("dbname" "dbpassword" "dbuser")
CFG_NAMES=("POSTGRES_DB" "POSTGRES_PASSWORD" "POSTGRES_USER")
CFG_NAMES_EXT=("NEXTCLOUD_ADMIN_USER" "NEXTCLOUD_ADMIN_PASSWORD")
NC_CFG_PATH="config/config.php"
PG_CFG_PATH="db/postgresql.conf"
PG_COMMENT_OUT=("data_directory" "hba_file" "ident_file" "external_pid_file" "port" "ssl" "ssl_cert_file" "ssl_key_file" "log_line_prefix" "cluster_name" "stats_temp_directory" "include_dir")
if [ -d "$POSTGRESPATH" ]
then
mapfile -t test < <(find /usr -wholename '*/bin/postgres' |grep -Eo "[0-9][0-9]")
PSQLVERSION=0
for v in "${test[@]}"; do
if (( v > PSQLVERSION )); then PSQLVERSION=$v; fi;
done
echo "Postgresql installation Version $PSQLVERSION found"
else
echo "No postgresql installation found"
exit 0
fi
PG_CFG="/etc/postgresql/$PSQLVERSION/main"
PG_DATA="/var/lib/postgresql/$PSQLVERSION/main"
if (( PSQLVERSION < PSQLVERSION_DOCKER )); then
echo "Migrating database from version $PSQLVERSION to version $PSQLVERSION_DOCKER"
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
echo "Adding postgresql 13 repo and installing"
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
apt-get update
apt-get -y install postgresql-$PSQLVERSION_DOCKER -y
echo "Stopping Version $PSQLVERSION_DOCKER cluster"
pg_dropcluster 13 main --stop
echo "Migrating old cluster"
{
pg_upgradecluster -m upgrade "$PSQLVERSION" main
} ||
{
# could also check postgresql owner
#USER=$(stat -c '%U' "/etc/postgresql/12/main")
#echo $USER
#USER=$(stat -c '%U' "/var/lib/postgresql/12/main")
#echo $USER
chown -R postgres:postgres "$PG_CFG"
chown -R postgres:postgres "$PG_DATA"
pg_upgradecluster -m upgrade "$PSQLVERSION" main
}
fi
echo "making new folders"
mkdir "$DIR"
echo "Copying docker-compose file"
cp docker-compose.yml "$DIR"
cd "$DIR" || exit 0
mkdir db
mkdir config
echo "Copying database files"
cp -R /var/lib/postgresql/13/main db
cp /etc/postgresql/13/main/pg_hba.conf db
cp /etc/postgresql/13/main/pg_ident.conf db
cp /etc/postgresql/13/main/postgresql.conf db
echo "copying Nextcloud config file"
cp -R /var/www/nextcloud/config/* config
echo "Creating .env file"
for var in "${CFG_VARS[@]}"
do
file=$(grep "$var" < config/config.php)
IFS=" " read -r -a line <<< "$(grep "[\"'][^\"']*[\"']" <<< "$file")"
value=$(echo "${line[2]}"| sed -r "s/[\"',-]//gi")
echo "${CFG_NAMES[INDEX]}=$value saved in .env file"
echo "${CFG_NAMES[INDEX]}=$value" >> ".env"
((INDEX=INDEX+1))
done
{
echo "${CFG_NAMES_EXT[0]}=$NC_USER"
echo "${CFG_NAMES_EXT[1]}=$NC_PWD"
}>> ".env"
echo "NC_PORT=${NC_PORT}" >> ".env"
file=$(grep datadirectory < config/config.php)
IFS=" " read -r -a line <<< "$(grep "[\"'][^\"']*[\"']" <<< "$file")"
ORG_DATADIR=$(echo "${line[2]}"| sed -r "s/[\"',-]//gi")
echo "NC_DATADIR=${ORG_DATADIR}" >> ".env"
echo "Patching Nextcloud configuration file"
sed -i '/memcache.distributed/s/^/#/g' $NC_CFG_PATH
sed -i '/memcache.locking/s/^/#/g' $NC_CFG_PATH
start=$(sed -n '/redis/=' $NC_CFG_PATH| head -1)
mapfile -t ends < <(sed -n '/),/=' $NC_CFG_PATH )
for e in "${ends[@]}"
do
if [ "$e" -gt "$start" ]; then
end=$e
break
fi
done
sed -i "$start,$end s/^/#/" $NC_CFG_PATH
start=$(sed -n '/dbhost/=' $NC_CFG_PATH)
sed -i "$start s/.*/ 'dbhost' => 'db',/" $NC_CFG_PATH
start=$(sed -n '/datadirectory/=' $NC_CFG_PATH)
sed -i "$start s/.*/ 'datadirectory' => '\/var\/www\/html\/data',/" $NC_CFG_PATH
echo "Patching Postgresql configuration file"
for cmt in "${PG_COMMENT_OUT[@]}"
do
sed -i "/$cmt/s/^/#/g" $PG_CFG_PATH
done
start=$(sed -n '/listen_addresses/=' $PG_CFG_PATH)
sed -i "$start s/.*/listen_addresses = '*'/" $PG_CFG_PATH
echo "Patching Postgresql HBA file"
echo "host all all all md5" >> db/pg_hba.conf
chown -R www-data:docker ./*
echo "Disabling postgresql"
systemctl disable postgresql
systemctl stop postgresql
echo "Finished"
echo "Change the 'trusted_domains' section in the config/config.php file to match your needs"
echo "Run 'docker-compose up -d' to start the Nextcloud docker container"
echo "You may have to adjust the ownership of config and db folders"
echo "Consider changing your Apache configuration"

View File

@ -1,25 +0,0 @@
This repo is intended to help migrate an existing Nextcloud VM installation to a Docker container.
The Docker container will use the existing Postgresql Database (and it may update it) and the existing datadir.
# WARNING
This subfolder, and the migration tool have not been tested by the main maintainers of this repo. We put this here solely for inspiration, and you're on your own if something fails. We would still appreciate if you told us what went wrong though, by creating an issue.
How to use:
1. clone git
2. cd nc_migration
3. chmod +x migrate.sh
4. sudo ./migrate.sh destinationdir nc_username nc_password nc_port
5. change the trusted_domainssection in the config/config.php file to you needs
6. run it: 'docker-compose up-d'
Explanation of the bash script arguments:
- destinationdir = the folder containing all the files needed to run the Docker container
- nc_user = the Nextcloud administrator user
- nc_password = password for this user
- nc_port = port exposed by the container
TBD:
1. Implement SSL
2. Change bash script to include 'help' section and to be more versatile
3. Add redis

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Implements this way of doing it: https://askubuntu.com/a/1281319
@ -33,9 +33,9 @@ install_if_not build-essential
install_if_not dkms
INSTALLDIR="$SCRIPTS/PN51"
OLDRVERSION=( 9.005.06 9.006.04 9.007.01 9.008.00 9.009.00)
OLDRVERSION=( 9.005.06 9.006.04 9.007.01 9.008.00 9.009.00 9.009.01 9.010.01)
# Add old versions with a single space inside the variable above.
RVERSION="9.009.01"
RVERSION="9.011.00"
# Before changing the RVERSION here, please download it to the repo first.
# Make sure the installation directory exist
@ -57,7 +57,7 @@ fi
# Download the driver before it's removed (no internet when it's removed)
if [ ! -f "$INSTALLDIR"/r8125-"$RVERSION".tar.bz2 ]
then
curl_to_dir https://github.com/nextcloud/vm/raw/master/network/asusnuc r8125-"$RVERSION".tar.bz2 "$INSTALLDIR"
curl_to_dir https://github.com/nextcloud/vm/raw/main/network/asusnuc r8125-"$RVERSION".tar.bz2 "$INSTALLDIR"
fi
# Install latest driver

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true

View File

@ -1,6 +1,6 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
# Use local lib file in case there is no internet connection
if printf "Testing internet connection..." && ping github.com -c 2 >/dev/null 2>&1

View File

@ -1,28 +1,14 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
true
SCRIPT_NAME="Trusted"
SCRIPT_NAME="Set trusted domain"
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
source <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/main/lib.sh)
# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode
# Removed in NC 26.0.0.
download_script NETWORK update-config
if [ -f $SCRIPTS/update-config.php ]
then
# Change config.php
php $SCRIPTS/update-config.php $NCPATH/config/config.php 'trusted_domains[]' localhost "${ADDRESS[@]}" "$(hostname)" "$(hostname --fqdn)" >/dev/null 2>&1
php $SCRIPTS/update-config.php $NCPATH/config/config.php overwrite.cli.url https://"$(hostname --fqdn)"/ >/dev/null 2>&1
# Change .htaccess accordingly
sed -i "s|RewriteBase /nextcloud|RewriteBase /|g" $NCPATH/.htaccess
# Cleanup
rm -f $SCRIPTS/update-config.php
fi
# Set trusted domains
nextcloud_occ config:system:set trusted_domains 0 --value="localhost"
nextcloud_occ config:system:set trusted_domains 1 --value="$ADDRESS"
nextcloud_occ config:system:set trusted_domains 2 --value="$(hostname -f)"
nextcloud_occ config:system:set overwrite.cli.url --value="https://$(hostname --fqdn)"
nextcloud_occ maintenance:update:htaccess

View File

@ -1,53 +0,0 @@
#!/usr/bin/php
# Credit to: https://github.com/jnweiger
<?php
#
# Update or delete an entry in config.php.
# Called by kiwi's config.sh
#
if ($argc < 3)
{
print "Example Usage:\n\t". __FILE__." path/to/config.php overwritewebroot /nextcloud\n";
print "\t".__FILE__." path/to/config.php trusted_domains[] 17.0.2.15 localhost\n";
# nothing to do
return;
}
if (!is_file($argv[1]))
{
# do not create the file, if missing.
# Wrong permissions are deadly for nextcloud.
## FIXME: get some proper errno or strerror() please?
print($argv[1] . ": \$CONFIG cannot be loaded?\n");
return;
}
include "$argv[1]";
if ($argc > 3)
{
# append [] to the key name, if you need to pass an array object.
if (substr($argv[2], -2) === '[]')
{
$CONFIG[substr($argv[2],0,-2)] = array_slice($argv,3);
}
else
{
$CONFIG[$argv[2]] = $argv[3];
}
}
else
{
# exactly two parameter given -- means delete.
unset($CONFIG[$argv[2]]);
}
$text = var_export($CONFIG, true);
## A warning is printed, if argv[1] is not writable.
## PHP does not issue proper errno or strerror() does it?
file_put_contents($argv[1], "<?php\n\$CONFIG = $text;\n");
?>

View File

@ -1,607 +0,0 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# GNU General Public License v3.0
# https://github.com/nextcloud/vm/blob/master/LICENSE
#########
IRed='\e[0;91m' # Red
IGreen='\e[0;92m' # Green
ICyan='\e[0;96m' # Cyan
Color_Off='\e[0m' # Text Reset
print_text_in_color() {
printf "%b%s%b\n" "$1" "$2" "$Color_Off"
}
print_text_in_color "$ICyan" "Fetching all the variables from lib.sh..."
is_process_running() {
PROCESS="$1"
while :
do
RESULT=$(pgrep "${PROCESS}")
if [ "${RESULT:-null}" = null ]; then
break
else
print_text_in_color "$ICyan" "${PROCESS} is running, waiting for it to stop..."
sleep 10
fi
done
}
#########
# Check if dpkg or apt is running
is_process_running apt
is_process_running dpkg
true
SCRIPT_NAME="Nextcloud Startup Script"
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
# Get all needed variables from the library
ncdb
# Check if root
root_check
# Create a snapshot before modifying anything
check_free_space
if does_snapshot_exist "NcVM-installation" || [ "$FREE_SPACE" -ge 50 ]
then
if does_snapshot_exist "NcVM-installation"
then
check_command lvremove /dev/ubuntu-vg/NcVM-installation -y
fi
if ! lvcreate --size 5G --snapshot --name "NcVM-startup" /dev/ubuntu-vg/ubuntu-lv
then
msg_box "The creation of a snapshot failed.
If you just merged and old one, please reboot your server once more.
It should work afterwards again."
exit 1
fi
fi
# Check network
if network_ok
then
print_text_in_color "$IGreen" "Online!"
else
print_text_in_color "$ICyan" "Setting correct interface..."
[ -z "$IFACE" ] && IFACE=$(lshw -c network | grep "logical name" | awk '{print $3; exit}')
# Set correct interface
cat <<-SETDHCP > "/etc/netplan/01-netcfg.yaml"
network:
version: 2
renderer: networkd
ethernets:
$IFACE:
dhcp4: true
dhcp6: true
SETDHCP
check_command netplan apply
print_text_in_color "$ICyan" "Checking connection..."
sleep 1
set_systemd_resolved_dns "$IFACE"
if ! nslookup github.com
then
msg_box "The script failed to get an address from DHCP.
You must have a working network connection to run this script.
You will now be provided with the option to set a static IP manually instead."
# Run static_ip script
bash /var/scripts/static_ip.sh
fi
fi
# Check network again
if network_ok
then
print_text_in_color "$IGreen" "Online!"
elif home_sme_server
then
msg_box "It seems like the last try failed as well using LAN ethernet.
Since the Home/SME server is equipped with a Wi-Fi module, you will now be asked to enable it to get connectivity.
Please note: It's not recommended to run a server on Wi-Fi; using an ethernet cable is always the best."
if yesno_box_yes "Do you want to enable Wi-Fi on this server?"
then
install_if_not network-manager
nmtui
fi
if network_ok
then
print_text_in_color "$IGreen" "Online!"
else
msg_box "Network is NOT OK. You must have a working network connection to run this script.
Please contact us for support:
https://shop.hanssonit.se/product/premium-support-per-30-minutes/
Please also post this issue on: https://github.com/nextcloud/vm/issues"
exit 1
fi
else
msg_box "Network is NOT OK. You must have a working network connection to run this script.
Please contact us for support:
https://shop.hanssonit.se/product/premium-support-per-30-minutes/
Please also post this issue on: https://github.com/nextcloud/vm/issues"
exit 1
fi
# Check that this run on the PostgreSQL VM
if ! is_this_installed postgresql-common
then
print_text_in_color "$IRed" "This script is intended to be \
run using a PostgreSQL database, but PostgreSQL is not installed."
print_text_in_color "$IRed" "Aborting..."
exit 1
fi
# Run the startup menu
run_script MENU startup_configuration
true
SCRIPT_NAME="Nextcloud Startup Script"
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
# Get all needed variables from the library
ncdb
nc_update
# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode
# Nextcloud 21 is required
lowest_compatible_nc 21
# Add temporary fix if needed
if network_ok
then
run_script STATIC temporary-fix-beginning
fi
# Import if missing and export again to import it with UUID
zpool_import_if_missing
# Set phone region (needs the latest KEYBOARD_LAYOUT from lib)
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
if [ -n "$KEYBOARD_LAYOUT" ]
then
nextcloud_occ config:system:set default_phone_region --value="$KEYBOARD_LAYOUT"
fi
# Is this run as a pure root user?
if is_root
then
if [[ "$UNIXUSER" == "ncadmin" ]]
then
sleep 1
else
if [ -z "$UNIXUSER" ]
then
msg_box "You seem to be running this as the root user.
You must run this as a regular user with sudo permissions.
Please create a user with sudo permissions and the run this command:
sudo -u [user-with-sudo-permissions] sudo bash /var/scripts/nextcloud-startup-script.sh
We will do this for you when you hit OK."
download_script STATIC adduser
bash $SCRIPTS/adduser.sh "$SCRIPTS/nextcloud-startup-script.sh"
rm $SCRIPTS/adduser.sh
else
msg_box "You probably see this message if the user 'ncadmin' does not exist on the system,
which could be the case if you are running directly from the scripts on Github and not the VM.
As long as the user you created have sudo permissions it's safe to continue.
This would be the case if you created a new user with the script in the previous step.
If the user you are running this script with is a user that doesn't have sudo permissions,
please abort this script and report this issue to $ISSUES."
if yesno_box_yes "Do you want to abort this script?"
then
exit
fi
fi
fi
fi
######## The first setup is OK to run to this point several times, but not any further ########
if [ -f "$SCRIPTS/you-can-not-run-the-startup-script-several-times" ]
then
msg_box "The $SCRIPT_NAME script that handles this first setup \
is designed to be run once, not several times in a row.
If you feel uncertain about adding some extra features during this setup, \
then it's best to wait until after the first setup is done. You can always add all the extra features later.
[For the Nextcloud VM:]
Please delete this VM from your host and reimport it once again, then run this setup like you did the first time.
[For the Nextcloud Home/SME Server:]
It's a bit trickier since you can't revert in the same way as a VM. \
The best thing you can do now is to save all the output from the session you \
ran before this one + write down all the steps you took and send and email to:
github@hanssonit.se with the subject 'Issues with first setup', and we'll take it from there.
Full documentation can be found here: https://docs.hanssonit.se
Please report any bugs you find here: $ISSUES"
exit 1
fi
touch "$SCRIPTS/you-can-not-run-the-startup-script-several-times"
if home_sme_server
then
download_script STATIC nhss_index
mv $SCRIPTS/nhss_index.php $HTML/index.php && rm -f $HTML/html/index.html
chmod 750 $HTML/index.php && chown www-data:www-data $HTML/index.php
else
download_script STATIC index
mv $SCRIPTS/index.php $HTML/index.php && rm -f $HTML/html/index.html
chmod 750 $HTML/index.php && chown www-data:www-data $HTML/index.php
fi
# Change 000-default to $WEB_ROOT
sed -i "s|DocumentRoot /var/www/html|DocumentRoot $HTML|g" /etc/apache2/sites-available/000-default.conf
# Make possible to see the welcome screen (without this php-fpm won't reach it)
sed -i '14i\ # http://lost.l-w.ca/0x05/apache-mod_proxy_fcgi-and-php-fpm/' /etc/apache2/sites-available/000-default.conf
sed -i '15i\ <FilesMatch "\.php$">' /etc/apache2/sites-available/000-default.conf
sed -i '16i\ <If "-f %{SCRIPT_FILENAME}">' /etc/apache2/sites-available/000-default.conf
sed -i '17i\ SetHandler "proxy:unix:/run/php/php'$PHPVER'-fpm.nextcloud.sock|fcgi://localhost"' /etc/apache2/sites-available/000-default.conf
sed -i '18i\ </If>' /etc/apache2/sites-available/000-default.conf
sed -i '19i\ </FilesMatch>' /etc/apache2/sites-available/000-default.conf
sed -i '20i\ ' /etc/apache2/sites-available/000-default.conf
# Allow $UNIXUSER to run figlet script
chown "$UNIXUSER":"$UNIXUSER" "$SCRIPTS/nextcloud.sh"
msg_box "This script will configure your Nextcloud and activate TLS.
It will also do the following:
- Generate new SSH keys for the server
- Generate new PostgreSQL password
- Install selected apps and automatically configure them
- Detect and set hostname
- Detect and set trusted domains
- Upgrade your system and Nextcloud to latest version
- Set secure permissions to Nextcloud
- Set new passwords to Linux and Nextcloud
- Change timezone
- Set correct Rewriterules for Nextcloud
- Copy content from .htaccess to .user.ini (because we use php-fpm)
- Add additional options if you choose them
- And more..."
msg_box "PLEASE NOTE:
[#] Please finish the whole setup. The server will reboot once done.
[#] Please read the on-screen instructions carefully, they will guide you through the setup.
[#] When complete it will delete all the *.sh, *.html, *.tar, *.zip inside:
/root
/home/$UNIXUSER
[#] Please consider donating if you like the product:
https://shop.hanssonit.se/product-category/donate/
[#] You can also ask for help here:
https://help.nextcloud.com/c/support/appliances-docker-snappy-vm
https://shop.hanssonit.se/product/premium-support-per-30-minutes/"
msg_box "PLEASE NOTE:
The first setup is meant to be run once, and not aborted.
If you feel uncertain about the options during the setup, just choose the defaults by hitting [ENTER] at each question.
When the setup is done, the server will automatically reboot.
Please report any issues to: $ISSUES"
# Change timezone in PHP
sed -i "s|;date.timezone.*|date.timezone = $(cat /etc/timezone)|g" "$PHP_INI"
# Change timezone for logging
nextcloud_occ config:system:set logtimezone --value="$(cat /etc/timezone)"
# Pretty URLs
print_text_in_color "$ICyan" "Setting RewriteBase to \"/\" in config.php..."
chown -R www-data:www-data $NCPATH
nextcloud_occ config:system:set overwrite.cli.url --value="http://localhost/"
nextcloud_occ config:system:set htaccess.RewriteBase --value="/"
nextcloud_occ maintenance:update:htaccess
bash $SECURE & spinner_loading
# Generate new SSH Keys
printf "\nGenerating new SSH keys for the server...\n"
rm -v /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server
# Generate new PostgreSQL password
print_text_in_color "$ICyan" "Generating new PostgreSQL password..."
check_command bash "$SCRIPTS/change_db_pass.sh"
sleep 3
# Server configurations
bash $SCRIPTS/server_configuration.sh
# Nextcloud configuration
bash $SCRIPTS/nextcloud_configuration.sh
# Install apps
bash $SCRIPTS/additional_apps.sh
### Change passwords
# CLI USER
UNIXUSER="$(getent group sudo | cut -d: -f4 | cut -d, -f1)"
if [[ "$UNIXUSER" != "ncadmin" ]]
then
print_text_in_color "$ICyan" "No need to change password for CLI user '$UNIXUSER' since it's not the default user."
else
msg_box "For better security, we will now change the password for the CLI user in Ubuntu."
while :
do
UNIX_PASSWORD=$(input_box_flow "Please type in the new password for the current CLI user in Ubuntu: $UNIXUSER.")
if [[ "$UNIX_PASSWORD" == *" "* ]]
then
msg_box "Please don't use spaces."
else
break
fi
done
if check_command echo "$UNIXUSER:$UNIX_PASSWORD" | sudo chpasswd
then
msg_box "The new password for the current CLI user in Ubuntu ($UNIXUSER) is now set to: $UNIX_PASSWORD
This is used when you login to the Ubuntu CLI."
fi
fi
unset UNIX_PASSWORD
# NEXTCLOUD USER
NCADMIN=$(nextcloud_occ user:list | awk '{print $3}')
if [[ "$NCADMIN" != "ncadmin" ]]
then
print_text_in_color "$ICyan" "No need to change password for GUI user '$NCADMIN' since it's not the default user."
else
msg_box "We will now change the username and password for the Web Admin in Nextcloud."
while :
do
NEWUSER=$(input_box_flow "Please type in the name of the Web Admin in Nextcloud.
It must differ from the current one: $NCADMIN.\n\nThe only allowed characters for the username are:
'a-z', 'A-Z', '0-9', and '_.@-'")
if [[ "$NEWUSER" == *" "* ]]
then
msg_box "Please don't use spaces."
elif [ "$NEWUSER" = "$NCADMIN" ]
then
msg_box "This username ($NCADMIN) is already in use. Please choose a different one."
# - has to be escaped otherwise it won't work.
# Inspired by: https://unix.stackexchange.com/a/498731/433213
elif [ "${NEWUSER//[A-Za-z0-9_.\-@]}" ]
then
msg_box "Allowed characters for the username are:\na-z', 'A-Z', '0-9', and '_.@-'\n\nPlease try again."
else
break
fi
done
while :
do
OC_PASS=$(input_box_flow "Please type in the new password for the new Web Admin ($NEWUSER) in Nextcloud.")
if [[ "$OC_PASS" == *" "* ]]
then
msg_box "Please don't use spaces."
fi
# Create new user
export OC_PASS
if su -s /bin/sh www-data -c "php $NCPATH/occ user:add $NEWUSER --password-from-env -g admin"
then
msg_box "The new Web Admin in Nextcloud is now: $NEWUSER\nThe password is set to: $OC_PASS
This is used when you login to Nextcloud itself, i.e. on the web."
unset OC_PASS
break
else
any_key "Press any key to choose a different password."
fi
done
# Delete old user
if [[ "$NCADMIN" ]]
then
print_text_in_color "$ICyan" "Deleting $NCADMIN..."
nextcloud_occ user:delete "$NCADMIN"
sleep 2
fi
fi
# We need to unset the cached admin-user since we have changed its name
unset NC_ADMIN_USER
msg_box "Well done, you have now finished most of the setup.
There are still a few steps left but they are automated so sit back and relax! :)"
# Add default notifications
notify_admin_gui \
"Please set up SMTP" \
"Please remember to set up SMTP to be able to send shared links, user notifications and more via email. \
Please go here and start setting it up: https://your-nextcloud/settings/admin."
notify_admin_gui \
"Do you need support?" \
"If you need support, please visit the shop: https://shop.hanssonit.se, or the forum: https://help.nextcloud.com."
if ! is_this_installed php"$PHPVER"-imagick
then
notify_admin_gui \
"Regarding Imagick not being installed" \
"As you may have noticed, Imagick is not installed. We care about your security, \
and here's the reason: https://github.com/nextcloud/server/issues/13099"
fi
# Fixes https://github.com/nextcloud/vm/issues/58
a2dismod status
restart_webserver
if home_sme_server
then
install_if_not bc
mem_available="$(awk '/MemTotal/{print $2}' /proc/meminfo)"
mem_available_gb="$(echo "scale=0; $mem_available/(1024*1024)" | bc)"
# 32 GB RAM
if [[ 30 -lt "${mem_available_gb}" ]]
then
# Add specific values to PHP-FPM based on 32 GB RAM
check_command sed -i "s|pm.max_children.*|pm.max_children = 600|g" "$PHP_POOL_DIR"/nextcloud.conf
check_command sed -i "s|pm.start_servers.*|pm.start_servers = 100|g" "$PHP_POOL_DIR"/nextcloud.conf
check_command sed -i "s|pm.min_spare_servers.*|pm.min_spare_servers = 20|g" "$PHP_POOL_DIR"/nextcloud.conf
check_command sed -i "s|pm.max_spare_servers.*|pm.max_spare_servers = 480|g" "$PHP_POOL_DIR"/nextcloud.conf
restart_webserver
# 16 GB RAM
elif [[ 14 -lt "${mem_available_gb}" ]]
then
# Add specific values to PHP-FPM based on 16 GB RAM
check_command sed -i "s|pm.max_children.*|pm.max_children = 300|g" "$PHP_POOL_DIR"/nextcloud.conf
check_command sed -i "s|pm.start_servers.*|pm.start_servers = 50|g" "$PHP_POOL_DIR"/nextcloud.conf
check_command sed -i "s|pm.min_spare_servers.*|pm.min_spare_servers = 20|g" "$PHP_POOL_DIR"/nextcloud.conf
check_command sed -i "s|pm.max_spare_servers.*|pm.max_spare_servers = 280|g" "$PHP_POOL_DIR"/nextcloud.conf
restart_webserver
fi
else
# Calculate the values of PHP-FPM based on the amount of RAM available (minimum 2 GB or 8 children)
calculate_php_fpm
# Run again if values are reset on last run
calculate_php_fpm
fi
# Add temporary fix if needed
if network_ok
then
run_script STATIC temporary-fix-end
fi
# Cleanup 1
nextcloud_occ maintenance:repair
rm -f "$SCRIPTS/ip.sh"
rm -f "$SCRIPTS/change_db_pass.sh"
rm -f "$SCRIPTS/instruction.sh"
rm -f "$NCDATA/nextcloud.log"
rm -f "$SCRIPTS/static_ip.sh"
rm -f "$SCRIPTS/lib.sh"
rm -f "$SCRIPTS/server_configuration.sh"
rm -f "$SCRIPTS/nextcloud_configuration.sh"
rm -f "$SCRIPTS/additional_apps.sh"
rm -f "$SCRIPTS/adduser.sh"
rm -f "$SCRIPTS/activate-tls.sh"
rm -f "$SCRIPTS/desec_menu.sh"
rm -f "$NCDATA"/*.log
find /root "/home/$UNIXUSER" -type f \( -name '*.sh*' -o -name '*.html*' -o -name '*.tar*' -o -name 'results' -o -name '*.zip*' \) -delete
find "$NCPATH" -type f \( -name 'results' -o -name '*.sh*' \) -delete
sed -i "s|instruction.sh|nextcloud.sh|g" "/home/$UNIXUSER/.bash_profile"
truncate -s 0 \
/root/.bash_history \
"/home/$UNIXUSER/.bash_history" \
/var/spool/mail/root \
"/var/spool/mail/$UNIXUSER" \
/var/log/apache2/access.log \
/var/log/apache2/error.log \
"$VMLOGS/nextcloud.log"
sed -i "s|sudo -i||g" "$UNIXUSER_PROFILE"
cat << ROOTNEWPROFILE > "$ROOT_PROFILE"
# ~/.profile: executed by Bourne-compatible login shells.
if [ "/bin/bash" ]
then
if [ -f ~/.bashrc ]
then
. ~/.bashrc
fi
fi
if [ -x /var/scripts/nextcloud-startup-script.sh ]
then
/var/scripts/nextcloud-startup-script.sh
fi
if [ -x /var/scripts/history.sh ]
then
/var/scripts/history.sh
fi
mesg n
ROOTNEWPROFILE
# Set trusted domain in config.php
run_script NETWORK trusted
# Upgrade system
print_text_in_color "$ICyan" "System will now upgrade..."
bash $SCRIPTS/update.sh minor
# Cleanup 2
apt-get autoremove -y
apt-get autoclean
# Remove preference for IPv4
rm -f /etc/apt/apt.conf.d/99force-ipv4
apt-get update
# Success!
msg_box "The installation process is *almost* done.
Please hit OK in all the following prompts and let the server reboot to complete the installation process."
msg_box "TIPS & TRICKS:
1. Publish your server online: https://goo.gl/iUGE2U
2. To login to PostgreSQL just type: sudo -u postgres psql nextcloud_db
3. To update this server just type: sudo bash /var/scripts/update.sh
4. Install apps, configure Nextcloud, and server: sudo bash $SCRIPTS/menu.sh"
msg_box "SUPPORT:
Please ask for help in the forums, visit our shop to buy support,
or buy a yearly subscription from Nextcloud:
- SUPPORT: https://shop.hanssonit.se/product/premium-support-per-30-minutes/
- FORUM: https://help.nextcloud.com/
- SUBSCRIPTION: https://shop.hanssonit.se/product/nextcloud-enterprise-license-100-users/
BUGS:
Please report any bugs here: https://github.com/nextcloud/vm/issues"
msg_box "### PLEASE HIT OK TO REBOOT ###
Congratulations! You have successfully installed Nextcloud!
LOGIN:
Login to Nextcloud in your browser:
- IP: $ADDRESS
- Hostname: $(hostname -f)
### PLEASE HIT OK TO REBOOT ###"
# Reboot
print_text_in_color "$IGreen" "Installation done, system will now reboot..."
check_command rm -f "$SCRIPTS/you-can-not-run-the-startup-script-several-times"
check_command rm -f "$SCRIPTS/nextcloud-startup-script.sh"
reboot

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +0,0 @@
# What is this subfolder about?
This subdirectory of the Nextcloud VM contains scripts that probably *never* will get merged into the released version, but we keep them here so that users can test, and enjoy the befnefits of having an easy way set up the different software offered in this sub-folder. Freedom of choice basically.
## Can I help?
Yes, of course! :)<br>
Although mostof the scripts might not be 100% ready, we would love to hear your feedback anyway.
Feedback is especially welcome, if you would like to add some features that these scripts bring in the released version of the NcVM.<br>
So, please report back! 🚀
## How to run this inside my NcVM?
We have prepared a menu for you to choose from available options. You can download the menu with the following command:<br>
`sudo wget https://raw.githubusercontent.com/nextcloud/vm/master/not-supported/not-supported.sh -P /var/scripts`<br>
After downloading the menu, you just run it with the following command:<br>
`sudo bash /var/scripts/not-supported.sh`<br>
Running the not-supported script will show the menu with the latest options to choose from.

View File

@ -1,340 +0,0 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true
SCRIPT_NAME="Backup Viewer"
SCRIPT_EXPLAINER="This script shows the content of daily and/or off-shore backups."
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode
# Check if root
root_check
# Variables
DAILY_BACKUP_FILE="$SCRIPTS/daily-borg-backup.sh"
OFFSHORE_BACKUP_FILE="$SCRIPTS/off-shore-rsync-backup.sh"
# Ask for execution
msg_box "$SCRIPT_EXPLAINER"
if ! yesno_box_yes "Do you want to view the content of your backups?"
then
exit
fi
# Check if restore is possible
if ! [ -f "$DAILY_BACKUP_FILE" ]
then
msg_box "It seems like you haven't set up daily borg backups.
Please do that before you can view backups."
exit 1
fi
# Get needed variables
ENCRYPTION_KEY="$(grep "ENCRYPTION_KEY=" "$DAILY_BACKUP_FILE" | sed 's|.*ENCRYPTION_KEY="||;s|"||')"
DAILY_BACKUP_MOUNTPOINT="$(grep "BACKUP_MOUNTPOINT=" "$DAILY_BACKUP_FILE" | sed 's|.*BACKUP_MOUNTPOINT="||;s|"||')"
DAILY_BACKUP_TARGET="$(grep "BACKUP_TARGET_DIRECTORY=" "$DAILY_BACKUP_FILE" | sed 's|.*BACKUP_TARGET_DIRECTORY="||;s|"||')"
if [ -z "$ENCRYPTION_KEY" ] || [ -z "$DAILY_BACKUP_FILE" ] || [ -z "$DAILY_BACKUP_FILE" ]
then
msg_box "Some daily backup variables are empty. This is wrong."
exit 1
fi
# Also get variables from the offshore backup file
if [ -f "$OFFSHORE_BACKUP_FILE" ]
then
OFFSHORE_BACKUP_MOUNTPOINT="$(grep "BACKUP_MOUNTPOINT=" "$OFFSHORE_BACKUP_FILE" | sed 's|.*BACKUP_MOUNTPOINT="||;s|"||')"
OFFSHORE_BACKUP_TARGET="$(grep "BACKUP_TARGET_DIRECTORY=" "$OFFSHORE_BACKUP_FILE" | sed 's|.*BACKUP_TARGET_DIRECTORY="||;s|"||')"
if [ -z "$OFFSHORE_BACKUP_MOUNTPOINT" ] ||[ -z "$OFFSHORE_BACKUP_TARGET" ]
then
msg_box "Some off-shore backup variables are empty. This is wrong."
exit 1
fi
fi
# Check if pending snapshot is existing and cancel the viewing in this case.
if does_snapshot_exist "NcVM-snapshot-pending"
then
msg_box "The snapshot pending does exist. Can currently not show the backup.
Please try again later.\n
If you are sure that no update or backup is currently running, you can fix this by rebooting your server."
exit 1
fi
# Check if startup snapshot is existing and cancel the viewing in this case.
if does_snapshot_exist "NcVM-startup"
then
msg_box "The snapshot startup does exist.
Please run the update script first."
exit 1
fi
# Check if snapshot can get renamed
if ! does_snapshot_exist "NcVM-snapshot"
then
msg_box "The NcVM-snapshot doesn't exist. This isn't allowed."
exit 1
fi
# Select your way of showing the backups
choice=$(whiptail --title "$TITLE" --menu \
"Which way do you prefer of showing your backups?
$MENU_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
"Midnight Commander" "(Only for viewing your backups, no easy way to copy and move files)" \
"Webmin" "(Copy and move files via webpage but has bad mimetype support)" \
"Remotedesktop" "(Best way to copy and move files but needs xrdp to be installed)" 3>&1 1>&2 2>&3)
case "$choice" in
"Midnight Commander")
if ! is_this_installed mc
then
msg_box "It seems like Midnight Commander isn't installed, yet."
if yesno_box_yes "Do you want to install it now?"
then
run_script APP midnight-commander
else
exit 1
fi
if ! is_this_installed mc
then
msg_box "It seems like Midnight Commander stil isn't installed. Cannot proceed!"
exit 1
fi
fi
;;
"Webmin")
if ! is_this_installed webmin
then
msg_box "It seems like Webmin isn't installed, yet."
if yesno_box_yes "Do you want to install it now?"
then
run_script APP webmin
else
exit 1
fi
if ! is_this_installed webmin
then
msg_box "It seems like Webmin stil isn't installed. Cannot proceed!"
exit 1
fi
fi
;;
"Remotedesktop")
if ! is_this_installed xrdp
then
msg_box "It seems like Remotedesktop isn't installed, yet.
You need to install it on your server before you can use it.
To do that, you need to manually download and execute the following script on your server:
$NOT_SUPPORTED_FOLDER/remotedesktop.sh"
exit 1
fi
;;
"")
msg_box "No option chosen. Exiting!"
exit 1
;;
*)
;;
esac
# Safe the choice in a new variable
PROGRAM_CHOICE="$choice"
# View backup repository menu
args=(whiptail --title "$TITLE" --menu \
"Please select the backup repository that you want to view.
$MENU_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4)
print_text_in_color "$ICyan" "Looking for connected Backup drives. This can take a while..."
# Check if at least one drive is connected
DAILY=1
if ! [ -d "$DAILY_BACKUP_TARGET" ]
then
mount "$DAILY_BACKUP_MOUNTPOINT"
if ! [ -d "$DAILY_BACKUP_TARGET" ]
then
DAILY=""
fi
umount "$DAILY_BACKUP_MOUNTPOINT"
fi
if [ -f "$OFFSHORE_BACKUP_FILE" ]
then
OFFSHORE=1
if ! [ -d "$OFFSHORE_BACKUP_TARGET" ]
then
mount "$OFFSHORE_BACKUP_MOUNTPOINT"
if ! [ -d "$OFFSHORE_BACKUP_TARGET" ]
then
OFFSHORE=""
fi
fi
umount "$OFFSHORE_BACKUP_MOUNTPOINT"
fi
if [ -z "$DAILY" ] && [ -z "$OFFSHORE" ]
then
msg_box "Not even one backup drive is connected.
You must connect one if you want to view a backup."
exit 1
fi
# Get which one is connected
if [ -n "$DAILY" ]
then
args+=("$DAILY_BACKUP_TARGET" " Daily Backup Repository")
fi
if [ -n "$OFFSHORE" ]
then
args+=("$OFFSHORE_BACKUP_TARGET" " Off-Shore Backup Repository")
fi
# Show the menu
choice=$("${args[@]}" 3>&1 1>&2 2>&3)
if [ -z "$choice" ]
then
msg_box "No target selected. Exiting."
exit 1
fi
# Check the mountpoint
if mountpoint -q /tmp/borg
then
umount /tmp/borg
if mountpoint -q /tmp/borg
then
msg_box "There is still something mounted on /tmp/borg. Cannot proceed."
exit 1
fi
fi
# Check if pending snapshot is existing a second time and cancel the viewing in this case.
if does_snapshot_exist "NcVM-snapshot-pending"
then
msg_box "The snapshot pending does exist. Can currently not show the backup.
Please try again later.\n
If you are sure that no update or backup is currently running, you can fix this by rebooting your server."
exit 1
fi
# Rename the snapshot to represent that the backup is locked
if ! lvrename /dev/ubuntu-vg/NcVM-snapshot /dev/ubuntu-vg/NcVM-snapshot-pending
then
msg_box "Could not rename the snapshot. Please reboot your server!"
exit 1
fi
# Find out which one was mounted
if [ "$choice" = "$DAILY_BACKUP_TARGET" ]
then
BACKUP_MOUNTPOINT="$DAILY_BACKUP_MOUNTPOINT"
elif [ "$choice" = "$OFFSHORE_BACKUP_TARGET" ]
then
BACKUP_MOUNTPOINT="$OFFSHORE_BACKUP_MOUNTPOINT"
# Work around issue with borg
# https://github.com/borgbackup/borg/issues/3428#issuecomment-380399036
mv /root/.config/borg/security/ /root/.config/borg/security.bak
mv /root/.cache/borg/ /root/.cache/borg.bak
fi
# Mount the drive
mount "$BACKUP_MOUNTPOINT"
# Break the borg lock if it exists because we have the snapshot that prevents such situations
if [ -f "$BACKUP_TARGET_DIRECTORY/lock.roster" ]
then
print_text_in_color "$ICyan" "Breaking the borg lock..."
borg break-lock "$BACKUP_TARGET_DIRECTORY"
fi
# Mount the repository
export BORG_PASSPHRASE="$ENCRYPTION_KEY"
mkdir -p /tmp/borg
borg mount "$choice" /tmp/borg
unset BORG_PASSPHRASE
unset ENCRYPTION_KEY
case "$PROGRAM_CHOICE" in
"Midnight Commander")
while :
do
msg_box "We will now open Midnight Commander so that you can view the content of your backup repository.\n
Please remember a few things for Midnight Commander:
1. You can simply navigate with the [ARROW] keys and [ENTER]
2. When you are done, please close Midnight Commander completely by pressing [F10]. \
Otherwise we will not be able to unmount the backup repository again and there will \
most likely be problems during the next regular backup."
if yesno_box_no "Do you remember all two points?"
then
break
fi
done
# Set the needed settings for mc
mkdir -p "/root/.config/mc"
cat << MC_INI > "/root/.config/mc/panels.ini"
[New Left Panel]
list_format=user
user_format=full name | mtime:15 | size:15 | owner:12 | group:12 | perm:12
MC_INI
# Show Midnight commander
mc /tmp/borg
# Revert panel settings to MC
echo "" > "/root/.config/mc/panels.ini"
;;
"Webmin")
msg_box "For showing your backups with Webmin, you should be able to access them by visiting in a Browser:
https://$ADDRESS:10000/filemin/index.cgi?path=/tmp/borg \n
If you haven't been logged in to Webmin, yet, you might need to log in first and open the link after you've done that.\n
After you are done, just press [ENTER] here to unmount the backup again."
;;
"Remotedesktop")
msg_box "For showing your backups with Remotedesktop, you need to connect to your server using an RDP client.
After you are connected, open a terminal in the session and execute the following command \
which should open the file manager with the correct location:\n
xhost +si:localuser:root && sudo nautilus /tmp/borg \n
After you are done, just press [ENTER] here to unmount the backup again."
;;
*)
;;
esac
# Restore original cache and security folder
if [ "$BACKUP_MOUNTPOINT" = "$OFFSHORE_BACKUP_MOUNTPOINT" ]
then
rm -r /root/.config/borg/security
mv /root/.config/borg/security.bak/ /root/.config/borg/security
rm -r /root/.cache/borg
mv /root/.cache/borg.bak/ /root/.cache/borg
fi
# Re-rename the snapshot to represent that it is done
if ! lvrename /dev/ubuntu-vg/NcVM-snapshot-pending /dev/ubuntu-vg/NcVM-snapshot
then
msg_box "Could not re-rename the snapshot. Please reboot your server!"
exit 1
fi
# Unmount borg backup
if ! umount /tmp/borg
then
msg_box "Could not unmount the backup archives."
fi
# Unmount the backup drive
sleep 1
if ! umount "$BACKUP_MOUNTPOINT"
then
msg_box "Could not unmount the backup drive."
exit 1
fi
# End message
msg_box "Just unmounted the backup repository and drive again."
# Adjust permissions
if [ -f "$SCRIPTS/adjust-startup-permissions.sh" ]
then
nohup bash "$SCRIPTS/adjust-startup-permissions.sh" &>/dev/null &
fi

View File

@ -1,196 +0,0 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true
SCRIPT_NAME="Bitlocker Mount"
SCRIPT_EXPLAINER="This script automates mounting Bitlocker encrypted drives locally in your system.
Currently supported are only Bitlocker encrypted NTFS (Windows) drives.
You need a password to mount the drive. Recovery keys are not supported."
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode
# Check if root
root_check
# Show install_popup
if ! is_this_installed dislocker
then
# Ask for installing
install_popup "$SCRIPT_NAME"
fi
# Test if one drive is already mounted/created
if grep -q "/media/bitlocker/1" /etc/fstab || mountpoint -q /media/bitlocker/1
then
msg_box "This script currently only supports mounting one Bitlocker encrypted drive.
Please unmount the current one and remove it from /etc/fstab if you want to mount a different one.
The easiest way to do so is to run the following two commands:
sudo sed -i '/\/media\/bitlocker\/1/d' /etc/fstab
sudo reboot"
exit
fi
# Install needed packet
install_if_not dislocker
# Secure fstab
chown root:root /etc/fstab
chmod 600 /etc/fstab
# Connect Bitlocker drive
msg_box "Please connect your Bitlocker encrypted NTFS (Windows) drive now if you haven't already done this.
After you hit OK, we wil scan for Bitlocker drives."
print_text_in_color "$ICyan" "Please connect your Bitlocker encrypted drive now."
count=0
while [ "$count" -lt 60 ]
do
PARTUUID=$(lsblk -o FSTYPE,PARTUUID | grep BitLocker | awk '{print $2}' | head -1)
if [ -z "$PARTUUID" ]
then
print_text_in_color "$ICyan" "No Bitlocker drive found. Please connect your drive now."
sleep 5 & spinner_loading
echo ""
count=$((count+5))
else
break
fi
done
# Exit after 60 seconds
if [ "$count" -ge 60 ]
then
msg_box "No drive found within 60 seconds.
Please run this script again if you want to try again."
msg_box "We will now remove dislocker so that you keep a clean system."
apt-get purge dislocker -y
apt-get autoremove -y
exit
fi
# Inform the user
msg_box "A Bitlocker encrypted drive was found!
Please leave it connected. We will now continue with the mounting process."
# Enter the password
while :
do
PASSWORD=$(input_box_flow "Please enter your password for the Bitlocker encrypted drive now!
If you want to cancel, type 'exit' and press [ENTER].")
if [ "$PASSWORD" = "exit" ]
then
msg_box "We will now remove dislocker so that you keep a clean system."
apt-get purge dislocker -y
apt-get autoremove -y
exit 1
fi
mkdir -p /media/bitlocker/1
echo "PARTUUID=$PARTUUID /media/bitlocker/1 fuse.dislocker \
user-password=$PASSWORD,nofail 0 0" >> /etc/fstab
if ! mount /media/bitlocker/1
then
msg_box "The password seems to be false. Please try again."
sed -i '/fuse.dislocker/d' /etc/fstab
else
break
fi
done
# Inform the user
msg_box "The password is correct."
# Enter the mountpoint
while :
do
MOUNT_PATH=$(input_box_flow "Please type in the directory where you want to mount the Bitlocker encrypted drive.
One example is: '/mnt/data'
The directory has to start with '/mnt/'
If you want to cancel, type 'exit' and press [ENTER].")
if [ "$MOUNT_PATH" = "exit" ]
then
umount /media/bitlocker/1
sed -i '/fuse.dislocker/d' /etc/fstab
msg_box "We will now remove dislocker so that you keep a clean system."
apt-get purge dislocker -y
apt-get autoremove -y
exit 1
elif echo "$MOUNT_PATH" | grep -q " "
then
msg_box "Please don't use spaces!"
elif ! echo "$MOUNT_PATH" | grep -q "^/mnt/"
then
msg_box "The directory has to stat with '/mnt/'"
elif grep -q " $MOUNT_PATH " /etc/fstab
then
msg_box "The mountpoint already exists in fstab. Please try a different one."
elif mountpoint -q "$MOUNT_PATH"
then
msg_box "The mountpoint is already mounted. Please try a different one."
elif echo "$MOUNT_PATH" | grep -q "^/mnt/ncdata"
then
msg_box "The directory isn't allowed to start with '/mnt/ncdata'"
elif echo "$MOUNT_PATH" | grep -q "^/mnt/smbshares"
then
msg_box "The directory isn't allowed to start with '/mnt/smbshares'"
else
echo "/media/bitlocker/1/dislocker-file $MOUNT_PATH ntfs-3g \
windows_names,uid=www-data,gid=www-data,umask=007,nofail 0 0" >> /etc/fstab
mkdir -p "$MOUNT_PATH"
if ! mount "$MOUNT_PATH"
then
msg_box "The mount wasn't successful. Please try again.
Most likely it fails because the Bitlocker encrypted drive is no NTFS (Windows) drive."
sed -i '/\/media\/bitlocker\/1\/dislocker-file /d' /etc/fstab
else
break
fi
fi
done
# Inform the user
msg_box "Congratulations! The mount was successful.
You can now access the Bitlocker drive here:
$MOUNT_PATH"
# Test if Plex is installed
if is_docker_running && docker ps -a --format "{{.Names}}" | grep -q "^plex$"
then
# Reconfiguring Plex
msg_box "Plex Media Server found. We are now adjusting Plex to be able to use the new drive.
This can take a while. Please be patient!"
print_text_in_color "$ICyan" "Downloading the needed tool to get the current Plex config..."
docker pull assaflavie/runlike
echo '#/bin/bash' > /tmp/pms-conf
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock assaflavie/runlike -p plex >> /tmp/pms-conf
if ! grep -q "$MOUNT_PATH:$MOUNT_PATH:ro" /tmp/pms-conf
then
MOUNT_PATH_SED="${MOUNT_PATH//\//\\/}"
sed -i "0,/--volume/s// -v $MOUNT_PATH_SED:$MOUNT_PATH_SED:ro \\\\\n&/" /tmp/pms-conf
docker stop plex
if ! docker rm plex
then
msg_box "Something failed while removing the old container."
exit 1
fi
if ! bash /tmp/pms-conf
then
msg_box "Starting the new container failed. You can find the config here: '/tmp/pms-conf'"
exit 1
fi
rm /tmp/pms-conf
msg_box "Plex was adjusted!"
else
rm /tmp/pms-conf
msg_box "No need to update Plex, since the drive is already mounted to Plex."
fi
fi
exit

View File

@ -1,727 +0,0 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
# shellcheck disable=2024
true
SCRIPT_NAME="Borg Backup"
SCRIPT_EXPLAINER="This script creates the Borg backup of your server."
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode
# Check if root
root_check
# Variables
LVM_MOUNT="/system"
ZFS_MOUNT="/ncdata"
START_TIME=$(date +%s)
CURRENT_DATE=$(date --date @"$START_TIME" +"%Y%m%d_%H%M%S")
CURRENT_DATE_READABLE=$(date --date @"$START_TIME" +"%d.%m.%Y - %H:%M:%S")
LOG_FILE="$VMLOGS/borgbackup-$CURRENT_DATE.log"
# This is needed for running via cron
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
# Functions
inform_user() {
echo -e "\n\n# $2"
print_text_in_color "$1" "$2"
}
start_services() {
inform_user "$ICyan" "Starting services..."
systemctl start postgresql
if [ -z "$MAINTENANCE_MODE_ON" ]
then
nextcloud_occ_no_check maintenance:mode --off
fi
start_if_stopped docker
# Restart notify push if existing
if [ -f "$NOTIFY_PUSH_SERVICE_PATH" ]
then
systemctl restart notify_push
fi
}
paste_log_file() {
cat "$LOG_FILE" >> "$BORGBACKUP_LOG"
echo -e "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" >> "$BORGBACKUP_LOG"
}
remove_log_file() {
rm "$LOG_FILE"
}
show_drive_usage() {
inform_user "$ICyan" "Showing drive usage..."
lsblk -o FSUSE%,SIZE,MOUNTPOINT,NAME | grep -v "loop[0-9]" | grep "%" | sed 's|`-||;s/|-//;s/ | //'
echo ""
df -h | grep -v "loop[0-9]" | grep -v "tmpfs" | grep -v "^udev" | grep -v "^overlay"
}
send_error_mail() {
if [ -n "$ZFS_PART_EXISTS" ]
then
if mountpoint -q "$ZFS_MOUNT"
then
umount "$ZFS_MOUNT"
fi
fi
if [ -d "$BACKUP_TARGET_DIRECTORY" ]
then
if [ -z "$DO_NOT_UMOUNT_DAILY_BACKUP_DRIVE" ]
then
inform_user "$ICyan" "Unmounting the backup drive..."
umount "$BACKUP_MOUNTPOINT"
fi
fi
get_expiration_time
MAIL_TITLE="$2"
if [ -z "$2" ]
then
MAIL_TITLE="Daily backup"
fi
inform_user "$IRed" "$MAIL_TITLE sent error on $END_DATE_READABLE ($DURATION_READABLE)"
inform_user "$IRed" "$MAIL_TITLE failed! $1"
if ! send_mail "$MAIL_TITLE failed! $1" "$(cat "$LOG_FILE")"
then
notify_admin_gui \
"$MAIL_TITLE failed! Though mail sending didn't work!" \
"Please look at the log file $LOG_FILE if you want to find out more."
paste_log_file
else
paste_log_file
remove_log_file
fi
exit 1
}
re_rename_snapshot() {
if mountpoint -q "$LVM_MOUNT"
then
umount "$LVM_MOUNT"
fi
inform_user "$ICyan" "Re-renaming the snapshot..."
if ! lvrename /dev/ubuntu-vg/NcVM-snapshot-pending /dev/ubuntu-vg/NcVM-snapshot
then
return 1
else
return 0
fi
}
get_expiration_time() {
END_TIME=$(date +%s)
END_DATE_READABLE=$(date --date @"$END_TIME" +"%d.%m.%Y - %H:%M:%S")
DURATION=$((END_TIME-START_TIME))
DURATION_SEC=$((DURATION % 60))
DURATION_MIN=$(((DURATION / 60) % 60))
DURATION_HOUR=$((DURATION / 3600))
DURATION_READABLE=$(printf "%02d hours %02d minutes %02d seconds" $DURATION_HOUR $DURATION_MIN $DURATION_SEC)
}
check_snapshot_pending() {
if does_snapshot_exist "NcVM-snapshot-pending"
then
DO_NOT_UMOUNT_DAILY_BACKUP_DRIVE=1
msg_box "The snapshot pending does exist. Can currently not proceed.
Please try again later.\n
If you are sure that no update or backup is currently running, you can fix this by rebooting your server."
send_error_mail "NcVM-snapshot-pending exists. Please try again later!" "$1"
fi
}
# Secure the backup file
chown root:root "$SCRIPTS/daily-borg-backup.sh"
chmod 700 "$SCRIPTS/daily-borg-backup.sh"
# Skip daily backup creation if needed
if [ -z "$SKIP_DAILY_BACKUP_CREATION" ]
then
# Add automatical unlock upon reboot
crontab -u root -l | grep -v "lvrename /dev/ubuntu-vg/NcVM-snapshot-pending" | crontab -u root -
crontab -u root -l | { cat; echo "@reboot /usr/sbin/lvrename /dev/ubuntu-vg/NcVM-snapshot-pending \
/dev/ubuntu-vg/NcVM-snapshot &>/dev/null" ; } | crontab -u root -
# Write output to logfile.
exec > >(tee -i "$LOG_FILE")
exec 2>&1
# Check if dpkg or apt is running
is_process_running apt
is_process_running dpkg
# Start backup
inform_user "$IGreen" "Daily backup started! $CURRENT_DATE_READABLE"
# Check if the file exists
if ! [ -f "$SCRIPTS/daily-borg-backup.sh" ]
then
send_error_mail "The daily-borg-backup.sh doesn't exist."
fi
# Check if /mnt/ncdata is mounted
if grep -q " /mnt/ncdata " /etc/mtab && ! grep " /mnt/ncdata " /etc/mtab | grep -q zfs
then
msg_box "The '/mnt/ncdata' directory is mounted and not existing on the root drive."
exit 1
fi
# The home directory must exist on the root drive
if grep -q " /home " /etc/mtab
then
send_error_mail "The '/home' directory is mounted and not existing on the root drive."
fi
fi
# Check if all needed variables are there (they get exported by the local daily-backup-script.sh)
if [ -z "$ENCRYPTION_KEY" ] || [ -z "$BACKUP_TARGET_DIRECTORY" ] || [ -z "$BORGBACKUP_LOG" ] || [ -z "$BACKUP_MOUNTPOINT" ] \
|| [ -z "$CHECK_BACKUP_INTERVAL_DAYS" ] || [ -z "$DAYS_SINCE_LAST_BACKUP_CHECK" ]
then
send_error_mail "Didn't get all needed variables."
elif [ -n "$ADDITIONAL_BACKUP_DIRECTORIES" ]
# ADDITIONAL_BACKUP_DIRECTORIES is optional
then
mapfile -t ADDITIONAL_BACKUP_DIRECTORIES <<< "$ADDITIONAL_BACKUP_DIRECTORIES"
for directory in "${ADDITIONAL_BACKUP_DIRECTORIES[@]}"
do
DIRECTORY="${directory%%/}"
if ! [ -d "$directory" ]
then
send_error_mail "$directory doesn't exist. Drive not connected?"
else
if ! test "$(timeout 5 ls -A "$directory")"
then
mount "$directory" &>/dev/null
if ! test "$(timeout 5 ls -A "$directory")"
then
send_error_mail "$directory doesn't exist. Drive not connected?"
fi
fi
fi
done
fi
# Export default values
export BORG_PASSPHRASE="$ENCRYPTION_KEY"
export BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes
export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
# Skip daily backup creation if needed
if [ -z "$SKIP_DAILY_BACKUP_CREATION" ]
then
# Check if backup shall get checked
if [ "$DAYS_SINCE_LAST_BACKUP_CHECK" -ge "$CHECK_BACKUP_INTERVAL_DAYS" ]
then
CHECK_BACKUP=1
else
DAYS_SINCE_LAST_BACKUP_CHECK=$((DAYS_SINCE_LAST_BACKUP_CHECK+1))
sed -i "s|^export DAYS_SINCE_LAST_BACKUP_CHECK.*|export DAYS_SINCE_LAST_BACKUP_CHECK=$DAYS_SINCE_LAST_BACKUP_CHECK|" "$SCRIPTS/daily-borg-backup.sh"
fi
# Check if pending snapshot is existing and cancel the backup in this case.
check_snapshot_pending
# Check if snapshot can get created
check_free_space
if ! does_snapshot_exist "NcVM-snapshot" && ! [ "$FREE_SPACE" -ge 50 ]
then
send_error_mail "Not enough free space on your vgs."
fi
# Prepare backup repository
inform_user "$ICyan" "Mounting the backup drive..."
if ! [ -d "$BACKUP_TARGET_DIRECTORY" ]
then
mount "$BACKUP_MOUNTPOINT" &>/dev/null
if ! [ -d "$BACKUP_TARGET_DIRECTORY" ]
then
send_error_mail "Could not mount the backup drive. Is it connected?"
fi
fi
# Test if btrfs volume
if grep " $BACKUP_MOUNTPOINT " /etc/mtab | grep -q btrfs
then
IS_BTRFS_PART=1
mkdir -p "$BACKUP_MOUNTPOINT/.snapshots"
btrfs subvolume snapshot -r "$BACKUP_MOUNTPOINT" "$BACKUP_MOUNTPOINT/.snapshots/@$CURRENT_DATE"
while [ "$(find "$BACKUP_MOUNTPOINT/.snapshots/" -maxdepth 1 -mindepth 1 -type d -name '@*_*' | wc -l)" -gt 14 ]
do
DELETE_SNAP="$(find "$BACKUP_MOUNTPOINT/.snapshots/" -maxdepth 1 -mindepth 1 -type d -name '@*_*' | sort | head -1)"
btrfs subvolume delete "$DELETE_SNAP"
done
fi
# Send mail that backup was started
if ! send_mail "Daily backup started!" "You will be notified again when the backup is finished!
Please don't restart or shutdown your server until then!"
then
notify_admin_gui "Daily backup started!" "You will be notified again when the backup is finished!
Please don't restart or shutdown your server until then!"
fi
# Check if pending snapshot is existing and cancel the backup in this case.
check_snapshot_pending
# Fix too large Borg cache
# https://borgbackup.readthedocs.io/en/stable/faq.html#the-borg-cache-eats-way-too-much-disk-space-what-can-i-do
find /root/.cache/borg/ -maxdepth 2 -name chunks.archive.d -type d -exec rm -r {} \; -exec touch {} \;
# Stop services
inform_user "$ICyan" "Stopping services..."
if is_docker_running
then
systemctl stop docker
fi
if [ "$(nextcloud_occ_no_check config:system:get maintenance)" = "true" ]
then
MAINTENANCE_MODE_ON=1
fi
nextcloud_occ_no_check maintenance:mode --on
# Database export
# Not really necessary since the root partition gets backed up but easier to restore on new systems
ncdb # get NCDB
rm -f "$SCRIPTS"/nextclouddb.sql "$SCRIPTS"/nextclouddb.dump
rm -f "$SCRIPTS"/alldatabases.sql "$SCRIPTS"/alldatabases.dump
if sudo -Hiu postgres psql -c "SELECT 1 AS result FROM pg_database WHERE datname='$NCDB'" | grep -q "1 row"
then
inform_user "$ICyan" "Doing pgdump of $NCDB..."
sudo -Hiu postgres pg_dump "$NCDB" > "$SCRIPTS"/nextclouddb.dump
chown root:root "$SCRIPTS"/nextclouddb.dump
chmod 600 "$SCRIPTS"/nextclouddb.dump
else
inform_user "$ICyan" "Doing pgdump of all databases..."
sudo -Hiu postgres pg_dumpall > "$SCRIPTS"/alldatabases.dump
chown root:root "$SCRIPTS"/alldatabases.dump
chmod 600 "$SCRIPTS"/alldatabases.dump
fi
systemctl stop postgresql
# Check if pending snapshot is existing and cancel the backup in this case.
check_snapshot_pending
# Create LVM snapshot & Co.
inform_user "$ICyan" "Creating LVM snapshot..."
if does_snapshot_exist "NcVM-snapshot"
then
if ! lvremove /dev/ubuntu-vg/NcVM-snapshot -y
then
start_services
send_error_mail "Could not remove old NcVM-snapshot - Please reboot your server!"
fi
fi
if ! lvcreate --size 5G --snapshot --name "NcVM-snapshot" /dev/ubuntu-vg/ubuntu-lv
then
start_services
send_error_mail "Could not create NcVM-snapshot - Please reboot your server!"
else
inform_user "$IGreen" "Snapshot successfully created!"
fi
start_services
# Cover zfs snapshots
if grep " /mnt/ncdata " /etc/mtab | grep -q zfs
then
ZFS_PART_EXISTS=1
sed -i "s|date --utc|date|g" /usr/sbin/zfs-auto-snapshot
if ! zfs-auto-snapshot -r ncdata
then
send_error_mail "Could not create ZFS snapshot!"
fi
inform_user "$IGreen" "ZFS snapshot successfully created!"
ZFS_SNAP_NAME="$(zfs list -t snapshot | grep ncdata | grep snap-202 | sort -r | head -1 | awk '{print $1}')"
# Mount zfs snapshot
if mountpoint -q "$ZFS_MOUNT"
then
if ! umount "$ZFS_MOUNT"
then
send_error_mail "Could not unmount '$ZFS_MOUNT'!"
fi
fi
mkdir -p "$ZFS_MOUNT"
inform_user "$ICyan" "Mounting the ZFS snapshot..."
if ! mount --read-only --types zfs "$ZFS_SNAP_NAME" "$ZFS_MOUNT"
then
send_error_mail "Could not mount the ZFS snapshot!"
fi
fi
# Check if pending snapshot is existing and cancel the backup in this case.
check_snapshot_pending
# Rename the snapshot to represent that the backup is pending
inform_user "$ICyan" "Renaming the snapshot..."
if ! lvrename /dev/ubuntu-vg/NcVM-snapshot /dev/ubuntu-vg/NcVM-snapshot-pending
then
send_error_mail "Could not rename the snapshot to snapshot-pending."
fi
# Mount the snapshot
if mountpoint -q "$LVM_MOUNT"
then
if ! umount "$LVM_MOUNT"
then
re_rename_snapshot
send_error_mail "Could not unmount '$LVM_MOUNT'!"
fi
fi
mkdir -p "$LVM_MOUNT"
inform_user "$ICyan" "Mounting the snapshot..."
if ! mount --read-only /dev/ubuntu-vg/NcVM-snapshot-pending "$LVM_MOUNT"
then
re_rename_snapshot
send_error_mail "Could not mount the LVM snapshot!"
fi
# Borg backup based on this
# https://borgbackup.readthedocs.io/en/stable/deployment/automated-local.html?highlight=files%20cache#configuring-the-system
# https://iwalton.com/wiki/#[[Backup%20Script]]
# https://decatec.de/linux/backup-strategie-fuer-linux-server-mit-borg-backup/
# Log Borg version
borg --version
# Break the borg lock if it exists because we have the snapshot that prevents such situations
if [ -f "$BACKUP_TARGET_DIRECTORY/lock.roster" ]
then
inform_user "$ICyan" "Breaking the borg lock..."
if ! borg break-lock "$BACKUP_TARGET_DIRECTORY"
then
re_rename_snapshot
send_error_mail "Some errors were reported while breaking the borg lock!"
fi
fi
# Borg options
# auto,zstd compression seems to has the best ratio based on:
# https://forum.level1techs.com/t/optimal-compression-for-borg-backups/145870/6
BORG_OPTS=(--stats --compression "auto,zstd" --exclude-caches --checkpoint-interval 86400)
# System backup
EXCLUDED_DIRECTORIES=(home/*/.cache root/.cache home/plex/transcode var/cache lost+found \
run var/run dev tmp "home/plex/config/Library/Application Support/Plex Media Server/Cache")
# mnt, media, sys, prob don't need to be excluded because of the usage of lvm-snapshots and the --one-file-system flag
for directory in "${EXCLUDED_DIRECTORIES[@]}"
do
EXCLUDE_DIRS+=(--exclude "$LVM_MOUNT/$directory/")
done
# Create system backup
inform_user "$ICyan" "Creating system partition backup..."
if ! borg create "${BORG_OPTS[@]}" --one-file-system "${EXCLUDE_DIRS[@]}" \
"$BACKUP_TARGET_DIRECTORY::$CURRENT_DATE-NcVM-system-partition" "$LVM_MOUNT/"
then
inform_user "$ICyan" "Deleting the failed system backup archive..."
borg delete --stats "$BACKUP_TARGET_DIRECTORY::$CURRENT_DATE-NcVM-system-partition"
show_drive_usage
re_rename_snapshot
send_error_mail "Some errors were reported during the system partition backup!"
fi
# Check Snapshot size
inform_user "$ICyan" "Testing how full the snapshot is..."
SNAPSHOT_USED=$(lvs -o name,data_percent | grep "NcVM-snapshot-pending" | awk '{print $2}' | sed 's|\..*||' | sed 's|,.*||')
if [ "$SNAPSHOT_USED" -lt 100 ]
then
inform_user "$IGreen" "Backup ok: Snapshot is not full ($SNAPSHOT_USED%)"
else
inform_user "$IRed" "Backup corrupt: Snapshot is full ($SNAPSHOT_USED%)"
inform_user "$ICyan" "Deleting the corrupt system backup archive..."
borg delete --stats "$BACKUP_TARGET_DIRECTORY::$CURRENT_DATE-NcVM-system-partition"
show_drive_usage
re_rename_snapshot
send_error_mail "The backup archive was corrupt because the snapshot is full and has been deleted."
fi
# Unmount LVM_snapshot
inform_user "$ICyan" "Unmounting the snapshot..."
if ! umount "$LVM_MOUNT"
then
send_error_mail "Could not unmount the LVM snapshot."
fi
rm -r "$LVM_MOUNT"
# Prune options
BORG_PRUNE_OPTS=(--stats --keep-within=7d --keep-weekly=4 --keep-monthly=6 "$BACKUP_TARGET_DIRECTORY")
# Prune system archives
inform_user "$ICyan" "Pruning the system archives..."
if ! borg prune --prefix '*_*-NcVM-system-partition' "${BORG_PRUNE_OPTS[@]}"
then
re_rename_snapshot
send_error_mail "Some errors were reported by the prune system command."
fi
# Boot partition backup
inform_user "$ICyan" "Creating boot partition backup..."
if ! borg create "${BORG_OPTS[@]}" "$BACKUP_TARGET_DIRECTORY::$CURRENT_DATE-NcVM-boot-partition" "/boot/"
then
inform_user "$ICyan" "Deleting the failed boot partition backup archive..."
borg delete --stats "$BACKUP_TARGET_DIRECTORY::$CURRENT_DATE-NcVM-boot-partition"
show_drive_usage
re_rename_snapshot
send_error_mail "Some errors were reported during the boot partition backup!"
fi
# Prune boot archives
inform_user "$ICyan" "Pruning the boot archives..."
if ! borg prune --prefix '*_*-NcVM-boot-partition' "${BORG_PRUNE_OPTS[@]}"
then
re_rename_snapshot
send_error_mail "Some errors were reported by the prune boot command."
fi
# Create ZFS backup
if [ -n "$ZFS_PART_EXISTS" ]
then
inform_user "$ICyan" "Creating ncdata partition backup..."
if ! borg create "${BORG_OPTS[@]}" --one-file-system \
"$BACKUP_TARGET_DIRECTORY::$CURRENT_DATE-NcVM-ncdata-partition" "$ZFS_MOUNT/"
then
inform_user "$ICyan" "Deleting the failed ncdata backup archive..."
borg delete --stats "$BACKUP_TARGET_DIRECTORY::$CURRENT_DATE-NcVM-ncdata-partition"
show_drive_usage
re_rename_snapshot
send_error_mail "Some errors were reported during the ncdata partition backup!"
fi
# Prune ncdata archives
inform_user "$ICyan" "Pruning the ncdata archives..."
if ! borg prune --prefix '*_*-NcVM-ncdata-partition' "${BORG_PRUNE_OPTS[@]}"
then
re_rename_snapshot
send_error_mail "Some errors were reported by the prune ncdata command."
fi
# Unmount ZFS snapshot
inform_user "$ICyan" "Unmounting the ZFS snapshot..."
if ! umount "$ZFS_MOUNT"
then
re_rename_snapshot
send_error_mail "Could not unmount the ZFS snapshot."
fi
rm -r "$ZFS_MOUNT"
fi
# Backup additional locations
for directory in "${ADDITIONAL_BACKUP_DIRECTORIES[@]}"
do
if [ -z "$directory" ]
then
continue
fi
DIRECTORY="${directory%%/}"
DIRECTORY_NAME=$(echo "$DIRECTORY" | sed 's|^/||;s|/|-|;s| |_|')
# Wait for the drive to spin up (else it is possible that some subdirectories are not backed up)
inform_user "$ICyan" "Waiting 15s for the $DIRECTORY_NAME directory..."
timeout 0.1s ls -l "$DIRECTORY/" &>/dev/null
if ! sleep 15
then
# In case someone cancels with ctrl+c here
re_rename_snapshot
send_error_mail "Something failed while waiting for the $DIRECTORY_NAME directory."
fi
# Create backup
inform_user "$ICyan" "Creating $DIRECTORY_NAME backup..."
if ! borg create "${BORG_OPTS[@]}" --one-file-system --exclude "$DIRECTORY/.snapshots/" \
"$BACKUP_TARGET_DIRECTORY::$CURRENT_DATE-NcVM-$DIRECTORY_NAME-directory" "$DIRECTORY/"
then
inform_user "$ICyan" "Deleting the failed $DIRECTORY_NAME backup archive..."
borg delete --stats "$BACKUP_TARGET_DIRECTORY::$CURRENT_DATE-NcVM-$DIRECTORY_NAME-directory"
show_drive_usage
re_rename_snapshot
send_error_mail "Some errors were reported during the $DIRECTORY_NAME backup!"
fi
# Prune archives
inform_user "$ICyan" "Pruning the $DIRECTORY_NAME archives..."
if ! borg prune --prefix "*_*-NcVM-$DIRECTORY_NAME-directory" "${BORG_PRUNE_OPTS[@]}"
then
re_rename_snapshot
send_error_mail "Some errors were reported by the prune $DIRECTORY_NAME command."
fi
done
# Run a borg compact which is required with borg 1.2.0 and higher
if borg compact -h &>/dev/null
then
inform_user "$ICyan" "Starting borg compact which will clean up not needed commits and free space..."
if ! borg compact "$BACKUP_TARGET_DIRECTORY"
then
re_rename_snapshot
send_error_mail "Some errors were reported during borg compact!"
fi
fi
# Rename the snapshot back to normal
if ! re_rename_snapshot
then
send_error_mail "Could not rename the snapshot-pending to snapshot."
fi
# Print usage of drives into log
show_drive_usage
# Adjust permissions and scrub volume
if [ -n "$IS_BTRFS_PART" ]
then
inform_user "$ICyan" "Adjusting permissions..."
find "$BACKUP_MOUNTPOINT/" -not -path "$BACKUP_MOUNTPOINT/.snapshots/*" \
\( ! -perm 600 -o ! -group root -o ! -user root \) -exec chmod 600 {} \; -exec chown root:root {} \;
fi
# Unmount the backup drive
inform_user "$ICyan" "Unmounting the backup drive..."
if ! umount "$BACKUP_MOUNTPOINT"
then
send_error_mail "Could not unmount the backup drive!"
fi
# Show expiration time
get_expiration_time
inform_user "$IGreen" "Backup finished on $END_DATE_READABLE ($DURATION_READABLE)"
# Send mail about successful backup
if ! send_mail "Daily backup successful!" "$(cat "$LOG_FILE")"
then
notify_admin_gui \
"Daily backup successful! Though mail sending didn't work!" \
"Please look at the log file $LOG_FILE if you want to find out more."
if [ -z "$CHECK_BACKUP" ]
then
paste_log_file
fi
else
paste_log_file
remove_log_file
fi
# Create a file that can be checked for
rm -f /tmp/DAILY_BACKUP_CREATION_SUCCESSFUL
touch /tmp/DAILY_BACKUP_CREATION_SUCCESSFUL
# Exit here if the backup doesn't shall get checked
if [ -z "$CHECK_BACKUP" ]
then
exit
fi
# Exit here if we want to skip the backup check
if [ -n "$SKIP_DAILY_BACKUP_CHECK" ]
then
exit
fi
fi
# Recreate logfile
if ! [ -f "$LOG_FILE" ]
then
touch "$LOG_FILE"
# Write output to logfile.
exec > >(tee -i "$LOG_FILE")
exec 2>&1
fi
# New start time
START_TIME=$(date +%s)
CURRENT_DATE=$(date --date @"$START_TIME" +"%Y%m%d_%H%M%S")
CURRENT_DATE_READABLE=$(date --date @"$START_TIME" +"%d.%m.%Y - %H:%M:%S")
# Inform user
inform_user "$IGreen" "Backup integrity check started! $CURRENT_DATE_READABLE"
# Check if pending snapshot is existing and cancel the backup check in this case.
check_snapshot_pending "Backup integrity check"
# Prepare backup repository
inform_user "$ICyan" "Mounting the backup drive..."
if ! [ -d "$BACKUP_TARGET_DIRECTORY" ]
then
mount "$BACKUP_MOUNTPOINT" &>/dev/null
if ! [ -d "$BACKUP_TARGET_DIRECTORY" ]
then
send_error_mail "Could not mount the backup drive. Is it connected?" "Backup integrity check"
fi
fi
# Send mail that backup was started
if ! send_mail "Weekly backup check started!" "You will be notified again when the check is finished!
Please don't restart or shutdown your server until then!"
then
notify_admin_gui "Weekly backup check started!" "You will be notified again when the check is finished!
Please don't restart or shutdown your server until then!"
fi
# Check if pending snapshot is existing and cancel the backup check in this case.
check_snapshot_pending "Backup integrity check"
# Rename the snapshot to represent that the backup is pending
inform_user "$ICyan" "Renaming the snapshot..."
if ! lvrename /dev/ubuntu-vg/NcVM-snapshot /dev/ubuntu-vg/NcVM-snapshot-pending
then
send_error_mail "Could not rename the snapshot to snapshot-pending." "Backup integrity check"
fi
# Check the backup
inform_user "$ICyan" "Checking the backup integity..."
# TODO: check how long this takes. If too long, remove the --verifa-data flag
if ! borg check --verify-data "$BACKUP_TARGET_DIRECTORY"
then
re_rename_snapshot
send_error_mail "Some errors were reported during the backup integrity check!" "Backup integrity check"
fi
# Adjust permissions and scrub volume
if [ -n "$IS_BTRFS_PART" ] && [ "$BTRFS_SCRUB_BACKUP_DRIVE" = "yes" ]
then
inform_user "$ICyan" "Scrubbing BTRFS partition..."
if ! btrfs scrub start -B "$BACKUP_MOUNTPOINT"
then
re_rename_snapshot
send_error_mail "Some errors were reported while scrubbing the BTRFS partition."
fi
fi
# Rename the snapshot back to normal
if ! re_rename_snapshot
then
send_error_mail "Could not rename the snapshot-pending to snapshot." "Backup integrity check"
fi
# Print usage of drives into log
show_drive_usage
# Unmount the backup drive
if [ -z "$SKIP_DAILY_BACKUP_CREATION" ]
then
inform_user "$ICyan" "Unmounting the backup drive..."
if mountpoint -q "$BACKUP_MOUNTPOINT" && ! umount "$BACKUP_MOUNTPOINT"
then
send_error_mail "Could not unmount the backup drive!" "Backup integrity check"
fi
fi
# Resetting the integrity Check
inform_user "$ICyan" "Resetting the backup check timer..."
sed -i "s|^export DAYS_SINCE_LAST_BACKUP_CHECK.*|export DAYS_SINCE_LAST_BACKUP_CHECK=0|" "$SCRIPTS/daily-borg-backup.sh"
# Show expiration time
get_expiration_time
inform_user "$IGreen" "Backup integrity check finished on $END_DATE_READABLE ($DURATION_READABLE)"
# Send mail about successful backup
if ! send_mail "Backup integrity check successful!" "$(cat "$LOG_FILE")"
then
notify_admin_gui \
"Backup integrity check successful! Though mail sending didn't work!" \
"Please look at the log file $LOG_FILE if you want to find out more."
paste_log_file
else
paste_log_file
remove_log_file
fi
# Create a file that can be checked for
rm -f /tmp/DAILY_BACKUP_CHECK_SUCCESSFUL
touch /tmp/DAILY_BACKUP_CHECK_SUCCESSFUL
exit

View File

@ -1,150 +0,0 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true
SCRIPT_NAME="BTRFS Mount"
SCRIPT_EXPLAINER="This script automates formatting drives to BTRFS."
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode
# Check if root
root_check
# Show explainer
msg_box "$SCRIPT_EXPLAINER"
# Mount drive
format_drive() {
local UUID
local LABEL
msg_box "Please disconnect your drive for now and connect it again AFTER you hit OK.
Otherwise we will not be able to detect it."
CURRENT_DRIVES=$(lsblk -o KNAME,TYPE | grep disk | awk '{print $1}')
count=0
while [ "$count" -lt 60 ]
do
print_text_in_color "$ICyan" "Please connect your drive now."
sleep 5 & spinner_loading
echo ""
NEW_DRIVES=$(lsblk -o KNAME,TYPE | grep disk | awk '{print $1}')
if [ "$CURRENT_DRIVES" = "$NEW_DRIVES" ]
then
count=$((count+5))
else
msg_box "A new drive was found. We will continue with the mounting now.
Please leave it connected."
break
fi
done
# Exit if no new drive was found
if [ "$count" -ge 60 ]
then
msg_box "No new drive found within 60 seconds.
Please run this option again if you want to try again."
return 1
fi
# Get all new drives
mapfile -t CURRENT_DRIVES <<< "$CURRENT_DRIVES"
for drive in "${CURRENT_DRIVES[@]}"
do
NEW_DRIVES=$(echo "$NEW_DRIVES" | grep -v "^$drive")
done
# Partition menu
args=(whiptail --title "$TITLE" --menu \
"Please select the drive that you would like to format to BTRFS.
$MENU_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4)
# Get information that are important
mapfile -t NEW_DRIVES <<< "$NEW_DRIVES"
for drive in "${NEW_DRIVES[@]}"
do
DRIVE_DESCRIPTION=$(lsblk -o NAME,SIZE,VENDOR,MODEL | grep "^$drive" | awk '{print $2, $3, $4}')
args+=("/dev/$drive" " $DRIVE_DESCRIPTION")
done
# Show the drive menu
DEVICE=$("${args[@]}" 3>&1 1>&2 2>&3)
if [ -z "$DEVICE" ]
then
return 1
fi
# Enter partition label
while :
do
LABEL="$(input_box_flow "Please enter the partition label that the drive shall get.
If you want to cancel, type in 'exit' and press [ENTER].")"
if [ "$LABEL" = exit ]
then
return 1
else
break
fi
done
# Last info box
if ! yesno_box_no "Warning: Are you really sure, that you want to format the drive '$DEVICE' to BTRFS?
All current files on the drive will be erased!
Select 'Yes' to continue with the process. Select 'No' to cancel."
then
exit 1
fi
# Inform user
msg_box "We will now format the drive '$DEVICE' to BTRFS. Please be patient!"
# Wipe drive
dd if=/dev/urandom of="$DEVICE" bs=1M count=2
parted "$DEVICE" mklabel gpt --script
parted "$DEVICE" mkpart primary 0% 100% --script
# Wait because mkfs fails otherwise
sleep 1
# Format drive
if ! mkfs.btrfs "${DEVICE}1" --quiet --label "$LABEL"
then
msg_box "Something failed while formatting the drive to BTRFS."
exit 1
fi
# Inform user
msg_box "Formatting $DEVICE to BTRFS was successful!
You can now use the 'BTRFS Mount' script from the Not-Supported Menu to mount the drive to your system."
}
# Show main_menu
while :
do
choice=$(whiptail --title "$TITLE" --menu \
"Choose what you want to do.
$MENU_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
"Format a drive" "(Interactively format a drive to BTRFS)" \
"Exit" "(Exit this script)" 3>&1 1>&2 2>&3)
case "$choice" in
"Format a drive")
format_drive
;;
"Exit")
break
;;
"")
break
;;
*)
;;
esac
done
exit

View File

@ -1,345 +0,0 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true
SCRIPT_NAME="BTRFS Mount"
SCRIPT_EXPLAINER="This script automates mounting BTRFS drives locally in your system."
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode
# Check if root
root_check
# Show explainer
msg_box "$SCRIPT_EXPLAINER"
# Mount drive
mount_drive() {
local UUIDS
local UUID
local LABEL
msg_box "Please disconnect your drive for now and connect it again AFTER you hit OK.
Otherwise we will not be able to detect it."
CURRENT_DRIVES=$(lsblk -o KNAME,TYPE | grep disk | awk '{print $1}')
count=0
while [ "$count" -lt 60 ]
do
print_text_in_color "$ICyan" "Please connect your drive now."
sleep 5 & spinner_loading
echo ""
NEW_DRIVES=$(lsblk -o KNAME,TYPE | grep disk | awk '{print $1}')
if [ "$CURRENT_DRIVES" = "$NEW_DRIVES" ]
then
count=$((count+5))
else
msg_box "A new drive was found. We will continue with the mounting now.
Please leave it connected."
break
fi
done
# Exit if no new drive was found
if [ "$count" -ge 60 ]
then
msg_box "No new drive found within 60 seconds.
Please run this option again if you want to try again."
return 1
fi
# Wait until the drive has spin up
countdown "Waiting for the drive to spin up..." 15
# Get all new drives
mapfile -t CURRENT_DRIVES <<< "$CURRENT_DRIVES"
for drive in "${CURRENT_DRIVES[@]}"
do
NEW_DRIVES=$(echo "$NEW_DRIVES" | grep -v "^$drive$")
done
# Partition menu
args=(whiptail --title "$TITLE" --menu \
"Please select the partition that you would like to mount.
$MENU_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4)
# Get information that are important to show the partition menu
mapfile -t NEW_DRIVES <<< "$NEW_DRIVES"
for drive in "${NEW_DRIVES[@]}"
do
DRIVE_DESCRIPTION=$(lsblk -o NAME,VENDOR,MODEL | grep "^$drive" | awk '{print $2, $3}')
PARTITION_STATS=$(lsblk -o KNAME,FSTYPE,SIZE,UUID,LABEL | grep "^$drive" | grep -v "^$drive ")
unset PARTITIONS
mapfile -t PARTITIONS <<< "$(echo "$PARTITION_STATS" | awk '{print $1}')"
for partition in "${PARTITIONS[@]}"
do
STATS=$(echo "$PARTITION_STATS" | grep "^$partition ")
FSTYPE=$(echo "$STATS" | awk '{print $2}')
if [ "$FSTYPE" != "btrfs" ]
then
continue
fi
SIZE=$(echo "$STATS" | awk '{print $3}')
UUID=$(echo "$STATS" | awk '{print $4}')
if [ -z "$UUID" ]
then
continue
fi
LABEL=$(echo "$STATS" | awk '{print $5,$6,$7,$8,$9,$10,$11,$12}' | sed 's| |_|g' | sed -r 's|[_]+$||')
if ! grep -q "$UUID" /etc/fstab
then
args+=("$UUID" "$LABEL $DRIVE_DESCRIPTION $SIZE $FSTYPE")
UUIDS+="$UUID"
else
msg_box "The partition
$UUID $LABEL $DRIVE_DESCRIPTION $SIZE $FSTYPE
is already existing.\n
If you want to remove it, run the following two commands:
sudo sed -i '/$UUID/d' /etc/fstab
sudo reboot"
fi
done
done
# Check if at least one drive was found
if [ -z "$UUIDS" ]
then
msg_box "No drive found that can get mounted.
Most likely none is BTRFS formatted."
return 1
fi
# Show the partition menu
UUID=$("${args[@]}" 3>&1 1>&2 2>&3)
if [ -z "$UUID" ]
then
return 1
fi
# Get the label of the partition
LABEL=$(lsblk -o UUID,LABEL | grep "^$UUID " | awk '{print $2,$3,$4,$5,$6,$7,$8,$9}' | sed 's| |_|g' | sed -r 's|[_]+$||')
if [ -z "$LABEL" ]
then
LABEL="partition-label"
fi
# Create plex user
if ! id plex &>/dev/null
then
check_command adduser --no-create-home --quiet --disabled-login --force-badname --gecos "" "plex"
fi
# Enter the mountpoint
while :
do
MOUNT_PATH=$(input_box_flow "Please type in the directory where you want to mount the partition.
One example is: '/mnt/$LABEL'
The directory has to start with '/mnt/'
If you want to cancel, type 'exit' and press [ENTER].")
if [ "$MOUNT_PATH" = "exit" ]
then
exit 1
elif echo "$MOUNT_PATH" | grep -q " "
then
msg_box "Please don't use spaces!"
elif ! echo "$MOUNT_PATH" | grep -q "^/mnt/"
then
msg_box "The directory has to stat with '/mnt/'"
elif grep -q " $MOUNT_PATH " /etc/fstab
then
msg_box "The mountpoint already exists in fstab. Please try a different one."
elif mountpoint -q "$MOUNT_PATH"
then
msg_box "The mountpoint is already mounted. Please try a different one."
elif echo "$MOUNT_PATH" | grep -q "^/mnt/ncdata"
then
msg_box "The directory isn't allowed to start with '/mnt/ncdata'"
elif echo "$MOUNT_PATH" | grep -q "^/mnt/smbshares"
then
msg_box "The directory isn't allowed to start with '/mnt/smbshares'"
else
echo "UUID=$UUID $MOUNT_PATH btrfs defaults 0 0" >> /etc/fstab
mkdir -p "$MOUNT_PATH"
if ! mount "$MOUNT_PATH"
then
msg_box "The mount wasn't successful. Please try again."
sed -i "/$UUID/d" /etc/fstab
else
break
fi
fi
done
# Inform the user
msg_box "Congratulations! The mount was successful.
You can now access the partition here:
$MOUNT_PATH"
# Ask if this is a backup drive
if ! yesno_box_no "Is this drive meant to be a backup drive?
If you choose yes, it will only get mounted by a backup script \
and will restrict the read/write permissions to the root user."
then
print_text_in_color "$ICyan" "Adjusting permissions..."
chown -R plex:plex "$MOUNT_PATH" &>/dev/null
chmod -R 770 "$MOUNT_PATH" &>/dev/null
# Adjust permissions at start up
if ! [ -f "$SCRIPTS/adjust-startup-permissions.sh" ]
then
cat << PERMISSIONS > "$SCRIPTS/adjust-startup-permissions.sh"
#!/bin/bash
# Secure the file
chown root:root "$SCRIPTS/adjust-startup-permissions.sh"
chmod 700 "$SCRIPTS/adjust-startup-permissions.sh"
# Entries
PERMISSIONS
fi
cat << PERMISSIONS >> "$SCRIPTS/adjust-startup-permissions.sh"
find "$MOUNT_PATH/" -not -path "$MOUNT_PATH/.snapshots/*" \\( ! -perm 770 -o ! -group plex \
-o ! -user plex \\) -exec chmod 770 {} \\; -exec chown plex:plex {} \\;
PERMISSIONS
chown root:root "$SCRIPTS/adjust-startup-permissions.sh"
chmod 700 "$SCRIPTS/adjust-startup-permissions.sh"
crontab -u root -l | grep -v "$SCRIPTS/adjust-startup-permissions.sh" | crontab -u root -
crontab -u root -l | { cat; echo "@reboot $SCRIPTS/adjust-startup-permissions.sh"; } | crontab -u root -
# Automatically create snapshots
mkdir -p "$MOUNT_PATH/.snapshots"
if ! [ -f "$SCRIPTS/create-daily-btrfs-snapshots.sh" ]
then
cat << SNAPSHOT > "$SCRIPTS/create-daily-btrfs-snapshots.sh"
#!/bin/bash
# Secure the file
chown root:root "$SCRIPTS/create-daily-btrfs-snapshots.sh"
chmod 700 "$SCRIPTS/create-daily-btrfs-snapshots.sh"
# Variables
MAX_SNAPSHOTS=14
CURRENT_DATE=\$(date --date @"\$(date +%s)" +"%Y%m%d_%H%M%S")
SNAPSHOT
fi
cat << SNAPSHOT >> "$SCRIPTS/create-daily-btrfs-snapshots.sh"
# $MOUNT_PATH
btrfs subvolume snapshot -r "$MOUNT_PATH/" "$MOUNT_PATH/.snapshots/@\$CURRENT_DATE"
while [ "\$(find "$MOUNT_PATH/.snapshots/" -maxdepth 1 -mindepth 1 -type d -name '@*_*' | wc -l)" -gt "\$MAX_SNAPSHOTS" ]
do
DELETE="\$(find "$MOUNT_PATH/.snapshots/" -maxdepth 1 -mindepth 1 -type d -name '@*_*' | sort | head -1)"
btrfs subvolume delete "\$DELETE"
done
SNAPSHOT
chown root:root "$SCRIPTS/create-daily-btrfs-snapshots.sh"
chmod 700 "$SCRIPTS/create-daily-btrfs-snapshots.sh"
crontab -u root -l | grep -v "$SCRIPTS/create-daily-btrfs-snapshots.sh" | crontab -u root -
crontab -u root -l | { cat; echo "@daily $SCRIPTS/create-daily-btrfs-snapshots.sh >/dev/null"; } | crontab -u root -
# Execute monthly scrubs
if ! [ -f "$SCRIPTS/scrub-btrfs-monthly.sh" ]
then
cat << SNAPSHOT > "$SCRIPTS/scrub-btrfs-monthly.sh"
#!/bin/bash
# Secure the file
chown root:root "$SCRIPTS/scrub-btrfs-monthly.sh"
chmod 700 "$SCRIPTS/scrub-btrfs-monthly.sh"
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
SNAPSHOT
fi
cat << SNAPSHOT >> "$SCRIPTS/scrub-btrfs-monthly.sh"
# $MOUNT_PATH
notify_admin_gui "Starting monthly BTRFS check of $MOUNT_PATH" "Starting BTRFS-scrub of $MOUNT_PATH.
You will be notified again when the scrub is done"
if ! btrfs scrub start -B "$MOUNT_PATH"
then
notify_admin_gui "Error while performing monthly BTRFS scrub of $MOUNT_PATH!" \
"Error on $MOUNT_PATH\nPlease look at $VMLOGS/monthly-btrfs-scrub.log for further info!"
else
notify_admin_gui "Monthly BTRFS scrub successful of $MOUNT_PATH!" \
"$MOUNT_PATH was successfully tested!\nPlease look at $VMLOGS/monthly-btrfs-scrub.log for further info!"
fi
SNAPSHOT
chown root:root "$SCRIPTS/scrub-btrfs-monthly.sh"
chmod 700 "$SCRIPTS/scrub-btrfs-monthly.sh"
crontab -u root -l | grep -v "$SCRIPTS/scrub-btrfs-monthly.sh" | crontab -u root -
crontab -u root -l | { cat; echo "@monthly $SCRIPTS/scrub-btrfs-monthly.sh >> $VMLOGS/monthly-btrfs-scrub.log 2>&1"; } | crontab -u root -
# Test if Plex is installed
if is_docker_running && docker ps -a --format "{{.Names}}" | grep -q "^plex$"
then
# Reconfiguring Plex
msg_box "Plex Media Server found. We are now adjusting Plex to be able to use the new drive.
This can take a while. Please be patient!"
print_text_in_color "$ICyan" "Downloading the needed tool to get the current Plex config..."
docker pull assaflavie/runlike
echo '#/bin/bash' > /tmp/pms-conf
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock assaflavie/runlike -p plex >> /tmp/pms-conf
if ! grep -q "$MOUNT_PATH:$MOUNT_PATH:ro" /tmp/pms-conf
then
MOUNT_PATH_SED="${MOUNT_PATH//\//\\/}"
sed -i "0,/--volume/s// -v $MOUNT_PATH_SED:$MOUNT_PATH_SED:ro \\\\\n&/" /tmp/pms-conf
docker stop plex
if ! docker rm plex
then
msg_box "Something failed while removing the old container."
return
fi
if ! bash /tmp/pms-conf
then
msg_box "Starting the new container failed. You can find the config here: '/tmp/pms-conf'"
return
fi
rm /tmp/pms-conf
msg_box "Plex was adjusted!"
else
rm /tmp/pms-conf
msg_box "No need to update Plex, since the drive is already mounted to Plex."
fi
fi
return
fi
# Execute the change to a backup drive
print_text_in_color "$ICyan" "Adjusting permissions..."
sed -i "/$UUID/s/defaults/defaults,noauto/" /etc/fstab
chown -R root:root "$MOUNT_PATH"
chmod -R 600 "$MOUNT_PATH"
umount "$MOUNT_PATH"
msg_box "Your Backup drive is ready."
}
# Show main_menu
while :
do
choice=$(whiptail --title "$TITLE" --menu \
"Choose what you want to do.
$MENU_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
"Mount a drive" "(Interactively mount a BTRFS drive)" \
"Exit" "(Exit this script)" 3>&1 1>&2 2>&3)
case "$choice" in
"Mount a drive")
mount_drive
;;
"Exit")
break
;;
"")
break
;;
*)
;;
esac
done
exit

View File

@ -1,489 +0,0 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true
SCRIPT_NAME="Daily Backup Wizard"
SCRIPT_EXPLAINER="This script helps creating a daily backup script for your server."
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode
# Check if root
root_check
# Variables
BACKUP_SCRIPT_NAME="$SCRIPTS/daily-borg-backup.sh"
# Functions
mount_if_connected() {
umount "$1" &>/dev/null
mount "$1" &>/dev/null
if ! mountpoint -q "$1"
then
return 1
fi
return 0
}
get_backup_mounts() {
BACKUP_MOUNTS=""
BACKUP_MOUNTS="$(grep "ntfs-3g" /etc/fstab | grep "windows_names" | grep "uid=root" \
| grep "gid=root" | grep "umask=177" | grep "noauto" | awk '{print $2}')"
BACKUP_MOUNTS+="\n"
BACKUP_MOUNTS+="$(grep cifs /etc/fstab | grep "uid=root" | grep "gid=root" \
| grep "file_mode=0600" | grep "dir_mode=0600" | grep "noauto" | awk '{print $2}')"
BACKUP_MOUNTS+="\n"
BACKUP_MOUNTS+="$(grep btrfs /etc/fstab | grep ",noauto" | awk '{print $2}')"
}
# Ask for execution
msg_box "$SCRIPT_EXPLAINER"
if ! yesno_box_yes "Do you want to create a daily backup script?"
then
exit
fi
# Before starting check if the requirements are met
if [ -f "$BACKUP_SCRIPT_NAME" ]
then
msg_box "The daily backup script already exists.
Please rename or delete $BACKUP_SCRIPT_NAME if you want to reconfigure the backup."
exit 1
fi
# Check if pending snapshot is existing and cancel the setup in this case.
if does_snapshot_exist "NcVM-startup"
then
# Cannot get executed during the startup script
if [ -f "$SCRIPTS/nextcloud-startup-script.sh" ]
then
msg_box "The daily backup cannot get configured during the startup script.
Please try again after it is finished by running:
'sudo bash $SCRIPTS/menu.sh' -> 'Server Configuration' -> 'Daily Backup Wizard'."
exit
fi
msg_box "You need to run the update script once before you can continue with creating the backup script."
if yesno_box_yes "Do you want to do this now?"
then
bash "$SCRIPTS"/update.sh minor
else
exit 1
fi
if does_snapshot_exist "NcVM-startup"
then
msg_box "It seems like the statup script wasn't correctly removed. Cannot proceed."
exit 1
fi
fi
if does_snapshot_exist "NcVM-snapshot-pending"
then
msg_box "It seems to be currently running a backup or update.
Cannot set up the daily backup now. Please try again later.\n
If you are sure that no update or backup is currently running, you can fix this by rebooting your server."
exit 1
fi
# Check if snapshot/free space exists
check_free_space
if ! does_snapshot_exist "NcVM-snapshot" && ! [ "$FREE_SPACE" -ge 50 ]
then
msg_box "Unfortunately you have not enough free space on your vgs to \
create a LVM-snapshot which is a requirement to create a backup script.
If you are running the script in a VM and not on barebones, you can increase your root partition manually by following these steps:
1. Shut down the VM and create a snapshot/copy of it (in order to be able to restore the current state)
2. Now increase the size of the virtual disk1 in your hypervisor by at least 5 GB (e.g. in VMWare Virtualplayer)
3. Power the VM back on
4. Log in via SSH and run the following command:
'sudo pvresize \$(sudo pvs | grep ubuntu-vg | grep -oP \"/dev/sda[0-9]\")'
5. Now you can run this script again:
'sudo bash $SCRIPTS/menu.sh' -> 'Server Configuration' -> 'Daily Backup Wizard'"
exit 1
fi
# Check if backup drives existing
get_backup_mounts
if [ "$BACKUP_MOUNTS" = "\n\n" ]
then
msg_box "No backup mount found that can be used as daily backup target.
Please mount one with the SMB Mount script from the Additional Apps Menu \
or with the BTRFS Mount script or NTFS Mount script from the Not-Supported Menu."
if yesno_box_yes "Do you want to mount a SMB-share that can be used as backup target with the SMB Mount script?
(This requires a SMB-server in your network.)"
then
run_script APP smbmount
else
exit 1
fi
get_backup_mounts
if [ "$BACKUP_MOUNTS" = "\n\n" ]
then
msg_box "Still haven't found any backup mount that can be used as daily backup target. Cannot proceed!"
exit 1
fi
fi
BACKUP_MOUNTS="$(echo -e "$BACKUP_MOUNTS")"
mapfile -t BACKUP_MOUNTS <<< "$BACKUP_MOUNTS"
for drive in "${BACKUP_MOUNTS[@]}"
do
if ! mount_if_connected "$drive"
then
continue
fi
BACKUP_DRIVES+=("$drive")
umount "$drive"
done
if [ -z "${BACKUP_DRIVES[*]}" ]
then
msg_box "No backup drive found that is currently connected.
Please connect it to your server before you can continue."
exit 1
else
msg_box "At least one backup mount found. Please leave it connected."
fi
# Check if /mnt/ncdata is mounted
if grep -q " /mnt/ncdata " /etc/mtab && ! grep " /mnt/ncdata " /etc/mtab | grep -q zfs
then
msg_box "The '/mnt/ncdata' directory is mounted and not existing on the root drive.
This is currently not supported."
exit 1
fi
# The same with the /home directory
if grep -q " /home " /etc/mtab
then
msg_box "The '/home' directory is mounted and not existing on the root drive.
This is currently not supported."
exit 1
fi
# Test sending of mails
if ! send_mail "Testmail" \
"This is a testmail to test if the server can send mails which is needed for the 'Daily Backup Wizard'."
then
msg_box "The server is not configured to send mails."
if yesno_box_yes "Do you want to do this now?"
then
run_script ADDONS smtp-mail
else
exit 1
fi
if ! send_mail "Testmail" \
"This is a testmail to test if the server can send mails which is needed for the 'Daily Backup Wizard'."
then
msg_box "The server still cannot send mails. Cannot proceed!"
exit 1
fi
fi
# Drive Menu
args=(whiptail --title "$TITLE" --separate-output --checklist \
"Please select the drives/mountpoints that you want to backup.
Always included is a full system backup (aka '/') and the '/mnt/ncdata' directory/drive.
$CHECKLIST_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4)
# Get mountpoints
DRIVE_MOUNTS=$(find /mnt/ -mindepth 1 -maxdepth 2 -type d | grep -v "/mnt/ncdata")
mapfile -t DRIVE_MOUNTS <<< "$DRIVE_MOUNTS"
# Check if drives are connected
if [ -n "${DRIVE_MOUNTS[*]}" ]
then
for mountpoint in "${DRIVE_MOUNTS[@]}"
do
if mountpoint -q "$mountpoint" && [ "$(stat -c '%a' "$mountpoint")" = "770" ] \
&& [ "$(stat -c '%U' "$mountpoint")" = "www-data" ] && [ "$(stat -c '%G' "$mountpoint")" = "www-data" ]
then
args+=("$mountpoint" "" OFF)
RESULTS+="$mountpoint"
fi
done
# Only show menu if at least one additional drive is connected
if [ -n "$RESULTS" ]
then
selected_options=$("${args[@]}" 3>&1 1>&2 2>&3)
else
msg_box "No connected drive found that can get backed up.
Always included is a full system backup (aka '/') and the '/mnt/ncdata' directory/drive."
fi
# Let the user select directories on the found drives
if [ -n "$selected_options" ]
then
mapfile -t SELECTED_DRIVES <<< "$selected_options"
for mountpoint in "${SELECTED_DRIVES[@]}"
do
if yesno_box_yes "Do you want to backup the whole drive that is mounted at '$mountpoint'?"
then
ADDITIONAL_BACKUP_DIRECTORIES+=("$mountpoint")
continue
fi
DIRECTORIES=$(find "$mountpoint" -maxdepth 2 -type d | grep "$mountpoint/")
while :
do
msg_box "Those are existing directories on that drive. Please remember one.\n\n$mountpoint/\n$DIRECTORIES"
SELECTION=$(input_box_flow "Please type in one \
directory that you would like to backup on this drive '$mountpoint'.
If you want to cancel, just type in 'exit' and press [ENTER].")
if [ "$SELECTION" = "exit" ]
then
exit 1
elif ! echo "$SELECTION" | grep -q "^$mountpoint/"
then
msg_box "It has to be a directory in '$mountpoint'. Please try again."
elif ! [ -d "$SELECTION" ]
then
msg_box "The directory doesn't exist. Please try again."
else
ADDITIONAL_BACKUP_DIRECTORIES+=("$SELECTION")
break
fi
done
done
fi
fi
# Backup drive menu
args=(whiptail --title "$TITLE" --menu \
"Please select the backup drive that you want to use.
$MENU_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4)
# Get all backup drives
for drive in "${BACKUP_DRIVES[@]}"
do
if ! mount_if_connected "$drive"
then
continue
fi
args+=("$drive" "")
CONNECTED_DRIVES+="$drive"
umount "$drive"
done
# Show backup drive menu
if [ -n "$CONNECTED_DRIVES" ]
then
selected_options=$("${args[@]}" 3>&1 1>&2 2>&3)
else
msg_box "No backup drive connected.
Hence, unable to continue."
exit 1
fi
# Cancel if nothing chosen
if [ -z "$selected_options" ]
then
msg_box "No backup drive chosen. Hence exiting."
exit 1
else
BACKUP_TARGET_DIRECTORY="${selected_options%%/}"
# Mount the backup drive
check_command mount "$BACKUP_TARGET_DIRECTORY"
BACKUP_MOUNT="$BACKUP_TARGET_DIRECTORY"
fi
# Ask if default directory shall get used
if yesno_box_yes "Do you want to use the recommended backup directory which is:
'$BACKUP_TARGET_DIRECTORY/borgbackup/NcVM'?"
then
if [ -d "$BACKUP_TARGET_DIRECTORY/borgbackup/NcVM" ] && ! rm -d "$BACKUP_TARGET_DIRECTORY/borgbackup/NcVM" &>/dev/null
then
msg_box "The directory '$BACKUP_TARGET_DIRECTORY/borgbackup/NcVM' exists and cannot be used.
Please choose a custom one."
CUSTOM_DIRECTORY=1
else
BACKUP_TARGET_DIRECTORY="$BACKUP_TARGET_DIRECTORY/borgbackup/NcVM"
fi
else
CUSTOM_DIRECTORY=1
fi
# Choose custom backup directory
if [ -n "$CUSTOM_DIRECTORY" ]
then
while :
do
SELECTED_DIRECTORY=$(input_box_flow "Please type in the directory that you want to use as backup directory.
It has to start with '$BACKUP_TARGET_DIRECTORY/'.
Recommended is '$BACKUP_TARGET_DIRECTORY/borgbackup/NcVM'
If you want to cancel, just type in 'exit' and press [ENTER].")
if [ "$SELECTED_DIRECTORY" = "exit" ]
then
exit 1
elif echo "$SELECTED_DIRECTORY" | grep -q " "
then
msg_box "Please don't use spaces."
elif ! echo "$SELECTED_DIRECTORY" | grep -q "^$BACKUP_TARGET_DIRECTORY/"
then
msg_box "The backup directory has to start with '$BACKUP_TARGET_DIRECTORY/'. Please try again."
elif [ -d "$SELECTED_DIRECTORY" ] && ! rm -d "$SELECTED_DIRECTORY" &>/dev/null
then
msg_box "This directory already exists. Please try again."
else
if ! mkdir -p "$SELECTED_DIRECTORY"
then
msg_box "Couldn't create the directory. Please try again."
rm -d "$SELECTED_DIRECTORY" &>/dev/null
else
rm -d "$SELECTED_DIRECTORY" &>/dev/null
BACKUP_TARGET_DIRECTORY="$SELECTED_DIRECTORY"
break
fi
fi
done
fi
# Ask for an Encryption key
while :
do
ENCRYPTION_KEY=$(input_box_flow "Please enter the encryption key that shall get used for Borg backups.
Please remember to store this key at a save place. You will not be able to restore your backup if you lose the key.
If you want to cancel, just type in 'exit' and press [ENTER].")
if [ "$ENCRYPTION_KEY" = "exit" ]
then
exit 1
elif yesno_box_no "Have you saved the encryption key for your backup?"
then
break
fi
done
# Ask when the daily backup shall run
if yesno_box_yes "Do you want to run the daily backup at the recommended time 4.00 am?"
then
BACKUP_TIME="00 04"
else
while :
do
BACKUP_TIME=$(input_box_flow "Please enter the time when the backup shall get executed daily in this format:
'mm hh' (minutes first, hours second)
Recommended is: '00 04' (Backups will be executed at 4.00 am)
Please enter it in 24h format. (No am and pm).
If you want to cancel, just type in 'exit' and press [ENTER].")
if [ "$BACKUP_TIME" = "exit" ]
then
exit 1
elif ! echo "$BACKUP_TIME" | grep -q "^[0-5][0-9] [0-1][0-9]$" && ! echo "$BACKUP_TIME" | grep -q "^[0-5][0-9] 2[0-3]$"
then
msg_box "Please enter the time in this format:
'mm hh' (minutes first, hours second)
Recommended is: '00 04' (Backups will be executed at 4.00 am)"
else
break
fi
done
fi
# Install needed tools
msg_box "We will now install all needed tools, initialize the Borg backup repository and create the daily backup script now."
install_if_not borgbackup
# Initialize the borg backup repository
export BORG_PASSPHRASE="$ENCRYPTION_KEY"
mkdir -p "$BACKUP_TARGET_DIRECTORY"
check_command borg init --encryption=repokey-blake2 "$BACKUP_TARGET_DIRECTORY"
borg config "$BACKUP_TARGET_DIRECTORY" additional_free_space 2G
unset BORG_PASSPHRASE
# Fix too large Borg cache
# https://borgbackup.readthedocs.io/en/stable/faq.html#the-borg-cache-eats-way-too-much-disk-space-what-can-i-do
BORG_ID="$(borg config "$BACKUP_TARGET_DIRECTORY" id)"
check_command rm -r "/root/.cache/borg/$BORG_ID/chunks.archive.d"
check_command touch "/root/.cache/borg/$BORG_ID/chunks.archive.d"
# Make a backup from the borg config file
if ! [ -f "$BACKUP_TARGET_DIRECTORY/config" ]
then
msg_box "The borg config file wasn't created. Something is wrong."
exit 1
else
if ! send_mail "Your daily backup config file! Please save/archive it!" "$(cat "$BACKUP_TARGET_DIRECTORY/config")"
then
msg_box "Could not send the daily backup config file. This is wrong."
exit 1
fi
fi
# Unmount the backup drive
check_command umount "$BACKUP_MOUNT"
# Write beginning of the script
cat << WRITE_BACKUP_SCRIPT > "$BACKUP_SCRIPT_NAME"
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true
SCRIPT_NAME="Daily Borg Backup"
SCRIPT_EXPLAINER="This script executes the daily Borg backup."
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode
# Check if root
root_check
# Export Variables
export ENCRYPTION_KEY='$ENCRYPTION_KEY'
export BACKUP_TARGET_DIRECTORY="$BACKUP_TARGET_DIRECTORY"
export BACKUP_MOUNTPOINT="$BACKUP_MOUNT"
export BORGBACKUP_LOG="$VMLOGS/borgbackup.log"
export CHECK_BACKUP_INTERVAL_DAYS=14
export DAYS_SINCE_LAST_BACKUP_CHECK=14
WRITE_BACKUP_SCRIPT
unset ENCRYPTION_KEY
# Secure the file
chown root:root "$BACKUP_SCRIPT_NAME"
chmod 700 "$BACKUP_SCRIPT_NAME"
# Add a variable for enabling/disabling btrfs scrub for the backup drive
if grep "$BACKUP_MOUNT" /etc/fstab | grep -q btrfs
then
echo 'export BTRFS_SCRUB_BACKUP_DRIVE="yes"' >> "$BACKUP_SCRIPT_NAME"
fi
# Write additional backup sources to the script
SOURCES='export ADDITIONAL_BACKUP_DIRECTORIES="'
for source in "${ADDITIONAL_BACKUP_DIRECTORIES[@]}"
do
SOURCES+="$source\n"
done
SOURCES="${SOURCES%%\\n}"
SOURCES+='"'
echo -e "$SOURCES" >> "$BACKUP_SCRIPT_NAME"
# Write end of the script
cat << WRITE_BACKUP_SCRIPT >> "$BACKUP_SCRIPT_NAME"
# Execute backup
if network_ok
then
echo "Executing \$SCRIPT_NAME. \$(date +%Y-%m-%d_%H-%M-%S)" >> "\$BORGBACKUP_LOG"
run_script NOT_SUPPORTED_FOLDER borgbackup
else
echo "Unable to execute \$SCRIPT_NAME. No network connection. \$(date +%Y-%m-%d_%H-%M-%S)" >> "\$BORGBACKUP_LOG"
notify_admin_gui "Unable to execute \$SCRIPT_NAME." "No network connection."
fi
WRITE_BACKUP_SCRIPT
# Create fstab entry
crontab -u root -l | grep -v "$BACKUP_SCRIPT_NAME" | crontab -u root -
crontab -u root -l | { cat; echo "$BACKUP_TIME * * * $BACKUP_SCRIPT_NAME > /dev/null 2>&1" ; } | crontab -u root -
# Inform user
msg_box "The Borg backup script was successfully created!
It is located here: '$BACKUP_SCRIPT_NAME'\n
The first backup will run automatically at your chosen time."
exit

View File

@ -1,119 +0,0 @@
#!/bin/bash
# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
true
SCRIPT_NAME="Firewall"
SCRIPT_EXPLAINER="This script helps setting up a firewall for your NcVM."
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh
# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode
# Check if root
root_check
# Check if firewall is already enabled
if ! ufw status | grep -q " active"
then
# Ask for installing
install_popup "$SCRIPT_NAME"
else
# Ask for removal or reinstallation
reinstall_remove_menu "$SCRIPT_NAME"
# Removal
ufw disable
ufw --force reset
# Show successful uninstall if applicable
removal_popup "$SCRIPT_NAME"
fi
# Install and enable firewall
if ! is_this_installed ufw
then
DEBIAN_FRONTEND=noninteractive apt-get install ufw -y --no-install-recommends
systemctl enable ufw &>/dev/null
systemctl start ufw &>/dev/null
fi
# SSH
print_text_in_color "$ICyan" "Allow SSH"
ufw allow ssh comment SSH
# Web server
print_text_in_color "$ICyan" "Web server"
ufw allow http comment http
ufw allow https comment https
# UPnP
print_text_in_color "$ICyan" "UPnP"
ufw allow proto udp from 192.168.0.0/16 comment UPnP
# Adminer
print_text_in_color "$ICyan" "Allow Adminer"
ufw allow 9443/tcp comment Adminer
# Netdata
print_text_in_color "$ICyan" "Allow Netdata"
ufw allow 19999/tcp comment 'Netdata TCP'
ufw allow 19999/udp comment 'Netdata UDP'
# Talk (no custom port possible)
print_text_in_color "$ICyan" "Allow Talk"
ufw allow 3478/tcp comment 'Talk TCP'
ufw allow 3478/udp comment 'Talk UDP'
# Webmin
print_text_in_color "$ICyan" "Allow Webmin"
ufw allow 10000/tcp comment Webmin
# RDP
if is_this_installed xrdp
then
print_text_in_color "$ICyan" "Allow RDP"
ufw allow 3389/tcp comment Remotedesktop
fi
# Samba
if is_this_installed samba
then
print_text_in_color "$ICyan" "Allow Samba"
ufw allow samba comment Samba
fi
# Pi-hole
if pihole &>/dev/null
then
print_text_in_color "$ICyan" "Allow Pi-hole"
ufw allow 53/tcp comment 'Pi-hole TCP'
ufw allow 53/udp comment 'Pi-hole UDP'
ufw allow 8094/tcp comment 'Pi-hole Web'
fi
# PiVPN
if pivpn &>/dev/null
then
print_text_in_color "$ICyan" "Allow PiVPN"
ufw allow 51820/udp comment 'PiVPN'
fi
# Plex
if is_docker_running && docker ps -a --format "{{.Names}}" | grep -q "^plex$"
then
print_text_in_color "$ICyan" "Allow Plex"
for port in 32400/tcp 3005/tcp 8324/tcp 32469/tcp 1900/udp 32410/udp 32412/udp 32413/udp 32414/udp
do
ufw allow "$port" comment "Plex $port"
done
fi
# Enable firewall
print_text_in_color "$ICyan" "Enable Firewall"
ufw --force enable
msg_box "The Firewall was configured successfully!"

Some files were not shown because too many files have changed in this diff Show More