Deleted Added
sdiff udiff text old ( 252995 ) new ( 263791 )
full compact
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 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
35f_include $BSDCFG_SHARE/strings.subr
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
352 local zoneinfo_file="$1"
353 local copymode title msg height width
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
366 f_sprintf msg "$msg_removing_file" "$_PATH_LOCALTIME"
367 elif [ "$copymode" ]; then
368 f_sprintf msg "$msg_copying_file" \
369 "$zoneinfo_file" "$_PATH_LOCALTIME"
370 else
371 f_sprintf msg "$msg_creating_symlink" \
372 "$_PATH_LOCALTIME" "$zoneinfo_file"
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
388 if [ ! "$zoneinfo_file" ]; then
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
393
394 if [ "$VERBOSE" ]; then
395 f_sprintf msg "$msg_removed_file" "$_PATH_LOCALTIME"
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
404 return $SUCCESS
405 fi # ! zoneinfo_file
406
407 if [ "$copymode" ]; then
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" ||
412 return $FAILURE
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
424 fi # copymode
425
426 if [ "$VERBOSE" ]; then
427 if [ "$copymode" ]; then
428 f_sprintf msg "$msg_copied_timezone_file" \
429 "$zoneinfo_file" "$_PATH_LOCALTIME"
430 else
431 f_sprintf msg "$msg_created_symlink" \
432 "$_PATH_LOCALTIME" "$zoneinfo_file"
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 )"
487 local prompt # Calculated below
488 local height=5 width=72
489
490 f_sprintf prompt "$msg_look_reasonable" "$tm_zone"
491 if [ "$USE_XDIALOG" ]; then
492 height=$(( $height + 4 ))
493 $DIALOG \
494 --title "$title" \
495 --backtitle "$btitle" \
496 --ok-label "$msg_yes" \
497 --cancel-label "$msg_no" \
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 ---