2014년 9월 9일 화요일

Sencha Touch 센차터치 app 내부 파일 구조

Sencha generate 를 이용하여 app을 생성하면 아래와 같은 구조의 directory, file framework로 생성된다. 
  • app - The directory containing the Models, Views, Controllers, and Stores for your app.
  • app.js - The main JavaScript entry point for your app.
  • app.json - The configuration file for your app.
  • index.html - The HTML file for your app.
  • packager.json - The configuration file used by Sencha Cmd for creating native packages for your application.
  • resources - The directory containing the CSS and the images for your app

app.js 파일에는 Sencha Touch의 엔트리 포인트 코드가 들어있다.
app실행 시 main 객체를 생성하고, main view를 생성하는 코드 이다. 
객체 지향에서 흔히 사용하는 entry code로 크게 수정할 내용은 없어 보인다 .
아래는 app.js의 샘플 코드이다. 
Ext.application({
    name: 'Test',

    extend: 'Test.Application',
    
    autoCreateViewport: 'Test.view.main.Main'
    //-------------------------------------------------------------------------
    // Most customizations should be made to Test.Application. If you need to
    // customize this file, doing so below this section reduces the likelihood
    // of merge conflicts when upgrading to new versions of Sencha Cmd.
    //-------------------------------------------------------------------------
});

/app/view/main/Main.js에는 main view 의 UI 코드가 들어있다. 

Ext.define('Test.view.main.Main', {
    extend: 'Ext.container.Container',

    xtype: 'app-main',
    
    controller: 'main',
    viewModel: {
        type: 'main'
    },

    layout: {
        type: 'border'
    },

    items: [{
        xtype: 'panel',
        bind: {
            title: '{name}'
        },
        region: 'west',
        html: '<ul><li>This area is commonly used for navigation, for example, using a "tree" component.</li></ul>',
        width: 250,
        split: true,
        tbar: [{
            text: 'Button',
            handler: 'onClickButton'
        }]
    },{
        region: 'center',
        xtype: 'tabpanel',
        items:[{
            title: 'Tab 1',
            html: '<h2>Content appropriate for the current navigation.</h2>'
        }]
    }]
});



Test.view.main.Main에 대한 클래스는 Ext.define 함수를 사용해서 선언한다. 
Ext.define('Test.view.main.Main', {         // Ext.define 함수를 사용하여 class선언 
    extend : 'Ext.container.Container',     // Ext.container.Container 를 상속 받는다. 
   controller: 'main',
    viewModel: {
        type: 'main'
    }

   .... 
});



Sencha Touch App Generate 센차터치 앱 생성

Sencha Touch를 사용하여 app을 생성하기 위해

기본적으로 리눅스 서버 상에 Sencha Touch와 Sencha Touch CMD가 설치되어 있어야 한다.

Sencha Touch 개발 환경 세팅에 대한 자세한 내용은 나중에 ..

Sencha Touch 문서에서는 아래 명령어를 통해 App 디렉토리를 생성하도록 가이드하고있다.

/path/to/touch 는 Sencha touch 관련 파일을 zip파일로 받은 후 압축을 풀어놓은 경로를 말한다.

sencha -sdk /path/to/touch generate app MyApp .

경로를 지정하지 않고 app을 생성하는 방법이 있다.

sencha help generate app 명령어를 실행하여 generate app 관련 문서를 보면 아래와 같다.

This command generates an empty application given a name and target folder.

The application can be extended using other sencha generate commands (e.g.,
sencha generate model).

Other application actions are provided in the sencha app category (e.g.,
sencha app build).

Sencha Cmd can also automatically download and extract a framwork by
specifying the name of the framework as an argument:

    sencha generate app -ext MyAppName ./MyAppPath

This will generate an application using the newest version available

for the specified framework.


   sencha generate app -ext MyAppName ./MyAppPath

-ext 명령어를 사용하면 외부 링크에서 Sencha Touch framework를 받아 서버에 세팅한다. 외부에서 새로 파일을 받아야 하는 리소스와 시간의 소모가 있지만 Sencha버전을 항상 최신으로 유지 가능하다는 장점이 있다. 





2014년 9월 8일 월요일

rhel 7.0 래드햇 리눅스 7 Linux 7 static routing 설정 ip route

static route 스택틱 라우팅은 default gateway로 가면 안 되는 트래픽을 정의할 때 사용한다.  일반적으로 routing은 서버나 클라이언트 단에서 조정하는 것이 아니라, 네트워크 장비 상의 router에서 결정된다. static routing은 특정 트래픽을 의도적으로 특정 위치로 보내야 할때나 VPN tunnel등에서만 사용한다.
default gateway는 목적지 트래픽이 local network 안에 없을 경우 또는 routing table에 preferred 된 트래픽이 없을 경우 사용한다.
일반적으로 default gateway는 장비에 물린 네트워크 라우터의 주소이다.

ip packet이 전송 될 시 1차적으로는 routing table로 static routing이 설정 되어있는지 검사,
2차적으로 설정된 ip address 상의 local network 안 주소인지 검사, 최종적으로 모두 해당하지 않는 패킷의 경우 default gateway로 넘겨버린다.

routing table은 아래 명령어로 확인 가능 하다.

ip route [ add | del | change | append | replace ] destination-address

~]$ ip route
default via 192.168.122.1 dev ens9  proto static  metric 1024
192.168.122.0/24 dev ens9  proto kernel  scope link  src 192.168.122.107
192.168.122.0/24 dev eth0  proto kernel  scope link  src 192.168.122.126

