Hub auto update cronjob (#1817)
Add hub cron installation to install scripts Plus remove on uninstall
This commit is contained in:
parent
ec0d2a5ed2
commit
0ecb6dcd4d
2
debian/postinst
vendored
2
debian/postinst
vendored
|
@ -82,6 +82,8 @@ if [ "$1" = configure ]; then
|
||||||
set -e
|
set -e
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
install_cronjob
|
||||||
|
|
||||||
if [[ -f /var/lib/crowdsec/data/crowdsec.db.backup ]]; then
|
if [[ -f /var/lib/crowdsec/data/crowdsec.db.backup ]]; then
|
||||||
cp /var/lib/crowdsec/data/crowdsec.db.backup /var/lib/crowdsec/data/crowdsec.db
|
cp /var/lib/crowdsec/data/crowdsec.db.backup /var/lib/crowdsec/data/crowdsec.db
|
||||||
rm -f /var/lib/crowdsec/data/crowdsec.db.backup
|
rm -f /var/lib/crowdsec/data/crowdsec.db.backup
|
||||||
|
|
3
debian/postrm
vendored
3
debian/postrm
vendored
|
@ -1,4 +1,7 @@
|
||||||
if [ "$1" = "purge" ]; then
|
if [ "$1" = "purge" ]; then
|
||||||
find /etc/crowdsec -maxdepth 1 -mindepth 1 | grep -v "bouncer" | xargs rm -rf || echo ""
|
find /etc/crowdsec -maxdepth 1 -mindepth 1 | grep -v "bouncer" | xargs rm -rf || echo ""
|
||||||
rm -rf /var/lib/crowdsec
|
rm -rf /var/lib/crowdsec
|
||||||
|
if [[ -d /etc/cron.daily/ ]] && [[ -f /etc/cron.daily/crowdsec-hub ]]; then
|
||||||
|
rm /etc/cron.daily/crowdsec-hub
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -175,6 +175,7 @@ if [ $1 == 1 ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cscli hub update
|
cscli hub update
|
||||||
|
install_cronjob
|
||||||
CSCLI_BIN_INSTALLED="/usr/bin/cscli" SILENT=true install_collection
|
CSCLI_BIN_INSTALLED="/usr/bin/cscli" SILENT=true install_collection
|
||||||
|
|
||||||
#upgrade
|
#upgrade
|
||||||
|
@ -227,6 +228,10 @@ if [ $1 == 0 ]; then
|
||||||
rm -rf /etc/crowdsec/hub
|
rm -rf /etc/crowdsec/hub
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -d /etc/cron.daily/ ]] && [[ -f /etc/cron.daily/crowdsec-hub ]]; then
|
||||||
|
rm /etc/cron.daily/crowdsec-hub
|
||||||
|
fi
|
||||||
|
|
||||||
#systemctl stop crowdsec || echo "crowdsec was not started"
|
#systemctl stop crowdsec || echo "crowdsec was not started"
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
|
22
wizard.sh
22
wizard.sh
|
@ -68,6 +68,7 @@ telnet
|
||||||
smb
|
smb
|
||||||
'
|
'
|
||||||
|
|
||||||
|
CRON_NAME=/etc/cron.daily/crowdsec-hub
|
||||||
|
|
||||||
HTTP_PLUGIN_BINARY="./plugins/notifications/http/notification-http"
|
HTTP_PLUGIN_BINARY="./plugins/notifications/http/notification-http"
|
||||||
SLACK_PLUGIN_BINARY="./plugins/notifications/slack/notification-slack"
|
SLACK_PLUGIN_BINARY="./plugins/notifications/slack/notification-slack"
|
||||||
|
@ -552,6 +553,22 @@ uninstall_crowdsec() {
|
||||||
log_info "crowdsec successfully uninstalled"
|
log_info "crowdsec successfully uninstalled"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
install_cronjob() {
|
||||||
|
log_info "Installing Hub Cronjob"
|
||||||
|
if [[ -d /etc/cron.daily/ ]] && [[ ! -f $CRON_NAME ]]; then
|
||||||
|
echo "/usr/bin/cscli hub update" >> $CRON_NAME
|
||||||
|
echo "/usr/bin/cscli hub upgrade" >> $CRON_NAME
|
||||||
|
chmod 755 $CRON_NAME
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
uninstall_cronjob() {
|
||||||
|
if [[ -d /etc/cron.daily/ ]] && [[ -f $CRON_NAME ]]; then
|
||||||
|
log_info "Uninstall Hub Cronjob"
|
||||||
|
rm $CRON_NAME
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function show_link {
|
function show_link {
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -618,6 +635,7 @@ main() {
|
||||||
${CSCLI_BIN_INSTALLED} hub update
|
${CSCLI_BIN_INSTALLED} hub update
|
||||||
install_collection
|
install_collection
|
||||||
genacquisition
|
genacquisition
|
||||||
|
install_cronjob
|
||||||
if ! skip_tmp_acquis; then
|
if ! skip_tmp_acquis; then
|
||||||
mv "${TMP_ACQUIS_FILE}" "${ACQUIS_TARGET}"
|
mv "${TMP_ACQUIS_FILE}" "${ACQUIS_TARGET}"
|
||||||
fi
|
fi
|
||||||
|
@ -638,6 +656,7 @@ main() {
|
||||||
fi
|
fi
|
||||||
check_running_bouncers
|
check_running_bouncers
|
||||||
uninstall_crowdsec
|
uninstall_crowdsec
|
||||||
|
uninstall_cronjob
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -692,7 +711,8 @@ main() {
|
||||||
mkdir -p "${PATTERNS_PATH}"
|
mkdir -p "${PATTERNS_PATH}"
|
||||||
cp "./${PATTERNS_FOLDER}/"* "${PATTERNS_PATH}/"
|
cp "./${PATTERNS_FOLDER}/"* "${PATTERNS_PATH}/"
|
||||||
|
|
||||||
|
# install hub cronjob
|
||||||
|
install_cronjob
|
||||||
# api register
|
# api register
|
||||||
${CSCLI_BIN_INSTALLED} machines add --force "$(cat /etc/machine-id)" -a -f "${CROWDSEC_CONFIG_PATH}/${CLIENT_SECRETS}" || log_fatal "unable to add machine to the local API"
|
${CSCLI_BIN_INSTALLED} machines add --force "$(cat /etc/machine-id)" -a -f "${CROWDSEC_CONFIG_PATH}/${CLIENT_SECRETS}" || log_fatal "unable to add machine to the local API"
|
||||||
log_dbg "Crowdsec LAPI registered"
|
log_dbg "Crowdsec LAPI registered"
|
||||||
|
|
Loading…
Reference in a new issue