Skip to content

Commit

Permalink
Check if reboot required
Browse files Browse the repository at this point in the history
  • Loading branch information
Ataraxxia committed Jan 5, 2022
1 parent 65741fe commit 5120231
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions Report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type HostInfo struct {

type Report struct {
HostInfo HostInfo `json:"host_info"`
RebootRequired string `json:"reboot_required"`
RepositoryType string `json:"repo_type"`
Protocol string `json:"protocol"`
PackageManager string `json:"package_manager"`
Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.1
1.2.0
2 changes: 1 addition & 1 deletion client/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1
1.2.0
23 changes: 23 additions & 0 deletions client/godin_client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,23 @@ get_yum_packages() {
echo "]" >> $TMP_PKG_LIST
}

check_reboot_required() {
reboot=0
if check_command_exists needs-restarting ; then
if [[ $(needs-restarting -r >/dev/null) -eq 1 ]]; then
reboot=1
fi
elif check_command_exists dnf ; then
if [[ $(dnf needs-restarting -r >/dev/null) -eq 1 ]]; then
reboot=1
fi
elif [ -f /var/run/reboot-required ]; then
reboot=1
fi

return $reboot
}

cleanup() {
rm $TMP_HOST_INFO
rm $TMP_PKG_LIST
Expand Down Expand Up @@ -360,6 +377,12 @@ echo "{" >> $TMP_PAYLOAD
cat $TMP_HOST_INFO >> $TMP_PAYLOAD
echo "," >> $TMP_PAYLOAD

if check_reboot_required ; then
echo "\"reboot_required\": \"yes\"," >> $TMP_PAYLOAD
else
echo "\"reboot_required\": \"no\"," >> $TMP_PAYLOAD
fi

echo -n "\"tags\" : [" >> $TMP_PAYLOAD
if [ ! -z "$TAGS" ]; then
for tag in $(echo $TAGS | sed "s/,/ /g"); do
Expand Down

0 comments on commit 5120231

Please sign in to comment.