1641a6cfbSDevin Teske#!/bin/sh 2641a6cfbSDevin Teske#- 3*fb1f1beeSDevin Teske# Copyright (c) 2011-2015 Devin Teske 4f8ea072aSDevin Teske# All rights reserved. 5641a6cfbSDevin Teske# 6641a6cfbSDevin Teske# Redistribution and use in source and binary forms, with or without 7641a6cfbSDevin Teske# modification, are permitted provided that the following conditions 8641a6cfbSDevin Teske# are met: 9641a6cfbSDevin Teske# 1. Redistributions of source code must retain the above copyright 10641a6cfbSDevin Teske# notice, this list of conditions and the following disclaimer. 11641a6cfbSDevin Teske# 2. Redistributions in binary form must reproduce the above copyright 12641a6cfbSDevin Teske# notice, this list of conditions and the following disclaimer in the 13641a6cfbSDevin Teske# documentation and/or other materials provided with the distribution. 14641a6cfbSDevin Teske# 15641a6cfbSDevin Teske# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 168e37a7c8SDevin Teske# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17641a6cfbSDevin Teske# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18641a6cfbSDevin Teske# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19641a6cfbSDevin Teske# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 208e37a7c8SDevin Teske# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21641a6cfbSDevin Teske# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22641a6cfbSDevin Teske# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23641a6cfbSDevin Teske# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24641a6cfbSDevin Teske# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25641a6cfbSDevin Teske# SUCH DAMAGE. 26641a6cfbSDevin Teske# 27641a6cfbSDevin Teske# 28641a6cfbSDevin Teske############################################################ INCLUDES 29641a6cfbSDevin Teske 30ab2043b8SDevin TeskeBSDCFG_SHARE="/usr/share/bsdconfig" 31ab2043b8SDevin Teske. $BSDCFG_SHARE/common.subr || exit 1 3256961fd7SDevin Teskef_dprintf "%s: loading includes..." "$0" 33ab2043b8SDevin Teskef_include $BSDCFG_SHARE/dialog.subr 34ab2043b8SDevin Teskef_include $BSDCFG_SHARE/mustberoot.subr 35ab2043b8SDevin Teskef_include $BSDCFG_SHARE/strings.subr 36ab2043b8SDevin Teskef_include $BSDCFG_SHARE/timezone/continents.subr 37ab2043b8SDevin Teskef_include $BSDCFG_SHARE/timezone/countries.subr 38ab2043b8SDevin Teskef_include $BSDCFG_SHARE/timezone/iso3166.subr 39ab2043b8SDevin Teskef_include $BSDCFG_SHARE/timezone/menus.subr 40ab2043b8SDevin Teskef_include $BSDCFG_SHARE/timezone/zones.subr 41641a6cfbSDevin Teske 42ab2043b8SDevin TeskeBSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="090.timezone" 43641a6cfbSDevin Teskef_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr 44641a6cfbSDevin Teske 45d4ae33f0SDevin Teskef_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm && 46d4ae33f0SDevin Teske pgm="${ipgm:-$pgm}" 47641a6cfbSDevin Teske 48641a6cfbSDevin Teske############################################################ CONFIGURATION 49641a6cfbSDevin Teske 50641a6cfbSDevin Teske# 51641a6cfbSDevin Teske# Standard pathnames 52641a6cfbSDevin Teske# 53641a6cfbSDevin Teske_PATH_DB="/var/db/zoneinfo" 54641a6cfbSDevin Teske_PATH_WALL_CMOS_CLOCK="/etc/wall_cmos_clock" 55641a6cfbSDevin Teske 56641a6cfbSDevin Teske############################################################ GLOBALS 57641a6cfbSDevin Teske 58641a6cfbSDevin Teske# 59641a6cfbSDevin Teske# Options 60641a6cfbSDevin Teske# 61641a6cfbSDevin TeskeREALLYDOIT=1 62641a6cfbSDevin TeskeREINSTALL= 63641a6cfbSDevin TeskeUSEDIALOG=1 64e91afc1cSDevin TeskeSKIPUTC= # See MAIN 65641a6cfbSDevin TeskeVERBOSE= 66641a6cfbSDevin TeskeTZ_OR_FAIL= 67641a6cfbSDevin TeskeCHROOTENV= 68641a6cfbSDevin Teske 69641a6cfbSDevin Teske# 70641a6cfbSDevin Teske# Dummy vars (populated dynamically) 71641a6cfbSDevin Teske# 72641a6cfbSDevin TeskeCOUNTRIES= # list of 2-character country codes created by f_read_iso3166_table 73641a6cfbSDevin Teske 74641a6cfbSDevin Teske############################################################ FUNCTIONS 75641a6cfbSDevin Teske 76641a6cfbSDevin Teske# dialog_menu_main 77641a6cfbSDevin Teske# 78641a6cfbSDevin Teske# Display the dialog(1)-based application main menu. 79641a6cfbSDevin Teske# 80641a6cfbSDevin Teskedialog_menu_main() 81641a6cfbSDevin Teske{ 82641a6cfbSDevin Teske local title="$DIALOG_TITLE" 83641a6cfbSDevin Teske local btitle="$DIALOG_BACKTITLE" 84641a6cfbSDevin Teske local prompt="$msg_select_region" 8577599778SDevin Teske local defaultitem= # Calculated below 86052f8969SDevin Teske local hline= 87641a6cfbSDevin Teske 8874036c4dSDevin Teske local height width rows 8974036c4dSDevin Teske eval f_dialog_menu_size height width rows \ 90641a6cfbSDevin Teske \"\$title\" \ 91641a6cfbSDevin Teske \"\$btitle\" \ 92641a6cfbSDevin Teske \"\$prompt\" \ 93052f8969SDevin Teske \"\$hline\" \ 9474036c4dSDevin Teske $continent_menu_list 95641a6cfbSDevin Teske 9677599778SDevin Teske # Obtain default-item from previously stored selection 9777599778SDevin Teske f_dialog_default_fetch defaultitem 9877599778SDevin Teske 99fd962ac6SDevin Teske local menu_choice 100fd962ac6SDevin Teske menu_choice=$( eval $DIALOG \ 101641a6cfbSDevin Teske --title \"\$title\" \ 102641a6cfbSDevin Teske --backtitle \"\$btitle\" \ 103052f8969SDevin Teske --hline \"\$hline\" \ 104641a6cfbSDevin Teske --ok-label \"\$msg_ok\" \ 105641a6cfbSDevin Teske --cancel-label \"\$msg_cancel\" \ 10677599778SDevin Teske --default-item \"\$defaultitem\" \ 10774036c4dSDevin Teske --menu \"\$prompt\" \ 10874036c4dSDevin Teske $height $width $rows \ 109641a6cfbSDevin Teske $continent_menu_list \ 11089498fdfSDevin Teske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 11189498fdfSDevin Teske ) 11289498fdfSDevin Teske local retval=$? 113fd962ac6SDevin Teske f_dialog_data_sanitize menu_choice 114fd962ac6SDevin Teske f_dialog_menutag_store "$menu_choice" 11577599778SDevin Teske f_dialog_default_store "$menu_choice" 11689498fdfSDevin Teske return $retval 117641a6cfbSDevin Teske} 118641a6cfbSDevin Teske 119641a6cfbSDevin Teske############################################################ MAIN 120641a6cfbSDevin Teske 121e91afc1cSDevin Teske# Skip initial question regarding UTC v. Wall-Clock time if run in VM 122e91afc1cSDevin Teske[ "$( sysctl -n kern.vm_guest 2> /dev/null )" = "none" ] || SKIPUTC=1 123e91afc1cSDevin Teske 124641a6cfbSDevin Teske# Incorporate rc-file if it exists 125641a6cfbSDevin Teske[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc" 126641a6cfbSDevin Teske 127641a6cfbSDevin Teske# 128641a6cfbSDevin Teske# Process command-line arguments 129641a6cfbSDevin Teske# 130c3755aa3SDevin Teskewhile getopts C:ehnrsv$GETOPTS_STDARGS flag; do 131641a6cfbSDevin Teske case "$flag" in 132641a6cfbSDevin Teske C) CHROOTENV="$OPTARG" ;; 133641a6cfbSDevin Teske e) TZ_OR_FAIL=1 ;; 134641a6cfbSDevin Teske n) REALLYDOIT= ;; 135641a6cfbSDevin Teske r) REINSTALL=1 136641a6cfbSDevin Teske USEDIALOG= ;; 137641a6cfbSDevin Teske s) SKIPUTC=1 ;; 138641a6cfbSDevin Teske v) VERBOSE=1 ;; 139641a6cfbSDevin Teske h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm" ;; 140641a6cfbSDevin Teske esac 141641a6cfbSDevin Teskedone 142641a6cfbSDevin Teskeshift $(( $OPTIND - 1 )) 143641a6cfbSDevin Teske 144641a6cfbSDevin Teske# 145641a6cfbSDevin Teske# Initialize 146641a6cfbSDevin Teske# 147641a6cfbSDevin Teskef_dialog_title "$msg_time_zone" 148641a6cfbSDevin Teskef_dialog_backtitle "${ipgm:+bsdconfig }$pgm" 149641a6cfbSDevin Teskef_mustberoot_init 150641a6cfbSDevin Teske 151641a6cfbSDevin Teske# 152641a6cfbSDevin Teske# Process `-C chroot_directory' command-line argument 153641a6cfbSDevin Teske# 154641a6cfbSDevin Teskeif [ "$CHROOTENV" ]; then 155641a6cfbSDevin Teske _PATH_ZONETAB="$CHROOTENV$_PATH_ZONETAB" 156641a6cfbSDevin Teske _PATH_ISO3166="$CHROOTENV$_PATH_ISO3166" 157641a6cfbSDevin Teske _PATH_ZONEINFO="$CHROOTENV$_PATH_ZONEINFO" 158641a6cfbSDevin Teske _PATH_LOCALTIME="$CHROOTENV$_PATH_LOCALTIME" 159641a6cfbSDevin Teske _PATH_DB="$CHROOTENV$_PATH_DB" 160641a6cfbSDevin Teske _PATH_WALL_CMOS_CLOCK="$CHROOTENV$_PATH_WALL_CMOS_CLOCK" 161641a6cfbSDevin Teskefi 162641a6cfbSDevin Teske 163641a6cfbSDevin Teske# 164641a6cfbSDevin Teske# Process `-r' command-line option 165641a6cfbSDevin Teske# 166641a6cfbSDevin Teskeif [ "$REINSTALL" ]; then 167641a6cfbSDevin Teske [ -f "$_PATH_DB" -a -r "$_PATH_DB" ] || 168641a6cfbSDevin Teske f_die 1 "$msg_cannot_open_for_reading" "$_PATH_DB" 169d4ae33f0SDevin Teske f_eval_catch -dk zoneinfo "$0" cat 'cat "%s"' "$_PATH_DB" || 170641a6cfbSDevin Teske f_die 1 "$msg_error_reading" "$_PATH_DB" 171641a6cfbSDevin Teske [ "$zoneinfo" ] || 172641a6cfbSDevin Teske f_die 1 "$msg_unable_to_determine_name_from_db" "$_PATH_DB" 173641a6cfbSDevin Teske f_install_zoneinfo "$zoneinfo" 174641a6cfbSDevin Teske exit $? 175641a6cfbSDevin Teskefi 176641a6cfbSDevin Teske 177641a6cfbSDevin Teske# 178641a6cfbSDevin Teske# If the arguments on the command-line do not specify a file, 179641a6cfbSDevin Teske# then interpret it as a zoneinfo name 180641a6cfbSDevin Teske# 181641a6cfbSDevin Teskeif [ $# -ge 1 ]; then 182641a6cfbSDevin Teske zoneinfo="$1" 183641a6cfbSDevin Teske 184641a6cfbSDevin Teske if [ ! -f "$zoneinfo" ]; then 185641a6cfbSDevin Teske USEDIALOG= 186641a6cfbSDevin Teske f_install_zoneinfo "$zoneinfo" 187641a6cfbSDevin Teske exit $? 188641a6cfbSDevin Teske fi 189641a6cfbSDevin Teske 190641a6cfbSDevin Teske # FALLTHROUGH 191641a6cfbSDevin Teskefi 192641a6cfbSDevin Teske 193641a6cfbSDevin Teske# 194641a6cfbSDevin Teske# Process the UTC option 195641a6cfbSDevin Teske# 196641a6cfbSDevin Teskeif [ "$_PATH_WALL_CMOS_CLOCK" -a ! "$SKIPUTC" ]; then 197641a6cfbSDevin Teske f_dialog_title "$msg_select_local_or_utc" 198641a6cfbSDevin Teske title="$DIALOG_TITLE" 199641a6cfbSDevin Teske btitle="$DIALOG_BACKTITLE" 200641a6cfbSDevin Teske f_dialog_title_restore 201641a6cfbSDevin Teske msg="$msg_is_machine_clock_utc" 202641a6cfbSDevin Teske 203641a6cfbSDevin Teske if [ "$USE_XDIALOG" ]; then 204641a6cfbSDevin Teske defaultno="default-no" 205641a6cfbSDevin Teske height=10 width=77 206641a6cfbSDevin Teske else 207641a6cfbSDevin Teske defaultno="defaultno" 208641a6cfbSDevin Teske height=7 width=73 209641a6cfbSDevin Teske fi 210641a6cfbSDevin Teske 211641a6cfbSDevin Teske if [ "$USE_XDIALOG" ]; then 212641a6cfbSDevin Teske $DIALOG \ 213641a6cfbSDevin Teske --title "$title" \ 214641a6cfbSDevin Teske --backtitle "$btitle" \ 215641a6cfbSDevin Teske --$defaultno \ 216641a6cfbSDevin Teske --ok-label "$msg_yes" \ 217641a6cfbSDevin Teske --cancel-label "$msg_no" \ 218641a6cfbSDevin Teske --yesno "$msg" $height $width 219641a6cfbSDevin Teske result=$? 220641a6cfbSDevin Teske else 221641a6cfbSDevin Teske $DIALOG \ 222641a6cfbSDevin Teske --title "$title" \ 223641a6cfbSDevin Teske --backtitle "$btitle" \ 224641a6cfbSDevin Teske --$defaultno \ 225641a6cfbSDevin Teske --yes-label "$msg_yes" \ 226641a6cfbSDevin Teske --no-label "$msg_no" \ 227641a6cfbSDevin Teske --yesno "$msg" $height $width 228641a6cfbSDevin Teske result=$? 229641a6cfbSDevin Teske fi 230641a6cfbSDevin Teske 231f677a9e2SDevin Teske if [ $result -eq $DIALOG_OK ]; then 232641a6cfbSDevin Teske # User chose YES 233641a6cfbSDevin Teske [ "$REALLYDOIT" ] && 234641a6cfbSDevin Teske f_quietly rm -f "$_PATH_WALL_CMOS_CLOCK" 235641a6cfbSDevin Teske else 236641a6cfbSDevin Teske # User chose NO, pressed ESC (or Ctrl-C), or closed box 237641a6cfbSDevin Teske [ "$REALLYDOIT" ] && 238641a6cfbSDevin Teske ( umask 222 && :> "$_PATH_WALL_CMOS_CLOCK" ) 239641a6cfbSDevin Teske fi 240641a6cfbSDevin Teskefi 241641a6cfbSDevin Teske 242641a6cfbSDevin Teske# 243641a6cfbSDevin Teske# Process optional default zone argument 244641a6cfbSDevin Teske# 245641a6cfbSDevin Teskeif [ $# -ge 1 ]; then 246641a6cfbSDevin Teske default="$1" 247641a6cfbSDevin Teske 248641a6cfbSDevin Teske f_dialog_title "$msg_default_zone_provided" 249d4ae33f0SDevin Teske f_sprintf msg "\n$msg_use_default_zone" "$default" 250b17d3670SDevin Teske hline= 251b17d3670SDevin Teske f_dialog_yesno "$msg" "$hline" 252641a6cfbSDevin Teske result=$? 253b17d3670SDevin Teske f_dialog_title_restore 254641a6cfbSDevin Teske 255f677a9e2SDevin Teske if [ $result -eq $DIALOG_OK ]; then 256641a6cfbSDevin Teske # User chose YES 257641a6cfbSDevin Teske f_install_zoneinfo_file "$default" 258641a6cfbSDevin Teske result=$? 259641a6cfbSDevin Teske [ ! "$USE_XDIALOG" ] && f_dialog_clear 260641a6cfbSDevin Teske exit $result 261641a6cfbSDevin Teske fi 262641a6cfbSDevin Teske 263641a6cfbSDevin Teske [ ! "$USE_XDIALOG" ] && f_dialog_clear 264641a6cfbSDevin Teskefi 265641a6cfbSDevin Teske 266641a6cfbSDevin Teske# 267641a6cfbSDevin Teske# Override the user-supplied umask 268641a6cfbSDevin Teske# 269641a6cfbSDevin Teskeumask 022 270641a6cfbSDevin Teske 271641a6cfbSDevin Teske# 272641a6cfbSDevin Teske# Read databases and perform initialization 273641a6cfbSDevin Teske# 274641a6cfbSDevin Teskef_read_iso3166_table # creates $COUNTRIES and $country_*_name 275641a6cfbSDevin Teskef_read_zones # creates $country_*_{descr,cont,filename} 276641a6cfbSDevin Teskef_sort_countries # sorts the countries listed for each continent 277641a6cfbSDevin Teskef_make_menus # creates $continent_menu_list and $continent_*_menu_list 278641a6cfbSDevin Teske 279641a6cfbSDevin Teske# 280641a6cfbSDevin Teske# Launch application main menu 281641a6cfbSDevin Teske# 282*fb1f1beeSDevin Teskedefaultctry= 283*fb1f1beeSDevin Teskedefaultzone= 284641a6cfbSDevin TeskeNEED_CONTINENT=1 285641a6cfbSDevin TeskeNEED_COUNTRY=1 286641a6cfbSDevin Teskewhile :; do 287641a6cfbSDevin Teske if [ "$NEED_CONTINENT" ]; then 288641a6cfbSDevin Teske dialog_menu_main # prompt the user to select a continent/ocean 289641a6cfbSDevin Teske retval=$? 290fd962ac6SDevin Teske f_dialog_menutag_fetch mtag 291641a6cfbSDevin Teske 292f677a9e2SDevin Teske if [ $retval -ne $DIALOG_OK ]; then 293641a6cfbSDevin Teske [ "$TZ_OR_FAIL" ] && f_die 294641a6cfbSDevin Teske exit $SUCCESS 295641a6cfbSDevin Teske fi 296641a6cfbSDevin Teske 297641a6cfbSDevin Teske NEED_CONTINENT= 298641a6cfbSDevin Teske 299641a6cfbSDevin Teske continent=$( eval f_dialog_menutag2item \"\$mtag\" \ 300641a6cfbSDevin Teske $continent_menu_list ) 301*fb1f1beeSDevin Teske f_find_continent "$continent" cont 302*fb1f1beeSDevin Teske f_continent $cont title cont_title 303*fb1f1beeSDevin Teske f_continent $cont nitems nitems 304*fb1f1beeSDevin Teske f_OCEANP $cont isocean 305641a6cfbSDevin Teske fi 306641a6cfbSDevin Teske 307641a6cfbSDevin Teske if [ "$NEED_COUNTRY" ]; then 308641a6cfbSDevin Teske if [ "$cont_title" = "$continent_utc_title" ]; then 309641a6cfbSDevin Teske if f_set_zone_utc; then 310641a6cfbSDevin Teske break 311641a6cfbSDevin Teske else 312641a6cfbSDevin Teske NEED_CONTINENT=1 313641a6cfbSDevin Teske continue 314641a6cfbSDevin Teske fi 315641a6cfbSDevin Teske fi 316641a6cfbSDevin Teske 317641a6cfbSDevin Teske # 318641a6cfbSDevin Teske # Short cut -- if there's only one country, don't post a menu. 319641a6cfbSDevin Teske # 320641a6cfbSDevin Teske if [ $nitems -eq 1 ]; then 321641a6cfbSDevin Teske tag=1 322641a6cfbSDevin Teske else 323641a6cfbSDevin Teske # 324641a6cfbSDevin Teske # It's amazing how much good grammar really matters... 325641a6cfbSDevin Teske # 326641a6cfbSDevin Teske if [ ! "$isocean" ]; then 327d4ae33f0SDevin Teske f_sprintf title "$msg_country_title" \ 328d4ae33f0SDevin Teske "$cont_title" 329641a6cfbSDevin Teske f_dialog_title "$title" 330641a6cfbSDevin Teske title="$DIALOG_TITLE" 331641a6cfbSDevin Teske btitle="$DIALOG_BACKTITLE" 332641a6cfbSDevin Teske f_dialog_title_restore 333641a6cfbSDevin Teske prompt="$msg_select_country" 334641a6cfbSDevin Teske else 335d4ae33f0SDevin Teske f_sprintf title "$msg_island_and_group_title" \ 336d4ae33f0SDevin Teske "$cont_title" 337641a6cfbSDevin Teske f_dialog_title "$title" 338641a6cfbSDevin Teske title="$DIALOG_TITLE" 339641a6cfbSDevin Teske btitle="$DIALOG_BACKTITLE" 340641a6cfbSDevin Teske f_dialog_title_restore 341641a6cfbSDevin Teske prompt="$msg_select_island_or_group" 342641a6cfbSDevin Teske fi 343641a6cfbSDevin Teske 344641a6cfbSDevin Teske # 345641a6cfbSDevin Teske # Calculate size of menu 346641a6cfbSDevin Teske # 347*fb1f1beeSDevin Teske f_continent $cont menu_list menu_list 34874036c4dSDevin Teske eval f_dialog_menu_size height width rows \ 349641a6cfbSDevin Teske \"\$title\" \ 350641a6cfbSDevin Teske \"\$btitle\" \ 351641a6cfbSDevin Teske \"\$prompt\" \ 352641a6cfbSDevin Teske \"\" \ 35374036c4dSDevin Teske $menu_list 354641a6cfbSDevin Teske 355641a6cfbSDevin Teske # 356641a6cfbSDevin Teske # Launch the country selection menu 357641a6cfbSDevin Teske # 358fd962ac6SDevin Teske tag=$( eval $DIALOG \ 359641a6cfbSDevin Teske --title \"\$title\" \ 360641a6cfbSDevin Teske --backtitle \"\$btitle\" \ 361641a6cfbSDevin Teske --ok-label \"\$msg_ok\" \ 362641a6cfbSDevin Teske --cancel-label \"\$msg_cancel\" \ 363d3a0f918SDevin Teske --default-item \"\$defaultctry\" \ 36474036c4dSDevin Teske --menu \"\$prompt\" \ 36574036c4dSDevin Teske $height $width $rows \ 366641a6cfbSDevin Teske $menu_list \ 36789498fdfSDevin Teske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 36889498fdfSDevin Teske ) 369641a6cfbSDevin Teske retval=$? 370fd962ac6SDevin Teske f_dialog_data_sanitize tag 371d3a0f918SDevin Teske defaultctry="$tag" 372641a6cfbSDevin Teske 373f677a9e2SDevin Teske if [ $retval -ne $DIALOG_OK ]; then 374641a6cfbSDevin Teske NEED_CONTINENT=1 375641a6cfbSDevin Teske continue # back to main menu 376641a6cfbSDevin Teske fi 377641a6cfbSDevin Teske fi 378641a6cfbSDevin Teske 379641a6cfbSDevin Teske # Get the country code from the user's selection 380*fb1f1beeSDevin Teske f_continent $cont tlc_$tag tlc 381641a6cfbSDevin Teske 382641a6cfbSDevin Teske NEED_COUNTRY= 383641a6cfbSDevin Teske fi 384641a6cfbSDevin Teske 385641a6cfbSDevin Teske # 386641a6cfbSDevin Teske # If the selection has only one zone (nzones == -1), 387641a6cfbSDevin Teske # just set it. 388641a6cfbSDevin Teske # 389*fb1f1beeSDevin Teske f_country $tlc nzones nzones 390641a6cfbSDevin Teske if [ $nzones -lt 0 ]; then 391*fb1f1beeSDevin Teske f_country $tlc cont real_cont 392*fb1f1beeSDevin Teske f_continent $real_cont name real_continent 393*fb1f1beeSDevin Teske f_country $tlc name name 394*fb1f1beeSDevin Teske f_country $tlc filename filename 395641a6cfbSDevin Teske 396641a6cfbSDevin Teske if ! f_confirm_zone "$real_continent/$filename"; then 397641a6cfbSDevin Teske [ $nitems -eq 1 ] && NEED_CONTINENT=1 398641a6cfbSDevin Teske NEED_COUNTRY=1 399641a6cfbSDevin Teske continue 400641a6cfbSDevin Teske fi 401641a6cfbSDevin Teske else 402*fb1f1beeSDevin Teske f_country $tlc name name 403*fb1f1beeSDevin Teske f_sprintf title "$msg_country_time_zones" "$name" 404641a6cfbSDevin Teske f_dialog_title "$title" 405d4ae33f0SDevin Teske title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE" 406641a6cfbSDevin Teske f_dialog_title_restore 407641a6cfbSDevin Teske prompt="$msg_select_zone" 408*fb1f1beeSDevin Teske f_country $tlc menu_list menu_list 40974036c4dSDevin Teske eval f_dialog_menu_size height width rows \ 41074036c4dSDevin Teske \"\$title\" \"\$btitle\" \"\$prompt\" \"\" $menu_list 411641a6cfbSDevin Teske 412641a6cfbSDevin Teske # 413641a6cfbSDevin Teske # Launch the zone selection menu 414641a6cfbSDevin Teske # NOTE: This is as deep as we go 415641a6cfbSDevin Teske # 416fd962ac6SDevin Teske n=$( eval $DIALOG \ 417641a6cfbSDevin Teske --title \"\$title\" \ 418641a6cfbSDevin Teske --backtitle \"\$btitle\" \ 419641a6cfbSDevin Teske --ok-label \"\$msg_ok\" \ 420641a6cfbSDevin Teske --cancel-label \"\$msg_cancel\" \ 421d3a0f918SDevin Teske --default-item \"\$defaultzone\" \ 42274036c4dSDevin Teske --menu \"\$prompt\" \ 42374036c4dSDevin Teske $height $width $rows \ 424641a6cfbSDevin Teske $menu_list \ 42589498fdfSDevin Teske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 42689498fdfSDevin Teske ) 427641a6cfbSDevin Teske retval=$? 428fd962ac6SDevin Teske f_dialog_data_sanitize n 429d3a0f918SDevin Teske defaultzone="$n" 430641a6cfbSDevin Teske 431f677a9e2SDevin Teske if [ $retval -ne $DIALOG_OK ]; then 432641a6cfbSDevin Teske [ $nitems -eq 1 ] && NEED_CONTINENT=1 433641a6cfbSDevin Teske NEED_COUNTRY=1 434641a6cfbSDevin Teske continue 435641a6cfbSDevin Teske fi 436641a6cfbSDevin Teske 437*fb1f1beeSDevin Teske f_country $tlc cont_$n real_cont 438*fb1f1beeSDevin Teske f_continent $real_cont name real_continent 439*fb1f1beeSDevin Teske f_country $tlc name name 440*fb1f1beeSDevin Teske f_country $tlc filename_$n filename 441641a6cfbSDevin Teske 442641a6cfbSDevin Teske f_confirm_zone "$real_continent/$filename" || continue 443641a6cfbSDevin Teske fi 444641a6cfbSDevin Teske 445f677a9e2SDevin Teske [ $retval -eq $DIALOG_OK ] || continue # back to main menu 446641a6cfbSDevin Teske 447641a6cfbSDevin Teske if ! f_install_zoneinfo "$real_continent/$filename"; then 448641a6cfbSDevin Teske [ $nzones -lt 0 ] && NEED_COUNTRY=1 449641a6cfbSDevin Teske else 450641a6cfbSDevin Teske break 451641a6cfbSDevin Teske fi 452641a6cfbSDevin Teskedone 453641a6cfbSDevin Teske 454641a6cfbSDevin Teske################################################################################ 455641a6cfbSDevin Teske# END 456641a6cfbSDevin Teske################################################################################ 457