-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathscript-config.conf
More file actions
313 lines (271 loc) · 12.9 KB
/
script-config.conf
File metadata and controls
313 lines (271 loc) · 12.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
CONFIG_VERSION="3.4" #DEV VERSION
######################
# USER VARIABLES #
######################
####################### USER CONFIGURATION START #######################
### NOTIFICATION SETTINGS ###
# Address where the output will be emailed to.
# This method uses "mailx", if it's not available or doesn't work,
# go to "Apprise email notification"
# If you do not want to receive emails and rely on other notification
# methods, leave these fields empty.
EMAIL_ADDRESS="destination-email-goes-here"
FROM_EMAIL_ADDRESS="sender-email-goes-here"
# Use Healthchecks.io to report script errors. Set to 1 to enable.
# Please note that every "WARNING" will be reported as failure.
# When enabled, enter your Healthchecks UUID (not the full URL).
# If using a self-hosted instance, change the URL to your endpoint
# including the trailing slash.
# HINT: If you self-host Healthchecks.io, you can directly integrate it
# with Apprise using its GUI
HEALTHCHECKS=0
HEALTHCHECKS_ID="your-uuid-here"
HEALTHCHECKS_URL="https://hc-ping.com/"
# Apprise can send a notification to almost all of the most popular
# notification services available to us today such as:
# Telegram, Discord, Slack, Amazon SNS, Gotify, you name it.
# It supersedes "Hook Notification", which will be
# eventually dismissed in the future.
# Set APPRISE to 1 to enable, 0 to disable.
# Set APPRISE_URL according to the service you want to invoke.
# Set APPRISE_ATTACH to get the report attached to the notification if a
# warning is issued. Not all services support this option.
# Apprise documentation and URL examples can be found here:
# https://github.com/caronc/apprise
# You can use multiple Apprise URLS separated by spaces.
# Example with Discord and Telegram:
# APPRISE_URL=("discord://<your-webook-url>" "tgram://<your-bot-token-here>/<your-chat-id-here>")
APPRISE=0
APPRISE_URL=()
APPRISE_ATTACH=0
# Apprise email notification
# Use Apprise internal service to send emails.
# This setting does not require to enable Apprise notification feature.
# To configure this properly, please read this documentation
# https://github.com/caronc/apprise/wiki/Notify_email
# Set 1 to enable.
# Set APPRISE_EMAIL_ATTACH to 1 to get the report attached if a
# warning is issued.
# The example below uses a custom SMTP. If you're using a public mail
# service like Gmail, Outlook and so on, the config is much easier.
# Please check Apprise docs.
# Example:
# APPRISE_EMAIL_URL='mailtos://_?user=senderusername@domain.com&pass=mySuperSafePWD!&smtp=smtp.mymailserver.com&from=sender@domain.com&to=recipient@gmail.com'
APPRISE_EMAIL=0
APPRISE_EMAIL_ATTACH=0
APPRISE_EMAIL_URL=''
# Use Telegram to report script execution summary (not the whole report)
# Consider using Apprise notification feature, it has more features.
# Set 1 to enable. Create a bot using @botfather, then copy the API token.
# To get your chat ID, use @getidsbot
TELEGRAM=0
TELEGRAM_TOKEN="your-token-here"
TELEGRAM_CHAT_ID="your-chat-id-here"
# Use Discord to report script execution summary (not the whole report)
# Consider using Apprise notification feature, it has more features.
# Set 1 to enable.
# To get your Webhook URL go to the channel settings -> Integrations and
# create a web hook
DISCORD=0
DISCORD_WEBHOOK_URL="your-webhook-url"
# Custom notification service
# Consider using Apprise notification feature, it has more features.
# Set this to a script/service to be used instead of the default email
# notification. You may want to use a service not natively supported by this
# script or a mail service with custom formatting.
# If you don't want to use this option, don't make changes to this.
# $CURRENT_DIR can be used to get the running directory of the script.
# This script will pass the following parameters to HOOK_NOTIFICATION:
# 1st parameter will be the subject
# 2nd parameter will be the body
HOOK_NOTIFICATION=""
# Check for script updates.
# On each run, the script will check via GitHub if there's an update, and will
# inform the user via the configured notification systems.
# 1 to enable, 0 to disable.
CHECK_UPDATES=1
### SCRIPT AND SNAPRAID SETTINGS ###
# Set the threshold of deleted and updated files to stop the sync job from running.
# Note that depending on how active your filesystem is being used, a low number
# here may result in your parity info being out of sync often and/or you having
# to do lots of manual syncing.
DEL_THRESHOLD=500
UP_THRESHOLD=500
# This setting allows you to specify a pattern to exclude certain files when
# computing the counts of changed files using 'snapraid diff'.
# These use standard Bash "pathname expansion" (globs).
#
# WARNING: Please use this setting only if you really know what you are doing,
# it is meant for an advanced use.
# Do not use this to ignore files changing often, such as log files.
# This will cause the parity information to be out of sync and make recoveries
# impossible if those files are needed.
# Use the snapraid ignore configuration option instead.
# More details: https://www.snapraid.it/manual#7.7
# https://www.snapraid.it/manual#8
#
# Syntax:
# - the whole pattern must be enclosed in parentheses.
# - Multiple patterns are separated by spaces inside the parentheses.
# - Each pattern must be wrapped in double quotes.
#
# Examples:
# IGNORE_PATTERN=("*.tmp" "/var/cache/*" "*/backup/*")
# *.tmp → ignore all .tmp files
# /var/cache/* → ignore everything under /var/cache
# */backup/* → ignore any "backup" directory, anywhere
#
# Glob cheatsheet:
# * → matches anything (zero or more characters)
# ? → matches exactly one character
# [abc] → matches any of a, b, or c
# [!abc] → matches any character except a, b, or c
#
# More details: https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html
IGNORE_PATTERN=()
# Allow a sync that would otherwise violate the delete threshold, but only
# if the ratio of added to deleted files is greater than the value set.
# Set to 0 to disable this option.
# Example: A senario with 5000 deleted files and 3800 added files would
# result in an ADD_DEL_THRESHOLD of 0.76 (3800/5000)
ADD_DEL_THRESHOLD=0
# Set number of warnings before forcing a sync, or force the sync every time
# ignoring thresholds (Forced Sync). This option comes in handy when you cannot be
# bothered to manually start a sync job when DEL_THRESHOLD or UP_THRESHOLD are
# breached due to false alarm.
# Set to 0 to ALWAYS force a sync (Forced Sync, ignoring the thresholds above)
# Set to -1 to NEVER force a sync, the default behaviour (need to manual sync if
# thresholds are breached).
SYNC_WARN_THRESHOLD=-1
# Set percentage and age, in days, of blocks in array to scrub if it is in sync.
# i.e. 0 to disable and 100 to scrub the full array in one go.
# WARNING - depending on size of your array, setting to 100 can take a long time!
SCRUB_PERCENT=5
SCRUB_AGE=10
# Scrub new blocks after sync that have yet to be scrubbed. 1 to enable and any
# other value to disable.
SCRUB_NEW=0
# Set number of script runs before running a scrub. Use this option if you
# don't want to scrub the array every time.
# Set to 0 to disable this option and run scrub every time.
SCRUB_DELAYED_RUN=0
# Prehash Data To avoid the risk of a latent hardware issue, you can enable the
# "pre-hash" mode and have all the data read two times to ensure its integrity.
# This option also verifies the files moved inside the array, to ensure that
# the move operation went successfully, and in case to block the sync and to
# allow to run a fix operation. 1 to enable, any other value to disable.
PREHASH=1
# Forces the operation of syncing a file with zero size that before was not.
# If SnapRAID detects a such condition, it stops proceeding unless you enable
# this option. Useful when syncing system files which can genuinely get
# changed to zero.
# Disabled by default, 1 to enable.
FORCE_ZERO=0
# Set if disk spindown should be performed. Depending on your system, this may
# not work. 1 to enable, any other value to disable.
# hd-idle is required and must be already configured.
SPINDOWN=0
# Increase verbosity of the email output. NOT RECOMMENDED!
# If set to 1, TOUCH and DIFF outputs will be kept in the email, producing
# a mostly unreadable email. You can always check TOUCH and DIFF outputs
# using the TMP file or use the feature RETENTION_DAYS.
# 1 to enable, any other value to disable.
VERBOSITY=0
# SnapRAID detailed output retention for each run.
# Default behaviour is RETENTION_DAYS=0: every time your run SnapRAID, the
# output is saved to "/tmp" and is overridden during every run.
# To enable retention, set RETENTION_DAYS to the days of output you want to
# keep in your home folder. Files will have timestamps.
# SNAPRAID_LOG_DIR can be changed to any folder you like.
RETENTION_DAYS=0
SNAPRAID_LOG_DIR="$HOME"
# Set the option to log SMART info collected by SnapRAID.
# Use SMART_LOG_NOTIFY to send the output using Apprise, Telegram and Discord.
# 1 to enable, any other value to disable.
SMART_LOG=1
SMART_LOG_NOTIFY=0
# Run 'snapraid status' command to show array general information.
# Use SNAP_STATUS_NOTIFY to send the output to Apprise, Telegram and Discord.
# 1 to enable, any other value to disable.
SNAP_STATUS=0
SNAP_STATUS_NOTIFY=0
# SnapRAID configuration file location. The default path works on most
# installations, including OMV6.
# If you're using OMV7, the script will try to pick the file automatically.
# If you have multiple SnapRAID arrays, you must must manually specify the
# config file you want to use. On OMV7 the files are located at /etc/snapraid/
SNAPRAID_CONF="/etc/snapraid.conf"
### DOCKER CONTAINERS MANAGEMENT ###
# Set to 1 to manage docker containers. They will be paused/stopped or
# resumed/restarted accordingly. If set to 0, all other options related to Docker
# will be ignored.
MANAGE_SERVICES=0
# Choose how to manage your containers: 1 to pause/unpause, 2 to stop/restart
# This option does not have any effect if MANAGE_SERVICES is set to 0
DOCKER_MODE=1
# Manage Docker containers running on the same host.
# Set to 1 to enable, 0 to disable it.
# Enter containers to be managed separated with spaces. Please ensure these containers
# are always running before executing the script, otherwise an error will be logged.
# Example:
# SERVICES="syncthing kopia nextcloud $(docker container ls -q --filter name=immich*)"
DOCKER_LOCAL=0
SERVICES="container1 container2 container3"
# Manage Docker containers running on a remote machine. To use this feature,
# you must setup passwordless ssh access between snapRAID host and Docker host.
# Set to 1 to enable management of Docker containers running eslewhere, then enter
# Docker host SSH user and machine IP or hostname.
# You can manage multiple remote Docker hosts.
# Reference:
# ('HOSTIP1:container1 container2 container3' 'HOSTIP2:container1 container2 container3 container4')
# Example:
# ('192.168.0.125:code-server portainer plex' '192.168.0.126:nextcloud handbrake transmission')
# Delay is the number of seconds to wait before sending the next docker
# command to avoid errors. Change it if you're experiencing errors.
DOCKER_REMOTE=0
DOCKER_USER="sshusernamegoeshere"
DOCKER_HOST_SERVICES=('HOSTIP1:container1 container2 container3' 'HOSTIP2:container1 container2 container3 container4')
DOCKER_DELAY=0
### CUSTOM HOOKS ###
# Hooks are shell commands that the scripts executes for you.
# You can specify 'before_hook' to perform preparation steps before SnapRAID
# actions and 'after_hook' to perform steps afterwards.
# Set to 1 to enable custom hooks
CUSTOM_HOOK=0
# Custom hook before SnapRAID activities
# This custom hook executes when pre-processing is complete and before
# SnapRAID operations.
# This option does not have any effect if CUSTOM_HOOK is set to 0
# Use NAME for a friendly name, CMD for the command itself.
BEFORE_HOOK_NAME=""
BEFORE_HOOK_CMD=""
# Custom hook after SnapRAID activities
# This custom hook executes after SnapRAID operations and will be the
# last command.
# This option does not have any effect if CUSTOM_HOOK is set to 0
# Use NAME for a friendly name, CMD for the command itself.
# Set EXECUTE_BEFORE_SPINDOWN to 1, if you have hd-idle configured
# to spin down your disks in the end and want the custom hook to be
# executed before that. Default is execution after spindown.
AFTER_HOOK_NAME=""
AFTER_HOOK_CMD=""
EXECUTE_BEFORE_SPINDOWN=0
####################### USER CONFIGURATION END #######################
####################### SYSTEM CONFIGURATION #######################
# Please make changes only if you know what you're doing
# locate snapraid using path
SNAPRAID_BIN="$(command -v snapraid)"
# location of the mail program binary
MAIL_BIN="/usr/bin/mailx"
# Init variables
CHK_FAIL=0
DO_SYNC=0
EMAIL_SUBJECT_PREFIX="(SnapRAID on $(hostname))"
SERVICES_STOPPED=0
SYNC_WARN_FILE="$CURRENT_DIR/snapRAID.warnCount"
SCRUB_COUNT_FILE="$CURRENT_DIR/snapRAID.scrubCount"
TMP_OUTPUT="/tmp/snapRAID.out"
SNAPRAID_LOG="/var/log/snapraid.log"
SECONDS=0 #Capture time
# Expand PATH for smartctl
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin