From 58106eef4d6fcdb798e6a8f08099d14d4f2e4b36 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Thu, 23 Mar 2023 10:18:43 +0100 Subject: [PATCH] libexec_startup: Import prj_github2_startup.sh Import existing script from /project/github2/sbin/setup-github-network.sh --- libexec_startup/prj_github2_startup.sh | 53 ++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 libexec_startup/prj_github2_startup.sh diff --git a/libexec_startup/prj_github2_startup.sh b/libexec_startup/prj_github2_startup.sh new file mode 100755 index 0000000..eb5fa7a --- /dev/null +++ b/libexec_startup/prj_github2_startup.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +modprobe kvm_amd 2>/dev/null +modprobe kvm_intel 2>/dev/null + +chmod a+rw /dev/kvm + +NETDEV=vlan.github0 +BRIDGEDEV=br.github0 +TAPDEV=tap.github0 +USER=github + +set -x + +function start +{ + # create tap device + ip tuntap add dev ${TAPDEV} mode tap user ${USER} + ip link set ${TAPDEV} up + + # activate network device + ip link set ${NETDEV} up + + # create bridge + brctl addbr ${BRIDGEDEV} + brctl addif ${BRIDGEDEV} ${NETDEV} + brctl addif ${BRIDGEDEV} ${TAPDEV} + ip link set ${BRIDGEDEV} up +} + +function stop +{ + ip link set ${BRIDGEDEV} down + brctl delbr ${BRIDGEDEV} + + ip link set ${TAPDEV} down + ip tuntap del dev ${TAPDEV} mode tap +} + +case "${1}" in + start) + start + ;; + + stop) + stop + ;; + + *) + echo "usage $0 {start|stop}" >&2 + exit 1 + ;; +esac