-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·116 lines (95 loc) · 1.68 KB
/
run
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
#!/usr/bin/env bash
# Desiccant by Eachtime https://github.com/eachtime
# Version : 0.1
# website: https://desiccant.fr
#
# This script is licensed under The GNU AFFERO GENERAL PUBLIC LICENSE.
# Please read the LICENSE file in the project root for more details
# set -Eeuo pipefail
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd -P )";
source "$ROOT/app/load.sh";
unset -v ROOT;
# options
DESICCANT_SYNC="false";
DESICCANT_RENEW="false";
DESICCANT_INFOS="false";
DESICCANT_LOCAL_CRON="false";
if [[ -z ${1+x} ]]
then
usage $(basename "${BASH_SOURCE[0]}");
exit;
fi
for arg in "$@"
do
if [ $arg == "--help" ] || [ $arg == "-h" ]
then
usage $(basename "${BASH_SOURCE[0]}");
exit;
fi
done
for arg in "$@"
do
if [[ $arg =~ ^[\-]*renew$ ]]
then
readonly DESICCANT_RENEW="true";
fi
if [[ $arg =~ ^[\-]*sync$ ]]
then
readonly DESICCANT_SYNC="true";
fi
if [[ $arg =~ ^[\-]*cron$ ]]
then
readonly DESICCANT_LOCAL_CRON="true";
fi
if [[ $arg =~ ^[\-]*info[s]?$ ]]
then
readonly DESICCANT_INFOS="true";
fi
done
function next_main(){
set_run;
logger_init;
if config_is_valid
then
if is $DESICCANT_RENEW
then
renew_all;
fi
if is $DESICCANT_LOCAL_CRON
then
cron;
fi
if is $DESICCANT_SYNC
then
sync_all;
fi
if is $DESICCANT_INFOS
then
hosts_infos;
fi
fi
clean_run;
}
function main(){
set_run;
logger_init;
if is $DESICCANT_RENEW
then
renew_all;
fi
if is $DESICCANT_LOCAL_CRON
then
local_cron;
fi
if is $DESICCANT_SYNC
then
sync_all;
fi
if is $DESICCANT_INFOS
then
hosts_infos;
fi
logger_clean;
clean_run;
}
main;