This is a simple systemd service that automatically adjusts the system time zone.
In Pop!_OS 22.04, I found that the "automatic time zone" wasn't updating my system time zone automatically. As an experiment, I wanted to create a service using golang that determines my location based on my public IP address.
Go seems to be growing in popularity, and I wanted to take it for a spin. I learn best by making something useful, so that's exactly what this is.
All that's really needed is Golang installed on your system at /usr/local/go/bin/go
, and all of your environment variables set correctly. Feel free to modify build.sh
to your needs. Or don't, it's your life.
I created a simple shell script build.sh
which handles all of the building + moving of files.
The script does the following:
- Checks to see if the service file exists. If it doesn't, it clones the template file and changes the execuatble path to
$GOBIN/geoboi
- Builds geoboi and installs it to
$GOBIN
- Creates a symbolic link from
geoboi.service
to/etc/systemd/system/
- Reloads systemctl with any changes in
geoboi.service
I've found that Bash can sometimes not see the global environment variables, so run the script with the -E flag (e.g. sudo -E bash build.sh
). I spent an uncomfortable amount of time figuring that out.