Skip to content

Commit

Permalink
Move existing logs to the new log location, if they exist
Browse files Browse the repository at this point in the history
  • Loading branch information
zrhoffman committed Apr 29, 2024
1 parent 8365645 commit 5da11ab
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
16 changes: 16 additions & 0 deletions traffic_monitor/build/traffic_monitor.spec
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,22 @@ cp "$src"/build/traffic_monitor.init "${RPM_BUILD_ROOT}"/etc/init.d/traffi
cp "$src"/build/traffic_monitor.logrotate "${RPM_BUILD_ROOT}"/etc/logrotate.d/traffic_monitor

%pre
old_log_dir=/opt/traffic_monitor/var/log
new_log_dir=/var/log/traffic_monitor
if [[ -d "$old_log_dir" ]]; then
if [[ -d "$new_log_dir" ]]; then
(
# Include files starting with . in the * glob
shopt -s dotglob
mv "$old_log_dir"/* "$new_log_dir" || true
)
rmdir "$old_log_dir"
else
mv "$old_log_dir" "$new_log_dir"
fi
sync
fi

/usr/bin/getent group traffic_monitor >/dev/null
if [ $? -ne 0 ]; then
/usr/sbin/groupadd -g 423 traffic_monitor
Expand Down
17 changes: 17 additions & 0 deletions traffic_router/core/src/main/scripts/preinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@
# limitations under the License.
#

set -o nounset
old_log_dir=/opt/traffic_router/var/log
new_log_dir=/var/log/traffic_router
if [[ -d "$old_log_dir" ]]; then
if [[ -d "$new_log_dir" ]]; then
(
# Include files starting with . in the * glob
shopt -s dotglob
mv "$old_log_dir"/* "$new_log_dir" || true
)
rmdir "$old_log_dir"
else
mv "$old_log_dir" "$new_log_dir"
fi
sync
fi

# figure out which version of traffic_router is currently running
# and then shut it down. Running both test just in case.
set +e
Expand Down
15 changes: 15 additions & 0 deletions traffic_router/tomcat-rpm/tomcat.spec
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ if [ -d /opt/apache-tomcat-* ]; then
fi

%pre
old_log_dir=/opt/tomcat/logs
new_log_dir=/var/log/tomcat
if [[ -d "$old_log_dir" ]]; then
if [[ -d "$new_log_dir" ]]; then
(
# Include files starting with . in the * glob
shopt -s dotglob
mv "$old_log_dir"/* "$new_log_dir" || true
)
rmdir "$old_log_dir"
else
mv "$old_log_dir" "$new_log_dir"
fi
sync
fi

%files
%license LICENSE
Expand Down
16 changes: 16 additions & 0 deletions traffic_stats/build/traffic_stats.spec
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,22 @@ cp "$src"/influxdb_tools/create_ts_databases "${RPM_BUILD_ROOT}"/opt/traffic_st


%pre
old_log_dir=/opt/traffic_stats/var/log
new_log_dir=/var/log/traffic_stats
if [[ -d "$old_log_dir" ]]; then
if [[ -d "$new_log_dir" ]]; then
(
# Include files starting with . in the * glob
shopt -s dotglob
mv "$old_log_dir"/* "$new_log_dir" || true
)
rmdir "$old_log_dir"
else
mv "$old_log_dir" "$new_log_dir"
fi
sync
fi

/usr/bin/getent group traffic_stats >/dev/null

if [ $? -ne 0 ]; then
Expand Down

0 comments on commit 5da11ab

Please sign in to comment.