Skip to content

Instantly share code, notes, and snippets.

View geunho's full-sized avatar
๐ŸŽฏ
Focusing

Geunho Kim geunho

๐ŸŽฏ
Focusing
View GitHub Profile
# remove_old_files.sh /path/of/root 90
#
# ์˜ค๋ž˜๋œ ํŒŒ์ผ์„ ์‚ญ์ œํ•œ๋‹ค.
##########################################
$root_path=$1
$days_past=$2
find $root_path -type d -ctime +$days_past | xargs rm -rf
# rm_directories.sh /path/of/root keyword
#
# ํŠน์ • ํŒŒ์ผ๊ณผ ํด๋” ๋ชฉ๋ก์„ ๊ฐ€์ ธ์™€์„œ ์‚ญ์ œํ•˜๋Š” ์Šคํฌ๋ฆฝํŠธ
##################################################
root_path=$1
keyword=$2
# 1. ์ „์ฒด ๋ชฉ๋ก์„ ๊ฐ€์ ธ์™€์„œ
# 2. ํ‚ค์›Œ๋“œ๋กœ ํ•„ํ„ฐํ•˜๊ณ 
# 3. ๋งˆ์ง€๋ง‰ ํŒŒ์ผ, ํด๋” ์ด๋ฆ„์„ ๊ฐ€์ ธ์™€์„œ
REM test A - 001
REM test B - 002
REM get rid of last 6 characters
SET title_a=test A - 001
SET title_b=test B - 002
SET first=%title_a:~0,-6%
SET second=%title_b:~0,-6%
@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)
@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 / 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 / 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 / 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 / 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: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-----