summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2017-09-17 21:45:24 +1200
committerDavid Phillips <david@sighup.nz>2017-09-17 21:45:24 +1200
commitcb887a3bb28d483a145e4e77642b4b497a208772 (patch)
treecd000736550f3128712de5ee1dd7a1a894982a5e
parentf486bb096e6a405822d4a02718012fb395270d13 (diff)
downloadinitscripts-cb887a3bb28d483a145e4e77642b4b497a208772.tar.xz
Add script to macro-ify hardcoded values/paths
-rwxr-xr-xreplace.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/replace.sh b/replace.sh
new file mode 100755
index 0000000..5bde2bd
--- /dev/null
+++ b/replace.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+if [ -z $1 ] ; then
+ echo missing argument: file to read
+ exit 1
+fi
+
+file="$1"
+
+sedargs=""
+for var in \
+ BINDIR \
+ OPENRC_RUN \
+ ; do
+ sedargs="${sedargs} -e s:\@${var}\@:${!var}:g "
+done
+
+cat "$file" | sed ${sedargs}