Script-based Date/Time/Locale/Timezone setting

Using applications, configuring, problems
Post Reply
Message
Author
User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

Script-based Date/Time/Locale/Timezone setting

#1 Post by greengeek »

When modern puppies boot they bring up a couple of splash screens that offer the user the opportunity to set a bunch of parameters such as Date / Time / Locale and Timezone etc

I would like to know if there are any ways to set these parameters via a script rather than manually.

Why?

My Timezone (Auckland NZ) is down towards the bottom of the dropdown menu and i have to scroll a long way to get there.

Often I am booting on laptops that have badly configured touchpads (or clickpads that have no rightclick or centreclick function) and navigating dopdown menus is tricky.

I never use a savefile so when I am testing various pups I have to set these parameters every time i boot - until I have set up personalisation scripts or a personal adrv or sfs.

I have a series of scripts set up that allow me to easily change backlight, screen intensity, clickpad setup etc etc but I am wondering if it is possible to set my Timezone via a single script.

Once I get this set up I will turn off the quicksetup screens in a remaster and just rely on the scripts to do my initial setup.

Does anyone know if the modern pups have similar Timezone setups that could be configured by script?

Thanks in advance for any thoughts.

User avatar
rockedge
Posts: 1864
Joined: Wed 11 Apr 2012, 13:32
Location: Connecticut, United States
Contact:

#2 Post by rockedge »

Yes you can do this with a script.

O.F.I.N.S.I.S.
Posts: 159
Joined: Sun 01 Mar 2020, 16:17

#3 Post by O.F.I.N.S.I.S. »

Content removed.
Last edited by O.F.I.N.S.I.S. on Fri 15 May 2020, 13:05, edited 1 time in total.
Our Future Is Not Set In Stone
[url]https://www.youtube.com/channel/UCyfyaxCNMduwyXlQFRQKhhQ[/url]
[url]https://soundcloud.com/user-633698367[/url]
[b]My own build of Bionic64[/b]

jafadmin
Posts: 1249
Joined: Thu 19 Mar 2009, 15:10

#4 Post by jafadmin »

This command will set the timezone to New Zealand on Bionics:

Code: Select all

cp /usr/share/zoneinfo/NZ /etc/localtime

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#5 Post by greengeek »

rockedge wrote:Yes you can do this with a script.
Is this something you have done? And if so do you have any examples of how you did it? I am getting a little confused by the interaction between the hardware clock in the PC, the time and timezone routine within the Initrd boot process and the post-boot puppy utilities for changing time/timezone.
O.F.I.N.S.I.S. wrote:Content removed.
Not sure why you have removed the content as I am grateful for what you originally posted - it just takes me time to test each idea. Thanks for the pointer to your work with script-based setting of these parameters - I will be researching that and using it. I stopped following your development of that method a couple of years ago as I largely lost my ability to follow complex technical ideas. Everything takes me longer now.
jafadmin wrote:This command will set the timezone to New Zealand on Bionics:

Code: Select all

cp /usr/share/zoneinfo/NZ /etc/localtime
Thanks for that. I get interesting results. It appears to work across a number of puppies - as noted by hovering over the clock at the bottom right - I see it change after running that command via script.

However i am confused by a couple of things and have been using Bionic32 to try to understand better.

My tests are run without using the quicksetup splash screen dialogs - i close them without alteration:

If my PC bios clock is incorrect for my timezone (which happens on a lot of the laptops i repair) , then the clock at bottom right boots with wrong time (obviously). If I then run the script containing your code for NZ timezone the clock changes to show the correct timezone although time still needs adjusting. However, i still sometimes get problems with internet access where some sites complain that my system timezone must be incorrect.

However, if I run the same test with my PC bios clock set to match my current time - then running your script puts my clock wrong again. It seems that the tray clock does not synchronise with the Bionic32 system timezone.

