timezone (252995) | timezone (263791) |
---|---|
1#!/bin/sh 2#- 3# Copyright (c) 2011-2013 Devin Teske 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: --- 10 unchanged lines hidden (view full) --- 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# | 1#!/bin/sh 2#- 3# Copyright (c) 2011-2013 Devin Teske 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: --- 10 unchanged lines hidden (view full) --- 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# |
27# $FreeBSD: stable/9/usr.sbin/bsdconfig/timezone/timezone 252995 2013-07-07 19:13:34Z dteske $ | 27# $FreeBSD: stable/9/usr.sbin/bsdconfig/timezone/timezone 263791 2014-03-27 03:20:47Z dteske $ |
28# 29############################################################ INCLUDES 30 31BSDCFG_SHARE="/usr/share/bsdconfig" 32. $BSDCFG_SHARE/common.subr || exit 1 33f_dprintf "%s: loading includes..." "$0" 34f_include $BSDCFG_SHARE/dialog.subr 35f_include $BSDCFG_SHARE/mustberoot.subr 36f_include $BSDCFG_SHARE/strings.subr 37f_include $BSDCFG_SHARE/timezone/continents.subr 38f_include $BSDCFG_SHARE/timezone/countries.subr 39f_include $BSDCFG_SHARE/timezone/iso3166.subr 40f_include $BSDCFG_SHARE/timezone/menus.subr 41f_include $BSDCFG_SHARE/timezone/zones.subr 42 43BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="090.timezone" 44f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr 45 | 28# 29############################################################ INCLUDES 30 31BSDCFG_SHARE="/usr/share/bsdconfig" 32. $BSDCFG_SHARE/common.subr || exit 1 33f_dprintf "%s: loading includes..." "$0" 34f_include $BSDCFG_SHARE/dialog.subr 35f_include $BSDCFG_SHARE/mustberoot.subr 36f_include $BSDCFG_SHARE/strings.subr 37f_include $BSDCFG_SHARE/timezone/continents.subr 38f_include $BSDCFG_SHARE/timezone/countries.subr 39f_include $BSDCFG_SHARE/timezone/iso3166.subr 40f_include $BSDCFG_SHARE/timezone/menus.subr 41f_include $BSDCFG_SHARE/timezone/zones.subr 42 43BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="090.timezone" 44f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr 45 |
46ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ) 47[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm" | 46f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm && 47 pgm="${ipgm:-$pgm}" |
48 49############################################################ CONFIGURATION 50 51# 52# Standard pathnames 53# 54_PATH_DB="/var/db/zoneinfo" 55_PATH_WALL_CMOS_CLOCK="/etc/wall_cmos_clock" --- 103 unchanged lines hidden (view full) --- 159fi 160 161# 162# Process `-r' command-line option 163# 164if [ "$REINSTALL" ]; then 165 [ -f "$_PATH_DB" -a -r "$_PATH_DB" ] || 166 f_die 1 "$msg_cannot_open_for_reading" "$_PATH_DB" | 48 49############################################################ CONFIGURATION 50 51# 52# Standard pathnames 53# 54_PATH_DB="/var/db/zoneinfo" 55_PATH_WALL_CMOS_CLOCK="/etc/wall_cmos_clock" --- 103 unchanged lines hidden (view full) --- 159fi 160 161# 162# Process `-r' command-line option 163# 164if [ "$REINSTALL" ]; then 165 [ -f "$_PATH_DB" -a -r "$_PATH_DB" ] || 166 f_die 1 "$msg_cannot_open_for_reading" "$_PATH_DB" |
167 zoneinfo=$( cat "$_PATH_DB" ) || | 167 f_eval_catch -dk zoneinfo "$0" cat 'cat "%s"' "$_PATH_DB" || |
168 f_die 1 "$msg_error_reading" "$_PATH_DB" 169 [ "$zoneinfo" ] || 170 f_die 1 "$msg_unable_to_determine_name_from_db" "$_PATH_DB" 171 f_install_zoneinfo "$zoneinfo" 172 exit $? 173fi 174 175# --- 45 unchanged lines hidden (view full) --- 221 --backtitle "$btitle" \ 222 --$defaultno \ 223 --yes-label "$msg_yes" \ 224 --no-label "$msg_no" \ 225 --yesno "$msg" $height $width 226 result=$? 227 fi 228 | 168 f_die 1 "$msg_error_reading" "$_PATH_DB" 169 [ "$zoneinfo" ] || 170 f_die 1 "$msg_unable_to_determine_name_from_db" "$_PATH_DB" 171 f_install_zoneinfo "$zoneinfo" 172 exit $? 173fi 174 175# --- 45 unchanged lines hidden (view full) --- 221 --backtitle "$btitle" \ 222 --$defaultno \ 223 --yes-label "$msg_yes" \ 224 --no-label "$msg_no" \ 225 --yesno "$msg" $height $width 226 result=$? 227 fi 228 |
229 if [ $result -eq 0 ]; then | 229 if [ $result -eq $DIALOG_OK ]; then |
230 # User chose YES 231 [ "$REALLYDOIT" ] && 232 f_quietly rm -f "$_PATH_WALL_CMOS_CLOCK" 233 else 234 # User chose NO, pressed ESC (or Ctrl-C), or closed box 235 [ "$REALLYDOIT" ] && 236 ( umask 222 && :> "$_PATH_WALL_CMOS_CLOCK" ) 237 fi 238fi 239 240# 241# Process optional default zone argument 242# 243if [ $# -ge 1 ]; then 244 default="$1" 245 246 f_dialog_title "$msg_default_zone_provided" | 230 # User chose YES 231 [ "$REALLYDOIT" ] && 232 f_quietly rm -f "$_PATH_WALL_CMOS_CLOCK" 233 else 234 # User chose NO, pressed ESC (or Ctrl-C), or closed box 235 [ "$REALLYDOIT" ] && 236 ( umask 222 && :> "$_PATH_WALL_CMOS_CLOCK" ) 237 fi 238fi 239 240# 241# Process optional default zone argument 242# 243if [ $# -ge 1 ]; then 244 default="$1" 245 246 f_dialog_title "$msg_default_zone_provided" |
247 msg=$( printf "\n$msg_use_default_zone" "$default" ) | 247 f_sprintf msg "\n$msg_use_default_zone" "$default" |
248 hline= 249 f_dialog_yesno "$msg" "$hline" 250 result=$? 251 f_dialog_title_restore 252 | 248 hline= 249 f_dialog_yesno "$msg" "$hline" 250 result=$? 251 f_dialog_title_restore 252 |
253 if [ $result -eq 0 ]; then | 253 if [ $result -eq $DIALOG_OK ]; then |
254 # User chose YES 255 f_install_zoneinfo_file "$default" 256 result=$? 257 [ ! "$USE_XDIALOG" ] && f_dialog_clear 258 exit $result 259 fi 260 261 [ ! "$USE_XDIALOG" ] && f_dialog_clear --- 20 unchanged lines hidden (view full) --- 282NEED_CONTINENT=1 283NEED_COUNTRY=1 284while :; do 285 if [ "$NEED_CONTINENT" ]; then 286 dialog_menu_main # prompt the user to select a continent/ocean 287 retval=$? 288 f_dialog_menutag_fetch mtag 289 | 254 # User chose YES 255 f_install_zoneinfo_file "$default" 256 result=$? 257 [ ! "$USE_XDIALOG" ] && f_dialog_clear 258 exit $result 259 fi 260 261 [ ! "$USE_XDIALOG" ] && f_dialog_clear --- 20 unchanged lines hidden (view full) --- 282NEED_CONTINENT=1 283NEED_COUNTRY=1 284while :; do 285 if [ "$NEED_CONTINENT" ]; then 286 dialog_menu_main # prompt the user to select a continent/ocean 287 retval=$? 288 f_dialog_menutag_fetch mtag 289 |
290 if [ $retval -ne 0 ]; then | 290 if [ $retval -ne $DIALOG_OK ]; then |
291 [ "$TZ_OR_FAIL" ] && f_die 292 exit $SUCCESS 293 fi 294 295 NEED_CONTINENT= 296 297 continent=$( eval f_dialog_menutag2item \"\$mtag\" \ 298 $continent_menu_list ) --- 18 unchanged lines hidden (view full) --- 317 # 318 if [ $nitems -eq 1 ]; then 319 tag=1 320 else 321 # 322 # It's amazing how much good grammar really matters... 323 # 324 if [ ! "$isocean" ]; then | 291 [ "$TZ_OR_FAIL" ] && f_die 292 exit $SUCCESS 293 fi 294 295 NEED_CONTINENT= 296 297 continent=$( eval f_dialog_menutag2item \"\$mtag\" \ 298 $continent_menu_list ) --- 18 unchanged lines hidden (view full) --- 317 # 318 if [ $nitems -eq 1 ]; then 319 tag=1 320 else 321 # 322 # It's amazing how much good grammar really matters... 323 # 324 if [ ! "$isocean" ]; then |
325 title=$( printf "$msg_country_title" \ 326 "$cont_title" ) | 325 f_sprintf title "$msg_country_title" \ 326 "$cont_title" |
327 f_dialog_title "$title" 328 title="$DIALOG_TITLE" 329 btitle="$DIALOG_BACKTITLE" 330 f_dialog_title_restore 331 prompt="$msg_select_country" 332 else | 327 f_dialog_title "$title" 328 title="$DIALOG_TITLE" 329 btitle="$DIALOG_BACKTITLE" 330 f_dialog_title_restore 331 prompt="$msg_select_country" 332 else |
333 title=$( printf "$msg_island_and_group_title" \ 334 "$cont_title" ) | 333 f_sprintf title "$msg_island_and_group_title" \ 334 "$cont_title" |
335 f_dialog_title "$title" 336 title="$DIALOG_TITLE" 337 btitle="$DIALOG_BACKTITLE" 338 f_dialog_title_restore 339 prompt="$msg_select_island_or_group" 340 fi 341 342 # --- 20 unchanged lines hidden (view full) --- 363 $height $width $rows \ 364 $menu_list \ 365 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 366 ) 367 retval=$? 368 f_dialog_data_sanitize tag 369 defaultctry="$tag" 370 | 335 f_dialog_title "$title" 336 title="$DIALOG_TITLE" 337 btitle="$DIALOG_BACKTITLE" 338 f_dialog_title_restore 339 prompt="$msg_select_island_or_group" 340 fi 341 342 # --- 20 unchanged lines hidden (view full) --- 363 $height $width $rows \ 364 $menu_list \ 365 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 366 ) 367 retval=$? 368 f_dialog_data_sanitize tag 369 defaultctry="$tag" 370 |
371 if [ $retval -ne 0 ]; then | 371 if [ $retval -ne $DIALOG_OK ]; then |
372 NEED_CONTINENT=1 373 continue # back to main menu 374 fi 375 fi 376 377 # Get the country code from the user's selection 378 tlc=$( f_continent $cont tlc_$tag ) 379 --- 12 unchanged lines hidden (view full) --- 392 filename=$( f_country $tlc filename ) 393 394 if ! f_confirm_zone "$real_continent/$filename"; then 395 [ $nitems -eq 1 ] && NEED_CONTINENT=1 396 NEED_COUNTRY=1 397 continue 398 fi 399 else | 372 NEED_CONTINENT=1 373 continue # back to main menu 374 fi 375 fi 376 377 # Get the country code from the user's selection 378 tlc=$( f_continent $cont tlc_$tag ) 379 --- 12 unchanged lines hidden (view full) --- 392 filename=$( f_country $tlc filename ) 393 394 if ! f_confirm_zone "$real_continent/$filename"; then 395 [ $nitems -eq 1 ] && NEED_CONTINENT=1 396 NEED_COUNTRY=1 397 continue 398 fi 399 else |
400 title=$( printf "$msg_country_time_zones" \ 401 "$( f_country $tlc name )" ) | 400 f_sprintf title "$msg_country_time_zones" \ 401 "$( f_country $tlc name )" |
402 f_dialog_title "$title" | 402 f_dialog_title "$title" |
403 title="$DIALOG_TITLE" 404 btitle="$DIALOG_BACKTITLE" | 403 title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE" |
405 f_dialog_title_restore 406 prompt="$msg_select_zone" 407 menu_list=$( f_country $tlc menu_list ) 408 eval f_dialog_menu_size height width rows \ 409 \"\$title\" \"\$btitle\" \"\$prompt\" \"\" $menu_list 410 411 # 412 # Launch the zone selection menu --- 9 unchanged lines hidden (view full) --- 422 $height $width $rows \ 423 $menu_list \ 424 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 425 ) 426 retval=$? 427 f_dialog_data_sanitize n 428 defaultzone="$n" 429 | 404 f_dialog_title_restore 405 prompt="$msg_select_zone" 406 menu_list=$( f_country $tlc menu_list ) 407 eval f_dialog_menu_size height width rows \ 408 \"\$title\" \"\$btitle\" \"\$prompt\" \"\" $menu_list 409 410 # 411 # Launch the zone selection menu --- 9 unchanged lines hidden (view full) --- 421 $height $width $rows \ 422 $menu_list \ 423 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 424 ) 425 retval=$? 426 f_dialog_data_sanitize n 427 defaultzone="$n" 428 |
430 if [ $retval -ne 0 ]; then | 429 if [ $retval -ne $DIALOG_OK ]; then |
431 [ $nitems -eq 1 ] && NEED_CONTINENT=1 432 NEED_COUNTRY=1 433 continue 434 fi 435 436 real_cont=$( f_country $tlc cont_$n ) 437 real_continent=$( f_continent $real_cont name ) 438 name=$( f_country $tlc name ) 439 filename=$( f_country $tlc filename_$n ) 440 441 f_confirm_zone "$real_continent/$filename" || continue 442 fi 443 | 430 [ $nitems -eq 1 ] && NEED_CONTINENT=1 431 NEED_COUNTRY=1 432 continue 433 fi 434 435 real_cont=$( f_country $tlc cont_$n ) 436 real_continent=$( f_continent $real_cont name ) 437 name=$( f_country $tlc name ) 438 filename=$( f_country $tlc filename_$n ) 439 440 f_confirm_zone "$real_continent/$filename" || continue 441 fi 442 |
444 [ $retval -eq 0 ] || continue # back to main menu | 443 [ $retval -eq $DIALOG_OK ] || continue # back to main menu |
445 446 if ! f_install_zoneinfo "$real_continent/$filename"; then 447 [ $nzones -lt 0 ] && NEED_COUNTRY=1 448 else 449 break 450 fi 451done 452 453################################################################################ 454# END 455################################################################################ | 444 445 if ! f_install_zoneinfo "$real_continent/$filename"; then 446 [ $nzones -lt 0 ] && NEED_COUNTRY=1 447 else 448 break 449 fi 450done 451 452################################################################################ 453# END 454################################################################################ |