This commit is contained in:
AlteredCoder 2020-06-28 16:39:48 +02:00
parent 77af2afb83
commit 1c8f22e866
3 changed files with 38 additions and 4 deletions

View file

@ -53,3 +53,5 @@ overrides:
deb:
scripts:
postinstall: ./scripts/post_install_deb.sh
preremove: ./scripts/pre_remove_deb.sh

View file

@ -1,6 +1,8 @@
CSCLI_BIN_INSTALLED="/usr/local/bin/cscli"
systemctl daemon-reload
cscli update
/usr/local/bin/cswizard -i
cscli install collection crowdsecurity/linux
cscli install scenario crowdsecurity/ssh-bf
${CSCLI_BIN_INSTALLED} update
${CSCLI_BIN_INSTALLED} install collection crowdsecurity/linux
${CSCLI_BIN_INSTALLED} install scenario crowdsecurity/ssh-bf
${CSCLI_BIN_INSTALLED} api register >> /etc/crowdsec/config/api.yaml || ${CSCLI_BIN_INSTALLED} api reset >> /etc/crowdsec/config/api.yaml || log_err "unable to register, skipping crowdsec api registration"
systemctl start crowdsec

View file

@ -357,6 +357,25 @@ setup_cron_pull() {
cp ./config/crowdsec_pull /etc/cron.d/
}
configure() {
${CSCLI_BIN_INSTALLED} update > /dev/null 2>&1 || (log_err "fail to update crowdsec hub. exiting" && exit 1)
# detect running services
detect_services
if ! [ ${#DETECTED_SERVICES[@]} -gt 0 ] ; then
log_err "No detected or selected services, stopping."
exit 1
fi;
# Generate acquisition file and move it to the right folder
genacquisition
mv "${TMP_ACQUIS_FILE}" "${ACQUIS_TARGET}"
# Install collections according to detected services
log_info "Installing needed collections ..."
install_collection
}
main() {
@ -376,6 +395,12 @@ main() {
return
fi
if [[ "$1" == "configure" ]];
then
configure
return
fi
if [[ "$1" == "binupgrade" ]];
then
if ! [ $(id -u) = 0 ]; then
@ -493,6 +518,7 @@ usage() {
echo " ./wizard.sh -d|--detect Detect running services and associated logs file"
echo " ./wizard.sh -i|--install Assisted installation of crowdsec/cscli and collections"
echo " ./wizard.sh --bininstall Install binaries and empty config, no wizard."
echo " ./wizard.sh --configure Configure an already installed crowdsec"
echo " ./wizard.sh --uninstall Uninstall crowdsec/cscli"
echo " ./wizard.sh --binupgrade Upgrade crowdsec/cscli binaries"
echo " ./wizard.sh --upgrade Perform a full upgrade and try to migrate configs"
@ -519,6 +545,10 @@ do
ACTION="binupgrade"
shift #past argument
;;
--configure)
ACTION="configure"
shift #past argument
;;
--upgrade)
ACTION="upgrade"
shift #past argument