NAS를 어떻게 구축할까, OpenMediaVault를 쓸까, Raspbian 위에 그냥 만들까, 그러려면 뭘 깔아야 하나 찾다가 찾은 글.
http://www.spacek.xyz/mle/?p=357
뭘 설치했는지 꽤 잘 나와 있다. 좀 해보다 별로면 OpenMediaVault로 이미지 바꿔보지 뭐.
쓸만한 글을 찾을 때마다 이 글을 업데이트하겠다.
NAS를 어떻게 구축할까, OpenMediaVault를 쓸까, Raspbian 위에 그냥 만들까, 그러려면 뭘 깔아야 하나 찾다가 찾은 글.
http://www.spacek.xyz/mle/?p=357
뭘 설치했는지 꽤 잘 나와 있다. 좀 해보다 별로면 OpenMediaVault로 이미지 바꿔보지 뭐.
쓸만한 글을 찾을 때마다 이 글을 업데이트하겠다.
QuickBuild를 이용할 때, 굳이 사이트에 접속해서 빌드를 돌리지 않아도 RESTful API를 이용하면 빌드를 걸 수 있다.
http://wiki.pmease.com/display/QB61/Interact+with+Build+Requests#InteractwithBuildRequests-requestnewbuild 에 해당 내용이 정리되어 있다.
Basic authentication 시에 curl을 이용해서 요청하는 방법은 다음과 같다.
$ curl -X POST -u dasomoli:password -d@request.xml http://<Server>:8810/rest/build_requests
위의 예제에서 사용한 request.xml 은 다음의 형식을 가진다. <varlables> 안에 채울 내용은 해당 configuration에서 실행한 빌드의 variables(http://<Server>:8810/build/<Build id>/variables) 페이지에서 확인 가능하다.
<com.pmease.quickbuild.BuildRequest>
<!-- This element tells QuickBuild in what configuration to trigger build. -->
<configurationId>10</configurationId>
<!-- This element tells whether or not to respect build condition of the configuration.
If this is set to true, and if the build condition evaluates to false, build will
not be triggered. -->
<respectBuildCondition>false</respectBuildCondition>
<!-- This element is optional and is used to specify variables for build triggering. If
specified, it will override the variable with the same name defined in configuration
basic setting. -->
<variables>
<entry>
<string>var_name1</string>
<string>var_value1</string>
</entry>
<entry>
<string>var_name2</string>
<string>var_value2</string>
</entry>
</variables>
<!-- This element is optional and is used to tell QuickBuild to request a build promotion. -->
<promotionSource>
<!-- This element is optional and is used to tell QuickBuild that the source build resides on another
QuickBuild server. -->
<server>
<url>http://another-qb-server:8810</url>
<userName>admin</userName>
<password>admin</password>
</server>
<!-- Identifier of the source build to promote from -->
<buildId>697</buildId>
<!-- This element is optional and used to specify files to promote -->
<deliveries>
<com.pmease.quickbuild.FileDelivery>
<srcPath>artifacts/dir1</srcPath>
<filePatterns>**/*.jar</filePatterns>
</com.pmease.quickbuild.FileDelivery>
<com.pmease.quickbuild.FileDelivery>
<srcPath>artifacts/dir2</srcPath>
<filePatterns>**/*.war</filePatterns>
</com.pmease.quickbuild.FileDelivery>
</deliveries>
</promotionSource>
</com.pmease.quickbuild.BuildRequest>
Sample XML의 comment에서 확인할 수 있듯이 <promotionSource>내부는 생략 가능하다.

24시간 내내 돌리면 라즈베리 파이가 너무 뜨거울 것 같아서 USB 선풍기를 포트에 연결하고, 이걸 껐다 켰다 하려고 시도했다. 결론적으론 다른 USB 기기를 쓰지 않는다면, 전체 USB 포트를 껐다 켜는 방식으로 가능하다. 다른 USB 기기를 사용한다면, 실패. 아직 디바이스 드라이버에 커널 컴파일까진 시도하고 싶지 않다.
https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=93463 쓰레드를 참고하면, hub-ctrl을 이용하면, 전체 포트 혹은 개별 포트를 껐다 켰다 하는 것을 할 수 있다. 그러나 개별 포트를 끄는 게, 실제 VBUS 전원까지 내리는 건 아니고, 그냥 못쓰게 할 뿐이다. 그래서, 전체 포트를 끄지 않는 한, 개별 포트를 꺼도 해당 포트 VBUS는 살아있기 때문에 USB 선풍기는 계속 돈다-_-;;
다음은 usb-ctrl의 설치 및 사용 방법이다.
라즈베리 파이에서 다음을 설치한다.
# apt-get install libusb-dev
다음으로 바이너리를 만든다.
# apt-get install git gcc
# git clone https://github.com/codazoda/hub-ctrl.c
# gcc -o hub-ctrl hub-ctrl.c -lusb
만든 바이너리를 적당한 곳(예를 들면, /usr/sbin/)에 설치한다.
# cp hub-ctrl /usb/sbin/
나의 경우 한 시간에 한번 정도, 50초 정도 돌게 하고 싶었다. /etc/cron.hourly 아래에 다음과 같은 스크립트를 만들어 실행 권한을 준다.
# vi /etc/cron.hourly/coolingusbfan
#!/bin/sh
hub-ctrl -h 0 -P 2 -p 1; sleep 50; sudo hub-ctrl -h 0 -P 2 -p 0
참고로, 다음 그림과 같이 포트 번호를 붙인다면,

라즈베리 파이 3 Model B의 경우, 다음과 같다고 한다.
Hub:Port — Controlled port(s)
0:1 — Controls the Ethernet port
0:2 — Controls all four USB ports (not the Ethernet)
0:3 — Controls USB Port 4
0:4 — Controls USB Port 2
0:5 — Controls USB Port 3
NAS를 위해, 외장 하드를 붙일 거라 이제 더는 위 스크립트를 사용하지 못한다.
개인의 경우는 대체적으로 설득 가능하다. 그러나, 모든 팀원이 그래서 모두를 설득해야 한다면, 팀 혹은 회사 차원의 문제다. 이런 경우, 개인을 설득하려 해도, “다들 그래요”, “그게 여기서 되겠어요?”, “그거 한다고 안바뀌어요”, “당신 때문에 내 코드가 못들어가고 있어요. 오늘 릴리즈인데, 당신이 책임질거요?” 따위의 말이나 듣는다. ‘협업 안되는 사람’이 되고.
내가 아는 어떤 회사가 그랬다. 요즘은 좀 바꾸려고 하는 것 같던데, 이런 사람들이 위에서 때리면, 제일 먼저 자기는 안그런다 하더라.
만약 당신이 동료를 향해 신경쓰이는 기분이 든다면 회사 혹은 팀의 경영 측면에서 문제가 있는 겁니다.
Eclipse는 내부적으로 Indexer가 돌아서 이를 이용해 찾고 싶은 File, Funtion decalaration/definition, symbol 등을 찾을 수 있다. 내가 자주 쓰는 단축키는 다음과 같다.
<html>
<head>
<meta http-equiv=”refresh” content=”0; url=./index.php”>
</head>
<body onload=”javascript:window.location=’./index.php'”>
Please follow <a href=”index.php”>this link</a>
</body>
</html>
참고: https://en.m.wikipedia.org/wiki/Meta_refresh
하나의 git repository로 체크 아웃을 한군데 하는게 아니라 여러군데에 하고 싶을 때 쓴다. 브랜치를 아예 물리적으로 다른 경로로 나누어서 작업하고 싶을 때라던지 용도는 매우 다양하다.
curl -b cookie.txt -c cookie.txt http://blog.dasomoli.org/
일단 기본 개념부터.
PSK는 Pre-Shared Key의 줄임말로, 보안이 필요한 통신을 하는 양자 간에 미리 공유된 symmetric 키를 말한다.
TLS는 Transport Layer Security의 줄임말로, SSL이 표준화되면서 쓰이는 이름이다.
TLS-PSK는 PSK를 이용해서 TLS연결을 맺는 것으로 RFC 4279에 문서화되어 있다.
RFC 4279의 내용을 살펴보자.
Client Server
------ ------
ClientHello -------->
ServerHello
(Certificate)
ServerKeyExchange*
(CertificateRequest)
<-------- ServerHelloDone
(Certificate)
ClientKeyExchange
(CertificateVerify)
ChangeCipherSpec
Finished -------->
ChangeCipherSpec
<-------- Finished
Application Data <-------> Application Data
위 그림이 TLS handshake과정을 나타낸다.
1. 클라이언트는 ClientHello 메시지에 TLS Version과 하나 이상의 cipher-suite을 실어 보낸다.
2. 서버는 ServerHello 메시지에 사용할 TLS Version과 사용할 cipher-suite를 실어 보낸다. ServerKeyExchange 메시지로 클라이언트가 어떤 PSK를 사용할 지, PSK identity hint를 함께 보낸다. ServerHelloDone도 보낸다.
3. 클라이언트는 ServerKeyExchange에 포함된 PSK identity hint로 사용할 PSK를 고른다. 고른 PSK의 PSK identity를 ClientKeyExchange 메시지에 실어 보낸다. Premaster secret은 PSK가 N octets라면, uint16 타입의 N, N개의 0 octets, 두번째 uint16타입의 N, 그리고 PSK N octets.
OpenSSL에서는 Client 쪽에서는 PSK callback을 SSL_CTX_set_psk_client_callback()이나 SSL_set_psk_client_callback()을 통해 설정하도록 되어있는데, 이 callback을 Server로부터 받은 PSK Identity Hint를 읽어 valid한지를 check하고, 해당 hint에 맞는 PSK를 psk에, PSK identity를 identity argument에 채워주는 역할을 한다. callback은 psk의 length를 return해야 한다. 0이나 그 이하는 error를 나타낸다.
Server쪽에서는 SSL_CTX_use_psk_identity_hint()나 SSL_use_psk_identity_hint()를 통해서 사용할 PSK Identity Hint를 Setting하고, SSL_CTX_set_psk_server_callback()나 SSL_set_psk_server_callback()을 통해 callback을 셋팅한다. 이 callback은 PSK identity가 valid한지를 체크하고, PSK identity가 있다면, pre-shared key를 psk argument에 채우고, PSK의 길이를 return한다.
* 참고
RFC 4279 – PSK Ciphersuites for TLS(https://tools.ietf.org/html/rfc4279)
TLS: https://en.wikipedia.org/wiki/Transport_Layer_Security, https://namu.wiki/w/TLS
TLS-PSK: https://en.wikipedia.org/wiki/TLS-PSK
OpenSSL
SSL_CTX_set_psk_client_callback: https://www.openssl.org/docs/manmaster/ssl/SSL_CTX_set_psk_client_callback.html
SSL_CTX_use_psk_identity_hint: https://www.openssl.org/docs/manmaster/ssl/SSL_CTX_use_psk_identity_hint.html