aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiam McLoughlin <hexxeh@hexxeh.net>2011-06-15 21:55:09 +0100
committerLiam McLoughlin <hexxeh@hexxeh.net>2011-06-15 21:55:09 +0100
commit38af0b233d9cb1a28df25a44838b4181ff3d2a18 (patch)
treee42b47de0b9e95fb3558bbcc9bd63d511eb00274 /parse_config.sh
parentConditionals for download and updated kernel config (diff)
downloadgentoaster-38af0b233d9cb1a28df25a44838b4181ff3d2a18.tar.gz
gentoaster-38af0b233d9cb1a28df25a44838b4181ff3d2a18.tar.bz2
gentoaster-38af0b233d9cb1a28df25a44838b4181ff3d2a18.zip
Added configuration loading support, fixed up the kernel config for framebuffer and EXT2 support (framebuffer/fluxbox not fully tested yet though!)
Diffstat (limited to 'parse_config.sh')
-rwxr-xr-xparse_config.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/parse_config.sh b/parse_config.sh
new file mode 100755
index 0000000..24aba14
--- /dev/null
+++ b/parse_config.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+# Bash INI file parser
+# Credit to ajdiaz
+# http://ajdiaz.wordpress.com/2008/02/09/bash-ini-parser/
+cfg_parser ()
+{
+ ini="$(<$1)" # read the file
+ ini="${ini//[/\[}" # escape [
+ ini="${ini//]/\]}" # escape ]
+ IFS=$'\n' && ini=( ${ini} ) # convert to line-array
+ ini=( ${ini[*]//;*/} ) # remove comments with ;
+ ini=( ${ini[*]/\ =/=} ) # remove tabs before =
+ ini=( ${ini[*]/=\ /=} ) # remove tabs be =
+ ini=( ${ini[*]/\ =\ /=} ) # remove anything with a space around =
+ ini=( ${ini[*]/#\\[/\}$'\n'cfg.section.} ) # set section prefix
+ ini=( ${ini[*]/%\\]/ \(} ) # convert text2function (1)
+ ini=( ${ini[*]/=/=\( } ) # convert item to array
+ ini=( ${ini[*]/%/ \)} ) # close array parenthesis
+ ini=( ${ini[*]/%\\ \)/ \\} ) # the multiline trick
+ ini=( ${ini[*]/%\( \)/\(\) \{} ) # convert text2function (2)
+ ini=( ${ini[*]/%\} \)/\}} ) # remove extra parenthesis
+ ini[0]="" # remove first element
+ ini[${#ini[*]} + 1]='}' # add the last brace
+ eval "$(echo "${ini[*]}")" # eval the result
+}
+
+
+cfg_parser $1
+cfg.section.vmconfig