aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2017-10-13 13:44:11 +0200
committerKarel Kočí <cynerd@email.cz>2017-10-13 13:44:11 +0200
commitc5f307a330c141c955d4bc99f4675d816b28e223 (patch)
tree35f76c615cdd9c1349e52e198dd330edd4051298
parent496fad1b1059118900d8450ce400330c65116497 (diff)
downloadmulticonfig-c5f307a330c141c955d4bc99f4675d816b28e223.tar.gz
multiconfig-c5f307a330c141c955d4bc99f4675d816b28e223.tar.bz2
multiconfig-c5f307a330c141c955d4bc99f4675d816b28e223.zip
Some update
-rw-r--r--README4
-rwxr-xr-xfirewall/multiconfig.sh14
-rwxr-xr-xmulticonfig.sh33
-rw-r--r--utils29
4 files changed, 59 insertions, 21 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..e5946fb
--- /dev/null
+++ b/README
@@ -0,0 +1,4 @@
+Distributed configuration tool
+==============================
+This is tool for distributed configuration. It provides the way to distribute
+configuration trough git to every host.
diff --git a/firewall/multiconfig.sh b/firewall/multiconfig.sh
index 1c9b6ff..0befbf1 100755
--- a/firewall/multiconfig.sh
+++ b/firewall/multiconfig.sh
@@ -1,10 +1,20 @@
#!/bin/sh
set -e
+LPATH="$(dirname "$0")"
+if [ -f "$LPATH/utils" ]; then
+ . "$LPATH/utils"
+elif [ -f "$LPATH/../utils" ]; then
+ . "$LPATH/../utils"
+else
+ echo "Can't locate utilities!"
+ exit 1
+fi
+######################################
-mkdir /etc/iptables
+mkdir -p /etc/iptables
configure() {
- if ! grep -q "$3_SAVE=\"/etc/iptables/$1\""; then
+ if ! grep -q "$3_SAVE=\"/etc/iptables/$1\"" "/etc/conf.d/$2"; then
echo "Reconfiguring $2 service configuration"
sed -i "s#^$3_SAVE=.*\$#$3_SAVE=\"/etc/iptables/$1\"#" "/etc/conf.d/$2"
fi
diff --git a/multiconfig.sh b/multiconfig.sh
index e85f0c0..500d0de 100755
--- a/multiconfig.sh
+++ b/multiconfig.sh
@@ -1,5 +1,6 @@
#!/bin/sh
set -e
+MODDIR="/usr/lib/multiconfig"
MODS=""
LOCAL=false
@@ -21,7 +22,14 @@ while [ $# -gt 0 ]; do
LOCAL=true
;;
*)
- MODS="$MODS $1"
+ if [ -x "$1" ]; then
+ MODS="$MODS $(pwd)/$1"
+ elif [ -x "$MODDIR/$1" ]; then
+ MODS="$MODS $MODDIR/$1"
+ else
+ echo "Requested unknown mod: $1"
+ exit 1
+ fi
;;
esac
shift
@@ -38,6 +46,8 @@ if ! $LOCAL; then
exit 1
fi
cd "/root/.multiconfig"
+ # Ensure that we have correct access rights on private key
+ chmod 600 ssh_key
# Update git repository
git fetch
git reset --hard origin/master
@@ -47,30 +57,15 @@ if ! $LOCAL; then
#git verify-commit HEAD
fi
-MODDIR="/usr/lib/multiconfig"
# No modules given means to process all modules
if [ -z "$MODS" ]; then
for M in $(find "$MODDIR" -executable); do
- MODS="$MODS $M"
+ MODS="$MODS $MODDIR/$M"
done
-else
- # Go trough all given modules and check if we have such module
- NMODS=""
- for M in $MODS; do
- if [ ! -x "$M" ]; then # Is not path directly to script
- if [ ! -x "$MODDIR/$M" ]; then
- echo "No such mode: $M"
- exit 1
- else
- NMODS="$NMODS $MODDIR/$M"
- fi
- else
- NMODS="$NMODS $M"
- fi
- done
- MODS="$NMODS"
fi
+[ -n "$MODS" ] || exit 0
+
mkdir -p /var/log/multiconfig
for M in $MODS; do
LOG="/var/log/multiconfig/$(basename "$M")"
diff --git a/utils b/utils
new file mode 100644
index 0000000..0b94707
--- /dev/null
+++ b/utils
@@ -0,0 +1,29 @@
+# vim: ft=sh
+
+die() {
+ kill $$
+}
+
+inst_f() {
+ if [ -f "$2" ]; then
+ else
+ mkdir "$(basedir "$2")"
+ echo "New file: $1 -> $2"
+ fi
+}
+
+inst_d() {
+ # TODO
+ true
+}
+
+inst() {
+ if [ -f "$1" ]; then
+ inst_f "$1" "$2"
+ elif [ -d "$1" ]; then
+ inst_d "$1" "$2"
+ else
+ echo "Unsupported install target type of: $1"
+ die
+ fi
+}