Skip to content

Instantly share code, notes, and snippets.

@Packet-Lost
Last active October 9, 2019 01:32
Show Gist options
  • Save Packet-Lost/19421deaa58df176901f6c35607560f4 to your computer and use it in GitHub Desktop.
Save Packet-Lost/19421deaa58df176901f6c35607560f4 to your computer and use it in GitHub Desktop.
EnsurePlex.ps1
$plexstatus = (systemctl | grep plex) | Out-String
if($plexstatus.length -eq 0 ){ $startplex = $true }
try{ $plexfind = $plexstatus.trim().Split('loaded ')[1].Split(' ')[1]}
catch { $plexfind = $null }
if ($plexfind -ne 'running') { $startplex = $true }
if($startplex){
systemctl start plexmediaserver.service
Add-Content /srv/logs/plexstart.log "$(Get-Date) Started plex."
} else { Write-Output 'Plex check completed, no need to start plex. Exiting.' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment