**.sh 실행시 $’\r’: command not found 오류 해결 –> Notepad++ 옵션: UNIX 형식으로 변환

Programming/Shell & Command / DS-9VM / 2021. 6. 16. 02:20

Notepad++ (노트패트++) 옵션: UNIX 형식으로 변환

sh파일을 윈도우에서 작업하고, 리눅스/유닉스에서 실행하면

아래와 같은 에러가 발생하는 경우가 발생할 수가 있습니다.

./test.sh: line 7: $’\r’: command not found

bash: ./test.sh: /bin/bash^M: bad interpreter: No such file or directory

원인은 Windows와 UNIX의 끝줄 처리 방식이 다르기 때문.

(줄바꿈 문자를 Windows에서는 \n\r을 사용하고, UNIX에서는 \n을 사용. )

<해결 방법>

해당 파일을 notepad++에서 열고 End of line 을 변환한다. 

Notepad++ 에서 

편집 > 줄의 끝문자(EOL) 변환 > UNIX 형식으로 변환

eidt > EOL Conversion > UNIX/OSX format

** 이건 내가알아낸 건데… 아래그림보면 메뉴의 설정 / 새문서 / 유닉스로 코딩하게 설정하면….

다음부턴..안그런듯..

Docker로 설치한 워드프레스 업데이트

 도커로 워드프레스를 설치하고 잘 사용하다가 업데이트를 마딱드린 순간이 찾아왔다. 워드프래스 내의 자동 업데이트 기능을 사용해 보려 했으나, FTP 정보를 입력 해라는둥 도커 시스템에는 적합하지 않는 업데이트 방법만 제시했다. 그래서 도커를 이용해서 WordPress를 업데이트할 방법을 찾아봤다.

 방법은 간단하다. 파일 두개를 삭제한 후, Docker의 워드프레스 이미지를 업데이트 하고 컨테이너를 재생성 하면 된다.

/index.php
/wp-includes/version.php

전체 코드는 아래와 같을것이다:

rm index.php && rm wp-includes/version.php
docker pull wordpress
docker stop wordpress_container
docker rm wordpress_container
docker run --name=wordpress_container --restart=always (그 외 옵션들)

Docker Compose 를 쓴다면 조금 더 깔끔하게 정리된다:

rm index.php && rm wp-includes/version.php
docker-compose pull 
docker-compose up -d

 주의할 부분이 있다. 이 방식은 WordPress 코어를 최신 버전으로 덮어쓴다는 것이다. /wp-content 폴더나 /wp-config.php 파일을 제외한 모든 기본 워드프레스 파일들이 모두 덮어써진다. 플러그인등을 사용하지 않고 기존에 워드프레스 코어를 직접 수정한 경우라면 이 방법을 사용해서는 안된다. 이 방법을 사용했다가는 기존 수정했던 코드들이 다 날라갈 것이다.

Docker image 만들기

컨테이너로 이미지 만들기…

– 기본이미지를 이용하여 django 웹 어플리케이션이 설치 및 구성된 이미지를 만들것이다.

1. docker 설치

– http://galid1.tistory.com/321

2. 기본 이미지 다운로드

– http://galid1.tistory.com/322

3. 컨테이너 실행 및 접속

1) 이미지 확인

$ docker images

2) 컨테이너 실행, 접속(centos systenctl permission 오류)

$ docker run -i -t docker.io/centos /bin/bash

3) Systemctl Permission오류 해결

1. 우선 /sbin/init을 쉘로  하는 컨테이너를 백그라운드로 실행시킨다

$ docker run -d –name centos docker.io/centos /sbin/init

2. 방금 백그라운드로 생성한 컨테이너에 docker exec를 통해 /bin/bash 프로세스를 생성한다

3. 확인

– docker centos 컨테이너 내부에서 systemctl 사용이 가능하다

4. django 웹 어플리케이션 환경 구축

– 컨테이너 안에서 웹어플리케이션 환경을 구축해야한다

– Django (CentOS7) 구축법 :  http://galid1.tistory.com/318http://galid1.tistory.com/319

5. 이미지화 하기

1) docker stop “이미지화 할 컨테이너”

