summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCtibor <ctibor@brancik.cz>2017-03-15 19:49:12 +0100
committerCtibor <ctibor@brancik.cz>2017-03-15 19:49:12 +0100
commit2092ed7bdbe4ca73fb59c8f1175d6a609d871ebc (patch)
tree487db7eb62aab67fdff3b6dc05c0867e6ddec2cb
parent37294d931231fda772bf1f6b5d3e159404a9dadb (diff)
downloadrpi-config-2092ed7bdbe4ca73fb59c8f1175d6a609d871ebc.tar.gz
rpi-config-2092ed7bdbe4ca73fb59c8f1175d6a609d871ebc.tar.bz2
Initial commit for sync-rpi-config tool
-rw-r--r--.gitignore2
-rw-r--r--tools/.sync-rpi.conf.kate-swpbin0 -> 517 bytes
-rw-r--r--tools/config.py3
-rw-r--r--tools/config.pycbin0 -> 210 bytes
-rw-r--r--tools/sync-rpi-config.py76
-rw-r--r--tools/sync-rpi.conf19
6 files changed, 100 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5357942
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+.git
+*.swp
diff --git a/tools/.sync-rpi.conf.kate-swp b/tools/.sync-rpi.conf.kate-swp
new file mode 100644
index 0000000..373ddea
--- /dev/null
+++ b/tools/.sync-rpi.conf.kate-swp
Binary files differ
diff --git a/tools/config.py b/tools/config.py
new file mode 100644
index 0000000..61dacd8
--- /dev/null
+++ b/tools/config.py
@@ -0,0 +1,3 @@
+configfile = ''
+device = ''
+action = ''
diff --git a/tools/config.pyc b/tools/config.pyc
new file mode 100644
index 0000000..270f526
--- /dev/null
+++ b/tools/config.pyc
Binary files differ
diff --git a/tools/sync-rpi-config.py b/tools/sync-rpi-config.py
new file mode 100644
index 0000000..9496c70
--- /dev/null
+++ b/tools/sync-rpi-config.py
@@ -0,0 +1,76 @@
+import ConfigParser, os, getopt, sys, config
+
+ini = ConfigParser.ConfigParser()
+
+# Parse parameters
+def get_opts(argv):
+ try:
+ opts, args = getopt.getopt(argv,"ha:c:d:l",["conf=","action=","device=","list-devices"])
+ except getopt.GetoptError:
+ print 'sync-rpi-config: -a <push/pull> -c <conf file> -d <device>'
+ sys.exit(2)
+ for opt, arg in opts:
+ if opt == '-h':
+ return usage()
+ sys.exit()
+ elif opt in ("-l", "--list-devices"):
+ print "You have configured these devices: " + list_devices()
+ sys.exit()
+ elif opt in ("-a", "--action"):
+ config.action = arg
+ elif opt in ("-c", "--conf"):
+ config.configfile = arg
+ elif opt in ("-d", "--device"):
+ config.device = arg
+
+# Check parameters for errors
+def check_opts():
+ if not config.action:
+ print "Error: No action has been specified."
+ return usage()
+ sys.exit(2)
+ if not config.action == "pull" or config.action == "push":
+ print "Error: Action \"" + config.action + "\" is invalid."
+ return usage()
+ sys.exit(2)
+ if not config.device:
+ print "Error: No device has been specified."
+ return usage()
+ sys.exit(2)
+ if config.device:
+ load_config(config.configfile)
+ if not ini.has_section(config.device):
+ print "Error: Device \"" + config.device + "\" not configured. Add it to\"" + config.configfile + "."
+ sys.exit(2)
+
+# Load provided config file or use default
+def load_config(configfile):
+ if not configfile:
+ config.configfile = "/etc/sync-rpi.conf"
+ try:
+ ini.read([config.configfile])
+ except:
+ sys.exit(2)
+
+# Check if configuration file is sane
+def check_config(configfile):
+ options_config = ['repo', 'repo_path', 'rpi1', 'rpi2', 'rpi3' ]
+ options_device = ['type']
+ load_config(config.configfile)
+ for option in options_config:
+ if not ini.has_option('config', option):
+ print "Option " + option + " not set in config"
+ break
+
+# List all devices defined in config.configfile
+def list_devices():
+ load_config(config.configfile)
+ return " ".join(ini.sections()[1:])
+
+def usage():
+ print """Usage: sync-rpi-config -a ACTION -d DEVICE [ -c [FILE] ] [ -l ]
+ Options
+ -a, --action ACTION can be either pull or push. You are pushing config from you workstation to device or pulling it back.
+ -d, --device DEVICE is set in configuration file. It is the machine you wish to push config to or pull from.
+ -c, --conf Path to configuration file.
+ -l, --list-devices List all devices defined in current configuration file."""
diff --git a/tools/sync-rpi.conf b/tools/sync-rpi.conf
new file mode 100644
index 0000000..b9651c1
--- /dev/null
+++ b/tools/sync-rpi.conf
@@ -0,0 +1,19 @@
+[config]
+## Define directories, where you store crosscompiled environment
+rpi1_path=/usr/armv6j-hardlofat-linux-gnueabi
+rpi2_path=/usr/armv7a-hardfloat-linux-gnueabi
+rpi3_path=/usr/aarch64-uknown-linux-gnu
+
+## Full URI to the git repository holding configuration files
+repo=ssh://git@git.brancik.cz/rpi-config.git
+
+## path to directory in repository where configuration files are stored
+repo_path=conf
+
+## Define values for devices
+## Name the section after the device
+[alcor-01]
+## Define the type of RPi being used
+type = rpi1
+[alcor-02]
+[mizar]