#!/bin/sh
#
# Usage:  $0 "Message-code" "Message-arg-1" "Message-arg-2" ....
# Lang:   Korean

# 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> Plex </strong>공유에 대한 <strong> 모든 권한 </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>로 변경합니다.</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>을 클릭하세요.<br>"
      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>\"$2\"에서 PlexMediaServer를 성공적으로 요청했습니다."
    } > $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>"
      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를 DSM 7로 마이그레이션 할 수 없습니다. 시스템 오류 $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를 선택하고 다시 시도하십시오.</strong>"
    } > $SYNOPKG_TEMP_LOGFILE
    ;;

  # No error text for message
  *)
    {
      echo "내부 패키지 오류입니다. 오류 코드 '$1'에 대한 텍스트가 없습니다. 이 오류를보고하십시오."
    } >> $SYNOPKG_TEMP_LOGFILE
    ;;

esac