– 컨테이너를 이미지화 하기전 멈춘다

2) docker ps -a

– 종료된 컨테이너의 이름을 알아낸다

3) $ docker commit -a “jjy”  container_id  image_name/tag

– 컨테이너를 이미지화 한다

mysql DDL, DML 포함해서 이미지 만들기 – https://medium.com/better-programming/customize-your-mysql-database-in-docker-723ffd59d8fb

실행 중인 Docker 컨테이너를 파일로 저장하고 다시 불러오기

2020. 03. 13

이전 글에서는 Docker를 사용해 게스트 유저가 서버를 운영할 수 있는 가상 환경을 만드는 것을 했다. 그런데 이전 글을 잘 보면 Volume 설정을 하지 않아 컨테이너를 종료하면 컨테이너 내의 모든 작업 내역이 유실된다.

모든 데이터를 보존하려 아래와 같이 컨테이너의 루트 디렉터리를 호스트와 공유하여 데이터를 동기화해보는 방법을 시도할 수는 있겠지만,

docker run -dit -v ~/guest1:/ ubuntu:18.04

루트 디렉터리는 볼륨으로 바인딩 할 수 없다는 오류를 볼 수 있다.

docker: Error response from daemon: invalid volume specification: '/home/ubuntu/guest1:/': invalid mount config for type "bind": invalid specification: destination can't be '/'.

bind mount를 하거나 tmpfs mount를 해도 결과는 같다.

docker run -dit --mount type=bind,source=~/guest1,target=/ ubuntu:18.04
# or
docker run -dit --tmpfs / ubuntu:18.04

그렇다면 어떻게 해결할 수 있을까? Docker는 여러 명령어를 지원하는데 export와 import 명령어를 사용하면 이 문제를 어느 정도 해결 할 수 있다.

정확히 말하면 위의 방법들처럼 실제 데이터를 호스트와 공유하는 것이 아닌, 특정 시점의 컨테이너 파일 시스템을 파일로 저장하고 불러오는 방법이다.

먼저 컨테이너를 파일로 저장하는 방법은 아래와 같다. export 명령어를 사용하여 컨테이너의 파일 시스템을 guest1_export.tar 파일로 아카이빙 할 수 있다.

docker export [CONTAINER_NAME] > guest1_export.tar

그리고 import 명령어를 사용하여 다시 Docker 이미지로 불러올 수 있다. guest1_export.tar 파일을 사용하여 ubuntu:imported 이미지로 만드는 것이다.

docker import guest1_export.tar ubuntu:imported

이미지가 정상적으로 만들어진다면 아래와 같이 이미지를 실행해보자.

docker run -dit ubuntu:imported

정상적으로 실행되지 않고 아래와 같이 오류가 발생한다.

docker: Error response from daemon: No command specified.

그 이유는 우리는 컨테이너의 파일 시스템을 아카이빙 하고 다시 이미지로 만든 것이므로 Docker는 이 이미지의 엔트리포인트가 무엇인지 알지 못한다. 그래서 우리는 이렇게 만든 이미지를 실행할 때 엔트리 포인트를 직접 지정해주어야 한다.

아래와 같이 명령어 뒤에 엔트리포인트를 지정하면 정상적으로 컨테이너가 실행된다.

docker run -dit ubuntu:imported /bin/bash

컨테이너로 이미지 만드는 명령어

먼저 아래의 명령어로 현재 Docker의 컨테이너를 확인해 봅니다.

copy bashadmin@myNAS:~# docker ps -a

CONTAINER ID        IMAGE                           COMMAND                  CREATED             STATUS                      PORTS                     NAMES
999999999999        strapi/strapi:latest            "docker-entrypoint.s…"   2 months ago        Up 25 hours                 0.0.0.0:6650->1337/tcp    strapi_strapi
999999999999        adminer:latest                  "entrypoint.sh docke…"   2 months ago        Up 25 hours                 0.0.0.0:6660->8080/tcp    strapi_adminer
999999999999        postgres:latest                 "docker-entrypoint.s…"   2 months ago        Up 25 hours                 0.0.0.0:15432->5432/tcp   strapi_postgres
999999999999        mongo:latest                    "docker-entrypoint.s…"   3 months ago        Exited (0) 2 months ago                               strapi_mongo
999999999999        mongo-express:latest            "tini -- /docker-ent…"   3 months ago        Exited (143) 2 months ago                             strapi_mongo-express
999999999999        synology/docviewer:1.3.0.0125   "sh -c 'while true; …"   3 months ago        Up 25 hours                                           synology_docviewer_2
999999999999        synology/docviewer:1.3.0.0125   "sh -c 'while true; …"   3 months ago        Up 25 hours                                           synology_docviewer_1

