From ba316685f6e6aa8c0193991922c0e33cdf5bbc6c Mon Sep 17 00:00:00 2001 From: Julien Kassar Date: Sat, 12 Mar 2016 14:25:09 -0500 Subject: [PATCH] Add install script --- README.md | 19 +++++++++++-- csfpost.sh => docker.sh | 5 ++-- install.sh | 60 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 5 deletions(-) rename csfpost.sh => docker.sh (97%) create mode 100755 install.sh diff --git a/README.md b/README.md index 916d466..13d36d4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,20 @@ # ConfigServer Security & Firewall (CSF) - Docker -Install: +## Installation +### Requirement +Make sure to use the scripts from `https://github.com/juliengk/csf-pre_post_sh` -cp csfpost.sh /usr/local/csf/bin/csfpost.sh +### Install +Installation is quite straightforward: + +``` +# cd /usr/local/src +# git clone https://github.com/juliengk/csf-post-docker.git +# cd csf-post-docker +# sh install.sh +``` + +## User Feedback +### Issues + +If you have any problems with or questions about this image, please contact us through a [GitHub](https://github.com/juliengk/csf-post-docker/issues) issue. diff --git a/csfpost.sh b/docker.sh similarity index 97% rename from csfpost.sh rename to docker.sh index c7640c2..a178677 100644 --- a/csfpost.sh +++ b/docker.sh @@ -1,8 +1,7 @@ #!/bin/bash -chain_exists() -{ - [ $# -lt 1 -o $# -gt 2 ] && { +chain_exists() { + [ $# -lt 1 -o $# -gt 2 ] && { echo "Usage: chain_exists [table]" >&2 return 1 } diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..d8ae1c7 --- /dev/null +++ b/install.sh @@ -0,0 +1,60 @@ +#!/bin/sh + +SCRIPT_NAME="docker.sh" + +CSF_CUSTOM_PATH="/usr/local/include/csf" +CSFPOSTD_PATH="${CSF_CUSTOM_PATH}/post.d" + + +if [ ! -d ${CSF_CUSTOM_PATH} ]; then + echo "** CSF-PRE_POST_SH is not installed **" + echo "Get it from https://github.com/juliengk/csf-pre_post_sh" + + exit 1 +fi + +PREFIX="None" +if [ "$1" == "-p" ] || [ "$1" == "--prefix" ]; then + PREFIX=$2 + + shift 2 +fi + +SCRIPT_NAME_FINAL="${SCRIPT_NAME}" +if [ ${PREFIX} != "None" ]; then + SCRIPT_NAME_FINAL="${PREFIX}_${SCRIPT_NAME}" +fi + +if [ -f ${CSFPOSTD_PATH}/${SCRIPT_NAME_FINAL} ]; then + md5_0=`md5sum docker.sh | awk '{ print $1 }'` + md5_1=`md5sum ${CSFPOSTD_PATH}/${SCRIPT_NAME_FINAL} | awk '{ print $1 }'` + + if [ ${md5_0} == ${md5_1} ]; then + exit 0 + else + ok=0 + while [ ${ok} -eq 0 ]; do + clear + + echo "** Warning! **" + echo "A different version of the script is already present" + echo "Do you want to replace it (y/n)?" + + read answer + + if [ ${answer} == "y" -o ${answer} == "n" ]; then + ok=1 + fi + done + + if [ ${answer} == "n" ]; then + exit 1 + fi + fi +fi + +cp -f ${SCRIPT_NAME} ${CSFPOSTD_PATH}/${SCRIPT_NAME_FINAL} +chown root:root ${CSFPOSTD_PATH}/${SCRIPT_NAME_FINAL} +chmod 700 ${CSFPOSTD_PATH}/${SCRIPT_NAME_FINAL} + +exit 0