mirror of
https://github.com/luscis/openlan.git
synced 2025-12-24 11:10:54 +08:00
dist: cleanup scripts.
This commit is contained in:
43
dist/rootfs/var/openlan/openvpn/openvpn.md
vendored
43
dist/rootfs/var/openlan/openvpn/openvpn.md
vendored
@@ -1,30 +1,29 @@
|
||||
# OpenVPN
|
||||
|
||||
yum install -y epel-release
|
||||
|
||||
yum install -y openvpn
|
||||
|
||||
```
|
||||
yum install -y epel-release
|
||||
yum install -y openvpn
|
||||
```
|
||||
## Generate Diffie-Hellman
|
||||
|
||||
openssl dhparam -out /var/openlan/openvpn/dh.pem 1024
|
||||
|
||||
```
|
||||
openssl dhparam -out /var/openlan/openvpn/dh.pem 1024
|
||||
```
|
||||
## Generate TLS Auth Key
|
||||
|
||||
openvpn --genkey --secret /var/openlan/openvpn/ta.key
|
||||
|
||||
```
|
||||
openvpn --genkey --secret /var/openlan/openvpn/ta.key
|
||||
```
|
||||
|
||||
# Configure OpenVPN in Network
|
||||
|
||||
{
|
||||
"name": "example",
|
||||
"openvpn": {
|
||||
"listen": "0.0.0.0:1194",
|
||||
"subnet": "10.9.9.0/24"
|
||||
}
|
||||
```
|
||||
{
|
||||
"name": "example",
|
||||
"openvpn": {
|
||||
"listen": "0.0.0.0:1194",
|
||||
"subnet": "10.9.9.0/24"
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Restart OpenLAN Switch Service
|
||||
|
||||
systemctl reload openlan-switch
|
||||
|
||||
```
|
||||
systemctl reload openlan-switch
|
||||
```
|
||||
|
||||
67
dist/rootfs/var/openlan/script/bridge
vendored
67
dist/rootfs/var/openlan/script/bridge
vendored
@@ -1,67 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
## Load configuration.
|
||||
cfg="eth0.cfg"
|
||||
if [ $# -ge 1 ]; then
|
||||
cfg="$1"
|
||||
shift
|
||||
fi
|
||||
if [ -e "$cfg" ]; then
|
||||
. $cfg
|
||||
fi
|
||||
|
||||
## Check enviroment.
|
||||
if [ -z "$PHY" ] || [ -z "$ADDR" ] || [ -z "$PREFIX" ]; then
|
||||
echo "Variable(PHY|ADDR|PREFIX) is NULL"
|
||||
exit
|
||||
fi
|
||||
|
||||
yum install bridge-utils -y
|
||||
|
||||
## Set variable
|
||||
phy="$PHY"
|
||||
addr="$ADDR"
|
||||
prefix="$PREFIX"
|
||||
br=br-"$PHY"
|
||||
gw="$GATEWAY"
|
||||
dns1="$DNS1"
|
||||
|
||||
## Configure script
|
||||
brCfg=/etc/sysconfig/network-scripts/ifcfg-"$br"
|
||||
phyCfg=/etc/sysconfig/network-scripts/ifcfg-"$phy"
|
||||
|
||||
## Generate bridge configure
|
||||
echo "## Generate by OpenLAN project" > $brCfg
|
||||
echo "STP=\"yes\"" >> $brCfg
|
||||
echo "DELAY=\"2\"" >> $brCfg
|
||||
echo "TYPE=\"Bridge\"" >> $brCfg
|
||||
echo "NAME=\"$br\"" >> $brCfg
|
||||
echo "DEVICE=\"$br\"" >> $brCfg
|
||||
echo "BOOTPROTO=\"none\"" >> $brCfg
|
||||
if [ -n "$addr" ]; then
|
||||
echo "IPADDR=\"$addr\"" >> $brCfg
|
||||
fi
|
||||
if [ -n "$prefix" ]; then
|
||||
echo "PREFIX=\"$prefix\"" >> $brCfg
|
||||
fi
|
||||
if [ -n "$gw" ]; then
|
||||
echo "GATEWAY=\"$gw\"" >> $brCfg
|
||||
fi
|
||||
if [ -n "$dns1" ]; then
|
||||
echo "DNS1=\"$dns1\"" >> $brCfg
|
||||
fi
|
||||
echo "ONBOOT=\"yes\"" >> $brCfg
|
||||
echo "NM_CONTROLLED=\"no\"" >> $brCfg
|
||||
|
||||
## Generate physical configure
|
||||
echo "## Generate by OpenLAN project" > $phyCfg
|
||||
echo "TYPE=\"Ethernet\"" >> $phyCfg
|
||||
echo "NAME=\"$phy\"" >> $phyCfg
|
||||
echo "DEVICE=\"$phy\"" >> $phyCfg
|
||||
echo "BOOTPROTO=\"none\"" >> $phyCfg
|
||||
echo "ONBOOT=\"yes\"" >> $phyCfg
|
||||
echo "NM_CONTROLLED=\"no\"" >> $phyCfg
|
||||
echo "BRIDGE=\"$br\"" >> $phyCfg
|
||||
echo "BRIDGING_OPTS=\"path_cost=4\"" >> $phyCfg # 4: 1G, 2: 10G, 19: 100Mb and 100: 1Mb.
|
||||
|
||||
ifdown "$br"; ifdown "$phy"; ifup "$br"; ifup "$phy";
|
||||
5
dist/rootfs/var/openlan/script/eth0.cfg
vendored
5
dist/rootfs/var/openlan/script/eth0.cfg
vendored
@@ -1,5 +0,0 @@
|
||||
PHY="eth0"
|
||||
ADDR="192.168.2.2"
|
||||
PREFIX="24"
|
||||
GATEWAY=""
|
||||
DNS1=""
|
||||
9
dist/rootfs/var/openlan/script/ifcfg-veth0
vendored
9
dist/rootfs/var/openlan/script/ifcfg-veth0
vendored
@@ -1,9 +0,0 @@
|
||||
DEVICE="veth0"
|
||||
TYPE="veth"
|
||||
DEVICETYPE="Ethernet"
|
||||
BOOTPROTO="static"
|
||||
IPADDR="192.168.3.4"
|
||||
NETMASK="255.255.255.0"
|
||||
ONBOOT="no"
|
||||
NM_CONTROLLED="no"
|
||||
VETH_PARENT="br0"
|
||||
60
dist/rootfs/var/openlan/script/ifdown-veth
vendored
60
dist/rootfs/var/openlan/script/ifdown-veth
vendored
@@ -1,60 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Derived from initscripts-macvlan
|
||||
# Copyright (C) 2014 Lars Kellogg-Stedman
|
||||
#
|
||||
# Adopted for veth by Oleksandr Natalenko <o.natalenko@lanet.ua>
|
||||
# Copyright (C) 2015 Lanet Network
|
||||
#
|
||||
# Based on Network Interface Configuration System
|
||||
# Copyright (c) 1996-2009 Red Hat, Inc. all rights reserved.
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
. /etc/init.d/functions
|
||||
|
||||
cd /etc/sysconfig/network-scripts
|
||||
. ./network-functions
|
||||
|
||||
[ -f ../network ] && . ../network
|
||||
|
||||
CONFIG=${1}
|
||||
|
||||
need_config ${CONFIG}
|
||||
|
||||
source_config
|
||||
|
||||
OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-${REAL_DEVICETYPE}"
|
||||
|
||||
if [ ! -x ${OTHERSCRIPT} ]; then
|
||||
OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-eth"
|
||||
fi
|
||||
|
||||
${OTHERSCRIPT} ${CONFIG}
|
||||
|
||||
if [ -n "${VETH_PARENT}" ] && [ -x /usr/sbin/brctl ]; then
|
||||
ip link set \
|
||||
dev ${DEVICE}-bp down
|
||||
brctl delif -- \
|
||||
${VETH_PARENT} ${DEVICE}-bp
|
||||
[ -r /var/run/radvd/radvd.pid ] && kill -HUP $(cat /var/run/radvd/radvd.pid)
|
||||
if [ -d /sys/class/net/${VETH_PARENT}/brif ] && [ $(ls -1 /sys/class/net/${VETH_PARENT}/brif | wc -l) -eq 0 ]; then
|
||||
ip link set \
|
||||
dev ${VETH_PARENT} down
|
||||
brctl delbr -- ${VETH_PARENT}
|
||||
fi
|
||||
fi
|
||||
|
||||
ip link del ${DEVICE}
|
||||
|
||||
78
dist/rootfs/var/openlan/script/ifup-veth
vendored
78
dist/rootfs/var/openlan/script/ifup-veth
vendored
@@ -1,78 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Derived from initscripts-macvlan
|
||||
# Copyright (C) 2014 Lars Kellogg-Stedman
|
||||
#
|
||||
# Adopted for veth by Oleksandr Natalenko <o.natalenko@lanet.ua>
|
||||
# Copyright (C) 2015 Lanet Network
|
||||
#
|
||||
# Based on Network Interface Configuration System
|
||||
# Copyright (c) 1996-2009 Red Hat, Inc. all rights reserved.
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
. /etc/init.d/functions
|
||||
|
||||
cd /etc/sysconfig/network-scripts
|
||||
. ./network-functions
|
||||
|
||||
[ -f ../network ] && . ../network
|
||||
|
||||
CONFIG=${1}
|
||||
|
||||
need_config ${CONFIG}
|
||||
|
||||
source_config
|
||||
|
||||
OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${REAL_DEVICETYPE}"
|
||||
|
||||
if [ ! -x ${OTHERSCRIPT} ]; then
|
||||
OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-eth"
|
||||
fi
|
||||
|
||||
ip link add \
|
||||
name ${DEVICE} \
|
||||
type veth \
|
||||
peer name ${DEVICE}-bp
|
||||
|
||||
if [ -n "${VETH_MAC}" ]; then
|
||||
ip link set \
|
||||
dev ${DEVICE} \
|
||||
address ${VETH_MAC}
|
||||
fi
|
||||
|
||||
if [ -n "${VETH_PARENT}" ] && [ -x /usr/sbin/brctl ]; then
|
||||
if [ ! -d /sys/class/net/${VETH_PARENT}/bridge ]; then
|
||||
brctl addbr -- \
|
||||
${VETH_PARENT} 2>/dev/null
|
||||
ip link set \
|
||||
dev ${VETH_PARENT} up
|
||||
fi
|
||||
ip addr flush dev ${DEVICE}-bp 2>/dev/null
|
||||
ip link set \
|
||||
dev ${DEVICE}-bp up
|
||||
ethtool_set
|
||||
[ -n "${LINKDELAY}" ] && /bin/sleep ${LINKDELAY}
|
||||
brctl addif -- \
|
||||
${VETH_PARENT} ${DEVICE}-bp
|
||||
for arg in $BRIDGING_OPTS ; do
|
||||
key=${arg%%=*};
|
||||
value=${arg##*=};
|
||||
echo $value > /sys/class/net/${DEVICE}-bp/brport/$key
|
||||
done
|
||||
[ -r /var/run/radvd/radvd.pid ] && kill -HUP $(cat /var/run/radvd/radvd.pid)
|
||||
fi
|
||||
|
||||
${OTHERSCRIPT} ${CONFIG}
|
||||
|
||||
Reference in New Issue
Block a user