Skip to content

Instantly share code, notes, and snippets.

View geunho's full-sized avatar
🎯
Focusing

Geunho Kim geunho

🎯
Focusing
View GitHub Profile
@geunho
geunho / robocopy_example.bat
Created January 14, 2019 06:42
robocopy sync dir and output CUD list to file
REM Sync destination dir to source dir
REM retry max 10 times wait 1 second every try
REM output created, updated, deleted file list to both stdout and rc-list.txt file
robocopy %src_path% %dest_path% /MIR /R:10 /W:1 /NJH /NJS /NC /NS /NDL /NP /TEE /LOG:rc-list.txt /XF *.log
@geunho
geunho / .bashrc
Created January 23, 2019 04:29
.bashrc
# 로그인이 아닌 Non-interactive shell에서는 프로파일을 로드하지 않는 default 설정이 들어간 경우가 있다.
#
# 예. Ubuntu default .bashrc의 시작 부분
#
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@geunho
geunho / cetos_gcc_4.4_to_4.7.sh
Created February 7, 2019 23:52
CentOS gcc 4.4에서 4.7 업그레이드
####################################################################################
# Upgrade CentOS GCC 4.4 to 4.7
#
# CentOS6의 기본 gcc 버전은 4.4,
# nodejs의 node-gyp 빌드를 하다보면 C++11 컴파일이 필요한데 gcc 4.7부터 11을 지원
# 이런 경우 직접 업그레이드 해줘야한다.
#
####################################################################################
# INSTALL
@geunho
geunho / gist:a330e6f241a50fd6ba59a30ba60f36c4
Created March 11, 2019 01:50
javax.net.ssl.SSLHandshakeException
#######################################################################################################################################################################################################################################
# javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
#######################################################################################################################################################################################################################################
# JDK에서 동작하는 consumer가 API provider 측의 SSL 인증서 경로를 제대로 찾지 못하거나 신뢰하지 못할 때 오류가 발생한다.
# 주로 오래된 버전의 HTTP 클라이언트 라이브러리를 사용하거나, JDK 버전이 낮은 경우 발생한다.
# consumer의 JRE keystore 경로에 provider의 인증서를 신뢰할 수 있는 인증서로 직접 추가하면 해결된다.
openssl s_client -connect $provider_internet_domain:443
# (1) 위 커맨드 입력 후
# ----BEGIN CERTIFICATE-----
@geunho
geunho / gist:0c93d074526d2ffd2e77b47240f8c365
Created March 13, 2019 03:57
register_windows_service
윈도우 서비스 등록 방법
1. ServiceMain을 구현한 바이너리인 경우
# 생성
> sc create "%SERVICE_NAME%" binpath= "%ABSOLUTE_BIN_PATH%" start= "auto"
# 삭제
> sc delete "%SERVICE_NAME%"
2. 그 외 백그라운드에서 실행되는 모든 바이너리
http://nssm.cc/
@geunho
geunho / gist:49a5a6fc7d5ce6857dfc08bccccab76f
Created March 13, 2019 04:43
Windows 서비스 권한 정책에 실행 계정 추가
sc 명령어는 서비스 생성/삭제 뿐만아니라 시작/중지 명령어를 원격 서버에 날릴 수 있다.
원격 사용자가 로컬 관리자 그룹에 속해있다면 원격 제어에 문제가 없으나, 그렇지 못할 경우 subInAcl 커맨드를 활용하면 된다.
1. SubInAcl 툴 다운로드: https://www.microsoft.com/en-us/download/details.aspx?id=23510
2. 명령어 실행:
# 원격 호스트
subinacl /SERVICE \\[호스트명]\[서비스명] /GRANT=[도메인]\[실행계정명]=TOS
# 로컬 호스트
subinacl /SERVICE [서비스명] /GRANT=[도메인]\[실행계정명]=TOS
@geunho
geunho / get_all_git_commiters_email.sh
Created March 15, 2019 00:10
get all git commiters' email
#
# 젠킨스 빌드 실패시 모든 커미터에게 메일을 보낼 때 유용한 스크립트.
#
# Generate environment variables from script
# Useful when jenkins E-mail notification on build failure
#
delemeter=" " # whitespace
commits=$(git log --merges -1 --format=%p)
emails=$(git --no-pager show -s --format=%ae $GIT_COMMIT)
if [ ! -z "$commits" ]
@geunho
geunho / jenkins_ha.md
Created March 21, 2019 22:48
Jenkins HA

-- Jenkins HA에 대한 고민

https://endocode.com/blog/2018/08/17/jenkins-high-availability-setup/

태생적으로 상태를 파일 시스템에 기록하는 방식이기 때문에 전체 상태를 관리하는 Master 노드를 이중화하기가 까다롭다. 파일 시스템을 여러 노드가 공유하는 순간 상태의 불일치가 발생할 가능성이 있다.

어쩔 수 없이.. Active/Active 이중화가 아닌 Active/Passive 이중화 구성을 고민을 했는데, 위 링크의 글에서 이 부분을 잘 긁어서 설명해놓았다.

@geunho
geunho / jenkins_active_passive_copy.md
Last active March 27, 2019 02:00
Jenkins Master Active/Passive 동기화 - Windows

흔치 않은 경우겠으나, 윈도우 서버에서 Jenkins Master를 구동하는 경우, Active -> Passive로 동기화 방법을 설명한다.

REM 심볼릭 링크에 Remote to remote로 접근할 수 있도록 설정
REM (아래 설정 안해주면 심볼릭 링크에서 오류를 뿜어낸다)
fsutil behavior set SymlinkEvaluation R2R:1 

REM JENKINS_HOME 폴더 동기화
robocopy %LOCAL_ACTIVE_JENKINS_HOME_DIR% %REMOTE_PASSIVE_JENKINS_HOME_DIR% /MIR 
@geunho
geunho / docker_get_image_digest.sh
Created April 3, 2019 02:24
docker get image digest
# get digest
digest=$(docker inspect --format='{{index .RepoDigests 0}}' $registry/$image:$tag)
# parse sha (split as '@' and get second one
sha=$(echo $digest | cut -d'@' -f2)
# or one line
sha=$(docker inspect --format='{{index .RepoDigests 0}}' $registry/$image:$tag | cut -d'@' -f2)