PACKAGE - Cleanup packaging
- Clean-up packaging scripts. More consistent with RDC.
- Remove all 'sudo' calls. all these scripts are to be ran by root.
- Reduce scope of variables.
- Remove unnecessary functions
Change-Id: Ib90f8e66ef4eae24f73e940fff44f515e12233f5
Signed-off-by: Galantsev, Dmitrii <dmitrii.galantsev@amd.com>
[ROCm/rocm_smi_lib commit: 431a7071a0]
Dieser Commit ist enthalten in:
committet von
Dmitrii Galantsev
Ursprung
a246645060
Commit
73ec4e32e6
@@ -1,21 +1,18 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#set -x
|
|
||||||
|
|
||||||
packageName="rocm-smi-lib"
|
|
||||||
logPath=/var/log/rocm_smi_lib
|
|
||||||
logName=ROCm-SMI-lib.log
|
|
||||||
logFile="${logPath}/${logName}"
|
|
||||||
logrotateConfFile=/etc/logrotate.d/rocm_smi.conf
|
|
||||||
|
|
||||||
do_addLogFolder() {
|
|
||||||
sudo mkdir -p "${logPath}"
|
|
||||||
sudo touch "${logFile}"
|
|
||||||
sudo chmod -R a+rw "${logPath}"
|
|
||||||
sudo chmod a+rw "${logFile}"
|
|
||||||
}
|
|
||||||
|
|
||||||
do_configureLogrotate() {
|
do_configureLogrotate() {
|
||||||
logrotate --version &>/dev/null
|
local IS_SYSTEMD=0
|
||||||
|
local packageName="rocm-smi-lib"
|
||||||
|
local logPath=/var/log/rocm_smi_lib
|
||||||
|
local logFile="${logPath}/ROCm-SMI-lib.log"
|
||||||
|
local logrotateConfFile=/etc/logrotate.d/rocm_smi.conf
|
||||||
|
|
||||||
|
mkdir -p "${logPath}"
|
||||||
|
touch "${logFile}"
|
||||||
|
chmod -R a+rw "${logPath}"
|
||||||
|
chmod a+rw "${logFile}"
|
||||||
|
|
||||||
|
command -v logrotate &>/dev/null
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "[WARNING] Detected logrotate is not installed."\
|
echo "[WARNING] Detected logrotate is not installed."\
|
||||||
"$packageName logs (when turned on) will not rotate properly."
|
"$packageName logs (when turned on) will not rotate properly."
|
||||||
@@ -23,14 +20,14 @@ do_configureLogrotate() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f $logrotateConfFile ]; then
|
if [ ! -f $logrotateConfFile ]; then
|
||||||
sudo touch "${logrotateConfFile}"
|
touch "${logrotateConfFile}"
|
||||||
sudo chmod 644 "${logrotateConfFile}" # root r/w, all others read
|
chmod 644 "${logrotateConfFile}" # root r/w, all others read
|
||||||
# ROCm SMI logging rotation, rotates files using root user/group
|
# ROCm SMI logging rotation, rotates files using root user/group
|
||||||
# Hourly logrotation check
|
# Hourly logrotation check
|
||||||
# Only rotates if size grew larger than 1MB
|
# Only rotates if size grew larger than 1MB
|
||||||
# Max of 4 rotation files, oldest will be removed
|
# Max of 4 rotation files, oldest will be removed
|
||||||
# Rotated files use date extention of ex. ROCm-SMI-lib.log.2023-05-09_16:51:42
|
# Rotated files use date extention of ex. ROCm-SMI-lib.log.2023-05-09_16:51:42
|
||||||
cat << EOF | sudo tee "${logrotateConfFile}" >/dev/null
|
cat << EOF > "${logrotateConfFile}"
|
||||||
${logFile} {
|
${logFile} {
|
||||||
su root root
|
su root root
|
||||||
hourly
|
hourly
|
||||||
@@ -47,43 +44,29 @@ EOF
|
|||||||
# issue was RPM build thought we were using macros
|
# issue was RPM build thought we were using macros
|
||||||
# https://gitlab.kitware.com/cmake/cmake/-/issues/22965
|
# https://gitlab.kitware.com/cmake/cmake/-/issues/22965
|
||||||
# https://rpm-software-management.github.io/rpm/manual/spec.html
|
# https://rpm-software-management.github.io/rpm/manual/spec.html
|
||||||
sudo sed -i s/%%/%/g "${logrotateConfFile}"
|
sed -i s/%%/%/g "${logrotateConfFile}"
|
||||||
# workaround: remove extra 'OURCE' text
|
# workaround: remove extra 'OURCE' text
|
||||||
# from rocm_smi.conf. Unsure if CMAKE,
|
# from rocm_smi.conf. Unsure if CMAKE,
|
||||||
# bash, or here document
|
# bash, or here document
|
||||||
# issue (only seen on RHEL 8.7)
|
# issue (only seen on RHEL 8.7)
|
||||||
sudo sed -i s/OURCE//g "${logrotateConfFile}"
|
sed -i s/OURCE//g "${logrotateConfFile}"
|
||||||
fi
|
fi
|
||||||
# check if logrotate uses system timers, Ubuntu/modern OS's do
|
# check if logrotate uses system timers, Ubuntu/modern OS's do
|
||||||
# Several older OS's like RHEL 8.7, do not. Instead defaults
|
# Several older OS's like RHEL 8.7, do not. Instead defaults
|
||||||
# to use daily cron jobs - see https://stackoverflow.com/a/69465677
|
# to use daily cron jobs - see https://stackoverflow.com/a/69465677
|
||||||
sudo systemctl list-timers|grep -iq logrotate
|
if [ -d /run/systemd/system ]; then
|
||||||
if [ $? -ne 0 ]; then
|
systemctl list-timers | grep -iq logrotate
|
||||||
# confirm logrotate file exists in daily
|
if [ $? -ne 0 ]; then
|
||||||
if [ -f /etc/cron.daily/logrotate ]; then
|
IS_SYSTEMD=1
|
||||||
# move logrotate daily to hourly
|
|
||||||
if [ -d /etc/cron.hourly ]; then
|
|
||||||
sudo mv /etc/cron.daily/logrotate /etc/cron.hourly/logrotate
|
|
||||||
else
|
|
||||||
echo "[WARNING] Could find and configure hourly cron for $packageName's"\
|
|
||||||
" logrotate. $packageName logs (when turned on) will not rotate properly."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# confirm that it's already been moved to hourly
|
|
||||||
sudo find /etc/cron.* -iname logrotate -print -quit |grep -iq hourly
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "[WARNING] Could not configure an hourly cron for $packageName's logrotate."\
|
|
||||||
"$packageName logs (when turned on) may not rotate properly."
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
return #done configuring for non-systemd timers
|
fi
|
||||||
else
|
if [ "$IS_SYSTEMD" -eq 1 ]; then
|
||||||
# Configure systemd timers - the typical setup for modern Linux logrotation setups
|
# Configure systemd timers - the typical setup for modern Linux logrotation setups
|
||||||
if [ -f /lib/systemd/system/logrotate.timer ]; then
|
if [ -f /lib/systemd/system/logrotate.timer ]; then
|
||||||
if [ ! -f /lib/systemd/system/logrotate.timer.backup ]; then
|
if [ ! -f /lib/systemd/system/logrotate.timer.backup ]; then
|
||||||
sudo cp /lib/systemd/system/logrotate.timer /lib/systemd/system/logrotate.timer.backup
|
cp /lib/systemd/system/logrotate.timer /lib/systemd/system/logrotate.timer.backup
|
||||||
fi
|
fi
|
||||||
cat <<'EOF' | sudo tee /lib/systemd/system/logrotate.timer >/dev/null
|
cat << EOF > /lib/systemd/system/logrotate.timer
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Hourly rotation of log files
|
Description=Hourly rotation of log files
|
||||||
Documentation=man:logrotate(8) man:logrotate.conf(5)
|
Documentation=man:logrotate(8) man:logrotate.conf(5)
|
||||||
@@ -97,12 +80,19 @@ Persistent=true
|
|||||||
[Install]
|
[Install]
|
||||||
WantedBy=timers.target
|
WantedBy=timers.target
|
||||||
EOF
|
EOF
|
||||||
sudo systemctl reenable --now logrotate.timer
|
systemctl reenable --now logrotate.timer
|
||||||
else
|
else
|
||||||
echo "[WARNING] Could not configure systemd timer for $packageName's logrotate."\
|
echo "[WARNING] Could not configure systemd timer for $packageName's logrotate."\
|
||||||
"$packageName logs (when turned on) will not rotate properly."
|
"$packageName logs (when turned on) will not rotate properly."
|
||||||
fi
|
fi
|
||||||
return #done configuring for systemd timers
|
else
|
||||||
|
# $IS_SYSTEMD -eq 0
|
||||||
|
if [ -f /etc/cron.daily/logrotate ]; then
|
||||||
|
# move logrotate daily to hourly
|
||||||
|
if [ -d /etc/cron.hourly ]; then
|
||||||
|
mv /etc/cron.daily/logrotate /etc/cron.hourly/logrotate
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +107,6 @@ do_ldconfig() {
|
|||||||
case "$1" in
|
case "$1" in
|
||||||
( configure )
|
( configure )
|
||||||
do_ldconfig
|
do_ldconfig
|
||||||
do_addLogFolder
|
|
||||||
do_configureLogrotate
|
do_configureLogrotate
|
||||||
;;
|
;;
|
||||||
( abort-upgrade | abort-remove | abort-deconfigure )
|
( abort-upgrade | abort-remove | abort-deconfigure )
|
||||||
|
|||||||
@@ -1,29 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
|
||||||
|
|
||||||
packageName="rocm-smi-lib"
|
|
||||||
logPath=/var/log/rocm_smi_lib
|
|
||||||
logName=ROCm-SMI-lib.log
|
|
||||||
logFile="${logPath}/${logName}"
|
|
||||||
logrotateConfFile=/etc/logrotate.d/rocm_smi.conf
|
|
||||||
|
|
||||||
rm_logFolder() {
|
|
||||||
sudo rm -rf "$logPath"
|
|
||||||
}
|
|
||||||
|
|
||||||
return_logrotateToOrigConfig() {
|
|
||||||
if [ -f $logrotateConfFile ]; then
|
|
||||||
sudo rm -rf "${logrotateConfFile}"
|
|
||||||
fi
|
|
||||||
if [ -f /etc/cron.hourly/logrotate ]; then
|
|
||||||
sudo mv /etc/cron.hourly/logrotate /etc/cron.daily/logrotate
|
|
||||||
fi
|
|
||||||
if [ -f /lib/systemd/system/logrotate.timer.backup ]; then
|
|
||||||
sudo cp /lib/systemd/system/logrotate.timer.backup /lib/systemd/system/logrotate.timer
|
|
||||||
sudo rm -rf /lib/systemd/system/logrotate.timer.backup
|
|
||||||
sudo systemctl reenable --now logrotate.timer
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
rm_ldconfig() {
|
rm_ldconfig() {
|
||||||
# left-hand term originates from ENABLE_LDCONFIG = ON/OFF at package build
|
# left-hand term originates from ENABLE_LDCONFIG = ON/OFF at package build
|
||||||
@@ -34,8 +9,27 @@ rm_ldconfig() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rm_pyc() {
|
rm_pyc() {
|
||||||
# remove pyc file generated by python
|
# remove pyc file generated by python
|
||||||
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/rocm_smi/__pycache__
|
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/rocm_smi/__pycache__
|
||||||
|
}
|
||||||
|
|
||||||
|
rm_logFolder() {
|
||||||
|
rm -rf /var/log/rocm_smi_lib
|
||||||
|
}
|
||||||
|
|
||||||
|
return_logrotateToOrigConfig() {
|
||||||
|
local logrotateConfFile=/etc/logrotate.d/rocm_smi.conf
|
||||||
|
if [ -f $logrotateConfFile ]; then
|
||||||
|
rm -rf "$logrotateConfFile"
|
||||||
|
fi
|
||||||
|
if [ -f /etc/cron.hourly/logrotate ]; then
|
||||||
|
mv /etc/cron.hourly/logrotate /etc/cron.daily/logrotate
|
||||||
|
fi
|
||||||
|
if [ -f /lib/systemd/system/logrotate.timer.backup ]; then
|
||||||
|
cp /lib/systemd/system/logrotate.timer.backup /lib/systemd/system/logrotate.timer
|
||||||
|
rm -rf /lib/systemd/system/logrotate.timer.backup
|
||||||
|
systemctl reenable --now logrotate.timer
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,18 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#set -x
|
|
||||||
|
|
||||||
packageName="rocm-smi-lib"
|
|
||||||
logPath=/var/log/rocm_smi_lib
|
|
||||||
logName=ROCm-SMI-lib.log
|
|
||||||
logFile="${logPath}/${logName}"
|
|
||||||
logrotateConfFile=/etc/logrotate.d/rocm_smi.conf
|
|
||||||
|
|
||||||
do_addLogFolder() {
|
|
||||||
sudo mkdir -p "${logPath}"
|
|
||||||
sudo touch "${logFile}"
|
|
||||||
sudo chmod -R a+rw "${logPath}"
|
|
||||||
sudo chmod a+rw "${logFile}"
|
|
||||||
}
|
|
||||||
|
|
||||||
do_configureLogrotate() {
|
do_configureLogrotate() {
|
||||||
logrotate --version &>/dev/null
|
local IS_SYSTEMD=0
|
||||||
|
local packageName="rocm-smi-lib"
|
||||||
|
local logPath=/var/log/rocm_smi_lib
|
||||||
|
local logFile="${logPath}/ROCm-SMI-lib.log"
|
||||||
|
local logrotateConfFile=/etc/logrotate.d/rocm_smi.conf
|
||||||
|
|
||||||
|
mkdir -p "${logPath}"
|
||||||
|
touch "${logFile}"
|
||||||
|
chmod -R a+rw "${logPath}"
|
||||||
|
chmod a+rw "${logFile}"
|
||||||
|
|
||||||
|
command -v logrotate &>/dev/null
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "[WARNING] Detected logrotate is not installed."\
|
echo "[WARNING] Detected logrotate is not installed."\
|
||||||
"$packageName logs (when turned on) will not rotate properly."
|
"$packageName logs (when turned on) will not rotate properly."
|
||||||
@@ -23,14 +20,14 @@ do_configureLogrotate() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f $logrotateConfFile ]; then
|
if [ ! -f $logrotateConfFile ]; then
|
||||||
sudo touch "${logrotateConfFile}"
|
touch "${logrotateConfFile}"
|
||||||
sudo chmod 644 "${logrotateConfFile}" # root r/w, all others read
|
chmod 644 "${logrotateConfFile}" # root r/w, all others read
|
||||||
# ROCm SMI logging rotation, rotates files using root user/group
|
# ROCm SMI logging rotation, rotates files using root user/group
|
||||||
# Hourly logrotation check
|
# Hourly logrotation check
|
||||||
# Only rotates if size grew larger than 1MB
|
# Only rotates if size grew larger than 1MB
|
||||||
# Max of 4 rotation files, oldest will be removed
|
# Max of 4 rotation files, oldest will be removed
|
||||||
# Rotated files use date extention of ex. ROCm-SMI-lib.log.2023-05-09_16:51:42
|
# Rotated files use date extention of ex. ROCm-SMI-lib.log.2023-05-09_16:51:42
|
||||||
cat << EOF | sudo tee "${logrotateConfFile}" >/dev/null
|
cat << EOF > "${logrotateConfFile}"
|
||||||
${logFile} {
|
${logFile} {
|
||||||
su root root
|
su root root
|
||||||
hourly
|
hourly
|
||||||
@@ -47,43 +44,29 @@ EOF
|
|||||||
# issue was RPM build thought we were using macros
|
# issue was RPM build thought we were using macros
|
||||||
# https://gitlab.kitware.com/cmake/cmake/-/issues/22965
|
# https://gitlab.kitware.com/cmake/cmake/-/issues/22965
|
||||||
# https://rpm-software-management.github.io/rpm/manual/spec.html
|
# https://rpm-software-management.github.io/rpm/manual/spec.html
|
||||||
sudo sed -i s/%%/%/g "${logrotateConfFile}"
|
sed -i s/%%/%/g "${logrotateConfFile}"
|
||||||
# workaround: remove extra 'OURCE' text
|
# workaround: remove extra 'OURCE' text
|
||||||
# from rocm_smi.conf. Unsure if CMAKE,
|
# from rocm_smi.conf. Unsure if CMAKE,
|
||||||
# bash, or here document
|
# bash, or here document
|
||||||
# issue (only seen on RHEL 8.7)
|
# issue (only seen on RHEL 8.7)
|
||||||
sudo sed -i s/OURCE//g "${logrotateConfFile}"
|
sed -i s/OURCE//g "${logrotateConfFile}"
|
||||||
fi
|
fi
|
||||||
# check if logrotate uses system timers, Ubuntu/modern OS's do
|
# check if logrotate uses system timers, Ubuntu/modern OS's do
|
||||||
# Several older OS's like RHEL 8.7, do not. Instead defaults
|
# Several older OS's like RHEL 8.7, do not. Instead defaults
|
||||||
# to use daily cron jobs - see https://stackoverflow.com/a/69465677
|
# to use daily cron jobs - see https://stackoverflow.com/a/69465677
|
||||||
sudo systemctl list-timers|grep -iq logrotate
|
if [ -d /run/systemd/system ]; then
|
||||||
if [ $? -ne 0 ]; then
|
systemctl list-timers | grep -iq logrotate
|
||||||
# confirm logrotate file exists in daily
|
if [ $? -ne 0 ]; then
|
||||||
if [ -f /etc/cron.daily/logrotate ]; then
|
IS_SYSTEMD=1
|
||||||
# move logrotate daily to hourly
|
|
||||||
if [ -d /etc/cron.hourly ]; then
|
|
||||||
sudo mv /etc/cron.daily/logrotate /etc/cron.hourly/logrotate
|
|
||||||
else
|
|
||||||
echo "[WARNING] Could find and configure hourly cron for $packageName's"\
|
|
||||||
" logrotate. $packageName logs (when turned on) will not rotate properly."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# confirm that it's already been moved to hourly
|
|
||||||
sudo find /etc/cron.* -iname logrotate -print -quit |grep -iq hourly
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "[WARNING] Could not configure an hourly cron for $packageName's logrotate."\
|
|
||||||
"$packageName logs (when turned on) may not rotate properly."
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
return #done configuring for non-systemd timers
|
fi
|
||||||
else
|
if [ "$IS_SYSTEMD" -eq 1 ]; then
|
||||||
# Configure systemd timers - the typical setup for modern Linux logrotation setups
|
# Configure systemd timers - the typical setup for modern Linux logrotation setups
|
||||||
if [ -f /lib/systemd/system/logrotate.timer ]; then
|
if [ -f /lib/systemd/system/logrotate.timer ]; then
|
||||||
if [ ! -f /lib/systemd/system/logrotate.timer.backup ]; then
|
if [ ! -f /lib/systemd/system/logrotate.timer.backup ]; then
|
||||||
sudo cp /lib/systemd/system/logrotate.timer /lib/systemd/system/logrotate.timer.backup
|
cp /lib/systemd/system/logrotate.timer /lib/systemd/system/logrotate.timer.backup
|
||||||
fi
|
fi
|
||||||
cat <<'EOF' | sudo tee /lib/systemd/system/logrotate.timer >/dev/null
|
cat << EOF > /lib/systemd/system/logrotate.timer
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Hourly rotation of log files
|
Description=Hourly rotation of log files
|
||||||
Documentation=man:logrotate(8) man:logrotate.conf(5)
|
Documentation=man:logrotate(8) man:logrotate.conf(5)
|
||||||
@@ -97,12 +80,19 @@ Persistent=true
|
|||||||
[Install]
|
[Install]
|
||||||
WantedBy=timers.target
|
WantedBy=timers.target
|
||||||
EOF
|
EOF
|
||||||
sudo systemctl reenable --now logrotate.timer
|
systemctl reenable --now logrotate.timer
|
||||||
else
|
else
|
||||||
echo "[WARNING] Could not configure systemd timer for $packageName's logrotate."\
|
echo "[WARNING] Could not configure systemd timer for $packageName's logrotate."\
|
||||||
"$packageName logs (when turned on) will not rotate properly."
|
"$packageName logs (when turned on) will not rotate properly."
|
||||||
fi
|
fi
|
||||||
return #done configuring for systemd timers
|
else
|
||||||
|
# $IS_SYSTEMD -eq 0
|
||||||
|
if [ -f /etc/cron.daily/logrotate ]; then
|
||||||
|
# move logrotate daily to hourly
|
||||||
|
if [ -d /etc/cron.hourly ]; then
|
||||||
|
mv /etc/cron.daily/logrotate /etc/cron.hourly/logrotate
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,14 +104,8 @@ do_ldconfig() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# left-hand term originates from ENABLE_LDCONFIG = ON/OFF at package build
|
|
||||||
if [ "@ENABLE_LDCONFIG@" == "ON" ]; then
|
|
||||||
echo -e "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@" > /etc/ld.so.conf.d/x86_64-librocm_smi_lib.conf
|
|
||||||
ldconfig
|
|
||||||
fi
|
|
||||||
|
|
||||||
# post install or upgrade, $i is 1 or 2 -> do these actions
|
# post install or upgrade, $i is 1 or 2 -> do these actions
|
||||||
if [ $1 -ge 1 ]; then
|
if [ "$1" -ge 1 ]; then
|
||||||
do_addLogFolder
|
do_ldconfig
|
||||||
do_configureLogrotate
|
do_configureLogrotate
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# second term originates from ENABLE_LDCONFIG = ON/OFF at package build
|
# second term originates from ENABLE_LDCONFIG = ON/OFF at package build
|
||||||
if [ $1 -le 1 ] && [ "@ENABLE_LDCONFIG@" == "ON" ]; then
|
if [ "$1" -le 1 ] && [ "@ENABLE_LDCONFIG@" == "ON" ]; then
|
||||||
# perform the below actions for rpm remove($1=0) or upgrade($1=1) operations
|
# perform the below actions for rpm remove($1=0) or upgrade($1=1) operations
|
||||||
rm -f /etc/ld.so.conf.d/x86_64-librocm_smi_lib.conf
|
rm -f /etc/ld.so.conf.d/x86_64-librocm_smi_lib.conf
|
||||||
ldconfig
|
ldconfig
|
||||||
|
|||||||
@@ -1,34 +1,32 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#set -x
|
|
||||||
|
|
||||||
packageName="rocm-smi-lib"
|
rm_pyc() {
|
||||||
logPath=/var/log/rocm_smi_lib
|
# remove pyc file generated by python
|
||||||
logName=ROCm-SMI-lib.log
|
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/rocm_smi/__pycache__
|
||||||
logFile="${logPath}/${logName}"
|
}
|
||||||
logrotateConfFile=/etc/logrotate.d/rocm_smi.conf
|
|
||||||
|
|
||||||
rm_logFolder() {
|
rm_logFolder() {
|
||||||
sudo rm -rf "$logPath"
|
rm -rf /var/log/rocm_smi_lib
|
||||||
}
|
}
|
||||||
|
|
||||||
return_logrotateToOrigConfig() {
|
return_logrotateToOrigConfig() {
|
||||||
|
local logrotateConfFile=/etc/logrotate.d/rocm_smi.conf
|
||||||
if [ -f $logrotateConfFile ]; then
|
if [ -f $logrotateConfFile ]; then
|
||||||
sudo rm -rf "${logrotateConfFile}"
|
rm -rf "$logrotateConfFile"
|
||||||
fi
|
fi
|
||||||
if [ -f /etc/cron.hourly/logrotate ]; then
|
if [ -f /etc/cron.hourly/logrotate ]; then
|
||||||
sudo mv /etc/cron.hourly/logrotate /etc/cron.daily/logrotate
|
mv /etc/cron.hourly/logrotate /etc/cron.daily/logrotate
|
||||||
fi
|
fi
|
||||||
if [ -f /lib/systemd/system/logrotate.timer.backup ]; then
|
if [ -f /lib/systemd/system/logrotate.timer.backup ]; then
|
||||||
sudo cp /lib/systemd/system/logrotate.timer.backup /lib/systemd/system/logrotate.timer
|
cp /lib/systemd/system/logrotate.timer.backup /lib/systemd/system/logrotate.timer
|
||||||
sudo rm -rf /lib/systemd/system/logrotate.timer.backup
|
rm -rf /lib/systemd/system/logrotate.timer.backup
|
||||||
sudo systemctl reenable --now logrotate.timer
|
systemctl reenable --now logrotate.timer
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ $1 -le 1 ]; then
|
if [ "$1" -le 1 ]; then
|
||||||
# perform the below actions for rpm remove($1=0) or upgrade($1=1) operations
|
# perform the below actions for rpm remove($1=0) or upgrade($1=1) operations
|
||||||
# remove pyc file generated by python
|
rm_pyc
|
||||||
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/rocm_smi/__pycache__
|
|
||||||
rm_logFolder
|
rm_logFolder
|
||||||
return_logrotateToOrigConfig
|
return_logrotateToOrigConfig
|
||||||
fi
|
fi
|
||||||
|
|||||||
In neuem Issue referenzieren
Einen Benutzer sperren