mirror of
https://github.com/ChuckPa/PlexDBRepair.git
synced 2025-11-06 03:08:55 -05:00
Fix Quit / Exit behavior
Separate Quit and exit into two commands. - Quit is immediate exit without cleanup - Exit provides option to remove temp files - EOF exit will always retain temp files.
This commit is contained in:
parent
9833228f71
commit
1f23bf8419
67
DBRepair.sh
67
DBRepair.sh
@ -3,7 +3,7 @@
|
||||
# Plex Media Server database check and repair utility script. #
|
||||
# Maintainer: ChuckPa #
|
||||
# Version: v1.0.5 #
|
||||
# Date: 04-May-2023 #
|
||||
# Date: 16-May-2023 #
|
||||
#########################################################################
|
||||
|
||||
# Version for display purposes
|
||||
@ -37,6 +37,7 @@ HaveStartStop=0
|
||||
HostType=""
|
||||
LOG_TOOL="echo"
|
||||
ShowMenu=1
|
||||
Exit=0
|
||||
|
||||
# Universal output function
|
||||
Output() {
|
||||
@ -254,11 +255,20 @@ ConfirmYesNo() {
|
||||
read Input
|
||||
|
||||
# EOF = No
|
||||
[ "$Input" = "" ] && Answer=N ; [ "$Input" = "n" ] && Answer=N ; [ "$Input" = "N" ] && Answer=N
|
||||
[ "$Input" = "y" ] && Answer=Y ; [ "$Input" = "Y" ] && Answer=Y
|
||||
case "$Input" in
|
||||
YES|YE|Y|yes|ye|y)
|
||||
Answer=Y
|
||||
;;
|
||||
NO|N|no|n)
|
||||
Answer=N
|
||||
;;
|
||||
*)
|
||||
Answer=""
|
||||
;;
|
||||
esac
|
||||
|
||||
# Unrecognized
|
||||
if [ "$Answer" != "Y" ] && [ "$Answer" != "N" ]; then
|
||||
if [ "$Answer" != "Y" ] || [ "$Answer" != "N" ]; then
|
||||
printf "$Input" was not a valid reply. Please try again.
|
||||
continue
|
||||
fi
|
||||
@ -1468,8 +1478,8 @@ do
|
||||
echo " 11 - 'status' - Report status of PMS (run-state and databases)"
|
||||
echo " 12 - 'undo' - Undo last successful command"
|
||||
echo ""
|
||||
|
||||
echo " 99 - exit"
|
||||
echo " 99 - 'quit' - Quit immediately. Keep all temporary files."
|
||||
echo " 'exit' - Exit with cleanup options."
|
||||
fi
|
||||
|
||||
if [ $Scripted -eq 0 ]; then
|
||||
@ -1481,7 +1491,8 @@ do
|
||||
# If end of line then force exit
|
||||
if [ "$Input" = "" ]; then
|
||||
Input="exit"
|
||||
Output "Unexpected EOF / End of command line options, Exiting"
|
||||
Exit=1
|
||||
Output "Unexpected EOF / End of command line options. Exiting. Keeping temp files."
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -1496,7 +1507,7 @@ do
|
||||
# Handle EOF/forced exit
|
||||
if [ "$Input" = "" ] ; then
|
||||
if [ $NullCommands -gt 4 ]; then
|
||||
Output "Unexpected EOF / End of command line options, Exiting"
|
||||
Output "Unexpected EOF / End of command line options. Exiting. Keeping temp files. "
|
||||
Input="exit" && Exit=1
|
||||
else
|
||||
NullCommands=$(($NullCommands + 1))
|
||||
@ -1768,31 +1779,39 @@ do
|
||||
DoUndo
|
||||
;;
|
||||
|
||||
# Quit
|
||||
99|quit)
|
||||
|
||||
# Quit/Exit
|
||||
99|exit|quit)
|
||||
Output "Retaining all temporary work files."
|
||||
WriteLog "Exit - Retain temp files."
|
||||
exit 0
|
||||
;;
|
||||
|
||||
# if cmd line mode, exit clean
|
||||
# Orderly Exit
|
||||
exit)
|
||||
|
||||
# If forced exit set, exit and retain
|
||||
if [ $Exit -eq 1 ]; then
|
||||
Output "Unexpected exit command. Keeping all temporary work files."
|
||||
WriteLog "EOFExit - Retain temp files."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If cmd line mode, exit clean without asking
|
||||
if [ $Scripted -eq 1 ]; then
|
||||
rm -rf $TMPDIR
|
||||
WriteLog "Exit - Delete temp files."
|
||||
|
||||
else
|
||||
# Ask questions on interactive exit
|
||||
if [ $Exit -eq 0 ]; then
|
||||
# Ask if the user wants to remove the DBTMP directory and all backups thus far
|
||||
if [ "$Input" = "exit" ] && ConfirmYesNo "Ok to remove temporary databases/workfiles for this session?" ; then
|
||||
# There it goes
|
||||
Output "Deleting all temporary work files."
|
||||
WriteLog "Exit - Delete temp files."
|
||||
rm -rf "$TMPDIR"
|
||||
else
|
||||
Output "Retaining all temporary work files."
|
||||
WriteLog "Exit - Retain temp files."
|
||||
fi
|
||||
if ConfirmYesNo "Ok to remove temporary databases/workfiles for this session?" ; then
|
||||
# There it goes
|
||||
Output "Deleting all temporary work files."
|
||||
WriteLog "Exit - Delete temp files."
|
||||
rm -rf "$TMPDIR"
|
||||
else
|
||||
Output "Unexpected exit command. Keeping all temporary work files."
|
||||
WriteLog "EOFExit - Retain temp files."
|
||||
Output "Retaining all temporary work files."
|
||||
WriteLog "Exit - Retain temp files."
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
33
README.md
33
README.md
@ -131,16 +131,16 @@ If sufficient privleges exist (root), and supported by the environment, the opti
|
||||
|
||||
|
||||
|
||||
|
||||
### EXAMPLE: To install & launch on Synology DSM 6 / DSM 7
|
||||
|
||||
cd /volume1/Plex (/volume1/PlexMediaServer on DSM 7)
|
||||
cd /volume1/Plex # use /volume1/PlexMediaServer on DSM 7
|
||||
sudo bash
|
||||
tar xf PlexDBRepair-x.y.z.tar.gz
|
||||
cd PlexDBRepair-x.y.z
|
||||
chmod +x DBRepair.sh
|
||||
./DBRepair.sh
|
||||
|
||||
|
||||
### EXAMPLE: Using DBRepair inside containers (manual start/stop included)
|
||||
|
||||
#### (Select containers allow stopping/starting PMS from the menu. See menu for details)
|
||||
@ -214,7 +214,7 @@ These examples
|
||||
1. (3) Check - Confirm there is no database damage
|
||||
2. (5) Repair - You are not really repairing. You are rebuilding the DB in perfect sorted order.
|
||||
3. (6) Reindex - Rebuild Indexes.
|
||||
4. Exit - (Option 9)
|
||||
4. (99) Exit
|
||||
|
||||
E. Undo
|
||||
Undo is a special case where you need the utility to backup ONE step.
|
||||
@ -234,8 +234,29 @@ Special considerations:
|
||||
3. When satisfied, Exit the utility.
|
||||
- There is no harm in keeping the database temp files (except for space used)
|
||||
- ALL database temps are named with date-time stamps in the name to avoid confusion.
|
||||
4. The Logfile ('show' command) shows all actions performed WITH timestamp so you can locate intermediate databases
|
||||
if desired for special / manual recovery cases.
|
||||
4. The Logfile ('show' command) shows all actions performed WITH timestamp so you can locate
|
||||
intermediate databases if desired for special / manual recovery cases.
|
||||
|
||||
Attention:
|
||||
|
||||
The behavior of command "99" is different than command "Exit"
|
||||
This is intentional.
|
||||
|
||||
"99" is the "Get out now, Keep all intermediate/temp files.
|
||||
-- This is for when DB operations keep getting worse and you don't know what to do.
|
||||
"99" is an old 'Get Smart' TV series reference where agent 99 would try to save agent 86 from harm.
|
||||
|
||||
"99" was originally going to be "Quit immediately save all files" but development feedback
|
||||
resulted in this configuration
|
||||
|
||||
"Exit" is the preferred method to leave.
|
||||
|
||||
"Quit" was desired instead of "99" but there are those who didn't understand the difference or references.
|
||||
|
||||
If community feedback wants both "Quit. save temps" and "Exit, delete temps", behavior is easily changed.
|
||||
|
||||
Also please be aware the script understands interactive versus scripted mode.
|
||||
|
||||
|
||||
|
||||
## Scripting support
|
||||
@ -243,7 +264,7 @@ Special considerations:
|
||||
Certain platforms don't provide for each command line access.
|
||||
To support those products, this utility can be operated by adding command line arguments.
|
||||
|
||||
Another use of this feature is to automate Plex Database maintenance
|
||||
Another use of this feature is to automate Plex Database maintenance44
|
||||
( Stop Plex, Run this sequence, Start Plex ) at a time when the server isn't busy
|
||||
|
||||
|
||||
|
||||
@ -11,7 +11,8 @@
|
||||
|
||||
v1.0.5
|
||||
- Add Arch Linux Support
|
||||
- Put system override processing in funtion
|
||||
- Put system override processing in function
|
||||
- Separate Quit (99) and Exit functionality to reduce confusion about temp file removal.
|
||||
|
||||
v1.0.4
|
||||
- Correct Start/Stop problem on some hosts
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user