test
This commit is contained in:
parent
98a0f47bb0
commit
a35329b5ea
@ -15,49 +15,37 @@ get_tz() {
|
|||||||
elif [ "$tz_type" == "timedatectl" ]; then
|
elif [ "$tz_type" == "timedatectl" ]; then
|
||||||
current_timezone=$(timedatectl | grep "zone" | sed -e 's/^[ ]*Time zone: \(.*\) (.*)$/\1/g')
|
current_timezone=$(timedatectl | grep "zone" | sed -e 's/^[ ]*Time zone: \(.*\) (.*)$/\1/g')
|
||||||
fi
|
fi
|
||||||
printf "$COL_LIGHT_BLUE" "* Timezone in $tz_type is set to $current_timezone"
|
printf "$COL_LIGHT_BLUE" "* Timezone in $tz_type is currently set to $current_timezone"
|
||||||
|
}
|
||||||
|
|
||||||
|
set_tz() {
|
||||||
|
local tz_type="$1"
|
||||||
|
local tz_current="$2"
|
||||||
|
local tz_desired="$3"
|
||||||
|
printf "$COL_LIGHT_BLUE" "* Desired Timezone is $tz_desired"
|
||||||
|
if [ $tz_current != $tz_desired ]
|
||||||
|
then
|
||||||
|
printf "$COL_LIGHT_BLUE" "* Setting Timezone to $desired_timezone"
|
||||||
|
if [ "$tz_type" == "/etc/timezone" ]; then
|
||||||
|
sudo ln -fs "/usr/share/zoneinfo/$desired_timezone" /etc/localtime
|
||||||
|
sudo dpkg-reconfigure -f noninteractive tzdata
|
||||||
|
elif [ "$tz_type" == "timedatectl" ]; then
|
||||||
|
timedatectl set-timezone $desired_timezone
|
||||||
|
fi
|
||||||
|
printf "$COL_LIGHT_BLUE" "* Timezone in $tz_type should now be set to $desired_timezone"
|
||||||
|
else
|
||||||
|
printf "$COL_LIGHT_BLUE" "* Timezone is already set to $tz_desired"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare -a TIMEPLACES=("/etc/timezone" "timedatectl")
|
if [ "$desired_timezone" == 0 ]; then
|
||||||
|
desired_timezone=$(whiptail --title "Set Timezone" --inputbox "What timezone should we set?" 10 80)
|
||||||
|
fi
|
||||||
|
|
||||||
|
declare -a TIMEPLACES=("/etc/timezone" "timedatectl")
|
||||||
for timeitem in "${TIMEPLACES[@]}"
|
for timeitem in "${TIMEPLACES[@]}"
|
||||||
do
|
do
|
||||||
get_tz $timeitem
|
get_tz $timeitem
|
||||||
echo $current_timezone
|
set_tz $timeitem $current_timezone $desired_timezone
|
||||||
done
|
done
|
||||||
|
|
||||||
exit
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
printf "$COL_LIGHT_BLUE" "* Checking Current Timezone in "
|
|
||||||
current_timezone=`cat /etc/timezone`
|
|
||||||
|
|
||||||
if [ "$desired_timezone" == 0 ]; then
|
|
||||||
sudo dpkg-reconfigure tzdata
|
|
||||||
else
|
|
||||||
if [ $desired_timezone != $current_timezone ]
|
|
||||||
then
|
|
||||||
printf "$COL_LIGHT_BLUE" "* Setting Timezone to $desired_timezone"
|
|
||||||
sudo ln -fs "/usr/share/zoneinfo/$desired_timezone" /etc/localtime
|
|
||||||
sudo dpkg-reconfigure -f noninteractive tzdata
|
|
||||||
else
|
|
||||||
printf "$COL_LIGHT_BLUE" "* Timezone is already set to $desired_timezone"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
current_timezonectl=$(timedatectl | grep "zone" | sed -e 's/^[ ]*Time zone: \(.*\) (.*)$/\1/g')
|
|
||||||
if [ "$desired_timezone" == 0 ]; then
|
|
||||||
desired_timezone=`cat /etc/timezone`
|
|
||||||
timedatectl set-timezone $current_timezone
|
|
||||||
else
|
|
||||||
if [ $desired_timezone != $current_timezonectl ]
|
|
||||||
then
|
|
||||||
printf "$COL_LIGHT_BLUE" "* Setting Timezone to $desired_timezone"
|
|
||||||
timedatectl set-timezone $desired_timezone
|
|
||||||
else
|
|
||||||
printf "$COL_LIGHT_BLUE" "* Timezone is already set to $desired_timezone"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user