Skip to content

Commit

Permalink
Merge pull request #882 from GNS3/feature/openvswitch-bash-completion
Browse files Browse the repository at this point in the history
Open VSwitch appliance bash completion
  • Loading branch information
grossmj authored May 9, 2024
2 parents e9375f2 + f5dfe27 commit eb92099
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
17 changes: 15 additions & 2 deletions docker/openvswitch/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
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

VOLUME /etc/openvswitch/

ADD boot.sh /bin/boot.sh

CMD /bin/sh /bin/boot.sh
CMD /bin/bash /bin/boot.sh
16 changes: 8 additions & 8 deletions docker/openvswitch/boot.sh
Original file line number Diff line number Diff line change
@@ -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
# it under the terms of the GNU General Public License as published by
Expand All @@ -16,7 +16,7 @@
# 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
ovsdb-tool create /etc/openvswitch/conf.db /usr/share/openvswitch/vswitch.ovsschema

Expand All @@ -25,20 +25,20 @@ then
ovs-vsctl --no-wait init

x=0
until [ $x = "4" ]; do
until [[ $x = "4" ]]; do
ovs-vsctl add-br br$x
ovs-vsctl set bridge br$x datapath_type=netdev
x=$((x+1))
done

if [ $MANAGEMENT_INTERFACE == 1 ]
if [[ $MANAGEMENT_INTERFACE == 1 ]]
then
x=1
else
x=0
fi

until [ $x = "16" ]; do
until [[ $x = "16" ]]; do
ovs-vsctl add-port br0 eth$x
x=$((x+1))
done
Expand All @@ -49,9 +49,9 @@ fi


x=0
until [ $x = "4" ]; do
until [[ $x = "4" ]]; do
ip link set dev br$x up
x=$((x+1))
done

/bin/sh
/bin/bash

0 comments on commit eb92099

Please sign in to comment.