ip route add 192.0.2.1 via 10.0.0.1 [dev ifname]
192.0.2.1 이라는 ip 의 host(single IP)에 대한 routing table을 추가하는 커맨드이다.
192.0.2.1 이 목적이 주소로 들어올 경유 ifname이라는 interface 의 10.0.0.1을  next-hop로 보내면 된다. ( 목적지 mac-address를 10.0.0.1로 바꿔서 전송한다. 이때 목적지 IP는 변하지 않는다. )

 ip route add 192.0.2.0/24 via 10.0.0.1 [dev ifname]
위와 비슷하게 192.0.2.0/24 network 대역에 대한 static routing을 추가할 시 위와 같은 명령어를 실행하면 된다.

이외에도 비슷한 형식으로 del, change, append, replace 명령어를 사용하여 routing table을 편집할 수 있다.

각 interface별 static routing table 정보는 /etc/sysconfig/network-scripts/route-interface 파일 안에 저장된다.






rhel 7.0 레드햇 리눅스 Linux 7 network static IP 설정하기

rhel 버전에서는 NetworkManager의 interactive tool을 추가로 설치하여 IP를 세팅할 수 있다.

하지만, 역시 기존의 script file 수정 방법이 있기에, 이를 따르는게 편하다.

네트워크 인터페이스 세팅은 ifcfg-<name> 파일에 설정이 저장된다. ex) ifcfg-eth1, ifcfg-bond1

eth0  인터페이스 네트워크 세팅
/etc/sysconfig/network-scripts/ifcfg-eth0 파일 
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=10.0.1.27
onboot 세팅을 yes로 해줘야 정상 동작한다. 
bootproto는 static, dhcp IP 설정을 담당한다. 

dhcp로 dynamic 한 주소를 갖는경우 아래와 같이 세팅된다.
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes

rhel 7.0 Linux 7.0 리눅스 network 설정 NetworkManager


레드햇 리눅스 7버전에서, 기본 네트워크 서비스는 NetworkManager에 의해 제공된다. NetworkManager은 동적 네트워크 설정과 제어 데몬이다. 전통적인 리눅스 네트워크 설정 ifcfg는 그대로 제공된다. 

NetworkManager에서 네트워크 영역,  IP 주소, 정적 라우팅, DNS설정, VPN연결 뿐만 아니라 다양한 접속 파라미터를 설정 할 수 있다. 기본적으로 기존에 ifcfg에서 해왔던 동작들이 NetworkManager를 통해 이루어 진다고 생각하면 될 것 같다.  rhel 7 버전에서는 NetworkManager의 숙지가 중요하다. 

1. NetworkManager 데몬 설치
    #yum install NetworkManager

2. NetworkManager 데몬 
    NetworkManager는 root권한에서 실행된다.  systemctl status로 상태를 확인한다. 
    ~]$ systemctl status NetworkManager
    NetworkManager.service - Network Manager
        Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled)
        Active: active (running) since Fri, 08 Mar 2013 12:50:04 +0100; 3 days ago

  NetworkManager의 Active 상태가 deactive(dead) 상태일 경우 start명령어를 실행
    ~]# systemctl start NetworkManager

   enable 실행 시 부팅 시마다 해당 데몬이 실행되도록 한다. ( 기존 rhel 6 버전에서의 chkconfig와 같은 역할)
    ~]# systemctl enable NetworkManager




2014년 9월 6일 토요일

linux 리눅스 vsftpd ftp 설정에서 유저가 home directory 밖의 영역으로 이동하지 못하게 제한 방법

linux 리눅스 vsftpd ftp 설정에서 유저가 home directory 밖의 영역으로 이동하지 못하게 제한 방법

해당 부분은 chmod를 사용하여 linux 계정의 유저 권한 부분을 조정하여 제한하려 했지만 잘 되지 않았다.

home directory 밖의 이동을 제한하기 위해서는 /etc/vsftpd/vsftpd.conf 파일을 직접 수정해야 한다.

----------------------------------------------------------------------------------
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
chroot_local_user=YES
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list
----------------------------------------------------------------------------------
vsftpd.conf 파일 내 chroot 부분을 수정한다.
chroot_local_user=YES
chroot_list_enable=YES
위의 설정값이 초기에는 # 주석처리 되어있다. chroot 관련 부분을 주석을 모두 해제한다.

chroot_list_file 은 home이외의 영역 조회가 가능한 계정 리스트에 관한 파일이다.

설정 완료 후 /etc/vsftpd/chroot_list 파일을 생성한다. ( home 영역을 벗어날 계정이 없더라도.. )

설정 완료 후 에는 service vsftpd restart로 FTP를 재시작한다.



linux 리눅스에서 vsftp ftp 계정별 접속 시 home directory 위치 설정

vsftp 를 사용하여 Linux에 FTP서버를 구축한 후 계정별 접속 홈 디렉토리 설정을 하기 위해
별도로 vsftp단에서 해줘야 하는 설정은 없다.

linux 계정 자체의 HOME directory를 원하는 경로로 설정해주면 된다.

웹 호스팅 시 일반적으로 telnet 접속등을 통한 서버 관리는 유저단에서 생각하지 않는 것 같다.

원하는 home 경로는 일반적으로 웹 서버 주소인 /var/www/html 내의 directory를 설정하면 된다.

홈 디렉토리를 변경하는 방법은 2가지 방법이 있다.

1. /etc/passwd 파일을 직접 수정하는 방법
2. usermod 명령어를 사용하는 방법

1. /etc/passwd 파일 수정
    hyun:x:501:501::/var/www/html/hyun:/bin/bash
    위 계정 설정 값에서 </var/www/html/hyun> 부분은 기존에 /home/hyun이 있던 부분이었다.
    해당 위치의 경로를 설정하면 된다.

2. usermod 명령어를 사용하는 방법
    usermod -d <변경할 home 경로> <변경할 계정 이름>
    ex) usermod -d /var/www/html/hyun hyun
    으로 설정하면 된다.