postplug/oldscripts/10localtime

98 lines
2.5 KiB
Plaintext
Raw Permalink Normal View History

2011-04-27 19:57:03 +02:00
#!/bin/bash
# localtime - localtime plugin for postplug
# Copyright (c) 2004-2005 by Silvan Calarco <silvan.calarco@qilinux.it>
# Copyright (c) 2004-2007 by Davide Madrisan <davide.madrisan@qilinux.it>
[ -e /etc/localtime ] && exit 0
[ -r /etc/postplug/postplug.defs ] ||
{ echo "${0##*/}: error: cannot read postplug.defs" >> $logfile
exit 1; }
. /etc/postplug/postplug.defs
tmpflt=`mktemp -q -t ${0##*/}.XXXXXXXX` ||
{ echo "${0##*/}: error: cannot create temporary files." >&2 >> $logfile
{ (exit 1); exit 1; }; }
tmpflt2=`mktemp -q -t ${0##*/}.XXXXXXXX` ||
{ echo "${0##*/}: error: cannot create temporary files." >&2 >> $logfile
{ (exit 1); exit 1; }; }
trap "rm -f $tmpflt $tmpflt2" 1 2 3 15
LOCALTIMEFILE=/etc/localtime
rootdir="/usr/share/zoneinfo"
# fixme: the following rootdirs are excluded:
# Brazil Canada Chile Mexico Mieast US"
rootdirs='
Africa
America
Antarctica
Arctic
Asia
Atlantic
Australia
Europe
Indian
Pacific'
currdir=$rootdir
while :; do
[ "$currdir" = "$rootdir" ] && unset extrabutton ||
extrabutton="--extra-button --extra-label "$"Back"
cat > $tmpflt2 << _EOF
$DIALOG --colors \
--cr-wrap --clear \
--output-fd 4 \
--exit-label _exit $extrabutton --clear \
--begin 3 11 \
--backtitle "$dialog_backtitle -- "$"Time zone selection" \
--title $" TIME ZONE SELECTION " \
--menu "
"$"Please select the local time zone for this system.""
"$"Use the \Z1UP\Zn/\Z1DOWN\
\Zn arrow keys to scroll through the whole \
list of choices." 20 60 9 \\
_EOF
if [ "$currdir" = "$rootdir" ]; then
for currzone in $rootdirs; do
echo "${currzone##*/} \"\" \\" >> $tmpflt2
done
else
#currlist=`find $currdir/* -maxdepth 0 -type d`
for currzone in `find $currdir/* -maxdepth 0 -type f`; do
[ -n "`grep "^TZif" $currzone`" ] &&
#echo "${currzone##*/} \"$currzone\" \\" >> $tmpflt2
echo "${currzone##*/} \"\" \\" >> $tmpflt2
done
fi
echo " 4>$tmpflt" >> $tmpflt2
[ -w /proc/splash ] && echo "verbose" > /proc/splash
. $tmpflt2
retval=$?
rm -f $tmpflt2
case $retval in
0) choice="`cat $tmpflt`"
[ $choice = "_exit" ] && clear && exit 1
currdir="$currdir/$choice"
if [ ! -d $currdir ]; then
cp $currdir $LOCALTIMEFILE
echo "$currdir" > /etc/timezone
sed -i "s|$rootdir/||" /etc/timezone
clear
exit 0
fi ;;
3) currdir=${currdir%\/*} ;;
*) clear; exit 1 ;;
esac
done