Deleted Added
full compact
zones.subr (252995) zones.subr (263791)
1if [ ! "$_TIMEZONE_ZONES_SUBR" ]; then _TIMEZONE_ZONES_SUBR=1
2#
3# Copyright (c) 2011-2012 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#
1if [ ! "$_TIMEZONE_ZONES_SUBR" ]; then _TIMEZONE_ZONES_SUBR=1
2#
3# Copyright (c) 2011-2012 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/share/zones.subr 252995 2013-07-07 19:13:34Z dteske $
27# $FreeBSD: stable/9/usr.sbin/bsdconfig/timezone/share/zones.subr 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..." timezone/zones.subr
34f_include $BSDCFG_SHARE/dialog.subr
28#
29############################################################ INCLUDES
30
31BSDCFG_SHARE="/usr/share/bsdconfig"
32. $BSDCFG_SHARE/common.subr || exit 1
33f_dprintf "%s: loading includes..." timezone/zones.subr
34f_include $BSDCFG_SHARE/dialog.subr
35f_include $BSDCFG_SHARE/strings.subr
35f_include $BSDCFG_SHARE/timezone/continents.subr
36
37BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="090.timezone"
38f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
39
40############################################################ CONFIGURATION
41
42#

--- 299 unchanged lines hidden (view full) ---

