diff options
author | Karel Kočí <cynerd@email.cz> | 2017-09-20 22:05:39 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2017-09-20 22:14:29 +0200 |
commit | 0a4fccef3c0d934cc820e2720c46297414f057f8 (patch) | |
tree | 99d0d0ebf99d1f844c761bafe5fcf996fe77e1d0 | |
download | multiconfig-f3457f88ee0fd145f87b245d96e17d31050758aa.tar.gz multiconfig-f3457f88ee0fd145f87b245d96e17d31050758aa.tar.bz2 multiconfig-f3457f88ee0fd145f87b245d96e17d31050758aa.zip |
Initial commitv0.1
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | bridge/dhcpd.conf | 13 | ||||
-rw-r--r-- | bridge/init/bridge | 22 | ||||
-rw-r--r-- | bridge/init/bridge-dhcp | 13 | ||||
-rw-r--r-- | bridge/sysctl.conf | 3 | ||||
-rwxr-xr-x | multiconfig.sh | 73 |
6 files changed, 128 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..e5946fb --- /dev/null +++ b/README.md @@ -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/bridge/dhcpd.conf b/bridge/dhcpd.conf new file mode 100644 index 0000000..7aa8ab2 --- /dev/null +++ b/bridge/dhcpd.conf @@ -0,0 +1,13 @@ +authoritative; + +default-lease-time 600; +max-lease-time 7200; + +subnet 192.168.30.0 netmask 255.255.255.0 { + range 192.168.30.10 192.168.30.250; + option routers 192.168.30.1; + option subnet-mask 255.255.255.0; + option broadcast-address 192.168.30.255; +} + +option domain-name-servers 217.31.204.130, 193.29.206.206; diff --git a/bridge/init/bridge b/bridge/init/bridge new file mode 100644 index 0000000..9cae7e4 --- /dev/null +++ b/bridge/init/bridge @@ -0,0 +1,22 @@ +#!/sbin/openrc-run +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +start() { + # Add bridge interface + if ! ip link list bridge 2>/dev/null >&2; then + ip link add name bridge type bridge + fi + # Set bridge up + ip link set bridge up + # Set ip address + if [ -z "$(ip addr show dev bridge to 192.168.30.1)" ]; then + ip addr add 192.168.30.1/24 dev vbr0 + fi +} + +stop() { + if ip link list bridge 2>/dev/null >&2; then + ip link del dev bridge + fi +} diff --git a/bridge/init/bridge-dhcp b/bridge/init/bridge-dhcp new file mode 100644 index 0000000..6bbb43f --- /dev/null +++ b/bridge/init/bridge-dhcp @@ -0,0 +1,13 @@ +#!/sbin/openrc-run +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +description="Bridge dhcp daemon" +command="/usr/sbin/dhcpd" +pidfile="/run/syncthing.pid" +command_args="-4 -pf $pidfile -cf /etc/dhcp/bridge_dhcpd.conf bridge" + +depend() { + need bridge + use logger +} diff --git a/bridge/sysctl.conf b/bridge/sysctl.conf new file mode 100644 index 0000000..9ad9779 --- /dev/null +++ b/bridge/sysctl.conf @@ -0,0 +1,3 @@ +# vim: ft=sysctl +# Enable ipv4 forwarding +net.ipv4.ip_forward=1 diff --git a/multiconfig.sh b/multiconfig.sh new file mode 100755 index 0000000..1519e48 --- /dev/null +++ b/multiconfig.sh @@ -0,0 +1,73 @@ +#!/bin/sh +set -e + +ARGS="" +LOCAL=false +SYSLOG=false + +# TODO email notifications + +while [ $# -gt 0 ]; do + case "$1" in + -h|--help) + echo "Multiconfig system call script" + echo "Usage: multiconfig.sh [OPTION]..." + echo + echo "Options:" + echo "--local - Use current working directory as multiconfig source." + echo "--syslog - pipe output to syslog" + echo "Passed options:" + echo "--verbose - Make output more verbose" + echo "--quiet - Make output more quiet" + echo "--operation OPT - run only given operation" + exit 0 + ;; + --verbose|-v|--quiet|-q) + ARGS="$ARGS $1" + ;; + --operation|-o) + ARGS="$ARGS $1 $2" + shift + ;; + --local) + LOCAL=true + ;; + --syslog) + SYSLOG=true + ;; + esac + shift +done + +[ "$(id -u)" == 0 ] || { + echo "Please run this script only as root." + exit 1 +} + +PREFIX="/root/.multiconfig" + +# Check if we have key +if [ ! -f "$PREFIX/key" ]; then + echo "Key is not in expected path. Please setup this host for multiconfig." + exit 1 +fi + +# TODO check key access rights + +if ! $LOCAL; then + if [ -d "$PREFIX/repo" ]; then + true + # TODO git clone + fi + cd "$PREFIX/repo" + # Pull git repository + git fetch + git reset --hard origin/master + git clean -xdf +fi + +# TODO check repository signature + +CMD="./run.sh --key $PREFIX/key $ARGS" +# Run command +$CMD |