커보러스 티켓 생성하기


$ kinit 계정명

#커보러스 티켓이 캐시에 저장 



커보러스 티켓 확인하기


$ klist

Ticket cache: FILE:/tmp/krb5cc_1000

Default principal:...


Valid starting       Expires              Service principal

...




티켓을 삭제하는 방법


$ kdestroy

klist: Credentials cache file '/tmp/krb5cc_1000' not found


Posted by '김용환'
,



centos의 git을 설치하면 (yum install git), 버전이 낮은 git이 설치된다. 따라서 git 명령어를 잘 인식 못할 수 있다.

현재는 yum install git으로 설치하면 2.2를 설치한다.



최신 git 을 설치하는 방법을 소개한다.



https://www.kernel.org/pub/software/scm/git/ 에 접속한다.


최신 버전을 찾는다. 현재는 2.9.3이 최신이다.



$ wget https://www.kernel.org/pub/software/scm/git/git-2.9.3.tar.gz

$ cd git-2.9.3

$ make prefix=/usr/local/git all

$ sudo make prefix=/usr/local/git install

$ echo "export PATH=$PATH:/usr/local/git/bin" >> ~/.bash_profile

$ source ~/.bash_profile


만약 root 사용자라면, ~/etc/bashrc를 수정한다.



Posted by '김용환'
,



jenkins에 job을 생성하고 jenkins의 환경 변수를 스크립트에서 쓸 수 있는 환경 변수를 얻으려면 다음 주소를 살펴본다.



https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project


build number, build url, job name, jenkins url, build tag 등 다양한 환경 변수를 사용할 수 있다. 



주의사항으로.. 장비 이름과 실제 호출되는 도메인 이름이 다를 때는 jenkins url이 의도한 것과 달리 나타날 수 있다.


jenkis url은 node 기준으로 나타나기 때문에 호출시 불리우는 dns name이 아닐 수 있다.  장비 관점의 도메인이 아니라, dns 서버 관점의 도메인이 url로 볼 수 없다. 이는 jenkins 로그인 설정이 활성화되어 있는 경우, 스크립트 내부에서 jenkins url을 사용할 때, 로그인을 다시 해야 하는 상황이 생길 수 있다. 