이제 이 중에서 하나의 컨테이너(strapi_strapi)를 이미지로 만들어 보도록 하겠습니다. 명령어 형식은 아래와 같습니다.

docker commit [컨테이너명] [이미지명:태그]

copy bashadmin@myNAS:~# docker commit strapi_strapi test_strapi:1.0

새로 생성된 이미지 확인

이제 생성된 이미지를 확인 볼 수 있습니다. 먼저 명령 프롬프트에서는 아래의 명령어로 확인할 수 있습니다.

docker images 명령어로 현재의 이미지를 확인할 수 있습니다. 또한 다.

copy bashadmin@myNAS:~# docker images

REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
test_strapi             1.0                 3a43b73d9e04        6 hours ago         1.15GB
postgres                latest              c5ec7353d87d        2 months ago        314MB
strapi/strapi           latest              87ed59852c1d        2 months ago        997MB

또한 synology의 Docker에서도 확인할 수 있습니다.

  1. Synology의 Docker의 좌측 메뉴 중 이미지 메뉴를 선택합니다.
  2. 우측 리스트 중 test_strapi:1.0 이미지를 확인할 수 있습니다.
  3. 또한 리스트를 선택한 후 내보내기를 선택하면 이미지를 따로 저장도 가능합니다.

우리나라에서 자막 파일에 주로 사용되는 형식은 SAMI이다.

그런데, 이 포맷은 치명적인 문제들이 많다.

무엇보다도 HTML에 기반을 둔 포맷이라 표현하지 못하는 글자가 많다1.

게다가, 쓸데없는 태그2가 너무 많아 파일이 깔끔해보이지도 않는다.

그런 등의 이유로 개인적으로는 SRT를 더 선호했는데, 이번에 아예 SRT를 주력으로 하기로 했다.


자막 작업을 하면서 필요로 하던 기능들을 모아 SRT 자막을 손쉽게 조작할 수 있는 프로그램을 만들었다.

이 프로그램의 주요 기능은 아래와 같다.

– SRT 파일 교정: SRT 파일을 읽은 뒤 오류를 수정한 뒤 다시 기록하거나 시간을 조정함

– 자막 변환: SAMI/SSA/ASS 자막을 SRT로 변환, SRT 자막을 SAMI로 변환

– 텍스트 추출: SRT 자막에서 텍스트만 추출

– 텍스트 합치기: 기존의 SRT 자막의 시간 코드에 맞춰 텍스트 파일의 내용을 합침

조금 더 상세히 보면 기능들은 이렇다.

1. SRT 파일 교정

   – OCR 과정에서 따옴표가 잘못 인식된 경우나 I(i)를 l(L)로 잘못 인식된 경우를 수정

   – OCR 과정에서 숫자 사이에 불필요한 공백이 들어간 경우 수정

   – 시간 수정. 일괄적으로 더하거나 뺄 수도 있고, 영상과 fps 및 싱크를 맞추기 위해 일정 비율로 적용 가능

2. 자막 변환

   – SSA/ASS 자막을 지정하면 SRT로 변환함

   – SAMI 자막을 지정하면 SRT로 변환하며, 다중 언어 자막인 경우 별도의 파일로 생성

   – SRT 자막을 지정하면 SAMI로 변환하며, ANSI 포맷의 표준 자막과 UTF-8 유니코드 자막을 동시에 생성

   – 모든 경우에 원본 파일의 코드 페이지를 자동으로 인식하며, 적절히 인식해서 처리함

   – SRT를 생성할 때는 UTF-8 포맷으로 저장하므로 유니코드의 모든 문자를 표현 가능함

