Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ sudo cp $IMAGE_CONFIGS/hostname/hostname-config.service $FILESYSTEM_ROOT/etc/sy
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable hostname-config.service
sudo cp $IMAGE_CONFIGS/hostname/hostname-config.sh $FILESYSTEM_ROOT/usr/bin/

# Copy timezone configuration scripts
sudo cp $IMAGE_CONFIGS/timezone/timezone-config.service $FILESYSTEM_ROOT/etc/systemd/system/
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable timezone-config.service
sudo cp $IMAGE_CONFIGS/timezone/timezone-config.sh $FILESYSTEM_ROOT/usr/bin/

# Copy updategraph script and service file
j2 files/build_templates/updategraph.service.j2 | sudo tee $FILESYSTEM_ROOT/etc/systemd/system/updategraph.service
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable updategraph.service
Expand Down
11 changes: 11 additions & 0 deletions files/image_config/timezone/timezone-config.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Update timezone based on configdb
Requires=updategraph.service
After=updategraph.service

[Service]
Type=oneshot
ExecStart=/usr/bin/timezone-config.sh

[Install]
WantedBy=multi-user.target
12 changes: 12 additions & 0 deletions files/image_config/timezone/timezone-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash -e

CURRENT_TIMEZONE=`cat /etc/timezone`
TIMEZONE=`sonic-cfggen -d -v DEVICE_METADATA[\'localhost\'][\'timezone\']`

if [ -n $TIMEZONE ]
then
sudo bash -c "echo $TIMEZONE > /etc/timezone"
sudo bash -c "dpkg-reconfigure -f noninteractive tzdata"
sudo bash -c "systemctl restart rsyslog"
sudo bash -c "systemctl restart cron"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't these already run as root ? Why need "sudo bash -c " ?
Could you use "timedatectl settimezone US/Pacific" to set the timezone instead of directly modifying the files ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left previous company i can't modify this pull request any more.

fi