Install a moduli(5) manual page.
[dragonfly.git] / contrib / bsdinstaller-1.1.6 / src / backend / lua / configure / menu / 300_set_timezone.lua
1 -- $Id: 300_set_timezone.lua,v 1.3 2005/02/24 23:08:03 cpressey Exp $
2
3 require "gettext"
4
5 local set_timezone = function()
6         local cmds, files, dir, filename, full_filename, found_file
7
8         if App.ui:present({
9             id = "internal_clock_type",
10             name = _("Local or UTC (Greenwich Mean Time) clock"),
11             short_desc = _(
12                 "Is this machine's internal clock set to local time " ..
13                 "or UTC (Universal Coordinated Time, roughly the same " ..
14                 "as Greenwich Mean Time)?\n\n" ..
15                 "If you don't know, assume local time for now."
16             ),
17
18             actions = {
19                 {
20                     id = "local",
21                     name = _("Local Time")
22                 },
23                 {
24                     id = "utc",
25                     name = _("UTC Time")
26                 }
27             }
28         }).action_id == "utc" then
29                 cmds = CmdChain.new()
30
31                 cmds:add({
32                     cmdline = "${root}${TOUCH} ${root}${base}etc/wall_cmos_clock",
33                     replacements = {
34                         base = App.state.target:get_base()
35                     }
36                 })
37                 cmds:execute()
38         end
39
40         --
41         -- Select a file.
42         --
43         dir = App.expand("${root}${base}usr/share/zoneinfo",
44             {
45                 base = App.state.target:get_base()
46             }
47         )
48
49         found_file = false
50         while not found_file do
51                 filename = App.ui:select_file{
52                     title = _("Select Time Zone"),
53                     short_desc = _("Select a Time Zone appropriate to your physical location."),
54                     cancel_desc = _("Return to Utilities Menu"),
55                     dir = dir
56                 }
57                 if filename == "cancel" then
58                         return false
59                 end
60                 full_filename = dir .. "/" .. filename
61                 if FileSystem.is_dir(full_filename) then
62                         dir = full_filename
63                 else
64                         filename = full_filename
65                         found_file = true
66                 end
67         end
68
69         cmds = CmdChain.new()
70         cmds:add({
71             cmdline = "${root}${CP} ${filename} ${root}${base}etc/localtime",
72             replacements = {
73                 filename = filename,
74                 base = App.state.target:get_base()
75             }
76         })
77         if cmds:execute() then
78                 App.ui:inform(_(
79                     "The Time Zone has been successfully set to %s.",
80                     filename
81                 ))
82         end
83 end
84
85 return {
86     name = _("Set Timezone"),
87     effect = function()
88         set_timezone()
89         return Menu.CONTINUE
90     end
91 }