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


# 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> does not have <strong>Full Control</strong> of existing <strong>Plex</strong> share.</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>共享的<strong>完全控制</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><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>。</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>用户的<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”作为安装卷，然后重试或将其从“Plex”共享中删除以重新开始。<br>"
    } >> $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上找到现有的Plex Media Server安装。</strong>"
    } > $SYNOPKG_TEMP_LOGFILE
    ;;

  # No error text for message
  *)
    {
      echo "内部包装错误。 没有错误代码“$1”的文本。 请报告此错误。"
    } >> $SYNOPKG_TEMP_LOGFILE
    ;;

esac
