This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.bash.conf
47 lines (37 loc) · 1.81 KB
/
example.bash.conf
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
#!/bin/bash
#####
# This file is for extra configuration properties and functions that will be loaded by extlib or other scripts
# You can use it by adding `source extlib.conf` to your script, or by passing `-s extlib.conf` to a script that sources extlib.bash.
#####
# This variable sets the user that is allowed to run this script.
# Currently, it will always match the current user, so will always work.
# Change the value as desired to control user access to the script.
export REQUIREUSER="$USER"
# You can specify variables that will be available to the script that sources this one.
export EXAMPLEVAR="value"
# If you do not want more than one instance of a script to run, set a pidfile
export PIDFILE="${0}.pid"
# Logs are saved to ${0}.log by default, but you can change that like so:
export LOGFILE="example.log"
# By default, the log level is INFO, but you can change that like so:
export LOGLEVEL="DEBUG"
# For logging purposes, you can set the name of the script. By default, this is ${0}, but you can change it like so:
export SCRIPT_NAME="Example Script"
# Functions can be defined for the parent script as well
example_function () {
# Setting a local variable for this function's name helps debugging by
# showing where the error occurred in the log.
local CURRENT_FUNC="example_function"
log_info "This is an example function, and the arguments passed to it were: '$@'"
}
example_finally () {
# Something to run at the end before exiting
local CURRENT_FUNC="example_finally"
log_debug "Example final command was called"
}
######
# Extra tasks that need to be done before exiting can be added to the FINALCMDS array like so:
# FINALCMDS+=("command1 argument argument")
# FINALCMDS+=("command2 argument argument")
# This depends on the bash4funcs function, which you can call here beforehand if you like
#####