3. 텍스트 추출

   – 주로 자막 번역시 편리하게 적용할 수 있는 기능으로, 시간 정보를 제거하고 텍스트만 추출함

   – 번역 시에 이 텍스트 파일을 문단별로 번역하면 됨

4. 텍스트 합치기

   – 3번에서 추출한 텍스트 파일에 다시 시간 정보를 입히는 기능

   – 역시 자막 번역시 활용할 수 있는 기능임

이 프로그램은 아래 링크에서 다운받을 수 있다.

 SRTIER.ZIP

HOW-TO:Modify the video cache

Jump to navigationJump to search

 ▶ advancedsettings.xml
▶ Video library
▶ HOW-TO:Modify the video cache

This page describes three advancedsettings.xml settings that can be used to maximize the video playback cache. You can use all or just a couple of these settings to see significant improvements in cache performance, should you require it (most users will not require these modifications). This can help with intermittent network issues, buffering, reduce how long the network is tied up, and sometimes improve battery life.


Note: Even if you change the cache settings in Kodi, that won’t change how fast the video file data comes in over the network. For example, it won’t make a slow server load the video any faster.

Contents

1 Steps

If you don’t already have an advancedsettings.xml file, it’s very simple to make. Kodi uses this file for advanced settings and features that normal users shouldn’t modify without first knowing what they do, as well as for experimental features, etc.

1Since you can use all or just some of the following settings, let’s start out with the basic file. Create a plain text file (no rich text formatting, don’t use .doc, etc) and save it as advancedsettings.xml. Make sure that the file extension is “.xml” and not “.txt” or “.xml.txt”.
2Cut and paste this into your new plain text file:<advancedsettings> <cache> <!— The three settings will go in this space, between the two cache tags. —> </cache> </advancedsettings>
3Add some or all of the settings tags from the next section.
4Save this file in your userdata folder:Note: If you have an existing file, make sure the <cache></cache> tags, and settings we’ll add between them, are between the main <advancedsettings></advancedsettings> tags.The Userdata folder is a subfolder of the Kodi Data Folder and is located as shown in the table below.Operating systemUserdata FolderAndroidAndroid/data/org.xbmc.kodi/files/.kodi/userdata/ (see note)iOS/private/var/mobile/Library/Preferences/Kodi/userdata/LibreELEC/storage/.kodi/userdata/Linux~/.kodi/userdata/Mac/Users/<your_user_name>/Library/Application Support/Kodi/userdata/Nvidia Shield (SMB)smb://<nvidiashieldurl>/internal/Android/data/org.xbmc.kodi/files/.kodi/userdataOSMC/home/osmc/.kodi/userdata/tvOS/private/var/mobile/Library/Preferences/Kodi/userdata/Windows%APPDATA%\Kodi\userdataWindows Portable<Install location chosen by you>\portable_data\userdata\Windows via Microsoft Store%LOCALAPPDATA%\Packages\XBMCFoundation.Kodi_4n2hpmxwrvr6p\LocalCache\Roaming\Kodi\Windows Xbox%LOCALAPPDATA%\Packages\XBMCFoundation.Kodi_4n2hpmxwrvr6p\LocalCache\Roaming\Kodi\Note: In some Android setups the path may be slightly different to the one stated above.

2 Cache settings

