Skip to content
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

Only reference logfile when log level > info #311

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

berendt
Copy link
Member

@berendt berendt commented Sep 30, 2024

This avois duplication entries like in this sample.

Last login: Sun Sep 29 15:50:41 2024 from 127.0.0.1

INFO: BOOTSTRAP COMPLETE

Review the progress in /var/log/install-cloud-in-a-box.log
INFO: DEPLOYMENT COMPLETED SUCCESSFULLY

Review the progress in /var/log/install-cloud-in-a-box.log

This avois duplication entries like in this sample.

```
Last login: Sun Sep 29 15:50:41 2024 from 127.0.0.1

INFO: BOOTSTRAP COMPLETE

Review the progress in /var/log/install-cloud-in-a-box.log
INFO: DEPLOYMENT COMPLETED SUCCESSFULLY

Review the progress in /var/log/install-cloud-in-a-box.log
```

Signed-off-by: Christian Berendt <berendt@osism.tech>
@berendt berendt requested a review from scoopex September 30, 2024 09:38
@scoopex
Copy link
Contributor

scoopex commented Sep 30, 2024

I think the duplicate entries are because the backups are made every time add_status is executed.

How would that be?

$ git diff
diff --git a/include.sh b/include.sh
index 7551f44..9b8f63f 100644
--- a/include.sh
+++ b/include.sh
@@ -96,12 +96,13 @@ add_status(){
        text="$text\n\nReview $BOOTSTRAP_LOGFILE to analyze what went wrong"
    fi
 
-   sudo cp /etc/issue.net /etc/.issue.net.backup
-   sudo cp /etc/issue /etc/.issue.backup
-   sudo touch /etc/motd
-   sudo cp /etc/motd /etc/.motd.backup
+   for file_status in /etc/issue.net /etc/issue /etc/motd; do
+      if [ -e "$file_status" ];then
+         sudo cp "$file_status" "${file_status}.backup"
+      else
+         sudo touch "${file_status}.backup"
+      fi
+      (cat "${file_status}.backup"; echo -e "$text") | sudo tee $file_status >/dev/null
+   done
 
-   (cat /etc/.issue.net.backup; echo -e "$text") | sudo tee /etc/issue.net >/dev/null
-   (cat /etc/.issue.backup ; echo -e "$text") | sudo tee /etc/issue
-   (cat /etc/.motd.backup ; echo -e "$text") | sudo tee /etc/motd
 }

Copy link
Contributor

@scoopex scoopex left a comment

Choose a reason for hiding this comment

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

I think the duplicate entries are because the backups are made every time add_status is executed.

if [[ "$type" = "info" ]] && [[ -n "$BOOTSTRAP_LOGFILE" ]];then
text="$text\n\nReview the progress in $BOOTSTRAP_LOGFILE"
elif [[ -n "$BOOTSTRAP_LOGFILE" ]];then
if [[ -n "$BOOTSTRAP_LOGFILE" ]];then
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if [[ -n "$BOOTSTRAP_LOGFILE" ]];then
if [[ "$type" = "info" ]] && [[ -n "$BOOTSTRAP_LOGFILE" ]];then
text="$text\n\nReview the progress in $BOOTSTRAP_LOGFILE"
elif [[ -n "$BOOTSTRAP_LOGFILE" ]];then
text="$text\n\nReview $BOOTSTRAP_LOGFILE to analyze what went wrong"
fi
for file_status in /etc/issue.net /etc/issue /etc/motd; do
if [ -e "$file_status" ];then
sudo cp "$file_status" "${file_status}.backup"
else
sudo touch "${file_status}.backup"
fi
(cat "${file_status}.backup"; echo -e "$text") | sudo tee $file_status >/dev/null
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants