-
Notifications
You must be signed in to change notification settings - Fork 0
/
sync-root.sh
112 lines (101 loc) · 3.69 KB
/
sync-root.sh
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
#!/bin/bash
##
## Utiliza o sync-it para sincronizar de acordo com as configurações no custom/custom-setup.sh
##
## TJSC / DTI / DAD
## Secao de Sistemas Operacionais
## Autor: Herbert Mattei de Borba <[email protected]>
##
MYDIR=`dirname $0`
. ${MYDIR}/common-setup.sh
function showusage {
echo "Modo de usar: ${MYNME} [-a] [-p] [-s] [-u] [-c] [-i] [-v]"
echo " -v: (opcional) verbose, mostra mais informacoes."
echo " -p: (opcional) profile, sincroniza \"/etc/profile.d/startup-sys-user.sh\"."
echo " -s: (opcional) sudoers, sincroniza \"/etc/sudoers.d/startup-sys-sudoers\"."
echo " -u: (opcional) arquivo sudoers, sincroniza \"/etc/sudoers\". CUIDADO! Um sudoers mal formatado pode deixar o sistema inacessivel."
echo " -c: (opcional) cron, sincroniza \"/etc/cron.d/startup-sys-crontab\"."
echo " -i: (opcional) iptables, sincroniza \"/etc/init.d/iptables\"."
echo " -a: (opcional) sincroniza todos, exceto \"/etc/suoders\" e \"/etc/init.d/iptables\" que demandam parametros explícitos."
exit ${ERROR}
}
#ARGV=${@}
#if [ "x$ARGV" = "x" ] ; then
# set_error $ERR_ARGUMENT_NOT_FOUND
# showusage
#fi
param_verbose=""
param_profile="nao"
param_sudoers="nao"
param_sudoersfile="nao"
param_cron="nao"
param_iptables="nao"
param_all="nao"
detected_parm="nao"
while getopts "vpsucia" option ; do
case "${option}" in
v)
param_verbose="-v"
;;
p)
param_profile="sim"
detected_parm="sim"
;;
s)
param_sudoers="sim"
detected_parm="sim"
;;
c)
param_cron="sim"
detected_parm="sim"
;;
i)
param_iptables="sim"
detected_parm="sim"
;;
u)
param_sudoersfile="sim"
detected_parm="sim"
;;
a)
param_all="sim"
detected_parm="sim"
;;
?)
set_error $ERR_INVALID_PARAMETER
showusage
;;
esac
done
if [[ ${detected_parm} == "sim" ]] ; then
if [[ ${param_all} == "sim" ]] || [[ ${param_profile} == "sim" ]] ; then
SYNC_SRC="/etc/profile.d/startup-sys-user.sh"
log_file="${LOG_PATH}/sync-root-${ROOT_SYNC_HOST}-${SYNC_SRC//\//^}-${DATAHORAHJPRECPREC}.log"
${MYDIR}/sync-it.sh -h ${ROOT_SYNC_HOST} -s ${SYNC_SRC} -u ${ROOT_SYNC_USR} -b ${ROOT_SYNC_BKP} -l ${log_file}
fi
if [[ ${param_all} == "sim" ]] || [[ ${param_sudoers} == "sim" ]] ; then
SYNC_SRC="/etc/sudoers.d/startup-sys-sudoers"
log_file="${LOG_PATH}/sync-root-${ROOT_SYNC_HOST}-${SYNC_SRC//\//^}-${DATAHORAHJPRECPREC}.log"
${MYDIR}/sync-it.sh -h ${ROOT_SYNC_HOST} -s ${SYNC_SRC} -u ${ROOT_SYNC_USR} -b ${ROOT_SYNC_BKP} -l ${log_file}
fi
if [[ ${param_sudoersfile} == "sim" ]] ; then
SYNC_SRC="/etc/sudoers"
log_file="${LOG_PATH}/sync-root-${ROOT_SYNC_HOST}-${SYNC_SRC//\//^}-${DATAHORAHJPRECPREC}.log"
${MYDIR}/sync-it.sh -h ${ROOT_SYNC_HOST} -s ${SYNC_SRC} -u ${ROOT_SYNC_USR} -b ${ROOT_SYNC_BKP} -l ${log_file}
fi
if [[ ${param_iptables} == "sim" ]] ; then
SYNC_SRC="/etc/init.d/iptables"
log_file="${LOG_PATH}/sync-root-${ROOT_SYNC_HOST}-${SYNC_SRC//\//^}-${DATAHORAHJPRECPREC}.log"
${MYDIR}/sync-it.sh -h ${ROOT_SYNC_HOST} -s ${SYNC_SRC} -u ${ROOT_SYNC_USR} -b ${ROOT_SYNC_BKP} -l ${log_file}
fi
if [[ ${param_all} == "sim" ]] || [[ ${param_cron} == "sim" ]] ; then
SYNC_SRC="/etc/cron.d/startup-sys-crontab"
log_file="${LOG_PATH}/sync-root-${ROOT_SYNC_HOST}-${SYNC_SRC//\//^}-${DATAHORAHJPRECPREC}.log"
${MYDIR}/sync-it.sh -h ${ROOT_SYNC_HOST} -s ${SYNC_SRC} -u ${ROOT_SYNC_USR} -b ${ROOT_SYNC_BKP} -l ${log_file}
fi
else
do_log "Parametro de sincronizacao nao detectado."
do_log "Utilize ao menos um parametro documentado."
showusage
fi
exit $(get_error)