mirror of
https://github.com/ChuckPa/PlexDBRepair.git
synced 2025-11-06 03:08:55 -05:00
Add Windows README and ReleaseNotes
Also fix Help command that broke after some last-minute refactoring, and tweak interactive EOF handling.
This commit is contained in:
parent
c9a9a1eb81
commit
f3175713a9
@ -24,14 +24,16 @@ class PlexDBRepair {
|
||||
return
|
||||
}
|
||||
|
||||
$this.PrintHeader()
|
||||
$this.PrintHeader($true)
|
||||
$this.MainLoop($Commands)
|
||||
}
|
||||
|
||||
[void] PrintHeader() {
|
||||
[void] PrintHeader([boolean] $WriteToLog) {
|
||||
$OS = [System.Environment]::OSVersion.Version
|
||||
if ($WriteToLog) {
|
||||
$this.WriteLog("============================================================")
|
||||
$this.WriteLog("Session start: Host is Windows $($OS.Major) (Build $($OS.Build))")
|
||||
}
|
||||
|
||||
Write-Host "`n"
|
||||
Write-Host " Plex Media Server Database Repair Utility (Windows $($OS.Major), Build $($OS.Build))"
|
||||
@ -40,7 +42,8 @@ class PlexDBRepair {
|
||||
}
|
||||
|
||||
[void] PrintHelp() {
|
||||
$this.PrintHeader()
|
||||
# -Help doesn't write to the log, since our log file path isn't set.
|
||||
$this.PrintHeader($false)
|
||||
Write-Host "When run without arguments, starts an interactive session that displays available options"
|
||||
Write-Host "and lets you select the operations you want to perform. Or, to run tasks automatically,"
|
||||
Write-Host "provide them directly to the script, e.g. '.\DBRepair-Windows.ps1 Stop Prune Start Exit'"
|
||||
@ -154,13 +157,19 @@ class PlexDBRepair {
|
||||
$Choice = Read-Host "Enter command # -or- command name (4 char min)"
|
||||
if ($Choice -eq "") {
|
||||
++$NullInput
|
||||
if ($NullInput -eq 4) {
|
||||
Write-Warning "Next empty command exists as EOF. "
|
||||
} elseif ($NullInput -eq 5) {
|
||||
if ($NullInput -eq 5) {
|
||||
$this.Output("Unexpected EOF / End of command line options. Exiting. Keeping temp files. ")
|
||||
$Choice = "exit"
|
||||
$EOFExit = $true
|
||||
} else {
|
||||
if ($NullInput -eq 4) {
|
||||
Write-Warning "Next empty command exits as EOF. "
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
$NullInput = 0
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,7 +235,7 @@ class PlexDBRepair {
|
||||
# and Stop-Process does a forced exit of the process, so use taskkill to ask
|
||||
# PMS to close nicely, and bail if that doesn't work.
|
||||
$ErrorText = $null
|
||||
Invoke-Expression "taskkill /im ""Plex Media Server.exe""" 2>$null -ErrorVariable errorText
|
||||
Invoke-Expression "taskkill /im ""Plex Media Server.exe""" 2>$null -ErrorVariable ErrorText
|
||||
if ($ErrorText) {
|
||||
$this.WriteOutputLogWarn("Failed to send terminate signal to PMS, please stop manually.")
|
||||
$this.WriteOutputLogWarn($ErrorText -join "`n")
|
||||
|
||||
76
README-Windows.md
Normal file
76
README-Windows.md
Normal file
@ -0,0 +1,76 @@
|
||||
# PlexDBRepair-Windows
|
||||
|
||||
DBRepair-Windows.ps1 (and DBRepair-Windows.bat) are scripts run from the command line, which have
|
||||
sufficient privilege to read/write the Plex databases in the
|
||||
[Plex data directory](https://support.plex.tv/articles/202915258-where-is-the-plex-media-server-data-directory-located/).
|
||||
|
||||
## DBRepair-Windows.ps1 vs. DBRepair-Windows.bat
|
||||
|
||||
Currently, there are two separate Windows scripts, a batch script (.bat) and a PowerShell script
|
||||
(.ps1). The batch script is a one-shot, zero-input script that attempts automatic database
|
||||
maintenance (repair/rebuild, check, and reindex). The PowerShell script is intended to align with
|
||||
PlexDBRepair.sh, offering command-name-based functionality that can either be scripted or
|
||||
interactive.
|
||||
|
||||
In the future, DBRepair-Windows.bat will be removed in favor of DBRepair-Windows.ps1. The batch
|
||||
file is currently kept as a backup while the PowerShell script continues to be expanded and
|
||||
tested. If any unexpected issues arise with the PowerShell script, please open an
|
||||
[issue](https://github.com/ChuckPa/PlexDBRepair/issues) so it can be investigated.
|
||||
|
||||
## Functions provided
|
||||
|
||||
The Windows utility aims to provide a similar interface to DBRepair.sh as outlined in the main
|
||||
[README file](README.md), but currently only offers a subset of its functionality. For a full
|
||||
description of the features below, consult that main README file.
|
||||
|
||||
The following commands (or their number) are currently supported on Windows.
|
||||
|
||||
```
|
||||
AUTO(matic)
|
||||
EXIT
|
||||
PRUN(e)
|
||||
STAR(t)
|
||||
STOP
|
||||
```
|
||||
|
||||
Run `.\DBRepair-Windows.ps1 -Help` for more complete documentation.
|
||||
|
||||
# Installation and usage instructions
|
||||
|
||||
DBRepair-Windows can be downloaded to any location. However, the PowerShell script might require
|
||||
some prerequisite work in order to run as expected. By default, PowerShell scripts are blocked on
|
||||
Windows machines, so in order to run DBRepair-Windows.ps1, you may need to do one of the following:
|
||||
|
||||
1. From an administrator PowerShell prompt, run `Set-ExecutionPolicy RemoteSigned`, then run the
|
||||
script from a normal PowerShell prompt. If PowerShell still will not run the script, you can do
|
||||
one of the following:
|
||||
* In Windows Explorer, right-click DBRepair-Windows.ps1, select Properties, and check 'Unblock'
|
||||
at the bottom of the dialog.
|
||||
* In PowerShell, run `Unblock-File <path\to\DBRepair-Windows.ps1>`
|
||||
* Run `Set-ExecutionPolicy Unrestricted` - this may result in an "are you sure" prompt before
|
||||
running the script. `Set-ExecutionPolicy Bypass` will get around this, but is not recommended,
|
||||
as it allows _any_ downloaded script to run without notification, not just DBRepair.
|
||||
2. Explicitly set the `ExecutionPolicy` when running the script, e.g.:
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass ".\DBRepair-Windows.ps1 stop auto start"
|
||||
```
|
||||
Note that this method may not work if your machine is managed with Group Policy, which
|
||||
can block manual `ExecutionPolicy` overrides.
|
||||
|
||||
3. Similar to 2, but make it a batch script (e.g. `DBRepair.bat`) that lives alongside
|
||||
the powershell script:
|
||||
```batch
|
||||
@echo off
|
||||
powershell -ExecutionPolicy Bypass -Command ".\DBRepair-Windows.ps1 %*"
|
||||
```
|
||||
Then run that script directly:
|
||||
```batch
|
||||
.\DBRepair.bat stop auto start
|
||||
```
|
||||
|
||||
Also note that the PowerShell script cannot be run directly from a Command Prompt window.
|
||||
If you are running this from Command Prompt, you must launch it via PowerShell:
|
||||
|
||||
```cmd
|
||||
powershell .\DBRepair-Windows.ps1 [args]
|
||||
```
|
||||
32
README.md
32
README.md
@ -989,34 +989,4 @@ sudo ./DBRepair.sh stop auto start exit
|
||||
|
||||
# Special Considerations - Windows
|
||||
|
||||
Windows development is currently not on-par with DBRepair.sh, with only a limited number
|
||||
of commands available. Additionally, the script (DBRepair-Windows.ps1) might fail to run
|
||||
if your machine's ExecutionPolicy blocks execution of PowerShell scripts, which is the
|
||||
default. There are several ways to potentially get around this:
|
||||
|
||||
1. From an administrator PowerShell prompt, run `Set-ExecutionPolicy RemoteSigned`, then
|
||||
run the script from a normal PowerShell prompt.
|
||||
2. Explicitly set the `ExecutionPolicy` when running the script, e.g.:
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass ".\DBRepair-Windows.ps1 stop auto start"
|
||||
```
|
||||
Note that this method may not work if your machine is managed with Group Policy, which
|
||||
can block manual `ExecutionPolicy` overrides.
|
||||
|
||||
3. Similar to 2, but make it a batch script (e.g. `DBRepair.bat`) that lives alongside
|
||||
the powershell script:
|
||||
```batch
|
||||
@echo off
|
||||
powershell -ExecutionPolicy Bypass -Command ".\DBRepair-Windows.ps1 %*"
|
||||
```
|
||||
Then run that script directly:
|
||||
```batch
|
||||
.\DBRepair.bat stop auto start
|
||||
```
|
||||
|
||||
Also note that the PowerShell script cannot be run directly from a Command Prompt window.
|
||||
If you are running this from Command Prompt, you must launch it via PowerShell:
|
||||
|
||||
```cmd
|
||||
powershell .\DBRepair-Windows.ps1 [args]
|
||||
```
|
||||
Windows support is available via DBRepair-Windows.ps1 and DBRepair-Windows.bat. See [README-Windows](README-Windows.md) for details.
|
||||
14
ReleaseNotes-Windows
Normal file
14
ReleaseNotes-Windows
Normal file
@ -0,0 +1,14 @@
|
||||
# PlexDBRepair-Windows
|
||||
|
||||
Release notes for the Windows counterpart to DBRepair.sh (DBRepair-Windows.ps1)
|
||||
|
||||
# Release Info
|
||||
|
||||
v1.00.00
|
||||
- Initial Windows PowerShell script release, aiming to provide a similar experience as DBRepair.sh, with command-name-based input.
|
||||
- Initial command support:
|
||||
- AUTO(matic)
|
||||
- EXIT
|
||||
- PRUN(e)
|
||||
- STAR(t)
|
||||
- STOP
|
||||
Loading…
x
Reference in New Issue
Block a user