#!/bin/sh
#
# Usage:  $0 "Message-code" "Message-arg-1" "Message-arg-2" ....
# Lang:   Chinese (Traditional)

# Message code  (alphabetical sort by name)
case "$1" in


  # Have ACL but still can't read "Application Support" or is empty
  "M-ACL-Failure-Get-Help")
    {
      echo "<strong>錯誤：</strong>無法讀取'$SYNOPKG_PKGDEST_VOL/Plex/Library/Application Support'<br>"
      echo "<br>"
      echo "請在我們的論壇中尋求其他幫助以解決此問題。"
    } >> $SYNOPKG_TEMP_LOGFILE
    ;;

# Preinstall/Postinstall - DSM 6 upgrade - Do not have Full Control of the shared fold
  "M-ACL-Failure-Plex-Share")
    {
      echo "<br><p style='color:red'>錯誤： <strong>PlexMediaServer</strong>無法<strong>完全控制</strong>現有的<strong>Plex</strong>共享</p><br>"
    } >> "$SYNOPKG_TEMP_LOGFILE"
    ;;

  # Postinstall - DSM 6 upgrade - Check if ready - still don't not have full control of all subdirs
  "M-ACL-Failure-Plex-Subdirs")
    {
      echo "<br><p style='color:red'>錯誤： <strong>PlexMediaServer</strong> 無法完全控制<strong> Plex </strong>共享中的所有子文件夾。</p><br>"
    } >> "$SYNOPKG_TEMP_LOGFILE"
    ;;

  # Pre/Post install remedy steps
  "M-ACL-Procedure")
    {
      echo "請執行以下步驟：<br><br>"
      echo " 1. 取消此安裝。卸載軟件包。<br>"
      echo " 2. 打開<strong>控制面板</strong> - <strong>共享文件夾</strong>。<br>"
      echo " 3. 選擇現有的 <strong>Plex</strong> 共享，然後單擊 <strong>編輯”按鈕</strong>。<br>"
      echo " 4. 單擊<strong>權限</strong>標籤<br>"
      echo " 5. 將下拉列表從<strong>本地用戶</strong>更改為<strong>系統內部用戶</strong>。<br>"
      echo " 6. 對於用戶 '<strong>PlexMediaServer</strong>'，單擊<strong>自定義</strong>複選框。<br>"
      echo " 7. 選中<strong> PlexMediaServer </strong>用戶<br>的<strong>管理，讀取和寫入</strong>組複選框。<br>"
      echo " 8. 單擊<strong>完成</strong>以關閉權限設置。<br>"
      echo "    確認已為'PlexMediaServer'分配了'完全控制'權限。<br>"
      echo " 9. 單擊<strong>應用於此文件夾，子文件夾和文件<p style ='color:red'>（重要）</p> </strong>。</p></strong><br>"
      echo "10. 單擊<strong>保存</strong>以確認新權限”。"
      echo "    迴聲“期望2分鐘/索引完成的1000個項目。<br>"
      echo "11. 卸載然後重新安裝Plex Media Server軟件包。<br>"
    } >> "$SYNOPKG_TEMP_LOGFILE"
    ;;

  # Postinstall - DSM 6 upgrade - Final pre-migration check - Something interrupted / interfered with ACL setting by FileStation
  "M-Cannot-Migrate-ACL-Incomplete")
    {
      echo "<strong>PlexMediaServer無法遷移您現有的服務器信息。</strong><br>"
      echo "<br><p style='color:red'>錯誤： <strong>PlexMediaServer</strong> 尚未具有<strong> Plex </strong>共享中的所有子文件夾的<strong>完全控制</strong>。</p><br>"
    } >> "$SYNOPKG_TEMP_LOGFILE"
    ;;

  # Claim with token but no token string provided.
  "M-Claim-No-Token-Provided")
    {
      echo "<br><strong>錯誤： 未提供理賠令牌。 請再試一次。</strong>"
    } >> "$SYNOPKG_TEMP_LOGFILE"
    ;;

  # Could not get Claim token
  "M-Could-Not-Claim")
    {
      echo "<strong>錯誤：  無法完成與Plex.tv的對話。無法聲明。</strong><br><br>"
      echo "安裝時間太長或與Plex.tv通信存在困難。<br><br>"
      echo "請重試或在我們的支持論壇中尋求幫助。<br>"
    } > $SYNOPKG_TEMP_LOGFILE
    ;;

  # Claim Successful
  "M-Claim-Successful")
    {
      echo "<br>PlexMediaServer成功聲明\"$2\"."
    } > $SYNOPKG_TEMP_LOGFILE
    ;;

  # Unexpected error(s) changing ownership of files
  "M-Error-Changing-Ownership")
    {
      echo "<strong>錯誤：  更改所有權時發生意外錯誤。</strong><br>"
      echo "<br><strong>遷移失敗。處理停止。</strong><br>"
      echo "請參閱遷移日誌'$2'，了解詳細信息。<br>"
      echo "請向我們的論壇尋求幫助。<br>"
    }  >> $SYNOPKG_TEMP_LOGFILE
    ;;

  # Could not fix fixed path subtitle links
  "M-Error-Updating-Subtitles")
    {
      echo "<strong>錯誤：  更新字幕鏈接時發生意外錯誤。</strong><br>"
      echo "<br><strong>遷移失敗。處理停止。</strong><br>"
      echo "請參閱遷移日誌'$2'，了解詳細信息。<br>"
      echo "請向我們的論壇尋求幫助。<br>"
    }  >> $SYNOPKG_TEMP_LOGFILE
    ;;

  #  Post Install/Upgrade/Migration - Installation complete media permissions reminder
  "M-Install-Complete-Check-Permissions")           # (dsm-migration-tool)
    {
      echo "<br><strong><p style='color:blue'><big><b>安裝成功！</big></p>"
      echo "<br><br><p style='color:blue'>注意：如果Plex無法訪問您的媒體，請在<strong>控制面板</strong>中確認授予用戶<strong> PlexMediaServer </strong>權限。</p><br>"
      echo "通過執行以下步驟來設置對媒體共享的訪問權限：<br><br>"
      echo "1. 打開<strong>控制面板</strong>，然後選擇<strong>共享文件夾</strong><br>"
      echo "2. 選擇包含您的媒體的共享，然後單擊<strong>編輯</strong><br>"
      echo "3. 單擊<strong>權限</strong>標籤<br>"
      echo "4. 將下拉列表從<strong>本地用戶</strong>更改為<strong>系統內部用戶</strong><br>"
      echo "5. 為<strong> PlexMediaServer </strong>用戶<br>選中<strong>讀/寫</strong>複選框<br>"
      echo "6. 單擊<strong>保存</strong>以確認新權限<br>"
      echo "7. 對要Plex Media Server訪問的每個共享重複步驟2-6”。<br>"
    } >> "$SYNOPKG_TEMP_LOGFILE"
    ;;

  # Postinstall/Postupgrade - LogPathname cannot be written to
  "M-LogPath-No-Write-Access")
    {
      echo "<br><strong>錯誤：  無法寫入'$2'。 檢查路徑名和權限。 請再試一次。</strong>"
    } >> "$SYNOPKG_TEMP_LOGFILE"
    ;;

  # Postinstall/PostUpgrade - Log option selected but no path given
  "M-LogPath-No-Path-Specified")
    {
      echo "<br><strong>錯誤： 已選擇“日誌”選項，但未提供路徑。 請再試一次。</strong>"
    } >> "$SYNOPKG_TEMP_LOGFILE"
    ;;

  #  Migration - Cleaning completed
  "M-Migration-Cleaned")
    echo "清除了 $2。.<br>"  >> $SYNOPKG_TEMP_LOGFILE
    ;;

  # Migration-tool MigrationStarted    # Start user error log (in case it's needed)
  "M-Migration-Started")
    {
      echo "<strong>Plex Media Server - DSM 6-> 7在 $date 升級。</strong><br><br>"
    }  >> $SYNOPKG_TEMP_LOGFILE
    ;;

  # Postinstall - Migration successful
  "M-Migration-Successful")
    {
      echo "從 $2 遷移現有的Plex Media Server安裝。<br>"
      echo "遷移日誌可供查看： $SYNOPKG_PKGDEST_VOL/Plex/Migration.log<br>"
    } >> $SYNOPKG_TEMP_LOGFILE

    echo "=== $(date) === Completed:  Migrate Plex Media Server" >>"$SYNOPKG_PKGDEST_VOL/Plex/Migration.log"
    ;;

  # Unexpected errror (Linux error code) during migration
 "M-Migration-System-Error")
    {
      echo "錯誤： 無法將現有 $2 遷移到DSM7。系統錯誤 $3。"
      echo "       遷移日誌文件： '$4'"
    } >> $SYNOPKG_TEMP_LOGFILE
    ;;

  # Preinstall/Postinstall - DSM 6 upgrade - Do not have Full Control of the shared fold
  "M-Preinstall-Check-Failure")
    {
      echo "<strong>錯誤： 安裝前檢查失敗。</strong><br>"
      echo "<br><p style='color:red'>錯誤： <strong>PlexMediaServer</strong> 沒有現有的<strong> Plex </strong>共享的<strong>完全控制</strong>。</p><br>"
    } >> "$SYNOPKG_TEMP_LOGFILE"
    ;;

