redis 스크립트 처리방법

LUA 스크립트를 활용해서 redis console 에서 처리하는 예제를 아래 남깁니다.

레디스 hash 에서 특정코드 검색해서 삭제하는 방법입니다

EVAL "
local hash_key = KEYS[1]
local condition = ARGV[1]

local fields = redis.call('HKEYS', hash_key)
local result = {}
for _, field in ipairs(fields) do
    local value = redis.call('HGET', hash_key, field)
    local startpos, endpos = string.find(value, condition)
    if startpos then
		redis.call('HDEL', hash_key, field)
		result[#result + 1] = field
    end
end
return result
" 1 test '24002'

test 해시키의 값에 24002 값이 있으면 삭제하고, 해당 필드값을 화면에 표시합니다.

다만, 해시 필드를 모두 가져와서 검색하기 때문에 느립니다.

하나의 세션을 잡기때문에 전체 성능에 영향은 주지 않을 것 같으나 검토는 필요합니다.

프로그램으로 안짜고, redis console 에서 실행할 수 있다는 것이 장점인데, 검색키워드 (condition) 에 날짜문자열(2024-04-20)를 줬는데 검색이 안되더라구요. 충분한 테스트가 필요할 듯 하네요.




썬더버드 메일클라이언트에 chatgpt 연결

부가기능에서 확장기능관리에서 “ChatGPT – Quick Access”를 설치한다.




썬더버드 메일클라이언트 chat 숨기는 방법

However, it can be done if you use a ‘userChrome.css’ file.

First ensure the following is enabled.

  • Settings > General
  • Scroll to bottom and click on ‘Config Editor’
  • In search type: legacy
  • look for this line: toolkit.legacyUserProfileCustomizations.stylesheets
  • If it is ‘False’ then toggle to ‘True’

  • Help > Troubleshooting Information
  • Under ‘Application Basics’ – half way – Profile Folder – click on ‘Open Folder’

A new window opens showing contents of profile name folder.

  • Exit Thunderbird now this is important

In the beta profile folder create a new folder called chrome (all lower case)

Open Notepad a simple text editor

Copy all the code between the following lines


/* Spaces Toolbar – Customise – Hide */ #calendarButton, #chatButton { display: none !important; }


Save the file as userChrome.css (all lower case except capital C as shown) in the chrome folder

Start Thunderbird.Read this answer in context👍 2




container healthCheck 처리

아래와 같이 HEALTHCHECK 를 compose 파일에 추가한다.
HEALTHCHECK --interval=5s --timeout=2s CMD curl --fail http://localhost || kill 1

HEALTHCHECK 를 추가한 경우, 에러서 재기동 될 수 있도록 restart 를 compose 에 추가한다.

      healthcheck:
        test: ["CMD-SHELL", "curl --silent --fail localhost:9600 || exit 1"]
        interval: 10s
        timeout: 10s
        retries: 3
      restart: on-failure



다운로드 스테이션 eac3 처리방안

패키지센터에서 ffmpeg 를 4, 5, 6 버전을 모두 설치한다.

이후 패치 스크립트를 수행한다.

자세한 관련 사항은 아래 링크를 참고 바랍니다.

https://ux.stories.pe.kr/m/318




Download station 수집차단 방법

iknowwhatyoudownload 와 같은 사이트에서 토렌트 다운로드 받는 정보를 수집한다.

이런 경우를 방지하기 위해 DHT 설정을 차단한다. (다운로드 스테이션 설정에서 할 수 있음)

https://iknowwhatyoudownload.com 에서 목록이 확인되지 않으면 차단이 성공한 것으로 보면 된다.

보통 10일정도 보관되며, 최대 50개를 보관한다고 전해지는데 확실치 않다.

기존 보관된 정보를 삭제하고자 한다면, 알려진 토렌트 파일을 50개 다운로드 받아본다.

모든 기록을 수집하지 않기 때문에 알려진 토렌트 파일을 추천한다.




도커 이미지를 최신상태로 유지- watchtower

docker-compose 로 설치

version: "3"
services:
  watchtower:
    image: containrrr/watchtower
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      TZ: Asia/Seoul
      WATCHTOWER_CLEANUP: 'true'
      WATCHTOWER_POLL_INTERVAL: 43200
    restart: unless-stopped

예외처리

labels:
com.centurylinklabs.watchtower.enable: 'false'



nginx proxy manager

설치 참고 : https://narup.tistory.com/241




linux 서버 리부트 모니터링 설정 – 이메일

참고) https://ko.linux-console.net/?p=9314#gsc.tab=0

  • mutt 설치
  • 발송 환경 구성

    • vi ~/.muttrc

      • set from = “발신자이메일”
      • set realname = “이름”
      • set smtp_url = “smtp://아이디@smtp주소:smtp포트/”
      • set smtp_pass = “비밀번호”

    • /etc/muttrc 에도 동일하게 설정

  • 발송 테스트

    • echo “This is an email body.” | mutt -s “This is an email subject” [수신자이메일]

  • 리부트 이메일 발송 스크립트 작성 및 권한부여

    • 스크립트 작성

      • sudo vi /usr/local/bin/reboot_notify.sh

        • !/bin/sh
        • echo “hostname was rebooted on date” | mutt -F /etc/muttrc -s “Notification on hostname” [수신자이메일]

    • 권한 부여

      • sudo chmod +x /usr/local/bin/reboot_notify.sh

    • 서비스 등록 및 실행

      • sudo mkdir -p /usr/local/lib/systemd/system
      • sudo vi /usr/local/lib/systemd/system/reboot-task.service
      • sudo systemctl enable reboot-task
      • sudo systemctl start reboot-task




telegram 에 이메일을 전송하자

nas 에서 발생하는 이벤트나 download station 의 알림을 telegram으로 전송하기 위해 이메일 전송 컨테이너를 설치한다.

참조 : https://hub.docker.com/r/kostyaesmukov/smtp_to_telegram

해당 이미지를 도커 컨테이너를 생성한다.

도커 환경변수 설정

ST_TELEGRAM_CHAT_IDS=<CHAT_ID1>,<CHAT_ID2>
ST_TELEGRAM_BOT_TOKEN=<BOT_TOKEN>
ST_TELEGRAM_MESSAGE_TEMPLATE=Subject: {subject}\\n\\n{body}

템플릿에 발송메시지 유형 등록

포트 포워딩 : 2525 포트를 적당한 포트로 포워딩

발송 시, smtp 를 <nas서버 도메인>, 포트 : 포워딩 포트 로 설정하여 발송

수신자 이메일 주소는 상관없음

nas 제어판 > 알림 > 이메일 정보 변경

nas 내정보 > 이메일 배달 : 발송서버 등록 및 기본서버로 설정

download station : 설정 > 알람 : 내정보에 등록한 발송서버 선택