I can test this by hovering over the tray clock while displaying the Puppy Timezone change utility (menu, desktop, set timezone) and you can see that Bionic still thinks I am in Los Angeles even though my tray clock says I have changed the timezone to NZST.

I guess what I really need is a method to tell ALL of my software what country i am in, what the time is, whether i want 12hr or 24hr time displayed - and most of all - to do all this regardless of the accuracy of the PC bios hardware clock which will often be incorrect due to a dead RTC battery.

I am hoping to do all this is a script placed in Startup or manually run.

I will continue testing - but I don't understand why Bionic still thinks my timezone is Los Angeles when the tray clock says different.
Attachments
TimezoneConflict.jpg
(38 KiB) Downloaded 80 times

O.F.I.N.S.I.S.
Posts: 159
Joined: Sun 01 Mar 2020, 16:17

#6 Post by O.F.I.N.S.I.S. »

greengeek wrote:
O.F.I.N.S.I.S. wrote:Content removed.
Not sure why you have removed the content as I am grateful for what you originally posted - it just takes me time to test each idea. Thanks for the pointer to your work with script-based setting of these parameters - I will be researching that and using it. I stopped following your development of that method a couple of years ago as I largely lost my ability to follow complex technical ideas. Everything takes me longer now.
I just thought it could be too complex for those two tasks and probably too excessive information.

What's your Puppy exactly?
Our Future Is Not Set In Stone
[url]https://www.youtube.com/channel/UCyfyaxCNMduwyXlQFRQKhhQ[/url]
[url]https://soundcloud.com/user-633698367[/url]
[b]My own build of Bionic64[/b]

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#7 Post by greengeek »

O.F.I.N.S.I.S. wrote:What's your Puppy exactly?
At the moment I am testing the following pups:

Xenialpup64
Bionicpup32
Bionicpup64
JRBs AprilQuirky_7Light 32
JRBs AprilQuirky_7Light 64
Radky's Dpup Stretch

and occasionally others like Tahr, Tahr64, LXpupSc,, Xslacko etc

For a long time I have used a Slacko 5.6 derivative without savefile and using an experimental method of saving personalisations to the "empowered" (relayered) zdrv, but at some point I will run out of 32bit hardware and will need to run with more modern pups.

In some ways the modern pups will be easier to run without savefile as they have extra "xdrv's" which can be used as a method of inserting personalisations.

I just need to find the easiest (or best) way to get a newish pup set up after boot with the minimum of manual input.