# - Preinstall
  # Upgradeable DSM 6 installation but is not on SYNOPKG_DEST_VOL  ($2 = ExistingVolume, $3 = PKGDEST_VOL)
  "M-Preinstall-Migrate-Wrong-Volume")
    {
      echo "<br><strong style='color:red'>錯誤：  安裝卷不正確。</strong><br><br>"
      echo "在 $2 '上找到了可升級的Plex Media Server安裝。<br><br>"
      echo "<strong>選擇 $2 作為安裝卷，然後重試<br>"
      echo "或將其從“ Plex”共享中刪除以重新開始。</strong>"
    } >> $SYNOPKG_TEMP_LOGFILE
    ;;

  # Existing DSM 7 installation in statis but is not on SYNOPKG_DEST_VOL
  "M-Preinstall-Wrong-Volume")
    {
      echo "<br><strong style='color:red'>錯誤：  安裝卷不正確。</strong><br><br>"
      echo "在$2上找到現有的Plex Media Server安裝。<br><br>"
      echo "<strong>選擇 $2 作為安裝量，然後重試。</strong>"
    } > $SYNOPKG_TEMP_LOGFILE
    ;;

  # No error text for message
  *)
    {
      echo "內部包裝錯誤。 沒有錯誤代碼 $1 的文本。 請報告此錯誤。"
    } >> $SYNOPKG_TEMP_LOGFILE
    ;;

esac
