-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support set timezone in ConfigDB #2568
Changes from 1 commit
a1e2dc8
c61aadb
fd7073a
6957749
de40c27
ad2ac36
b4e92da
9ca4b0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
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 [ ! $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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aren't these already run as root ? Why need "sudo bash -c " ? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest
if [ -n "$TIMEZONE" ]
to test for non-zero length.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modified as you suggested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add double-quotes around
$TIMEZONE
as I suggested.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.