342}
343
344# f_install_zoneinfo_file $filename
345#
346# Installs a zone file to _PATH_LOCALTIME.
347#
348f_install_zoneinfo_file()
349{
36f_include $BSDCFG_SHARE/timezone/continents.subr
37
38BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="090.timezone"
39f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
40
41############################################################ CONFIGURATION
42
43#

--- 299 unchanged lines hidden (view full) ---

343}
344
345# f_install_zoneinfo_file $filename
346#
347# Installs a zone file to _PATH_LOCALTIME.
348#
349f_install_zoneinfo_file()
350{
351 local funcname=f_install_zoneinfo_file
350 local zoneinfo_file="$1"
352 local zoneinfo_file="$1"
351 local copymode title msg err height width
353 local copymode title msg height width
352
353 if [ -L "$_PATH_LOCALTIME" ]; then
354 copymode=
355 elif [ ! -e "$_PATH_LOCALTIME" ]; then
356 # Nothing there yet...
357 copymode=1
358 else
359 copymode=1
360 fi
361
362 if [ "$VERBOSE" ]; then
363 if [ ! "$zoneinfo_file" ]; then
354
355 if [ -L "$_PATH_LOCALTIME" ]; then
356 copymode=
357 elif [ ! -e "$_PATH_LOCALTIME" ]; then
358 # Nothing there yet...
359 copymode=1
360 else
361 copymode=1
362 fi
363
364 if [ "$VERBOSE" ]; then
365 if [ ! "$zoneinfo_file" ]; then
364 msg=$( printf "$msg_removing_file" "$_PATH_LOCALTIME" )
366 f_sprintf msg "$msg_removing_file" "$_PATH_LOCALTIME"
365 elif [ "$copymode" ]; then
367 elif [ "$copymode" ]; then
366 msg=$( printf "$msg_copying_file" \
367 "$zoneinfo_file" "$_PATH_LOCALTIME" )
368 f_sprintf msg "$msg_copying_file" \
369 "$zoneinfo_file" "$_PATH_LOCALTIME"
368 else
370 else
369 msg=$( printf "$msg_creating_symlink" \
370 "$_PATH_LOCALTIME" "$zoneinfo_file" )
371 f_sprintf msg "$msg_creating_symlink" \
372 "$_PATH_LOCALTIME" "$zoneinfo_file"
371 fi
372 if [ "$USEDIALOG" ]; then
373 f_dialog_title "$msg_info"
374 f_dialog_msgbox "$msg"
375 f_dialog_title_restore
376 else
377 printf "%s\n" "$msg"
378 fi
379 fi
380
381 [ "$REALLYDOIT" ] || return $SUCCESS
382
373 fi
374 if [ "$USEDIALOG" ]; then
375 f_dialog_title "$msg_info"
376 f_dialog_msgbox "$msg"
377 f_dialog_title_restore
378 else
379 printf "%s\n" "$msg"
380 fi
381 fi
382
383 [ "$REALLYDOIT" ] || return $SUCCESS
384
385 local catch_args="-de"
386 [ "$USEDIALOG" ] && catch_args=
387
383 if [ ! "$zoneinfo_file" ]; then
388 if [ ! "$zoneinfo_file" ]; then
384 err=$( rm -f "$_PATH_LOCALTIME" 2>&1 )
385 if [ "$err" ]; then
386 if [ "$USEDIALOG" ]; then
387 f_dialog_title "$msg_error"
388 f_dialog_msgbox "$err"
389 f_dialog_title_restore
390 else
391 f_err "%s\n" "$err"
392 fi
393 return $FAILURE
394 fi
389 f_eval_catch $catch_args $funcname rm \
390 'rm -f "%s"' "$_PATH_LOCALTIME" || return $FAILURE
391 f_eval_catch $catch_args $funcname rm \
392 'rm -f "%s"' "$_PATH_DB" || return $FAILURE
395
393
396 err=$( rm -f "$_PATH_DB" 2>&1 )
397 if [ "$err" ]; then
398 if [ "$USEDIALOG" ]; then
399 f_dialog_title "$msg_error"
400 f_dialog_msgbox "$err"
401 f_dialog_title_restore
402 else
403 f_err "%s\n" "$err"
404 fi
405 return $FAILURE
406 fi
407
408 if [ "$VERBOSE" ]; then
394 if [ "$VERBOSE" ]; then
409 msg=$( printf "$msg_removed_file" "$_PATH_LOCALTIME" )
395 f_sprintf msg "$msg_removed_file" "$_PATH_LOCALTIME"
410 if [ "$USEDIALOG" ]; then
411 f_dialog_title "$msg_done"
412 f_dialog_msgbox "$msg"
413 f_dialog_title_restore
414 else
415 printf "%s\n" "$msg"
416 fi
417 fi
396 if [ "$USEDIALOG" ]; then
397 f_dialog_title "$msg_done"
398 f_dialog_msgbox "$msg"
399 f_dialog_title_restore
400 else
401 printf "%s\n" "$msg"
402 fi
403 fi
418
419 return $SUCCESS
404 return $SUCCESS
420
421 fi # ! zoneinfo_file
422
423 if [ "$copymode" ]; then
405 fi # ! zoneinfo_file
406
407 if [ "$copymode" ]; then
424
425 err=$( rm -f "$_PATH_LOCALTIME" 2>&1 )
426 if [ "$err" ]; then
427 if [ "$USEDIALOG" ]; then
428 f_dialog_title "$msg_error"
429 f_dialog_msgbox "$err"
430 f_dialog_title_restore
431 else
432 f_err "%s\n" "$err"
433 fi
408 f_eval_catch $catch_args $funcname rm \
409 'rm -f "%s"' "$_PATH_LOCALTIME" || return $FAILURE
410 f_eval_catch $catch_args $funcname sh \
411 'umask 222 && :> "%s"' "$_PATH_LOCALTIME" ||
434 return $FAILURE
412 return $FAILURE
435 fi
436
437 err=$( umask 222 && : 2>&1 > "$_PATH_LOCALTIME" )
438 if [ "$err" ]; then
439 if [ "$USEDIALOG" ]; then
440 f_dialog_title "$msg_error"
441 f_dialog_msgbox "$err"
442 f_dialog_title_restore
443 else
444 f_err "%s\n" "$err"
445 fi
446 return $FAILURE
447 fi
448
449 err=$( cat "$zoneinfo_file" 2>&1 > "$_PATH_LOCALTIME" )
450 if [ "$err" ]; then
451 if [ "$USEDIALOG" ]; then
452 f_dialog_title "$msg_error"
453 f_dialog_msgbox "$err"
454 f_dialog_title_restore
455 else
456 f_err "%s\n" "$err"
457 fi
458 return $FAILURE
459 fi
460
461 else # ! copymode
462
463 err=$( ( :< "$zoneinfo_file" ) 2>&1 )
464 if [ "$err" ]; then
465 if [ "$USEDIALOG" ]; then
466 f_dialog_title "$msg_error"
467 f_dialog_msgbox "$err"
468 f_dialog_title_restore
469 else
470 f_err "%s\n" "$err"
471 fi
472 return $FAILURE
473 fi
474
475 err=$( rm -f "$_PATH_LOCALTIME" 2>&1 )
476 if [ "$err" ]; then
477 if [ "$USEDIALOG" ]; then
478 f_dialog_title "$msg_error"
479 f_dialog_msgbox "$err"
480 f_dialog_title_restore
481 else
482 f_err "%s\n" "$err"
483 fi
484 return $FAILURE
485 fi
486
487 err=$( ln -s "$zoneinfo_file" "$_PATH_LOCALTIME" 2>&1 )
488 if [ "$err" ]; then
489 if [ "$USEDIALOG" ]; then
490 f_dialog_title "$msg_error"
491 f_dialog_msgbox "$err"
492 f_dialog_title_restore
493 else
494 f_err "%s\n" "$err"
495 fi
496 return $FAILURE
497 fi
498
413 f_eval_catch $catch_args $funcname sh \
414 'cat "%s" > "%s"' \
415 "$zoneinfo_file" "$_PATH_LOCALTIME" || return $FAILURE
416 else
417 f_eval_catch $catch_args $funcname sh \
418 '( :< "%s" )' "$zoneinfo_file" || return $FAILURE
419 f_eval_catch $catch_args $funcname rm \
420 'rm -f "%s"' "$_PATH_LOCALTIME" || return $FAILURE
421 f_eval_catch $catch_args $funcname ln \
422 'ln -s "%s" "%s"' \
423 "$zoneinfo_file" "$_PATH_LOCALTIME" || return $FAILURE
499 fi # copymode
500
501 if [ "$VERBOSE" ]; then
502 if [ "$copymode" ]; then
424 fi # copymode
425
426 if [ "$VERBOSE" ]; then
427 if [ "$copymode" ]; then
503 msg=$( printf "$msg_copied_timezone_file" \
504 "$zoneinfo_file" "$_PATH_LOCALTIME" )
428 f_sprintf msg "$msg_copied_timezone_file" \
429 "$zoneinfo_file" "$_PATH_LOCALTIME"
505 else
430 else
506 msg=$( printf "$msg_created_symlink" \
507 "$_PATH_LOCALTIME" "$zoneinfo_file" )
431 f_sprintf msg "$msg_created_symlink" \
432 "$_PATH_LOCALTIME" "$zoneinfo_file"
508 fi
509 if [ "$USEDIALOG" ]; then
510 f_dialog_title "$msg_done"
511 f_dialog_msgbox "$msg"
512 f_dialog_title_restore
513 else
514 printf "%s\n" "$msg"
515 fi

--- 38 unchanged lines hidden (view full) ---

554#
555f_confirm_zone()
556{
557 local filename="$1"
558 f_dialog_title "$msg_confirmation"
559 local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE"
560 f_dialog_title_restore
561 local tm_zone="$( TZ="$filename" date +%Z )"
433 fi
434 if [ "$USEDIALOG" ]; then
435 f_dialog_title "$msg_done"
436 f_dialog_msgbox "$msg"
437 f_dialog_title_restore
438 else
439 printf "%s\n" "$msg"
440 fi

--- 38 unchanged lines hidden (view full) ---

479#
480f_confirm_zone()
481{
482 local filename="$1"
483 f_dialog_title "$msg_confirmation"
484 local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE"
485 f_dialog_title_restore
486 local tm_zone="$( TZ="$filename" date +%Z )"
562 local prompt="$( printf "$msg_look_reasonable" "$tm_zone" )"
487 local prompt # Calculated below
563 local height=5 width=72
564
488 local height=5 width=72
489
490 f_sprintf prompt "$msg_look_reasonable" "$tm_zone"
565 if [ "$USE_XDIALOG" ]; then
566 height=$(( $height + 4 ))
567 $DIALOG \
491 if [ "$USE_XDIALOG" ]; then
492 height=$(( $height + 4 ))
493 $DIALOG \
568 --title "$title" \
569 --backtitle "$btitle" \
570 --ok-label "$msg_yes" \
571 --cancel-label "$msg_no" \
494 --title "$title" \
495 --backtitle "$btitle" \
496 --ok-label "$msg_yes" \
497 --cancel-label "$msg_no" \
572 --yesno "$prompt" $height $width
573 else
574 $DIALOG \
575 --title "$title" \
576 --backtitle "$btitle" \
577 --yes-label "$msg_yes" \
578 --no-label "$msg_no" \
579 --yesno "$prompt" $height $width

--- 18 unchanged lines hidden ---
498 --yesno "$prompt" $height $width
499 else
500 $DIALOG \
501 --title "$title" \
502 --backtitle "$btitle" \
503 --yes-label "$msg_yes" \
504 --no-label "$msg_no" \
505 --yesno "$prompt" $height $width

--- 18 unchanged lines hidden ---