Signed-off-by: cuiyili 2268260388@qq.com --- container/conserver/conserver-head.cf | 16 +++++++++++ container/conserver/generate_conserver | 37 ++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 container/conserver/conserver-head.cf create mode 100755 container/conserver/generate_conserver
diff --git a/container/conserver/conserver-head.cf b/container/conserver/conserver-head.cf new file mode 100644 index 0000000..6648f88 --- /dev/null +++ b/container/conserver/conserver-head.cf @@ -0,0 +1,16 @@ +# This is a fairly basic configuration file that interacts with one + +default * { + logfile /srv/cci/serial/logs/&; # '&' is replaced with console name + timestamp 1hab; # write timestamps + rw *; # allow all users + type exec; + master localhost; + portbase 2000; # port numbers start at 2001 and + portinc 100; # go up by 1 (port #1 == 2001, etc) +} + +access * { + trusted 127.0.0.1; +} + diff --git a/container/conserver/generate_conserver b/container/conserver/generate_conserver new file mode 100755 index 0000000..0d01350 --- /dev/null +++ b/container/conserver/generate_conserver @@ -0,0 +1,37 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ + +git clone file:///$CCI_REPOS/lab-$lab.git > /dev/null 2>&1 || exit 1 + +cat conserver-head.cf > conserver.cf + +# lab-z9/hosts/xxx +# nr_node: x +# nr_cpu: xx +# memory: xx +# nr_hdd_partitions: x +# hdd_partitions: +# - xx +# rootfs_partition: +# - xx +# mac_addr: +# - xx:xx:xx:xx:xx:xx +# model_name: xx-xx +for host in $(ls lab-$lab/hosts/*) +do + ipmi_ip=$(grep -q "ipmi_ip:" $host | awk '{print $2}') + [[ "$ipmi_ip" =~ ^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ ]] || continue + + textbox=$host + [ -n "$textbox" ] || continue + + cat <<EOF >> conserver.cf +console $textbox { + exec /usr/local/bin/ipmi-sol $ipmi_ip; +} + +EOF + +done + +[ -d "$PWD/lab-$lab" ] && rm -rf "$PWD/lab-$lab"
On Wed, Oct 14, 2020 at 07:12:45PM +0800, Cui Yili wrote:
Signed-off-by: cuiyili 2268260388@qq.com
container/conserver/conserver-head.cf | 16 +++++++++++ container/conserver/generate_conserver | 37 ++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 container/conserver/conserver-head.cf create mode 100755 container/conserver/generate_conserver
diff --git a/container/conserver/conserver-head.cf b/container/conserver/conserver-head.cf new file mode 100644 index 0000000..6648f88 --- /dev/null +++ b/container/conserver/conserver-head.cf @@ -0,0 +1,16 @@ +# This is a fairly basic configuration file that interacts with one
+default * {
- logfile /srv/cci/serial/logs/&; # '&' is replaced with console name
- timestamp 1hab; # write timestamps
- rw *; # allow all users
- type exec;
- master localhost;
- portbase 2000; # port numbers start at 2001 and
- portinc 100; # go up by 1 (port #1 == 2001, etc)
+}
+access * {
- trusted 127.0.0.1;
+}
diff --git a/container/conserver/generate_conserver b/container/conserver/generate_conserver new file mode 100755 index 0000000..0d01350 --- /dev/null +++ b/container/conserver/generate_conserver @@ -0,0 +1,37 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+
+git clone file:///$CCI_REPOS/lab-$lab.git > /dev/null 2>&1 || exit 1
Better not quiet it? Let the user know what's going on.
file:/// is a strong assumption. If there is file:/// perhaps we may also assume there is lab-$lab in PWD or another global path.
+cat conserver-head.cf > conserver.cf
+# lab-z9/hosts/xxx +# nr_node: x +# nr_cpu: xx +# memory: xx +# nr_hdd_partitions: x +# hdd_partitions: +# - xx +# rootfs_partition: +# - xx +# mac_addr: +# - xx:xx:xx:xx:xx:xx +# model_name: xx-xx +for host in $(ls lab-$lab/hosts/*) +do
- ipmi_ip=$(grep -q "ipmi_ip:" $host | awk '{print $2}')
ruby can be more handy for yaml parsing.
- [[ "$ipmi_ip" =~ ^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ ]] || continue
- textbox=$host
textbox => testbox
or directly use $host?
- [ -n "$textbox" ] || continue
- cat <<EOF >> conserver.cf
+console $textbox {
- exec /usr/local/bin/ipmi-sol $ipmi_ip;
+}
+EOF
+done
+[ -d "$PWD/lab-$lab" ] && rm -rf "$PWD/lab-$lab"
-d can be removed. $PWD/ can be removed.
Thanks, Fengguang