Templates
1.0.0-wpa_action.sh.j2
Synopsis: Template 1.0.0-wpa_action.sh.
Description of the template.
[templates/1.0.0-wpa_action.sh.j2]
1#!/bin/sh
2# {{ ansible_managed }}
3
4version="1.0.0"
5ifname=$1
6cmd=$2
7# TODO: test prams
8
9{% if wpacli_action_script_log_to_file %}
10logtofile="1"
11{% else %}
12logtofile="0"
13{% endif %}
14logfile="{{ wpacli_action_script_logfile }}"
15
16if [ "$logtofile" = "1" ]; then
17 my_date=`date +"%b %d %T"`
18 printf "$my_date $ifname: $cmd \n" >> $logfile
19fi
20
21# wpa_supplicant reports connection to SSID. Start dhclient and
22# restart routing
23if [ "$cmd" = "CONNECTED" ]; then
24 if [ "$logtofile" = "1" ]; then
25 ssid=`wpa_cli -i$ifname status | grep ^ssid= | cut -f2- -d=`
26 printf "$my_date $ifname: SSID: $ssid \n" >> $logfile
27 fi
28 message=`/etc/rc.d/dhclient forcestart $ifname 2>&1` # NOTE 1
29 if [ "$logtofile" = "1" ]; then
30 printf "$my_date $ifname: dhclient start: $message \n" >> $logfile
31 fi
32 message=`/etc/rc.d/routing restart 2>&1`
33 if [ "$logtofile" = "1" ]; then
34 printf "$my_date $ifname: routing restart: $message \n" >> $logfile
35 fi
36fi
37
38# wpa_supplicant reports disconnection from SSID. Stop dhclient and
39# restart routing
40if [ "$cmd" = "DISCONNECTED" ]; then
41 message=`/etc/rc.d/dhclient forcestop $ifname`
42 if [ "$logtofile" = "1" ]; then
43 printf "$my_date $ifname: dhclient forcestart: $message \n" >> $logfile
44 fi
45 message=`/etc/rc.d/routing restart 2>&1`
46 if [ "$logtofile" = "1" ]; then
47 printf "$my_date $ifname: routing restart: $message \n" >> $logfile
48 fi
49fi
50
51exit 0
52
53# NOTE 1
54# We don't want /etc/network.subr to handle DHCP and instruct
55# ifconfig, in rc.conf, to configure WPA only.
56# ifconfig_wlan1="WPA"
57# When we use "/etc/rc.d/dhclient start wlan1" it complains
58# 'wlan1' is not a DHCP-enabled interface
59# Hence we use /etc/rc.d/dhclient forcestart $ifname in this script
60
61# NOTE 2
62# Example how to activate the script.
63# wpa_cli -B -i wlan1 -a /root/bin/wpa_action.sh
64
65# EOF
1.1.0-wpa_action.sh.j2
Synopsis: Template 1.1.0-wpa_action.sh.
Description of the template.
[templates/1.1.0-wpa_action.sh.j2]
1#!/bin/sh
2# {{ ansible_managed }}
3
4version="1.1.0"
5ifname=$1
6cmd=$2
7# TODO: test prams
8
9{% if wpacli_action_script_log_to_file %}
10logtofile="1"
11{% else %}
12logtofile="0"
13{% endif %}
14logfile="{{ wpacli_action_script_logfile }}"
15
16{% if wpacli_action_script_ntp_set %}
17ntp_set="1"
18{% else %}
19ntp_set="0"
20{% endif %}
21ntp_server="{{ wpacli_action_script_ntp_server }}"
22ntpdate_flags="{{ wpacli_action_script_ntpdate_flags }}"
23
24# functions
25log() {
26 if [ "$logtofile" = "1" ]; then
27 my_date=`date +"%b %d %T"`
28 printf "$my_date $ifname: $cmd: $message \n" >> $logfile
29 fi
30}
31
32routing_restart() {
33 cmd="/etc/rc.d/routing restart"
34 message=`$cmd 2>&1`
35 log
36}
37
38dhclient_forcestart() {
39 cmd="/etc/rc.d/dhclient forcestart $ifname" # NOTE 1
40 message=`$cmd 2>&1`
41 log
42}
43
44dhclient_forcestop() {
45 cmd="/etc/rc.d/dhclient forcestop $ifname"
46 message=`$cmd 2>&1`
47 log
48}
49
50ntpd_stop() {
51 cmd="/etc/rc.d/ntpd stop"
52 message=`$cmd 2>&1`
53 log
54}
55
56ntpd_start() {
57 cmd="/etc/rc.d/ntpd start"
58 message=`$cmd 2>&1`
59 log
60}
61
62ntpdate_settimeofday() {
63 cmd="/usr/sbin/ntpdate $ntpdate_flags $ntp_server"
64 message=`$cmd 2>&1`
65 log
66}
67
68log_SSID() {
69 if [ "$logtofile" = "1" ]; then
70 ssid=`wpa_cli -i$ifname status | grep ^ssid= | cut -f2- -d=`
71 my_date=`date +"%b %d %T"`
72 printf "$my_date $ifname: SSID: $ssid \n" >> $logfile
73 fi
74}
75
76# log interface and command
77if [ "$logtofile" = "1" ]; then
78 my_date=`date +"%b %d %T"`
79 printf "$my_date $ifname: $cmd \n" >> $logfile
80fi
81
82# wpa_supplicant reports connection to SSID. Start dhclient and
83# restart routing
84if [ "$cmd" = "CONNECTED" ]; then
85 log_SSID
86 dhclient_forcestart
87 routing_restart
88 if [ "$ntp_set" = "1" ]; then # NOTE 3
89 ntpd_stop
90 ntpdate_settimeofday
91 ntpd_start
92 fi
93fi
94
95# wpa_supplicant reports disconnection from SSID. Stop dhclient and
96# restart routing
97if [ "$cmd" = "DISCONNECTED" ]; then
98 dhclient_forcestop
99 routing_restart
100fi
101
102exit 0
103
104# NOTE 1
105# We don't want /etc/network.subr to handle DHCP. Therefor we instruct
106# ifconfig, in rc.conf, to configure WPA only
107# ifconfig_wlan1="WPA"
108# When we use "/etc/rc.d/dhclient start wlan1" it complains
109# 'wlan1' is not a DHCP-enabled interface
110# Hence we use /etc/rc.d/dhclient forcestart $ifname in this script.
111
112# NOTE 2
113# Example how to activate the script
114# wpa_cli -B -i wlan1 -a /root/bin/wpa_action.sh
115
116# NOTE 3
117# In a wifi-only system, /etc/rc.d/ntpdate will time-out if it
118# executes before /etc/rc.d/wpa_supplicant connects to the network
119# (See rcorder /etc/rc.d/*)
120
121# EOF
dma-auth.conf.j2
Synopsis: Template dma-auth.conf.
Description of the template.
1# {{ ansible_managed }}
2# Format: myuser|smtp.gmail.com:mypassword
3{% for item in cl_dma_authconf %}
4{{ item }}
5{% endfor %}
6# EOF
handlers-auto1.yml.j2
Synopsis: Template handlers-auto1.yml.
Description of the template.
[templates/handlers-auto1.yml.j2]
1---
2# {{ ansible_managed }}
3# Automatically generated file with handlers.
4{% for iitem in item.value.handlers %}
5
6- name: {{ item.key }} {{ iitem.handler }}
7 {{ iitem.module }}:
8{% for param in iitem.params %}
9 {{ param }}
10{% endfor %}
11{% if iitem.conditions is defined %}
12 when:
13{% for condition in iitem.conditions %}
14 {{ condition }}
15{% endfor %}
16{% endif %}
17{% endfor %}
18
19# EOF
handlers-auto2.yml.j2
Synopsis: Template handlers-auto2.yml.
Description of the template.
[templates/handlers-auto2.yml.j2]
1---
2# {{ ansible_managed }}
3# Automatically generated file with handlers.
4{% for iitem in item.value.handlers %}
5
6- name: {{ iitem.handler }}
7 {{ iitem.module }}:
8{% for param in iitem.params %}
9 {{ param }}
10{% endfor %}
11{% if iitem.conditions is defined %}
12 when:
13{% for condition in iitem.conditions %}
14 {{ condition }}
15{% endfor %}
16{% endif %}
17
18{% endfor %}
19
20# EOF
hosts.j2
Synopsis: Template hosts.
Description of the template.
1# {{ ansible_managed }}
2{{ cl_hosts_localhost_IPv6 }} localhost localhost.{{ cl_domain }}
3{{ cl_hosts_localhost_IPv4 }} localhost localhost.{{ cl_domain }}
4
5{% for item in cl_hosts %}
6{{ item.ip }} {{ item.fqdn }} {{ item.hostname|default('') }}
7{% endfor %}
8
9# EOF
loader.conf.j2
Synopsis: Template loader.conf.
Description of the template.
1# {{ ansible_managed }}
2
3# bsd_cimage_loaderconf_data
4{% for item in cl_loaderconf_data %}
5{{ item }}
6{% endfor %}
7
8# bsd_cimage_loaderconf_sysctl
9{% for item in cl_loaderconf_sysctl %}
10{{ item }}
11{% endfor %}
12
13# bsd_cimage_loaderconf_modules
14{% for item in cl_loaderconf_modules %}
15{{ item }}_load="YES"
16{% endfor %}
17
18# EOF
mailer.conf.j2
Synopsis: Template mailer.conf.
Description of the template.
1# {{ ansible_managed }}
2# https://www.freebsd.org/cgi/man.cgi?mailer.conf
3{% for item in cl_mailerconf %}
4{{ item }}
5{% endfor %}
6# EOF
ntp.conf-minimal.j2
Synopsis: Template ntp.conf-minimal.
Description of the template.
[templates/ntp.conf-minimal.j2]
1# {{ ansible_managed }}
2{% for option in fp_ntp_config_options %}
3{{ option }}
4{% endfor %}
5{% for pool in fp_ntp_config_pool %}
6pool {{ pool }}
7{% endfor %}
8{% for restrict in fp_ntp_config_restrict %}
9restrict {{ restrict }}
10{% endfor %}
11{% if fp_ntp_config_leapfile %}
12leapfile {{ fp_ntp_config_leapfile }}
13{% endif %}
revaliases.j2
Synopsis: Template revaliases.
Description of the template.
1# {{ ansible_managed }}
2# Format: local_account:outgoing_address:mailhub
3{% for item in cl_ssmtp_revaliases %}
4{{ item }}
5{% endfor %}
6# EOF
ssmtp.conf.j2
Synopsis: Template ssmtp.conf.
Description of the template.
1# {{ ansible_managed }}
2
3# The user that gets all the mails (UID < 1000, usually the admin)
4# root=username@gmail.com
5root={{ cl_ssmtp_postmaster_address }}
6
7# The mail server (where the mail is sent to), both port 465 or 587 should be acceptable
8# See also https://support.google.com/mail/answer/78799
9# mailhub=smtp.gmail.com:587
10mailhub={{ cl_ssmtp_mailhub }}
11
12# The address where the mail appears to come from for user authentication.
13# rewriteDomain=gmail.com
14rewriteDomain={{ cl_ssmtp_rewriteDomain }}
15
16# The full hostname. Must be correctly formed, fully qualified domain
17# name or GMail will reject connection.
18# hostname=yourlocalhost.yourlocaldomain.tld
19hostname={{ cl_ssmtp_srv }}
20
21# Use SSL/TLS before starting negotiation
22#UseTLS=Yes
23#UseSTARTTLS=Yes
24UseTLS={{ cl_ssmtp_UseTLS }}
25UseSTARTTLS={{ cl_ssmtp_UseSTARTTLS }}
26
27# Username/Password
28#AuthUser=username
29#AuthPass=password
30#AuthMethod=LOGIN
31AuthUser={{ cl_ssmtp_AuthUser }}
32AuthPass={{ cl_ssmtp_AuthPass }}
33AuthMethod={{ cl_ssmtp_AuthMethod }}
34
35# Email 'From header's can override the default domain?
36#FromLineOverride=yes
37FromLineOverride={{ cl_ssmtp_FromLineOverride }}
38
39# EOF
wpa_cli.j2
Synopsis: Template wpa_cli.
Description of the template.
1#!/bin/sh
2# {{ ansible_managed }}"
3
4# PROVIDE: wpa_cli
5# REQUIRE: mountcritremote
6# KEYWORD: nojail nostart
7
8. /etc/rc.subr
9. /etc/network.subr
10
11name="wpa_cli"
12desc="Frontend to WPA/802.11i Supplicant for wireless network
13devices. Run in daemon mode executing the action file based on events
14from wpa_supplicant"
15rcvar=
16
17ifn="$2"
18if [ -z "$ifn" ]; then
19 return 1
20fi
21
22load_rc_config $name
23
24command="${wpa_cli_program}"
25pidfile="/var/run/${name}/${ifn}.pid"
26command_args="-B -i $ifn -P $pidfile -p ${wpa_cli_ctrl_interface} -a ${wpa_cli_action_file}"
27required_files="${wpa_cli_action_file}"
28
29run_rc_command "$1"
30
31# EOF
wpa_supplicant.conf.j2
Synopsis: Template wpa_supplicant.conf.
Description of the template.
[templates/wpa_supplicant.conf.j2]
1# {{ ansible_managed }}
2{% for gvar in cl_wpasupconf_global %}
3{{ gvar.key }}={{ gvar.value }}
4{% endfor %}
5{% for net in item.network %}
6{% for nvar in net.conf %}
7{% if loop.first %}
8
9network={
10{% endif %}
11 {{ nvar.key }}={{ nvar.value }}
12{% if loop.last %}
13}
14{% endif %}
15{% endfor %}
16{% endfor %}
17
18# EOF
wpa_supplicant.conf.wlan0.j2
Synopsis: Template wpa_supplicant.conf.wlan0.
Description of the template.
[templates/wpa_supplicant.conf.wlan0.j2]
1# {{ ansible_managed }}
2{% for gvar in cl_wpasupconf_global %}
3{{ gvar.key }}={{ gvar.value }}
4{% endfor %}
5{% for net in cl_wpasupconf_wlan0.network %}
6{% for nvar in net.conf %}
7{% if loop.first %}
8
9network={
10{% endif %}
11 {{ nvar.key }}={{ nvar.value }}
12{% if loop.last %}
13}
14{% endif %}
15{% endfor %}
16{% endfor %}
17
18# EOF