Merge pull request #882 from GNS3/feature/openvswitch-bash-completion

Open VSwitch appliance bash completion
This commit is contained in:
Jeremy Grossmann 2024-05-09 20:44:38 +07:00 committed by GitHub
commit eb92099082
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 10 deletions

View File

@ -1,6 +1,19 @@
FROM alpine:latest FROM alpine:latest
RUN apk add --update openvswitch nano && rm -rf /var/cache/apk/* RUN apk add --no-cache openvswitch nano bash bash-completion
# Make bash the default shell
RUN sed -i s,/bin/ash,/bin/bash, /etc/passwd
# Enable bash completion
RUN echo -e "source /etc/profile.d/bash_completion.sh" >> ~/.bashrc
# Enable openvswitch bash completion
RUN echo -e "source /usr/share/bash-completion/completions/ovs-vsctl-bashcomp.bash" >> ~/.bashrc
RUN echo -e "source /usr/share/bash-completion/completions/ovs-appctl-bashcomp.bash" >> ~/.bashrc
# Configure the prompt
RUN echo -e "PS1='\h:\w\$ '" >> ~/.bashrc
RUN mkdir /var/run/openvswitch RUN mkdir /var/run/openvswitch
@ -8,4 +21,4 @@ VOLUME /etc/openvswitch/
ADD boot.sh /bin/boot.sh ADD boot.sh /bin/boot.sh
CMD /bin/sh /bin/boot.sh CMD /bin/bash /bin/boot.sh

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/bash
# #
# Copyright (C) 2015 GNS3 Technologies Inc. # Copyright (C) 2024 GNS3 Technologies Inc.
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -16,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
if [ ! -f "/etc/openvswitch/conf.db" ] if [[ ! -f "/etc/openvswitch/conf.db" ]]
then then
ovsdb-tool create /etc/openvswitch/conf.db /usr/share/openvswitch/vswitch.ovsschema ovsdb-tool create /etc/openvswitch/conf.db /usr/share/openvswitch/vswitch.ovsschema
@ -25,20 +25,20 @@ then
ovs-vsctl --no-wait init ovs-vsctl --no-wait init
x=0 x=0
until [ $x = "4" ]; do until [[ $x = "4" ]]; do
ovs-vsctl add-br br$x ovs-vsctl add-br br$x
ovs-vsctl set bridge br$x datapath_type=netdev ovs-vsctl set bridge br$x datapath_type=netdev
x=$((x+1)) x=$((x+1))
done done
if [ $MANAGEMENT_INTERFACE == 1 ] if [[ $MANAGEMENT_INTERFACE == 1 ]]
then then
x=1 x=1
else else
x=0 x=0
fi fi
until [ $x = "16" ]; do until [[ $x = "16" ]]; do
ovs-vsctl add-port br0 eth$x ovs-vsctl add-port br0 eth$x
x=$((x+1)) x=$((x+1))
done done
@ -49,9 +49,9 @@ fi
x=0 x=0
until [ $x = "4" ]; do until [[ $x = "4" ]]; do
ip link set dev br$x up ip link set dev br$x up
x=$((x+1)) x=$((x+1))
done done
/bin/sh /bin/bash