Skip to content

Commit eb92099

Browse files
authored
Merge pull request #882 from GNS3/feature/openvswitch-bash-completion
Open VSwitch appliance bash completion
2 parents e9375f2 + f5dfe27 commit eb92099

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

docker/openvswitch/Dockerfile

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
FROM alpine:latest
22

3-
RUN apk add --update openvswitch nano && rm -rf /var/cache/apk/*
3+
RUN apk add --no-cache openvswitch nano bash bash-completion
4+
5+
# Make bash the default shell
6+
RUN sed -i s,/bin/ash,/bin/bash, /etc/passwd
7+
8+
# Enable bash completion
9+
RUN echo -e "source /etc/profile.d/bash_completion.sh" >> ~/.bashrc
10+
11+
# Enable openvswitch bash completion
12+
RUN echo -e "source /usr/share/bash-completion/completions/ovs-vsctl-bashcomp.bash" >> ~/.bashrc
13+
RUN echo -e "source /usr/share/bash-completion/completions/ovs-appctl-bashcomp.bash" >> ~/.bashrc
14+
15+
# Configure the prompt
16+
RUN echo -e "PS1='\h:\w\$ '" >> ~/.bashrc
417

518
RUN mkdir /var/run/openvswitch
619

720
VOLUME /etc/openvswitch/
821

922
ADD boot.sh /bin/boot.sh
1023

11-
CMD /bin/sh /bin/boot.sh
24+
CMD /bin/bash /bin/boot.sh

docker/openvswitch/boot.sh

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
#
3-
# Copyright (C) 2015 GNS3 Technologies Inc.
3+
# Copyright (C) 2024 GNS3 Technologies Inc.
44
#
55
# This program is free software: you can redistribute it and/or modify
66
# it under the terms of the GNU General Public License as published by
@@ -16,7 +16,7 @@
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

1818

19-
if [ ! -f "/etc/openvswitch/conf.db" ]
19+
if [[ ! -f "/etc/openvswitch/conf.db" ]]
2020
then
2121
ovsdb-tool create /etc/openvswitch/conf.db /usr/share/openvswitch/vswitch.ovsschema
2222

@@ -25,20 +25,20 @@ then
2525
ovs-vsctl --no-wait init
2626

2727
x=0
28-
until [ $x = "4" ]; do
28+
until [[ $x = "4" ]]; do
2929
ovs-vsctl add-br br$x
3030
ovs-vsctl set bridge br$x datapath_type=netdev
3131
x=$((x+1))
3232
done
3333

34-
if [ $MANAGEMENT_INTERFACE == 1 ]
34+
if [[ $MANAGEMENT_INTERFACE == 1 ]]
3535
then
3636
x=1
3737
else
3838
x=0
3939
fi
4040

41-
until [ $x = "16" ]; do
41+
until [[ $x = "16" ]]; do
4242
ovs-vsctl add-port br0 eth$x
4343
x=$((x+1))
4444
done
@@ -49,9 +49,9 @@ fi
4949

5050

5151
x=0
52-
until [ $x = "4" ]; do
52+
until [[ $x = "4" ]]; do
5353
ip link set dev br$x up
5454
x=$((x+1))
5555
done
5656

57-
/bin/sh
57+
/bin/bash

0 commit comments

Comments
 (0)