0 Members and 2 Guests are viewing this topic.
#!/bin/bash# Time, Date and Timezone configuration utility for Linux Lite# Fork of Date and Time Setting Tool Copyright 2009,2011 by Tony Brijeski under the GPL V2# TODO: add timezone settings, test on a live dvd, use image-list for the main dialog,DIALOG="`which zenity` --width 400"TITLE="--window-icon=/usr/share/icons/hicolor/24x24/apps/gnome-panel-clock.png --print-partial --title="TEXT="--text="ENTRY="--entry "ENTRYTEXT="--entry-text "MENU="--list --print-column=1 --column=Pick --column=Info"YESNO="--question "MSGBOX="--info "SCALE="--scale "PASSWORD="--entry --hide-text "TITLETEXT="Linux Lite Date and Time Setting Tool"if [ $EUID -ne 0 ]; then gksu -m ' <b>Lite Time requires Administrative privileges</b> Please enter your password to continue.' bash $0 exit else :fiwhile [ "$SETCHOICE" != "Exit" ]; doDAY="`date +%d`"MONTH="`date +%m`"YEAR="`date +%Y`"MINUTE="`date +%M`"HOUR="`date +%H`"SETCHOICE=`$DIALOG --height 300 $TITLE"$TITLETEXT" $MENU $TEXT"Set Year Date and Time Tool\n\nTime=$HOUR:$MINUTE\nDate=$MONTH-$DAY-$YEAR\n\n" Exit "Quit" SETTIME "Set Current Time" SETDATE "Set Current Date"`SETCHOICE=`echo $SETCHOICE | cut -d "|" -f 1`if [ "$SETCHOICE" = "SETTIME" ]; thenHOUR="`date +%H`"HOUR=`echo $HOUR | sed -e 's/^0//g'`SETHOUR=`$DIALOG $TITLE"$TITLETEXT" $SCALE --value=$HOUR --min-value=0 --max-value=23 $TEXT"Move the slider to the correct Hour"`if [ "$?" = "0" ]; thenif [ "${#SETHOUR}" = "1" ]; thenSETHOUR="0$SETHOUR"fiMINUTE="`date +%M`"MINUTE=`echo $MINUTE | sed -e 's/^0//g'`fiSETMINUTE=`$DIALOG $TITLE"$TITLETEXT" $SCALE --value=$MINUTE --min-value=0 --max-value=59 $TEXT"Move the slider to the correct Minute"`if [ "$?" = "0" ]; thenif [ "${#SETMINUTE}" = "1" ]; thenSETMINUTE="0$SETMINUTE"fidate $MONTH$DAY$SETHOUR$SETMINUTE$YEARhwclock --systohcfifiif [ "$SETCHOICE" = "SETDATE" ]; thenDAY="`date +%d`"DAY=`echo $DAY | sed -e 's/^0//g'`MONTH="`date +%m`"MONTH=`echo $MONTH | sed -e 's/^0//g'`YEAR="`date +%Y`"SETYEAR=`$DIALOG $TITLE"$TITLETEXT" $SCALE --value=$YEAR --min-value=2000 --max-value=2020 $TEXT"Move the slider to the correct Year"`if [ "$?" = "0" ]; thenSETMONTH=`$DIALOG $TITLE"$TITLETEXT" $SCALE --value=$MONTH --min-value=1 --max-value=12 $TEXT"Move the slider to the correct Month"`if [ "$?" = "0" ]; thenif [ "${#SETMONTH}" = "1" ]; thenSETMONTH="0$SETMONTH"fiSETDAY=`$DIALOG $TITLE"$TITLETEXT" $SCALE --value=$DAY --min-value=1 --max-value=31 $TEXT"Move the slider to the correct Day"`if [ "$?" = "0" ]; thenif [ "${#SETDAY}" = "1" ]; thenSETDAY="0$SETDAY"fiMINUTE="`date +%M`"HOUR="`date +%H`"date $SETMONTH$SETDAY$HOUR$MINUTE$SETYEARhwclock --systohcfifififidoneexit 0