From c706b9eefba010e518dc1fdfbb1597545894a5a0 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Fri, 21 Jul 2017 10:19:02 +0300 Subject: [PATCH 1/3] check current timezone before doing anything --- .../conf/type/__timezone/explorer/timezone_is | 20 +++++++++++++++++++ cdist/conf/type/__timezone/gencode-remote | 9 +++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100755 cdist/conf/type/__timezone/explorer/timezone_is diff --git a/cdist/conf/type/__timezone/explorer/timezone_is b/cdist/conf/type/__timezone/explorer/timezone_is new file mode 100755 index 00000000..7e9de076 --- /dev/null +++ b/cdist/conf/type/__timezone/explorer/timezone_is @@ -0,0 +1,20 @@ +#!/bin/sh -e +# +# 2016 Ander Punnar (cdist at kvlt.ee) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +cat /etc/timezone diff --git a/cdist/conf/type/__timezone/gencode-remote b/cdist/conf/type/__timezone/gencode-remote index d72da918..e512f861 100755 --- a/cdist/conf/type/__timezone/gencode-remote +++ b/cdist/conf/type/__timezone/gencode-remote @@ -20,11 +20,16 @@ # # This type allows to configure the desired localtime timezone. -timezone="$__object_id" +timezone_is=$(cat "$__object/explorer/timezone_is") +timezone_should="$__object_id" os=$(cat "$__global/explorer/os") +if [ "$timezone_is" = "$timezone_should" ]; then + exit 0 +fi + case "$os" in ubuntu|debian|devuan) - echo "echo \"$timezone\" > /etc/timezone" + echo "echo \"$timezone_should\" > /etc/timezone" ;; esac From 2c56622eebca26002f882bb2d17f20ccd27bc753 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Fri, 21 Jul 2017 10:22:54 +0300 Subject: [PATCH 2/3] check file first --- cdist/conf/type/__timezone/explorer/timezone_is | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__timezone/explorer/timezone_is b/cdist/conf/type/__timezone/explorer/timezone_is index 7e9de076..ec957139 100755 --- a/cdist/conf/type/__timezone/explorer/timezone_is +++ b/cdist/conf/type/__timezone/explorer/timezone_is @@ -17,4 +17,5 @@ # You should have received a copy of the GNU General Public License # along with cdist. If not, see . # -cat /etc/timezone + +[ -f /etc/timezone ] && cat /etc/timezone From 6bfe02094d960587d181d77437936189666d0248 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Fri, 21 Jul 2017 10:23:05 +0300 Subject: [PATCH 3/3] year is 2017 --- cdist/conf/type/__timezone/explorer/timezone_is | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__timezone/explorer/timezone_is b/cdist/conf/type/__timezone/explorer/timezone_is index ec957139..4e918121 100755 --- a/cdist/conf/type/__timezone/explorer/timezone_is +++ b/cdist/conf/type/__timezone/explorer/timezone_is @@ -1,6 +1,6 @@ #!/bin/sh -e # -# 2016 Ander Punnar (cdist at kvlt.ee) +# 2017 Ander Punnar (cdist at kvlt.ee) # # This file is part of cdist. #