This is a bash script solution. Go look elsewhere if you want to Frankenstein your system with alien or legacy rpms.
The old 'timeconfig' TUI that was present from the original Redhat 'Diaper' release all the way up through the RedHat 'EL5' release now occupies too many terabytes on the OS installation so it had to be discarded from RHEL6 (and CentOS 6). Ok, just kidding. The real reason they abandoned it is, is uh, uh, uh. Sorry. Cannot think of any justification for discarding the command line utility. "Moronic" is the first word that comes to mind. Nonetheless, I need it and its *gone*!!
That's all just unacceptable to me so I wrote a 'timeconfig' bash script to replace the abandoned OS feature. Here is how you can get it back too. Please keep in mind this was created to run on CentOS 6.x (and probably higher), but in theory should also work on RHEL6 and higher.
1. Login as 'root' (or su -) to begin. I use a remote session (SecureCRT, PuTTY or similar).
2. Make sure your installation fits the bill and that you don't have 'timeconfig' on your system. You can do so by typing the following commands:
Code:
cat /etc/redhat-release
timeconfig
If if comes back RHEL6 or CentOS 6.x -AND- 'timeconfig' comes back "command not found" then safe to proceed.
3. If you place this script in an appropriate location then it can be run from the system root prompt same as the old 'timeconfig' utility. I placed it in the following path:
Granted a bash script is not a binary executable but hey, the path already existed in my installation so I'm using it. Works for me so it should work for you. Create the path if it is not there.
Code:
cd /usr/local/
mkdir bin
4. Change into that directory and vi to create the new file.
Code:
cd /usr/local/bin/
vi timeconfig
5. Here is the code. Copy it to your clipboard and paste it into your vi session.
Code:
#!/bin/sh
#
clear
printf '\e[33;40;1m'
trap '' 2
until [ "$question" = "Where is the Rye Toast?" ]; do
region=
zonePick=
until [ "$answer" = "42" ]; do
clear
echo -n " "
date
echo " *********** PICK WORLD REGION ***********"
echo " ('q' to quit)"
echo ""
count=`find /usr/share/zoneinfo/ -maxdepth 1 -type d |wc -l`
dirName=(". "`find /usr/share/zoneinfo/ -maxdepth 1 -type d |sort |sed -e 's%^.*/%%'`)
tzDir=(`find /usr/share/zoneinfo/ -maxdepth 1 -type d |sort`)
offset=$(( count / 2 ))
count=$(( count - 1 ))
for left in $(eval echo {1..$offset})
do
right=$(( left + offset ))
ldummy=$left")"${dirName[left]}" "
ldummy=${ldummy:0:25}
rdummy=$right")"${dirName[right]}
echo " $ldummy $rdummy"
done
echo ""
echo -n " Pick a region: "
read region
if [[ ! $region = "" ]] ; then # Process user region
header=" ************ PICK '"${tzDir[$region]:20}"' ZONE ************"
clear
echo ""
echo "$header"
echo " ('q' to quit)"
zcount=`find ${tzDir[$region]} -maxdepth 1 -type f |wc -l`
zName=(`find ${tzDir[$region]} -maxdepth 1 -type f |sort |sed -e 's%^.*/%%'`)
tzFile=(`find ${tzDir[$region]} -maxdepth 1 -type f |sort`)
echo ""
case $region in
3|4|6|8|9|10|13|14|16 ) ################## DISPLAY 1 COLUMN ####################
zcount=$(( zcount - 1 ))
for col1 in $(eval echo {0..$zcount})
do
show1=$col1")"${zName[col1]}
echo " $show1"
done
break
;;
7 ) ###################################### DISPLAY 2 COLUMNS ###################
zoffset1=$(( ( zcount + 1 ) / 2 - 1 ))
fat=20
for col1 in $(eval echo {0..$zoffset1})
do
col2=$(( col1 + zoffset1 + 1 ))
show1=$col1")"${zName[col1]}" "
show1=${show1:0:$fat}
show2=$col2")"${zName[col2]}
show2=${show2:0:$fat}
test=`echo $show2`
test=${test#*)}
if [[ ${#test} -eq 0 ]] ; then
show2=
fi
echo " $show1 $show2"
done
break
;;
1|11|15|17|18 ) ########################## DISPLAY 3 COLUMNS ###################
zoffset1=$(( ( zcount + 2 ) / 3 - 1 ))
fat=21
for col1 in $(eval echo {0..$zoffset1})
do
col2=$(( col1 + zoffset1 + 1 ))
col3=$(( col2 + zoffset1 + 1 ))
col4=$(( col3 + zoffset1 + 1 ))
show1=$col1")"${zName[col1]}" "
show1=${show1:0:$fat}
show2=$col2")"${zName[col2]}" "
show2=${show2:0:$fat}
show3=$col3")"${zName[col3]}
show3=${show3:0:$fat}
test=`echo $show3`
test=${test#*)}
if [[ ${#test} -eq 0 ]] ; then
show3=
test=`echo $show2`
test=${test#*)}
if [[ ${#test} -eq 0 ]] ; then
show2=
fi
fi
echo " $show1 $show2 $show3"
done
break
;;
5|12 ) ################################### DISPLAY 4 COLUMNS ###################
zoffset1=$(( ( zcount + 3 ) / 4 - 1 ))
fat=18
for col1 in $(eval echo {0..$zoffset1})
do
col2=$(( col1 + zoffset1 + 1 ))
col3=$(( col2 + zoffset1 + 1 ))
col4=$(( col3 + zoffset1 + 1 ))
show1=$col1")"${zName[col1]}" "
show1=${show1:0:$fat}
show2=$col2")"${zName[col2]}" "
show2=${show2:0:$fat}
show3=$col3")"${zName[col3]}" "
show3=${show3:0:$fat}
show4=$col4")"${zName[col4]}
show4=${show4:0:$fat}
test=`echo $show4`
test=${test#*)}
if [[ ${#test} -eq 0 ]] ; then
show4=
test=`echo $show3`
test=${test#*)}
if [[ ${#test} -eq 0 ]] ; then
show3=
test=`echo $show2`
test=${test#*)}
if [[ ${#test} -eq 0 ]] ; then
show2=
fi
fi
fi
echo " $show1 $show2 $show3 $show4"
done
break
;;
2 ) ################################### DISPLAY 2 PAGE 4 COLUMNS ###############
zoffset1=$(( ( zcount + 3 ) / 4 - 1 ))
zset1=$(( zcount / 8 ))
fat=18
for col1 in $(eval echo {0..$zset1})
do
col2=$(( col1 + zoffset1 + 1 ))
col3=$(( col2 + zoffset1 + 1 ))
col4=$(( col3 + zoffset1 + 1 ))
show1=$col1")"${zName[col1]}" "
show1=${show1:0:$fat}
show2=$col2")"${zName[col2]}" "
show2=${show2:0:$fat}
show3=$col3")"${zName[col3]}" "
show3=${show3:0:$fat}
show4=$col4")"${zName[col4]}
show4=${show4:0:$fat}
test=`echo $show4`
test=${test#*)}
if [[ ${#test} -eq 0 ]] ; then
show4=
test=`echo $show3`
test=${test#*)}
if [[ ${#test} -eq 0 ]] ; then
show3=
test=`echo $show2`
test=${test#*)}
if [[ ${#test} -eq 0 ]] ; then
show2=
fi
fi
fi
echo " $show1 $show2 $show3 $show4"
done
echo ""
echo -n " Press Enter for next page or, pick by number: "
read zonePick
if [[ ${#zonePick} -eq 0 ]] ; then
clear
echo ""
echo "$header"
echo " ('q' to quit)"
echo ""
zset1=$(( zset1 + 1 ))
for col1 in $(eval echo {$zset1..$zoffset1})
do
col2=$(( col1 + zoffset1 + 1 ))
col3=$(( col2 + zoffset1 + 1 ))
col4=$(( col3 + zoffset1 + 1 ))
show1=$col1")"${zName[col1]}" "
show1=${show1:0:$fat}
show2=$col2")"${zName[col2]}" "
show2=${show2:0:$fat}
show3=$col3")"${zName[col3]}" "
show3=${show3:0:$fat}
show4=$col4")"${zName[col4]}
show4=${show4:0:$fat}
test=`echo $show4`
test=${test#*)}
if [[ ${#test} -eq 0 ]] ; then
show4=
test=`echo $show3`
test=${test#*)}
if [[ ${#test} -eq 0 ]] ; then
show3=
test=`echo $show2`
test=${test#*)}
if [[ ${#test} -eq 0 ]] ; then
show2=
fi
fi
fi
echo " $show1 $show2 $show3 $show4"
done
fi
break
;;
Q|q ) ################################ QUIT AND ABORT EXECUTION ################
clear
echo " Timezone modification aborted."
exit 0
;;
* ) ############################### CIRCLE ON BAD SELECTION INPUTS #############
clear
echo " Please make a valid selection!"
read -t2 junk
;;
esac
fi
region=
done
if [[ ${#zonePick} -eq 0 ]] ; then
echo ""
echo -n " Pick by number: "
read zonePick
fi
# PATH OF SELECTED "ZONE FILE" LOCATED INSIDE > > ${tzFile[$zonePick]}
if echo $zonePick | grep -iq q 2> /dev/null; then
clear
echo " Timezone modification aborted."
exit 0
fi
if [[ ${#zonePick} -ne 0 ]] ; then # not zero length
if [ $zonePick -eq $zonePick 2> /dev/null ]; then # is a whole number
zcount=$(( zcount - 1 ))
if [[ $zonePick -gt $zcount ]] ; then # is out of range
clear
echo " Please make a valid selection!"
read -t2 junk
else # ODDS ARE WE HAVE A VALID SELECTION
echo "Your selection was: ${tzFile[$zonePick]:20}"
# Shuffle files into place as needed to apply new selection
mv -f /etc/localtime /etc/localtime-old
cp -rf ${tzFile[$zonePick]} /etc/localtime
echo ""
echo "Please verify timezone and re-adjust if necessary:"
echo -n " "
date
echo ""
exit 0
fi
else # user does not understand "Pick by number"
clear
echo " You must select by number!"
read -t2 junk
fi
fi
done
6. Adjust permissions after you save the file so the user must be logged in root to use the script (same as the old line command version).
Code:
chmod 700 timeconfig
7. You're done. Just give it a spin at the root system prompt. Change directory first to verify it will launch as easily as the original utility without a path prefix:
Infinitely better than the 'timeconfig' that comes with CentOS 6.x, since there is no command line version of it in CentOS 6.x
Available zone selections are not as complete as the original 'timeconfig' but should be adequate to suit most needs. More than suits mine. Also, I'm no linux bash scripting guru so some of my techniques could undoubtedly be improved upon. Feel free to use 'as is' or modify to your liking, and either way have fun.