Skip to content

Commit 5484cc2

Browse files
michacassolammetc
andauthored
Fix cp -n (#3483)
* Fix cp -n * Don't rely on cp for file existence check * Busybox cp can be used now * test -s -> test -f * test -f -> test -e --------- Co-authored-by: marco <[email protected]>
1 parent 31b9145 commit 5484cc2

File tree

3 files changed

+6
-29
lines changed

3 files changed

+6
-29
lines changed

Dockerfile

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,4 @@ ENTRYPOINT ["/bin/bash", "/docker_start.sh"]
4949

5050
FROM slim AS full
5151

52-
# Due to the wizard using cp -n, we have to copy the config files directly from the source as -n does not exist in busybox cp
53-
# The files are here for reference, as users will need to mount a new version to be actually able to use notifications
54-
COPY --from=build \
55-
/go/src/crowdsec/cmd/notification-email/email.yaml \
56-
/go/src/crowdsec/cmd/notification-http/http.yaml \
57-
/go/src/crowdsec/cmd/notification-slack/slack.yaml \
58-
/go/src/crowdsec/cmd/notification-splunk/splunk.yaml \
59-
/go/src/crowdsec/cmd/notification-sentinel/sentinel.yaml \
60-
/staging/etc/crowdsec/notifications/
61-
6252
COPY --from=build /usr/local/lib/crowdsec/plugins /usr/local/lib/crowdsec/plugins

Dockerfile.debian

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,6 @@ ENTRYPOINT ["/bin/bash", "docker_start.sh"]
6565

6666
FROM slim AS plugins
6767

68-
# Due to the wizard using cp -n, we have to copy the config files directly from the source as -n does not exist in busybox cp
69-
# The files are here for reference, as users will need to mount a new version to be actually able to use notifications
70-
COPY --from=build \
71-
/go/src/crowdsec/cmd/notification-email/email.yaml \
72-
/go/src/crowdsec/cmd/notification-http/http.yaml \
73-
/go/src/crowdsec/cmd/notification-slack/slack.yaml \
74-
/go/src/crowdsec/cmd/notification-splunk/splunk.yaml \
75-
/go/src/crowdsec/cmd/notification-sentinel/sentinel.yaml \
76-
/staging/etc/crowdsec/notifications/
77-
7868
COPY --from=build /usr/local/lib/crowdsec/plugins /usr/local/lib/crowdsec/plugins
7969

8070
FROM slim AS geoip

wizard.sh

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ delete_plugins() {
497497
rm -rf ${CROWDSEC_PLUGIN_DIR}
498498
}
499499

500-
install_plugins(){
500+
install_plugins() {
501501
mkdir -p ${CROWDSEC_PLUGIN_DIR}
502502
mkdir -p /etc/crowdsec/notifications
503503

@@ -508,14 +508,11 @@ install_plugins(){
508508
cp ${SENTINEL_PLUGIN_BINARY} ${CROWDSEC_PLUGIN_DIR}
509509
cp ${FILE_PLUGIN_BINARY} ${CROWDSEC_PLUGIN_DIR}
510510

511-
if [[ ${DOCKER_MODE} == "false" ]]; then
512-
cp -n ${SLACK_PLUGIN_CONFIG} /etc/crowdsec/notifications/
513-
cp -n ${SPLUNK_PLUGIN_CONFIG} /etc/crowdsec/notifications/
514-
cp -n ${HTTP_PLUGIN_CONFIG} /etc/crowdsec/notifications/
515-
cp -n ${EMAIL_PLUGIN_CONFIG} /etc/crowdsec/notifications/
516-
cp -n ${SENTINEL_PLUGIN_CONFIG} /etc/crowdsec/notifications/
517-
cp -n ${FILE_PLUGIN_CONFIG} /etc/crowdsec/notifications/
518-
fi
511+
for yaml_conf in ${SLACK_PLUGIN_CONFIG} ${SPLUNK_PLUGIN_CONFIG} ${HTTP_PLUGIN_CONFIG} ${EMAIL_PLUGIN_CONFIG} ${SENTINEL_PLUGIN_CONFIG} ${FILE_PLUGIN_CONFIG}; do
512+
if [[ ! -e /etc/crowdsec/notifications/"$(basename "$yaml_conf")" ]]; then
513+
cp "$yaml_conf" /etc/crowdsec/notifications/
514+
fi
515+
done
519516
}
520517

521518
check_running_bouncers() {

0 commit comments

Comments
 (0)