Radix cross Linux

The main Radix cross Linux repository contains the build scripts of packages, which have the most complete and common functionality for desktop machines

452 Commits   2 Branches   1 Tag
     5         kx #!/bin/sh
     5         kx 
     5         kx # program name:
     5         kx program=`basename $0`
     5         kx 
     5         kx # 16 = root path has not specified arter --root option
     5         kx # 91 = root path not correct
     5         kx # 92 = Cannot create '/tmp/...' directory
     5         kx EXITSTATUS=0
     5         kx 
     5         kx CWD=`pwd`
     5         kx 
     5         kx umask 022
     5         kx if [ ! -z "$TMPDIR" ] ; then mkdir -p $TMPDIR ; fi
     5         kx TMP=$(mkdir -p /tmp/radix && mktemp -d -p /tmp/radix $program.XXXXXXXX) || { echo "Cannot create '/tmp/...' directory" ; exit 92; }
     5         kx trap "rm -rf $TMP" EXIT
     5         kx 
     5         kx 
     5         kx TARGET_ROOT_PATH=
     5         kx 
     5         kx usage() {
     5         kx  cat << EOF
     5         kx 
     5         kx Usage: $program [options]
     5         kx 
     5         kx $program - Radix Linux timezone configuration utility.
     5         kx 
     5         kx options:
     5         kx    --root <DIR>   - Configure timezone someplace else, like <DIR>.
     5         kx 
     5         kx EOF
     5         kx }
     5         kx 
     5         kx 
     5         kx check_abs_paths()
     5         kx {
     5         kx   if [ ! -z "$TARGET_ROOT_PATH" ] ; then
     5         kx     if [[ ${TARGET_ROOT_PATH:0:1} != "/" ]] ; then
     5         kx       TARGET_ROOT_PATH=$CWD/$TARGET_ROOT_PATH
     5         kx     fi
     5         kx     TARGET_ROOT_PATH="$(echo "$TARGET_ROOT_PATH" | sed -e "s/\/$//")/"
     5         kx   fi
     5         kx }
     5         kx 
     5         kx #
     5         kx # Parse options:
     5         kx #
     5         kx while [ 0 ]; do
     5         kx   if [ "$1" = "-h" -o "$1" = "--help" ]; then
     5         kx     usage
     5         kx     exit 0
     5         kx   elif [ "$1" = "--root" ]; then
     5         kx     if [ "$2" = "" ]; then
     5         kx       usage
     5         kx       echo "ERROR: Target ROOT directory has not specified. Check --root option."
     5         kx       EXITSTATUS=17
     5         kx       exit $EXITSTATUS
     5         kx     fi
     5         kx     TARGET_ROOT_PATH="$2"
     5         kx     shift 2
     5         kx   else
     5         kx     break
     5         kx   fi
     5         kx done
     5         kx 
     5         kx check_abs_paths
     5         kx 
     5         kx if [ -z "$TARGET_ROOT_PATH" ] ; then
     5         kx   TARGET_ROOT_PATH="/"
     5         kx fi
     5         kx 
     5         kx if [ ! -d $TARGET_ROOT_PATH ] ; then
     5         kx   echo "ERROR: Target ROOT path specified but not correct."
     5         kx   EXITSTATUS=91
     5         kx   exit $EXITSTATUS
     5         kx fi
     5         kx 
     5         kx : ${DIALOG=dialog}
     5         kx : ${DIALOGRC=${TARGET_ROOT_PATH}etc/dialogrc}
     5         kx 
     5         kx #
   303         kx # The hardware clock configuration files:
     5         kx #
     5         kx HWCLOCK_CONF=${TARGET_ROOT_PATH}etc/hardwareclock
   303         kx ADJTIME_CONF=${TARGET_ROOT_PATH}etc/adjtime
     5         kx 
     5         kx #
     5         kx # setzone( $TIMEZONE )
     5         kx #
     5         kx # This function accepts a time zone as the only parameter
     5         kx # and sets it as the default system time zone.
     5         kx #
     5         kx setzone()
     5         kx {
     5         kx   TZ=$1
     5         kx 
     5         kx   cd ${TARGET_ROOT_PATH}etc
     5         kx   if [ -r ${TARGET_ROOT_PATH}usr/share/zoneinfo/$TZ -o \
   303         kx        -L ${TARGET_ROOT_PATH}usr/share/zoneinfo/$TZ    ] ; then
     5         kx       ln -sf ../usr/share/zoneinfo/$TZ localtime-copied-from
   303         kx       rm -f localtime-copied-from
     5         kx       rm -f localtime
   303         kx       ln -sf ../usr/share/zoneinfo/$TZ localtime
     5         kx       cd ..
     5         kx    fi
     5         kx }
     5         kx 
     5         kx #
     5         kx # writeconf( $CLOCK_SET_TO )
     5         kx #
     5         kx # Writes out $HWCLOCK_CONF that tells rc.S how the hardware clock value is stored.
     5         kx #
     5         kx writeconf()
     5         kx {
     5         kx    echo "#"                                               > $HWCLOCK_CONF
     5         kx    echo "# /etc/hardwareclock"                           >> $HWCLOCK_CONF
     5         kx    echo "#"                                              >> $HWCLOCK_CONF
     5         kx    echo "# Tells how the hardware clock time is stored." >> $HWCLOCK_CONF
     5         kx    echo "# You should run timeconfig to edit this file." >> $HWCLOCK_CONF
     5         kx    echo ""                                               >> $HWCLOCK_CONF
     5         kx    echo $1 >> $HWCLOCK_CONF
     5         kx }
     5         kx 
   303         kx write_adjtime()
   303         kx {
   303         kx   if [ ! -f "$ADJTIME_CONF" ] ; then
   303         kx     echo "0.0 0 0.0"  > $ADJTIME_CONF
   303         kx     echo "0"         >> $ADJTIME_CONF
   303         kx     echo $1 >> $ADJTIME_CONF
   303         kx   else
   303         kx     if [ "$1" = "UTC" ] ; then
   303         kx       sed -i 's,^LOCAL,UTC,' $ADJTIME_CONF
   303         kx     else
   303         kx       sed -i 's,^UTC,LOCAL,' $ADJTIME_CONF
   303         kx     fi
   303         kx   fi
   303         kx }
   303         kx 
     5         kx #
     5         kx # Ask the user if the hardware clock is set for UTC/GMT
     5         kx #
     5         kx cat > $TMP/menu-utc$$ << EOF
     5         kx --colors \\
     5         kx --backtitle "\Z7Radix\Zn \Z1cross\Zn\Z7 Linux\Zn" \\
     5         kx --title " \Z4\ZbSet Hardware Clock\ZB\Zn " \\
     5         kx --menu "\\n\\
     5         kx  Is the hardware clock set to Coordinated Universal Time (UTC/GMT)?\\n\\
     5         kx  If it is, select YES here.\\n\\n\\
     5         kx  If the hardware clock is set to the current local time (this is how\\n\\
     5         kx  most PCs are set up), then say NO here.\\n\\n\\
     5         kx  If you are not sure what this is, you should answer NO here.\\n\\
     5         kx " 16 74 2 \\
     5         kx "NO" "Hardware clock is set to local time" \\
     5         kx "YES" "Hardware clock is set to UTC" \\
     5         kx EOF
     5         kx 
     5         kx $DIALOG --file $TMP/menu-utc$$ 2> $TMP/utc$$
     5         kx if [ $? = 1 -o $? = 255 ]; then
     5         kx   rm -f $TMP/utc$$
     5         kx   rm -f $TMP/menu-utc$$
     5         kx   exit
     5         kx fi
     5         kx if [ "`cat $TMP/utc$$`" = "YES" ]; then
     5         kx   # yes, the hardware clock is UTC
     5         kx   writeconf "UTC"
   303         kx   write_adjtime "UTC"
     5         kx else # must be NO
     5         kx   writeconf "localtime"
   303         kx   write_adjtime "LOCAL"
     5         kx fi
     5         kx rm -f $TMP/utc$$
     5         kx rm -f $TMP/menu-utc$$
     5         kx 
     5         kx #
     5         kx # Ask the user which timezone is preffered
     5         kx #
     5         kx cat > $TMP/menu-tz$$ << EOF
     5         kx --colors \\
     5         kx --backtitle "\Z7Radix\Zn \Z1cross\Zn\Z7 Linux\Zn" \\
     5         kx --title " \Z4\ZbTimezone Configuration\ZB\Zn " \\
     5         kx --menu "\\n\\
     5         kx  Please select one of the following timezones for your machine:\\n\\
     5         kx " 22 74 14 \\