Compare commits
4 commits
948c9a5d8d
...
dc0a3257fc
Author | SHA1 | Date | |
---|---|---|---|
|
dc0a3257fc | ||
|
c5d95d0e5e | ||
|
f05200bffc | ||
|
9064e5304f |
7 changed files with 93 additions and 15 deletions
|
@ -24,6 +24,8 @@ packages:
|
||||||
- "ntpsec"
|
- "ntpsec"
|
||||||
- "haveged"
|
- "haveged"
|
||||||
- "haveged-openrc"
|
- "haveged-openrc"
|
||||||
|
- "git"
|
||||||
|
- "git-lfs"
|
||||||
templates:
|
templates:
|
||||||
- "/etc/conf.d/iptables"
|
- "/etc/conf.d/iptables"
|
||||||
- "/etc/conf.d/ip6tables"
|
- "/etc/conf.d/ip6tables"
|
||||||
|
@ -38,6 +40,8 @@ templates:
|
||||||
- "/etc/sysctl.d/coredump.conf"
|
- "/etc/sysctl.d/coredump.conf"
|
||||||
- "/etc/docker/daemon.json"
|
- "/etc/docker/daemon.json"
|
||||||
- "/etc/ntp.conf"
|
- "/etc/ntp.conf"
|
||||||
|
executables:
|
||||||
|
- "/usr/libexec/ifupdown-ng/routes"
|
||||||
services:
|
services:
|
||||||
- runlevel: "sysinit"
|
- runlevel: "sysinit"
|
||||||
service: "devfs"
|
service: "devfs"
|
||||||
|
|
|
@ -9,6 +9,12 @@
|
||||||
dest: "/mnt{{ item }}"
|
dest: "/mnt{{ item }}"
|
||||||
mode: "640"
|
mode: "640"
|
||||||
loop: "{{ templates }}"
|
loop: "{{ templates }}"
|
||||||
|
- name: "Also executables."
|
||||||
|
template:
|
||||||
|
src: "templates{{ item }}.j2"
|
||||||
|
dest: "/mnt{{ item }}"
|
||||||
|
mode: "750"
|
||||||
|
loop: "{{ executables }}"
|
||||||
- name: "And services."
|
- name: "And services."
|
||||||
template:
|
template:
|
||||||
src: "templates{{ item }}.j2"
|
src: "templates{{ item }}.j2"
|
||||||
|
|
|
@ -7,6 +7,12 @@
|
||||||
dest: "{{ item }}"
|
dest: "{{ item }}"
|
||||||
mode: "640"
|
mode: "640"
|
||||||
loop: "{{ templates }}"
|
loop: "{{ templates }}"
|
||||||
|
- name: "Also executables."
|
||||||
|
template:
|
||||||
|
src: "templates{{ item }}.j2"
|
||||||
|
dest: "{{ item }}"
|
||||||
|
mode: "750"
|
||||||
|
loop: "{{ executables }}"
|
||||||
- name: "And services."
|
- name: "And services."
|
||||||
template:
|
template:
|
||||||
src: "templates{{ item }}.j2"
|
src: "templates{{ item }}.j2"
|
||||||
|
|
|
@ -1,20 +1,9 @@
|
||||||
#!/sbin/openrc-run
|
#!/sbin/openrc-run
|
||||||
|
|
||||||
DAEMON="/usr/sbin/ntpd"
|
command="/usr/sbin/ntpd"
|
||||||
PIDFILE="/var/run/ntpd.pid"
|
pidfile="/var/run/ntpd.pid"
|
||||||
|
command_args="-g"
|
||||||
|
|
||||||
depend() {
|
depend() {
|
||||||
need net
|
need net
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
|
||||||
ebegin "Starting NTPSec"
|
|
||||||
start-stop-daemon --start --exec "${DAEMON}" --pidfile "${PIDFILE}"
|
|
||||||
eend $?
|
|
||||||
}
|
|
||||||
|
|
||||||
stop() {
|
|
||||||
ebegin "Stopping NTPSec"
|
|
||||||
start-stop-daemon --stop --pidfile "${PIDFILE}"
|
|
||||||
eend $?
|
|
||||||
}
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ auto eth0
|
||||||
|
|
||||||
iface eth0 inet static
|
iface eth0 inet static
|
||||||
address {{ ansible_host }}/{{ netmask }}
|
address {{ ansible_host }}/{{ netmask }}
|
||||||
gateway {{ gateway }}
|
routes-static {{ gateway }},default via {{ gateway }}
|
||||||
|
|
||||||
{% if ip6 is defined %}
|
{% if ip6 is defined %}
|
||||||
iface eth0 inet6 static
|
iface eth0 inet6 static
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
# https://gist.github.com/jauderho/2ad0d441760fc5ed69d8d4e2d6b35f8d
|
# https://gist.github.com/jauderho/2ad0d441760fc5ed69d8d4e2d6b35f8d
|
||||||
server time.cloudflare.com nts iburst
|
server time.cloudflare.com nts iburst
|
||||||
driftfile /var/lib/ntp/ntp.drift
|
driftfile /var/lib/ntp/ntp.drift
|
||||||
|
file pidfile filename /var/run/ntpd.pid type pid
|
||||||
|
|
72
templates/usr/libexec/ifupdown-ng/routes.j2
Executable file
72
templates/usr/libexec/ifupdown-ng/routes.j2
Executable file
|
@ -0,0 +1,72 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# https://github.com/ifupdown-ng/ifupdown-ng/issues/42#issuecomment-849135927
|
||||||
|
[ -z "${VERBOSE}" ] || set -x
|
||||||
|
|
||||||
|
# routes-static 1.2.3.0/24,10.0.0.0/8 via 1.2.3.4
|
||||||
|
# routes-rule dport 25 table 123,dport 587 table 123
|
||||||
|
|
||||||
|
# adds $3 to $1 if $1 does not contain $2
|
||||||
|
addif() {
|
||||||
|
if [ "$1" = "${1%$2*}" ]; then
|
||||||
|
echo $1 $3
|
||||||
|
else
|
||||||
|
echo $1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
decidr() {
|
||||||
|
echo "${1%/*}"
|
||||||
|
}
|
||||||
|
addsrc() {
|
||||||
|
addif "$1" src "src $(decidr $IF_ADDRESS)"
|
||||||
|
}
|
||||||
|
adddev() {
|
||||||
|
addif "$1" dev "dev $IFACE"
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: input string
|
||||||
|
# $2: delimeter
|
||||||
|
# $3: function to call
|
||||||
|
foreach() {
|
||||||
|
list="$1"
|
||||||
|
|
||||||
|
while [ -n "$list" ]; do
|
||||||
|
line="${list%%$2*}"
|
||||||
|
list="${list#*$2}"
|
||||||
|
"$3" "$line"
|
||||||
|
|
||||||
|
[ "$line" = "$list" ] && break
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# add a route
|
||||||
|
prep() {
|
||||||
|
route="$1"
|
||||||
|
route=$(addsrc "$route")
|
||||||
|
route=$(adddev "$route")
|
||||||
|
echo $route
|
||||||
|
}
|
||||||
|
routeadd() {
|
||||||
|
${MOCK} ip route add $(prep "$1")
|
||||||
|
}
|
||||||
|
routedel() {
|
||||||
|
${MOCK} ip route del $(prep "$1")
|
||||||
|
}
|
||||||
|
|
||||||
|
ruleadd() {
|
||||||
|
${MOCK} ip rule add $1
|
||||||
|
}
|
||||||
|
ruledel() {
|
||||||
|
${MOCK} ip rule del $1
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$PHASE" in
|
||||||
|
up)
|
||||||
|
foreach "$IF_ROUTES_STATIC" , routeadd
|
||||||
|
foreach "$IF_ROUTES_RULE" , ruleadd
|
||||||
|
;;
|
||||||
|
down)
|
||||||
|
foreach "$IF_ROUTES_STATIC" , routedel
|
||||||
|
foreach "$IF_ROUTES_RULE" , ruledel
|
||||||
|
;;
|
||||||
|
*) exit 0 ;;
|
||||||
|
esac
|
Loading…
Reference in a new issue