advancedsettings.xml tagwhat it does
<buffermode>1</buffermode>Choose what to bufferThis setting will force Kodi to use a cache for all video files, including local network, internet, and even the local hard drive. Default value is 0 and will only cache videos that use internet file paths/sources.0Buffer all internet filesystems (like “2” but additionally also ftp, webdav, etc.) (default)1Buffer all filesystems, both internet and local2Only buffer true internet filesystems (streams) (http, etc.)3No buffer4All network filesystems (incl. smb, nfs, etc.)
<memorysize>20971520</memorysize>Increasing the cacheHere we can do two things:Value: 20971520 (or any value, in bytes)  keep the cache in RAM, but increase how much RAM is used. The number is the buffer size in bytes (20971520 is the default, which is 20MB, which requires 60MB of free RAM). Kodi will not buffer ahead more than this. Note: For the memory size set here, Kodi will require 3x the amount of RAM to be free. Setting this too high might cause Kodi to crash if it can’t get enough RAM.orValue: 0 – we can use the local disk memory (typically your hard drive), which will not put any limit on the size (outside of the size of your drive). This also allows devices with low RAM, such as the Raspberry Pi, to cache more than they normally would due to the small amount of RAM they have. The cache is deleted from the local disk whenever playback is stopped. Note: This will likely cause increased wear-and-tear on your drive.
Note: Do not use the 0 (zero) setting if you have a device with a low amount of local storage, such as 8GB on a Fire TV. As a general rule of thumb, only use this setting if you have at least 16 GB of local drive space that is currently free on the device. Otherwise, Kodi will stall and stop playing the video, or might even crash.
<readfactor>10</readfactor>Increase the fill-rate of the cacheBy default (value: 4), Kodi will only fill the cache a little above what is needed to play it back. It does this as to not max out your network and possibly max out some hardware. For most users and hardware, this setting shouldn’t cause any issues, but be aware of it if you have unusual CPU spikes in your HTPC.
The value of this setting is a multiplier of the default limit. If Kodi is loading a typical bluray raw file at 36 Mbit/s, then a value of 2 will need at least 72 Mbit/s of network bandwidth. However, unlike with the RAM setting, you can safely increase this value however high you want, and Kodi won’t crash. Just know that it might cause Kodi to attempt to use all available bandwidth on your HTPC during playback.

3 Kodi v17 changes

In Kodi v17, the cache-related tags were removed from <network> and placed under a new <cache> tag. In addition, the following tags were renamed:

  • <cachemembuffersize> was renamed to <memorysize>
  • <readbufferfactor> is renamed to <readfactor>

4 Examples

Emblem-important-yellow.pngNOTICE:
These are just examples to explain how the feature works. Most users will just want to use example 4.

4.1 Example 1

All three options enabled, using local hard drive for cache.

Stop hand.pngDo not use this for flash-based memory devices.

advancedsettings.xml

<advancedsettings>
  <cache>
    <buffermode>1</buffermode>
    <memorysize>0</memorysize>
    <readfactor>30</readfactor>
  </cache>
</advancedsettings>

4.2 Example 2

Only cache size changed, using 100MB of RAM for cache (which requires 300MB of free RAM).advancedsettings.xml

<advancedsettings>
  <cache>
    <memorysize>104857600</memorysize>
  </cache>
</advancedsettings>

4.3 Example 3

Two options enabled, using 50MB of RAM for cache (which requires 150MB of free RAM), and cache both internet, LAN, and local content.advancedsettings.xml

<advancedsettings>
  <cache>
    <buffermode>1</buffermode>
    <memorysize>52428800</memorysize>
  </cache>
</advancedsettings>

4.4 Example 4

A safe setting for most devices with 1GB of RAM that should help most users “on the edge”. All protocols get cached, cache rate fills up pretty much as fast as possible, and cache size is about 133MB, using about 400MB of ram total.advancedsettings.xml

<advancedsettings>
  <cache>
    <buffermode>1</buffermode>
    <memorysize>139460608</memorysize>
    <readfactor>20</readfactor>
  </cache>
</advancedsettings>

5 See also

Page updated for v18Categories

audacity 완벽정리 및 audacity 사용법 꿀팁 – 오다시티

오다시티(audacity) 는 무료 음악 편집 프로그램으로써 잡음을 제거할 수 있고 음악파일을 마음대로 자르고 붙일 수 있는 프로그램입니다. 사용법도 매우 간단하며 한글 적용이 되기 때문에 누구나  쉽게 사용이 가능하다는 장점이 있습니다. 오다시티 설치 및 간단한 오류해결과 사용법에 대해 알려드리도록 하겠습니다.

오다시티의 주요 기능은 아래 사진을 참고하시기 바랍니다. 저도 몇가지 무료 음악 편집 프로그램을 사용해봤었는데요. auda시티 만큼 소음 제거 기능이나 편집 기능이 쉽고 잘되있는 프로그램은 없던 것 같네요.

