Commit fa0d3a97 authored by nanahira's avatar nanahira

use systemd to run initialize script

parent 0ce4cd5a
......@@ -74,7 +74,11 @@ bridge_ports{% for link in br.links %} {% if br.macvlan is defined and br.macvla
{% else %}
bridge_ports none
{% endif %}
{% if br.stp is defined and br.stp %}
bridge_stp on
{% else %}
bridge_stp off
{% endif %}
bridge_maxwait 3
{% if br.type == "static" %}
address {{br.address}}
......
......@@ -12,7 +12,6 @@ restore_mark() {
}
ppp_origin() {
_nextgen_router_initialize
OPTION=$1
INTERFACE=$2
MARK=$[1000 + $(echo "$INTERFACE" | sed "s/ppp//g")]
......@@ -21,22 +20,7 @@ ppp_origin() {
# ip6tables -t mangle "$OPTION" PREROUTING ! -p ospf -i "$INTERFACE" -j CONNMARK --set-xmark "$MARK"
}
_nextgen_router_initialize_process() {
{% for subnet in localnets %}
ip rule add pref 80 to {{subnet}} lookup main
{% endfor %}
ip rule add pref 80 to 172.16.0.0/12 lookup main
arp -f
}
_nextgen_router_initialize() {
ipset restore -f {{ansible_user_dir}}/nextgen-router/localnet-ipset && \
_nextgen_router_initialize_process
true
}
eth_origin() {
_nextgen_router_initialize
OPTION=$1
BRIDGE_NAME=$2
GATEWAY_ID=$3
......
......@@ -33,6 +33,34 @@
name: /etc/ethers
state: touch
changed_when: false
- name: initialize script
template:
src: ./files/initialize.sh.j2
dest: '{{ansible_user_dir}}/nextgen-router/scripts/initialize.sh'
mode: 0755
- name: initialize systemd
become: true
copy:
content: |
[Unit]
Description=MyCard NextGen Router Initialize
Before=network-online.target
After=network-pre.target
[Service]
Type=oneshot
ExecStart={{ansible_user_dir}}/nextgen-router/scripts/initialize.sh
[Install]
WantedBy=multi-user.target
dest: /etc/systemd/system/nextgen-router-initialize.service
register: initialize_systemd_result
- name: initialize systemd enable
become: true
systemd:
name: nextgen-router-initialize
enabled: true
daemon_reload: '{{initialize_systemd_result.changed}}'
- name: clean some rubbish packages
become: true
apt:
......
......@@ -28,6 +28,7 @@ vars:
- 10.0.0.2/24 # 备选地址
gateways: null # 网关,看下面
masq: false # 是否MASQ
stp: false # 是否开启STP,默认false
linkUp: echo 'link up' # 链路启动脚本,用于奇怪的特殊链路或者netns
up: echo "up" # 启动脚本和关闭脚本
down: echo "down"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment