Opennet Firmware
 Alle Dateien Funktionen Variablen Gruppen Seiten
on-core-init
gehe zur Dokumentation dieser Datei
1 #!/bin/sh
2 #
3 # Dieses Skript wird nur ein einziges Mal nach einem Upgrade oder der Erstinstallation ausgefuehrt:
4 # http://wiki.openwrt.org/doc/uci#defaults
5 #
6 
7 
8 . "${IPKG_INSTROOT:-}/usr/lib/opennet/on-helper.sh"
9 
10 
11 # Die Einstellungen "use_olsrd_dns" und "use_olsrd_ntp" sind mit v0.5 hinzugekommen.
12 add_default_settings() {
13  prepare_on_uci_settings
14  # erzeuge die services-Node, falls noetig
15  for setting in use_olsrd_dns use_olsrd_ntp; do
16  [ -n "$(uci_get "on-core.settings.$setting")" ] && continue
17  uci set "on-core.settings.$setting=1"
18  done
19  apply_changes on-core
20 }
21 
22 
23 # cron-Logging abschalten (bis auf Fehlermeldungen)
24 # siehe http://wiki.openwrt.org/doc/uci/system#system
25 disable_cron_logging() {
26  uci set "system.@system[0].cronloglevel=9"
27  apply_changes system
28 }
29 
30 
31 # verschiedene dnsmasq-Einstellungen
32 configure_dnsmasq() {
33  # die Namensaufloesung im Opennet generiert auch 192.168er-Adressen - diese werden durch "rebind_protection" blockiert
34  uci set "dhcp.@dnsmasq[0].rebind_protection=0"
35  # keine Speicherung von DHCP leases
36  uci set "dhcp.@dnsmasq[0].quietdhcp=1"
37  apply_changes dhcp
38 }
39 
40 
41 add_crontab_entries() {
42  local crontab_file=/etc/crontabs/root
43  local cron_prefix="[ -x /usr/bin/on-function ] && /usr/bin/on-function run_parts"
44  local cron_suffix="2>&1 | logger -t cron-error"
45  line_in_file "$crontab_file" "^[^#].*run_parts.*/etc/cron\.minutely" \
46  "* * * * * $cron_prefix /etc/cron.minutely $cron_suffix"
47  line_in_file "$crontab_file" "^[^#].*run_parts.*/etc/cron\.5mins" \
48  "*/5 * * * * $cron_prefix /etc/cron.5mins $cron_suffix"
49  line_in_file "$crontab_file" "^[^#].*run_parts.*/etc/cron\.hourly" \
50  "18 * * * * $cron_prefix /etc/cron.hourly $cron_suffix"
51  line_in_file "$crontab_file" "^[^#].*run_parts.*/etc/cron\.daily" \
52  "02 4 * * * $cron_prefix /etc/cron.daily $cron_suffix"
53  # es ist schwer zu pruefen, ob die Datei sich geaendert hat - also einfach neustarten
54  /etc/init.d/cron restart
55 }
56 
57 
58 set_timezone_berlin() {
59  # "zonename" ist bereits gesetzt? Wert beibehalten ...
60  [ -n "$(uci_get "system.@system[0].zonename")" ] && return 0
61  # Zone und Verschiebung setzen
62  uci set "system.@system[0].zonename=Europe/Berlin"
63  uci set "system.@system[0].timezone=CET-1CEST,M3.5.0,M10.5.0/3"
64  uci commit system
65 }
66 
67 
68 enable_firewall_reload_trigger() {
69  local uci_prefix
70  script_path="/usr/lib/opennet/events/on-firewall-reload"
71  uci_prefix=$(find_first_uci_section "firewall" "include" "path=$script_path")
72  [ -n "$uci_prefix" ] && return 0
73  uci_prefix="firewall.$(uci add "firewall" "include")"
74  uci set "${uci_prefix}.path=$script_path"
75  uci set "${uci_prefix}.reload=1"
76  apply_changes firewall
77 }
78 
79 
80 add_default_settings
81 disable_cron_logging
82 configure_dnsmasq
83 add_crontab_entries
84 set_timezone_berlin
85 enable_firewall_reload_trigger
done
Definition: core.sh:81