간단하게 설치 방법부터 알려드리도록 하겠습니다. 가장 먼저 아래 링크를 클릭 – 무료 다운로드 버튼 클릭해서 설치파일을 다운로드 받습니다. 네이버 로그인 시 고속 다운로드를 받으실 수 있기 때문에 로그인 후 설치 파일을 받으시는 걸 권장합니다.

설치 파일을 다운로드 받으시고 실행시키시면 설치가 진행되는데요. English 선택 후 OK버튼을 클릭합니다. 간혹 English버전이 아니라 한글버전으로 받는 방법은 없는지 궁금해하시는 분들이 계신데요. 여기서 English를 선택해도 한글버전으로 설치가 되기 때문에 걱정안하셔도 될 것 같네요. ^^

OK버튼 클릭 후 다음 나오는 화면에서 Next -> 그 다음 화면에서도 Next 버튼을 클릭합니다. 정보를 소개하는 창이기 때문에 바로 넘어가셔도 상관없습니다.

Next 버튼을 클릭하시면 경로 설정하는 화면이 나오는데요. C드라이브의 용량이 부족한게 아니라면 기본적으로 설정되어있는 경로로 설치하시는걸 권장합니다.

경로 설정 후 Next 버튼을 클릭하시면 아래 사진과 같은 화면이 나오는데요. 첫 번째 체크 박스는 바탕화면에 바로 가기 생성 유무, 두 번째 체크 박스는 설정을 초기화하는 체크박스입니다. 첫 번째 체크박스에만 체크 후 Next 버튼을 클릭합니다.

다음 화면에서 Install 버튼을 클릭하시면 설치가 진행됩니다. 설치 완료 후 Finish 버튼을 클릭하시면 설치가 완료됩니다.

다음으로 간단한 사용법 및 오류 해결 방법에 대해 알려드리도록 하겠습니다

가장 먼저 파일(F) 버튼 클릭 – 가져오기(I) 버튼 클릭을 하시면 오디오, 레이블 등 다양한 형식의 파일을 불러올 수 있습니다.

파일 편집 방법 (자르기, 붙이기) 은 자르고 싶은 부분을 드래그 하시면 구간이 선택되는데요. 구간 선택 후 자르기를 원하시면 가위 버튼(잘라내기)을 클릭, 붙이고 싶으시면 붙여넣기 아이콘을 클릭하시면 됩니다. ^^ 해보시면 아시겠지만 전혀 어렵지않고 누구나 하실 수 있는 수준입니다.

이런식으로 원하는 대로 파일을 편집 후 저장을 해야겠죠? 저장 방법은 파일(F) 버튼 클릭 – 내보내기 버튼 클릭 후 파일이름과 mp3 파일 형식으로 변경 후 저장 버튼을 클릭합니다. 파일 형식은 마음대로 하셔도 되긴 하는데 보통 mp3 파일 형식을 많이 쓰기 때문에 mp3 파일 형식으로 하시는걸 권장합니다.

내보내기를 진행하시다가 아래 사진과 같이 lame_enc.dll파일이 필요하다는 메시지 창이 뜨는 경우가 있는데요. 오른쪽에 다운로드 버튼을 클릭합니다.

다운로드 버튼을 클릭하시면 아래와 같은 페이지로 이동하는데요. 가운데 exe 응용 프로그램을 다운받아 설치하시면 됩니다. 헷갈리시는 분들을 위해 아래에 링크를 첨부해두었으니 참고하시기 바랍니다. 설치화면이 열리면 그냥 다음 버튼만 모두 눌러주시고 마지막에 Finish 버튼만 눌러시면 완료됩니다. 매우 간단합니다.

Lame 설치 완료 후 다시 프로그램으로 이동해서 내보내기 버튼 클릭 – 파일 저장을 하시면 완료됩니다. ^^

여기까지 audacity 완벽정리 및 audacity 사용법 꿀팁 – 오다시티 에 대해 알아보았는데요. 사용법이 매우 간단하고 무료 프로그램이기 때문에 먼저 사용하시다가 어느정도 익숙해지시면 유료 프로그램도 한번 써보시는 것도 좋을 것 같습니다. 저도 현재 그렇게 하고있는데 확실히 처음에 무료 프로그램이 익숙해 진 후에 사용하는게 좋은 것 같더라구요.