mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-10 20:05:55 +02:00
add two options: configure and noop (#591)
This commit is contained in:
parent
0530aa6886
commit
862105669f
1 changed files with 35 additions and 3 deletions
38
wizard.sh
38
wizard.sh
|
@ -30,7 +30,12 @@ LAPI_SECRETS="online_api_credentials.yaml"
|
||||||
|
|
||||||
BIN_INSTALL_PATH="/usr/local/bin"
|
BIN_INSTALL_PATH="/usr/local/bin"
|
||||||
CROWDSEC_BIN_INSTALLED="${BIN_INSTALL_PATH}/crowdsec"
|
CROWDSEC_BIN_INSTALLED="${BIN_INSTALL_PATH}/crowdsec"
|
||||||
CSCLI_BIN_INSTALLED="${BIN_INSTALL_PATH}/cscli"
|
|
||||||
|
if [[ -f "/usr/bin/cscli" ]] ; then
|
||||||
|
CSCLI_BIN_INSTALLED="/usr/bin/cscli"
|
||||||
|
else
|
||||||
|
CSCLI_BIN_INSTALLED="${BIN_INSTALL_PATH}/cscli"
|
||||||
|
fi
|
||||||
|
|
||||||
ACQUIS_PATH="${CROWDSEC_CONFIG_PATH}"
|
ACQUIS_PATH="${CROWDSEC_CONFIG_PATH}"
|
||||||
TMP_ACQUIS_FILE="tmp-acquis.yaml"
|
TMP_ACQUIS_FILE="tmp-acquis.yaml"
|
||||||
|
@ -97,12 +102,10 @@ detect_services () {
|
||||||
for SRC in "${SYSTEMD_SERVICES}" "${PSAX}" ; do
|
for SRC in "${SYSTEMD_SERVICES}" "${PSAX}" ; do
|
||||||
echo ${SRC} | grep ${SVC} >/dev/null
|
echo ${SRC} | grep ${SVC} >/dev/null
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
|
|
||||||
#on centos, apache2 is named httpd
|
#on centos, apache2 is named httpd
|
||||||
if [[ ${SVC} == "httpd" ]] ; then
|
if [[ ${SVC} == "httpd" ]] ; then
|
||||||
SVC="apache2";
|
SVC="apache2";
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DETECTED_SERVICES+=(${SVC})
|
DETECTED_SERVICES+=(${SVC})
|
||||||
HMENU+=(${SVC} "on")
|
HMENU+=(${SVC} "on")
|
||||||
log_info "Found '${SVC}' running"
|
log_info "Found '${SVC}' running"
|
||||||
|
@ -525,6 +528,26 @@ main() {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "$1" == "configure" ]];
|
||||||
|
then
|
||||||
|
if ! [ $(id -u) = 0 ]; then
|
||||||
|
log_err "Please run the wizard as root or with sudo"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
detect_services
|
||||||
|
${CSCLI_BIN_INSTALLED} hub update
|
||||||
|
install_collection
|
||||||
|
genacquisition
|
||||||
|
mv "${TMP_ACQUIS_FILE}" "${ACQUIS_TARGET}"
|
||||||
|
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$1" == "noop" ]];
|
||||||
|
then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$1" == "uninstall" ]];
|
if [[ "$1" == "uninstall" ]];
|
||||||
then
|
then
|
||||||
if ! [ $(id -u) = 0 ]; then
|
if ! [ $(id -u) = 0 ]; then
|
||||||
|
@ -630,6 +653,7 @@ usage() {
|
||||||
echo " ./wizard.sh --docker-mode Will install crowdsec without systemd and generate random machine-id"
|
echo " ./wizard.sh --docker-mode Will install crowdsec without systemd and generate random machine-id"
|
||||||
echo " ./wizard.sh -r|--restore Restore saved configurations from ${BACKUP_DIR} to ${CROWDSEC_CONFIG_PATH}"
|
echo " ./wizard.sh -r|--restore Restore saved configurations from ${BACKUP_DIR} to ${CROWDSEC_CONFIG_PATH}"
|
||||||
echo " ./wizard.sh -b|--backup Backup existing configurations to ${BACKUP_DIR}"
|
echo " ./wizard.sh -b|--backup Backup existing configurations to ${BACKUP_DIR}"
|
||||||
|
echo " ./wizard.sh -n|--noop Do nothing"
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
@ -675,10 +699,18 @@ do
|
||||||
ACTION="restore_from_dir"
|
ACTION="restore_from_dir"
|
||||||
shift # past argument
|
shift # past argument
|
||||||
;;
|
;;
|
||||||
|
-c|--configure)
|
||||||
|
ACTION="configure"
|
||||||
|
shift # past argument
|
||||||
|
;;
|
||||||
-d|--detect)
|
-d|--detect)
|
||||||
ACTION="detect"
|
ACTION="detect"
|
||||||
shift # past argument
|
shift # past argument
|
||||||
;;
|
;;
|
||||||
|
-n|--noop)
|
||||||
|
ACTION="noop"
|
||||||
|
shift # past argument
|
||||||
|
;;
|
||||||
--unattended)
|
--unattended)
|
||||||
SILENT="true"
|
SILENT="true"
|
||||||
ACTION="install"
|
ACTION="install"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue