Changeset 2143


Ignore:
Timestamp:
Aug 23, 2012, 3:28:59 PM (6 years ago)
Author:
matthijs
Message:

luci: Allow changing the timezone.

Since Transmision offers scheduling downloads, having the timezone fixed
to UTC is not longer sufficient. This commit adds a database with
timezone information and adds a setting to the "Language" setting page
to change the Timezone.

Since changing the timezone at runtime is tricky (running applications
might not see the change, but new applications will) the timezone change
is not applied at all until the next reboot.

Closes: #1190

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/fon/fonbase/files/etc/init.d/configure

    r1 r2143  
    99        /lib/fon/config.sh wireless
    1010        /lib/fon/config.sh dhcp
     11        /lib/fon/config.sh timezone
    1112        echo -n "Offline" > /tmp/run/fonstate
    1213}
  • trunk/fon/fonbase/files/lib/fon/config.sh

    r2129 r2143  
    573573}
    574574
     575config_timezone() {
     576        config_get timezone advanced timezone
     577        if [ -n "$timezone" ]; then
     578                tzdesc=$(cat /etc/timezones.db | awk "\$1 == \"$timezone\" {print \$2}")
     579                # /etc/init.d/boot takes care of putting this in /etc/TZ
     580                uci_set "system" "@system[0]" "timezone" "$tzdesc"
     581                uci commit system
     582        fi
     583}
     584
    575585load_config
    576586
     
    588598        3g) config_umts;;
    589599        switch) config_switch;;
     600        timezone) config_timezone;;
    590601        *) true;;
    591602esac
  • trunk/luci/modules/admin-fon/luasrc/model/cbi/fon_lang/main.lua

    r35 r2143  
    3434        l:value("auto", translate("disc_auto", "Automatic"))
    3535end
    36 return m
     36
     37n = Map("fon",
     38        translate("timezone_title", "Timezone Settings"),
     39        translate("timezone_title", "Here you can select your timezone. A timezone change needs a reboot to take effect. The time is automatically synchronized when an internet connection is available."))
     40
     41-- Offer changing the timezone. Note that this does not update the
     42-- system config timezone setting (which is processed by
     43-- /etc/init.d/boot) directly, but instead changes a setting in the fon
     44-- config which is applied to the system config by /lib/fon/config.sh.
     45-- This is because the system config expects a timezone descriptor
     46-- (e.g., CET-1CEST,M3.5.0,M10.5.0/3) while the interface should offer
     47-- timezone names (e.g Europe/Amsterdam) and because the timezone
     48-- descriptors are not unique (so if we're just storing the timezone
     49-- descriptor, we can't tell which timezone the user selected exactly).
     50--
     51-- This approach has the added advantage that timezone settings are not
     52-- applied until after a reboot, which guarantees the new timezone is
     53-- applied consistently (otherwise, running programs would not pick up
     54-- the new timezone, while new programs would).
     55c = n:section(NamedSection, "advanced")
     56l = c:option(ListValue, "timezone", translate("timezone", "Timezone"), translate("current_time_is", "The current time is: ") .. os.date("%Y.%m.%d %k:%M %Z"))
     57
     58local util = require "luci.util"
     59local timezones = io.open((os.getenv("LUCI_SYSROOT") or "") .. "/etc/timezones.db", "r")
     60l.default = "UTC"
     61while true do
     62        local line = timezones:read("*line")
     63        if not line then break end
     64        if line ~= "" and line:sub(1,1) ~= "#" then
     65                split = line:split(" ", 2)
     66                l:value(split[1], split[1])
     67        end
     68end
     69
     70return m,n
Note: See TracChangeset for help on using the changeset viewer.