You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: common.sh
+40-39Lines changed: 40 additions & 39 deletions
Original file line number
Diff line number
Diff line change
@@ -4,55 +4,56 @@
4
4
## Does all common job
5
5
##
6
6
## Exits with codes:
7
-
## 1 - configuration file errors
8
-
## 2 - dependencies errors
7
+
## 1 - dependencies errors
8
+
## 2 - configuration file errors
9
9
##
10
10
11
+
# Dependencies check
12
+
WC=$(type -P wc)|| { echo"Error: wc not found"1>&2;exit 2; }
13
+
PS=$(type -P ps)|| { echo"Error: ps not found"1>&2;exit 2; }
14
+
RM=$(type -P rm)|| { echo"Error: rm not found"1>&2;exit 2; }
15
+
CAT=$(type -P cat)|| { echo"Error: cat not found"1>&2;exit 2; }
16
+
SED=$(type -P sed)|| { echo"Error: sed not found"1>&2;exit 2; }
17
+
DATE=$(type -P date)|| { echo"Error: date not found"1>&2;exit 2; }
18
+
KILL=$(type -P kill)|| { echo"Error: kill not found"1>&2;exit 2; }
19
+
GREP=$(type -P grep)|| { echo"Error: grep not found"1>&2;exit 2; }
20
+
TOUCH=$(type -P touch)|| { echo"Error: touch not found"1>&2;exit 2; }
21
+
MKDIR=$(type -P mkdir)|| { echo"Error: mkdir not found"1>&2;exit 2; }
22
+
NOHUP=$(type -P nohup)|| { echo"Error: nohup not found"1>&2;exit 2; }
23
+
SLEEP=$(type -P sleep)|| { echo"Error: sleep not found"1>&2;exit 2; }
24
+
FLOCK=$(type -P flock)|| { echo"Error: flock not found"1>&2;exit 2; }
25
+
FALSE=$(type -P false)|| { echo"Error: false not found"1>&2;exit 2; }
26
+
BASE64=$(type -P base64)|| { echo"Error: base64 not found"1>&2;exit 2; }
27
+
MKFIFO=$(type -P mkfifo)|| { echo"Error: mkfifo not found"1>&2;exit 2; }
28
+
11
29
# Config check (logging level)
12
-
[ -n"$LOG_LEVEL" ] ||! [[ "$LOG_LEVEL"=~ ^[[:digit:]]+$ ]] || { echo"Error: config directive LOG_LEVEL not defined correctly";exit 1;}
30
+
[ -n"$LOG_LEVEL" ] ||! [[ "$LOG_LEVEL"=~ ^[[:digit:]]+$ ]] || { echo"Error: config directive LOG_LEVEL is not defined correctly"1>&2;exit 1;}
13
31
14
32
# Config check (parallel tasks)
15
-
[ -n"$PARALLEL_TASKS" ] ||! [[ "$PARALLEL_TASKS"=~ ^[[:digit:]]+$ ]] || { echo"Error: config directive PARALLEL_TASKS not defined correctly";exit 1;}
33
+
[ -n"$PARALLEL_TASKS" ] ||! [[ "$PARALLEL_TASKS"=~ ^[[:digit:]]+$ ]] || { echo"Error: config directive PARALLEL_TASKS is not defined correctly"1>&2;exit 1;}
16
34
17
35
# Config check (script parts directories)
18
-
[ -n"$SCRIPT_DIR"-a-d"$SCRIPT_DIR"-a-w"$SCRIPT_DIR"-a-x"$SCRIPT_DIR" ] || { echo"Error: config directive SCRIPT_DIR not defined correctly";exit 1;}
19
-
[ -n"$LOCK_DIR"-a-d"$LOCK_DIR"-a-w"$LOCK_DIR"-a-x"$LOCK_DIR" ] || { echo"Error: config directive LOCK_DIR not defined correctly";exit 1;}
20
-
[ -n"$PIPE_DIR"-a-d"$PIPE_DIR"-a-w"$PIPE_DIR"-a-x"$PIPE_DIR" ] || { echo"Error: config directive PIPE_DIR not defined correctly";exit 1;}
21
-
[ -n"$TASK_DIR"-a-d"$TASK_DIR"-a-w"$TASK_DIR"-a-x"$TASK_DIR" ] || { echo"Error: config directive TASK_DIR not defined correctly";exit 1;}
22
-
[ -n"$LOG_DIR"-a-d"$LOG_DIR"-a-w"$LOG_DIR"-a-x"$LOG_DIR" ] || { echo"Error: config directive LOG_DIR not defined correctly";exit 1;}
23
-
[ -n"$PID_DIR"-a-d"$PID_DIR"-a-w"$PID_DIR"-a-x"$PID_DIR" ] || { echo"Error: config directive PID_DIR not defined correctly";exit 1;}
36
+
[ -n"$SCRIPT_DIR"-a-d"$SCRIPT_DIR"-a-w"$SCRIPT_DIR"-a-x"$SCRIPT_DIR" ] || { echo"Error: config directive SCRIPT_DIR is not defined correctly"1>&2;exit 1; }
37
+
[ -n"$PIPE_DIR"-a-d"$PIPE_DIR"-a-w"$PIPE_DIR"-a-x"$PIPE_DIR" ] || { echo"Error: config directive PIPE_DIR is not defined correctly"1>&2;exit 1; }
38
+
[ -n"$TASK_DIR"-a-d"$TASK_DIR"-a-w"$TASK_DIR"-a-x"$TASK_DIR" ] || { echo"Error: config directive TASK_DIR is not defined correctly"1>&2;exit 1; }
39
+
[ -n"$LOG_DIR"-a-d"$LOG_DIR"-a-w"$LOG_DIR"-a-x"$LOG_DIR" ] || { echo"Error: config directive LOG_DIR is not defined correctly"1>&2;exit 1; }
40
+
[ -n"$PID_DIR"-a-d"$PID_DIR"-a-w"$PID_DIR"-a-x"$PID_DIR" ] || { echo"Error: config directive PID_DIR is not defined correctly"1>&2;exit 1; }
24
41
25
42
# Config check (script part files)
26
-
[ -n"$COMMON_SCRIPT_FILE"-o-e"$COMMON_SCRIPT_FILE" ] || { echo"Error: config directive COMMON_SCRIPT_FILE not defined correctly";exit 1;}
27
-
[ -n"$WORKER_SCRIPT_FILE"-o-e"$WORKER_SCRIPT_FILE"-o-x"$WORKER_SCRIPT_FILE" ] || { echo"Error: config directive WORKER_SCRIPT_FILE not defined correctly";exit 1;}
28
-
[ -n"$DASHBOARD_SCRIPT_FILE"-o-e"$DASHBOARD_SCRIPT_FILE"-o-x"$DASHBOARD_SCRIPT_FILE" ] || { echo"Error: config directive DASHBOARD_SCRIPT_FILE not defined correctly";exit 1;}
29
-
[ -n"$TASKSQUEUE_SCRIPT_FILE"-o-e"$TASKSQUEUE_SCRIPT_FILE"-o-x"$TASKSQUEUE_SCRIPT_FILE" ] || { echo"Error: config directive TASKSQUEUE_SCRIPT_FILE not defined correctly";exit 1;}
43
+
[ -n"$COMMON_SCRIPT_FILE"-o-e"$COMMON_SCRIPT_FILE" ] || { echo"Error: config directive COMMON_SCRIPT_FILE is not defined correctly"1>&2;exit 1;}
44
+
[ -n"$WORKER_SCRIPT_FILE"-o-e"$WORKER_SCRIPT_FILE"-o-x"$WORKER_SCRIPT_FILE" ] || { echo"Error: config directive WORKER_SCRIPT_FILE is not defined correctly"1>&2;exit 1;}
45
+
[ -n"$DASHBOARD_SCRIPT_FILE"-o-e"$DASHBOARD_SCRIPT_FILE"-o-x"$DASHBOARD_SCRIPT_FILE" ] || { echo"Error: config directive DASHBOARD_SCRIPT_FILE is not defined correctly"1>&2;exit 1;}
46
+
[ -n"$TASKSQUEUE_SCRIPT_FILE"-o-e"$TASKSQUEUE_SCRIPT_FILE"-o-x"$TASKSQUEUE_SCRIPT_FILE" ] || { echo"Error: config directive TASKSQUEUE_SCRIPT_FILE is not defined correctly"1>&2;exit 1;}
30
47
31
48
# Config check (script files)
32
-
[ -n"$WORKERS_PID_FILE" ] || { echo"Error: config directive WORKERS_PID_FILE not defined correctly";exit 1;}
33
-
[ -n"$TASKSQUEUE_PID_FILE" ] || { echo"Error: config directive TASKSQUEUE_PID_FILE not defined correctly";exit 1;}
34
-
[ -n"$TASKS_DELAYED_FILE" ] || { echo"Error: config directive TASKS_DELAYED_FILE not defined correctly";exit 1;}
35
-
[ -n"$TASKS_DELAYED_FILE_LOCK" ] || { echo"Error: config directive TASKS_DELAYED_FILE_LOCK not defined correctly";exit 1;}
36
-
[ -n"$TASKS_TRANSPORT_PIPE" ] || { echo"Error: config directive TASKS_TRANSPORT_PIPE not defined correctly";exit 1;}
37
-
[ -n"$TASKS_TRANSPORT_PIPE_LOCK" ] || { echo"Error: config directive TASKS_TRANSPORT_PIPE_LOCK not defined correctly";exit 1;}
49
+
[ -n"$WORKERS_PID_FILE" ] || { echo"Error: config directive WORKERS_PID_FILE is not defined correctly"1>&2;exit 1; }
50
+
[ -n"$TASKSQUEUE_PID_FILE" ] || { echo"Error: config directive TASKSQUEUE_PID_FILE is not defined correctly"1>&2;exit 1; }
51
+
[ -n"$TASKS_FILE" ] || { echo"Error: config directive TASKS_FILE is not defined correctly"1>&2;exit 1; }
52
+
[ -n"$TASKS_PIPE" ] || { echo"Error: config directive TASKS_PIPE is not defined correctly"1>&2;exit 1; }
38
53
39
-
# Dependencies check
40
-
WC=$(type -P wc)|| { echo"Error: wc not found";exit 2;}
41
-
PS=$(type -P ps)|| { echo"Error: ps not found";exit 2;}
42
-
RM=$(type -P rm)|| { echo"Error: rm not found";exit 2;}
43
-
CAT=$(type -P cat)|| { echo"Error: cat not found";exit 2;}
44
-
SED=$(type -P sed)|| { echo"Error: sed not found";exit 2;}
45
-
DATE=$(type -P date)|| { echo"Error: date not found";exit 2;}
46
-
KILL=$(type -P kill)|| { echo"Error: kill not found";exit 2;}
47
-
GREP=$(type -P grep)|| { echo"Error: grep not found";exit 2;}
48
-
TOUCH=$(type -P touch)|| { echo"Error: touch not found";exit 2;}
49
-
MKDIR=$(type -P mkdir)|| { echo"Error: mkdir not found";exit 2;}
50
-
NOHUP=$(type -P nohup)|| { echo"Error: nohup not found";exit 2;}
51
-
SLEEP=$(type -P sleep)|| { echo"Error: sleep not found";exit 2;}
52
-
FLOCK=$(type -P flock)|| { echo"Error: flock not found";exit 2;}
53
-
FALSE=$(type -P false)|| { echo"Error: false not found";exit 2;}
54
-
BASE64=$(type -P base64)|| { echo"Error: base64 not found";exit 2;}
55
-
MKFIFO=$(type -P mkfifo)|| { echo"Error: mkfifo not found";exit 2;}
0 commit comments