Environment VariableDescription
BUILD_NUMBERThe current build number, such as "153"
BUILD_IDThe current build id, such as "2005-08-22_23-59-59" (YYYY-MM-DD_hh-mm-ss, defunct since version 1.597)
BUILD_URL 
The URL where the results of this build can be found (e.g. http://buildserver/jenkins/job/MyJobName/666/)
NODE_NAMEThe name of the node the current build is running on. Equals 'master' for master node.
JOB_NAMEName of the project of this build. This is the name you gave your job when you first set it up. It's the third column of the Jenkins Dashboard main page.
BUILD_TAGString of jenkins-${JOB_NAME}-${BUILD_NUMBER}. Convenient to put into a resource file, a jar file, etc for easier identification.
JENKINS_URLSet to the URL of the Jenkins master that's running the build. This value is used by Jenkins CLI for example
EXECUTOR_NUMBERThe unique number that identifies the current executor (among executors of the same machine) that's carrying out this build. This is the number you see in the "build executor status", except that the number starts from 0, not 1.
JAVA_HOMEIf your job is configured to use a specific JDK, this variable is set to the JAVA_HOME of the specified JDK. When this variable is set, PATH is also updated to have $JAVA_HOME/bin.
WORKSPACEThe absolute path of the workspace.
SVN_REVISIONFor Subversion-based projects, this variable contains the revision number of the module. If you have more than one module specified, this won't be set. 
CVS_BRANCHFor CVS-based projects, this variable contains the branch of the module. If CVS is configured to check out the trunk, this environment variable will not be set.
GIT_COMMIT 
For Git-based projects, this variable contains the Git hash of the commit checked out for the build (like ce9a3c1404e8c91be604088670e93434c4253f03) (all the GIT_* variables require git plugin)     
GIT_URLFor Git-based projects, this variable contains the Git url (like git@github.com:user/repo.git or [https://github.com/user/repo.git])
GIT_BRANCH 
For Git-based projects, this variable contains the Git branch that was checked out for the build (normally origin/master) 


Posted by '김용환'
,



Ruby에서  ~를 사용하여 File의 존재 여부를 확인하고 싶을 때가 있다.


아래와 같이 File.file api를 사용해 파일 존재 여부를 확인하는 코드를 짰지만, 동작되지 않았다.


if
File.file?('~/job_name')
phase = `cat ~/job_name`.strip
else
phase = "develop"
end



아래와 같은 코드는 동작된다. 하지만,  절대 path와 상대 path 둘 다 사용하는 형태라서 어색하다.


if
File.file?('/Users/samuel.kim/job_name')
phase = `cat ~/job_name`.strip
else
phase = "develop"
end




home 디렉토리를 의미하는 ~와 함께 사용할 떄는 File.expand_path를 써야 의도된 대로 동작한다. 


if (File.exist? File.expand_path "~/job_name")
phase = `cat ~/job_name`.strip
else
phase = "develop"
end




'Ruby' 카테고리의 다른 글

[capistrano] 다른 task 호출하기  (0) 2016.12.07
ruby on rails 애플리케이션 실행하기  (0) 2016.10.12
[ruby] or equals 기능 - ||=  (0) 2016.08.17
[ruby] difference, union, intersection  (0) 2016.08.17
[ruby] 타입(type) 알기  (0) 2016.08.17
Posted by '김용환'
,

[ruby] or equals 기능 - ||=

Ruby 2016. 8. 17. 21:03



특정 변수가 정의되지 않았다면, 값을 저장하는 코드가 있다고 가정한다.

아마도 c/c++/java에 익숙한 개발자라면, 다음과 같이 코드를 짤 수 있다. 


xx = 3
unless defined? xx
xx = [1,2,3].inject(0) { |sum, t| sum + t }
end
puts xx


ruby에서는 or equals 라는 ||=를 사용하면, if 또는 unless 문 없이 쉽게 한 줄로 구현할 수 있다. 


xx = 3
xx ||= [1,2,3].inject(0) { |sum, t| sum + t }
puts xx


Posted by '김용환'
,



숫자, 문자에 대해서 교집합, 합집합, -집합(supplement) 기능을 사용할 수 있다.



a = [1, 2, 3, 4, 5]

b = [4, 5, 6, 7, 8]

puts "a-b (int) : " + (a - b).map { |s| "#{s}" }.join(' ')



a = ["1", "2", "3", "4", "5"]

b = ["4", "5", "6", "7", "8"]

puts "a-b : " + (a - b).map { |s| "#{s}" }.join(' ')

puts "b-a : " + (b - a).map { |s| "#{s}" }.join(' ')

puts "(a-b) || (b-a) : " + (a- b | b - a).map { |s| "#{s}" }.join(' ')





<결과>

a - b (int) : 1 2 3

a-b : 1 2 3

b-a : 6 7 8

(a-b) || (b-a) : 1 2 3 6 7 8




Posted by '김용환'
,

[ruby] 타입(type) 알기

Ruby 2016. 8. 17. 14:18



ruby에서 타입을 확인하고 싶다면, .class를 호출한다.


require 'redis'


...

redis = Redis.new(TEST_REDIS)
result = redis.hgetall("test")
if (result.nil?)
return nil
end

puts result.class

ruby hash를 리턴한다.


<결과>

Hash








Posted by '김용환'
,



OS El Capitan(10.11.6)에서 Xcode 7.3.1를 설치한 후, ruby thrift 모듈이 컴파일이 실패했다.



$ sudo gem install thrift


compiling compact_protocol.c

compact_protocol.c:442:41: error: shifting a negative signed value is undefined [-Werror,-Wshift-negative-value]

    rb_exc_raise(get_protocol_exception(INT2FIX(-1), rb_str_new2(but)));

....



xcode 설치 디렉토리 정보는 다음과 같다. (뒷 부분에서 바꾼다).


$xcode-select -p

/Applications/Xcode.app/Contents/Developer




https://developer.apple.com/download/more/ 에 접속하고, 로그인 한 후, 

Command Line Tools OS X 10.11 for Xcode 7.2 설치 파일을 다운받고 설치한다.






OS X 10.11 for Xcode 7.2의 커맨드 라인의 위치를 변경한다.


$ sudo xcode-select -s /Library/Developer/CommandLineTools/



바뀐 xcode 커맨드 라인을 확인한다.


$ xcode-select -p

/Library/Developer/CommandLineTools




$ gem install thrift 를 실행한다. 


더 이상 shifting a negative signed value is undefined [-Werror,-Wshift-negative-value] 에러는 발생하지 않는다.

Posted by '김용환'
,


공개키가 포함된 인증서와 개인 키를 생성하는 예제이다.

centos 7 부터 키 생성 방법이 엄청 편해졌다.

 


$ cd /etc/pki/tls/certs



$ sudo make server.crt



$ ls -al

..

-rw-------. 1 root root 1249  8월 16 13:18 server.crt

-rw-------. 1 root root 1766  8월 16 13:18 server.key



키가 정상적인 지 확인하려면, 다음 커맨드를 실행해서 공개 키와 개인 키를 기반으로 나온 결과 값이 동일한지 확인한다.



$ sudo openssl x509 -noout -modulus -in server.crt | openssl md5

(stdin)= 797c0391f368bde47394aac7adf5bcdb




$ sudo openssl rsa -noout -modulus -in server.key | openssl md5

Enter pass phrase for server.key:

(stdin)= 797c0391f368bde47394aac7adf5bcdb




Posted by '김용환'
,



ruby에서 현재 디렉토리를 얻으려면, Dir 클래스를 사용하면 된다.

spec_path = Dir.pwd + "/spec"
puts spec_path


Posted by '김용환'
,