My greatest need at present is to get my locale set up correctly so that websites do not complain, and also set up my touchpad so that I can operate correctly. (My main test PC's at present use "Clickpads" which are super annoying as they have no clickable hardware buttons and usually no rightclick ability. Each different pup (and kernel) has it's own default setup and most of them are hopeless.

I need to use single click scripts to get my basic parameters set correctly.

When i started this testing I did already have it in the back of my mind that you had previously achieved full pup configuration (without savefile) with your earlier developments - but the one thing that I was not keen on was the need to modify the initrd.

I will use that method if I have no alternative but i really want to find out how much I can personalise a modern pup simply by using scripts after boot - probably the scripts will be placed in Startup in a remastered pup, but otherwise clicked manually.

And after that - then i just load pets or sfs depending on what I want to do in that session...

This way I can use a new pup exactly as it comes from the dev. I do not need to modify the base pup.sfs or the initrd, or run a remaster.

O.F.I.N.S.I.S.
Posts: 159
Joined: Sun 01 Mar 2020, 16:17

#8 Post by O.F.I.N.S.I.S. »

My greatest need at present is to get my locale set up correctly so that websites do not complain, and also set up my touchpad so that I can operate correctly.
This was one of the tasks I had to spend a lot of time to solve.

I'm doing this at the boot process within file /etc/profile.local.
To have this work correctly I had to set the time first to utc.
Then added a sleep 1 and after the sleep switched to local time.

The file /etc/profile.local either is created automatically if it's not there, or it's just expanded if already existing.

Within the N.E.M.E.S.I.S. config file I have two parameters:
# Set the Time Zone
export MYTIMEZONE=de
# Enable/Disable Local Time (0,1)
export MYLOCALTIME=1



Within the script that examines the config file I have a function for this:
# Set Timezone
function SetTZ_NemFunc(){
if [ "$MYTIMEZONE" != "" ]; then
echo "Setting up the Time Zone" >/dev/console
case "$MYTIMEZONE" in
da|DA|Oslo) TIMEZONE="/usr/share/zoneinfo/Europe/Oslo" ;;
de|DE|Berlin) TIMEZONE="/usr/share/zoneinfo/Europe/Berlin" ;;
es|ES|Madrid) TIMEZONE="/usr/share/zoneinfo/Europe/Madrid" ;;
fi|FI|Helsinki) TIMEZONE="/usr/share/zoneinfo/Europe/Helsinki" ;;
fr|FR|Paris) TIMEZONE="/usr/share/zoneinfo/Europe/Paris" ;;
it|IT|Rome) TIMEZONE="/usr/share/zoneinfo/Europe/Rome" ;;
pt|PT|Lisbon|Lisboa) TIMEZONE="/usr/share/zoneinfo/Europe/Lisbon" ;;
nl|NL|Amsterdam) TIMEZONE="/usr/share/zoneinfo/Europe/Amsterdam" ;;
tr|TR|Istanbul) TIMEZONE="/usr/share/zoneinfo/Europe/Istanbul" ;;
GMT*) TIMEZONE="/usr/share/zoneinfo/Etc/$MYTIMEZONE" ;; # GMT+0..12 or GMT-0..14
*) TIMEZONE="/usr/share/zoneinfo/Etc/GMT+1" ;; # GMT+0..12 or GMT-0..14
esac
rm -f "/etc/localtime"
ln -s -f "$TIMEZONE" "/etc/localtime"
fi
# Set Local Time by a short switch to utc and back
if [ "$MYLOCALTIME" = "1" ]; then
HWCLOCKTIME="utc"
hwclock --hctosys --${HWCLOCKTIME}
echo "Time switched to: $HWCLOCKTIME" >/dev/console
sleep 1
HWCLOCKTIME="localtime"
hwclock --hctosys --${HWCLOCKTIME}
echo "Time set to: $HWCLOCKTIME" >/dev/console
echo "#this is read/written by /usr/sbin/quicksetup, timezone-set
HWCLOCKTIME=localtime
" > /etc/clock
else
HWCLOCKTIME="utc"
hwclock --hctosys --${HWCLOCKTIME}
echo "Time switched to: $HWCLOCKTIME" >/dev/console
echo "Time set to: $HWCLOCKTIME" >/dev/console
echo "#this is read/written by /usr/sbin/quicksetup, timezone-set
HWCLOCKTIME=localtime
" > /etc/clock
fi
} # SetTZ_NemFunc


This should be already built into the archives from archive.org.

So, just for testings you could extract the related Xenial64-7.5 archive from archive.org into the your Xenila64-7.5 install directory - make a backup of the original initrd.gz first. Your install directory should have a directory N.E.M.E.S.I.S. then, which contains all the necessary stuff.

Edit the MYTIMEZONE in the config file in directory ConfigData to New Zealand. Let MYLOCALTIME activated by the 1. Save it and reboot Xenial64-7.5.

Edit:

I think I recall that the N.E.M.E.S.I.S. directory and the initrd.gz file is packaged into the .tar.gz by using a parent directory. So, just copy the content of this parent directory into the install directory and overwrite existing files liek the intird.gz.
Our Future Is Not Set In Stone
[url]https://www.youtube.com/channel/UCyfyaxCNMduwyXlQFRQKhhQ[/url]
[url]https://soundcloud.com/user-633698367[/url]
[b]My own build of Bionic64[/b]

Post Reply