Last active
January 17, 2026 14:42
-
-
Save darallium/2c70d8f2602eb6eefc096a1f6d027808 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -euo pipefail | |
| cd $(dirname $0) | |
| LOG_DIR="./log" | |
| LOG_NAME="build-log" | |
| ELOG_NAME="build-elog" | |
| LOG_FILE="${LOG_DIR}/${LOG_FILE}" | |
| ELOG_FILE="${LOG_DIR}/${ELOG_FILE}" | |
| if [ ! -d "$LOG_DIR" ]; then | |
| mkdir -p "$LOG_DIR" | |
| fi | |
| MAX_GEN=1000 | |
| for i in $( seq $((MAX_GEN - 1)) -1 1); do | |
| if [ -f "${LOG_FILE}.$i" ]; then | |
| mv "${LOG_FILE}.$i" "${LOG_FILE}.$((i + 1))" | |
| fi | |
| done | |
| if [ -f ${LOG_FILE} ] ; then | |
| mv "${LOG_FILE}" "${LOG_FILE}.1" | |
| touch "${LOG_FILE}" | |
| chmod 644 "${LOG_FILE}" | |
| fi | |
| for i in $( seq $((MAX_GEN - 1)) -1 1); do | |
| if [ -f "${ELOG_FILE}.$i" ]; then | |
| mv "${ELOG_FILE}.$i" "${ELOG_FILE}.$((i + 1))" | |
| fi | |
| done | |
| if [ -f ${ELOG_FILE} ] ; then | |
| mv "${ELOG_FILE}" "${ELOG_FILE}.1" | |
| touch "${ELOG_FILE}" | |
| chmod 644 "${ELOG_FILE}" | |
| fi | |
| exec > >(tee -a "${LOG_FILE}") | |
| exec 2> >(tee -a "${ELOG_FILE}") | |
| # your commands following here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment