Skip to content

Commit

Permalink
Add install script
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Kassar committed Mar 12, 2016
1 parent 3848c1e commit ba31668
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 5 deletions.
19 changes: 17 additions & 2 deletions 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.
5 changes: 2 additions & 3 deletions csfpost.sh → 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 <chain_name> [table]" >&2
return 1
}
Expand Down
60 changes: 60 additions & 0 deletions 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

0 comments on commit ba31668

Please sign in to comment.