Files
Virtnet.bond/runner.sh

97 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
git_pull="${SCRIPT_DIR}/gitpull.sh"
git_push="${SCRIPT_DIR}/gitpush.sh"
git_log="${SCRIPT_DIR}/laravallog.sh"
git_cache="${SCRIPT_DIR}/laravalcache.sh"
divider="==============================================="
while true; do
clear
cat <<EOF
$divider
Paymenter Utility Runner
$divider
[1] Run gitpull.sh
[2] Run gitpush.sh
[3] Run laravallog.sh
[4] Run laravalcache.sh
[5] Clear Laravel log
[6] Clear Laravel log and show logs
[7] Exit
$divider
Select an option by pressing the number key.
EOF
read -n1 -s choice
echo
case "$choice" in
1)
[ -x "$git_pull" ] || chmod +x "$git_pull"
"$git_pull"
;;
2)
[ -x "$git_push" ] || chmod +x "$git_push"
"$git_push"
;;
3)
[ -x "$git_log" ] || chmod +x "$git_log"
"$git_log"
;;
4)
[ -x "$git_cache" ] || chmod +x "$git_cache"
"$git_cache"
;;
5)
LOG_DATE=$(date +%Y-%m-%d)
LOG_FILE="${SCRIPT_DIR}/storage/logs/laravel-${LOG_DATE}.log"
if [ -f "$LOG_FILE" ]; then
> "$LOG_FILE"
echo "Log file cleared successfully: $LOG_FILE"
else
echo "Log file not found: $LOG_FILE"
fi
;;
6)
# Clear Laravel log first
LOG_DATE=$(date +%Y-%m-%d)
LOG_FILE="${SCRIPT_DIR}/storage/logs/laravel-${LOG_DATE}.log"
if [ -f "$LOG_FILE" ]; then
> "$LOG_FILE"
echo "Log file cleared successfully: $LOG_FILE"
else
echo "Log file not found: $LOG_FILE"
fi
# Pause and wait for user input
echo
echo "Press Enter to continue and show the logs..."
read -r
# Then show logs
echo "Showing Laravel logs..."
[ -x "$git_log" ] || chmod +x "$git_log"
"$git_log"
;;
7)
echo "Goodbye!"
exit 0
;;
*)
echo "Invalid selection. Press any key to continue."
read -n1 -s
;;
esac
echo
echo "Press any key to return to the menu..."
read -n1 -s
done