You are not logged in.

#1 2025-02-24 18:17:21

live4thamuzik
Member
Registered: 2024-02-27
Posts: 66

[SOLVED] set-timezone function being ignored as if it was never called

I have a bash script I have been working on to somewhat automate the installation of Arch. I used to have a clunky way of setting timezone that would make a numbered list from /usr/share/zoneinfo found in the live installer then set the timezone selected with ln -sf and save it to /mnt/etc/localtime then run hwclock --systohc.

I decided to try making it a little easier for the user by making a select_timezone function that lets the user type in a partial timezone name like "New_York" or "Eastern" that could be found in timedatectl list-timezones then save that selection to $ACTUAL_TIMEZONE with some logic to default the timezone to UTC if that fails. This happens in the main script install.sh

Once the script moves to chroot.sh a function called set_timezone is called where it checks the variable $ACTUAL_TIMEZONE and will default time to UTC if ACTUAL_TIMEZONE can't be found, other wise it will set the timezone to the users selection. For whatever reason the set_timezone function is being completely ignored and I cannot figure out why.

code can be found on github.

Last edited by live4thamuzik (2025-02-25 00:18:45)

Offline

#2 2025-02-25 00:17:58

live4thamuzik
Member
Registered: 2024-02-27
Posts: 66

Re: [SOLVED] set-timezone function being ignored as if it was never called

I guess it was being executed the whole time, I just couldn't see it until I echoed a comment when the function was called and added

log_info "Setting timezone to $ACTUAL_TIMEZONE"

before this

timedatectl set-timezone "$ACTUAL_TIMEZONE"

Without those adds the only way to know the function was used if the $ACTUAL_TIME variable failed and the time was defaulted to UTC because I had a "log_info" for that part.

Offline

#3 2025-02-25 09:27:43

ReDress
Member
From: Nairobi
Registered: 2024-11-30
Posts: 125

Re: [SOLVED] set-timezone function being ignored as if it was never called

live4thamuzik wrote:

I have a bash script I have been working on to somewhat automate the installation of Arch.

It beats me that people make installation scripts for Linux. Isn't this something you only do once in a while or barely ever do? Why do you need  script for installation?

Offline

#4 2025-02-25 14:45:05

live4thamuzik
Member
Registered: 2024-02-27
Posts: 66

Re: [SOLVED] set-timezone function being ignored as if it was never called

It beats me that people make installation scripts for Linux. Isn't this something you only do once in a while or barely ever do? Why do you need  script for installation?

This is more so a learning exercise for me to learn scripting in bash but is also a useful tool to have for setting up new systems or messing around with in VM's rather than hand jamming commands to install the manual way when I feel like tinkering. I am still fairly new to linux as far as using it for my daily driver. Maybe a year in and for some reason I liked the challenge of Arch. My only real experience with linux is managing Ubuntu Servers for things like FOG Project, Clonezilla, and JAMF Pro Servers in my day job as a sys admin.  Eventually I'll dive into Python or something else but I thought it made sense to work on my bash skills 1st.

Offline

#5 2025-02-25 17:54:46

mountaintrek
Member
Registered: 2024-02-01
Posts: 49

Re: [SOLVED] set-timezone function being ignored as if it was never called

It beats me that people make installation scripts for Linux. Isn't this something you only do once in a while or barely ever do? Why do you need  script for installation?

Like the OP mentioned,  it is a tool that can be used to set up and customize virtual machines, like kvm/qemu, for development, testing, separation, and running other operating systems.

Offline

Board footer

Powered by FluxBB