미니의 블로그

  • 워드프레스 글꼴 바꾸기

    워드프레스 기본 글꼴이 조금 별로다. 그래서 이번엔 폰트를 바꿔보기로 한다.

    먼저 플러그인을 추가해 주고 활성화 해 준다. 아무거나 해도 될것 같다.

    나는 Daniele De Santis의 WP Add Custom CSS을 설치해 줄것이다.

    이제 폰트를 검색해 보자. https://fonts.google.com 같은 곳에서 폰트를 검색한다. 다른 곳도 괜찮다.

    나는 제목과 본문 등에는 나눔바른고딕을, 명령어 쓰는 부분에는 D2코딩을 쓸 것이다.

    플러그인 설정으로 가면 위 사진과 같이 나오는데 아래 내용을 입력을 하자.

    @import url("https://cdn.jsdelivr.net/gh/moonspam/NanumBarunGothic@latest/nanumbarungothicsubset.css");
    @import url("http://mapoo.net/font/d2coding.css" ) ;
    
    body, h1, h2, h3, h4, h5, h6, p, a, p, div, span, ul, li { font-family: 'NanumBarunGothic', sans-serif; }
    code { font-family: 'D2Coding', monospace; }
    
    .wp-block-code code {
        font-family: 'D2Coding', monospace;
    }

    이렇게 하면 제목, 본문 등의 글꼴은 나눔바른고딕이 되고 코딩부분은 D2코딩으로 설정된다.

    참조
    GitHub – moonspam/NanumBarunGothic: 나눔바른고딕 경량화 웹폰트 (NanumBarunGothic Webfont Optimization)
    워드프레스에 Nanum Gothic Coding 고정폭 폰트 적용하기 – mapoo’s blog
    워드프레스에 커스텀 CSS 추가하기 – WordPress 가이드 (usefulparadigm.com)

  • 도커 이미지 저장소 옮기기

    도커로 이것저것 돌리다 보니 용량이 금방 쌓여 8기가 밖에 안되는 라즈베리파이가 저장공간이 부족하다.

    그래서 남는 USB를 꽂고 제일 저장공간 많이차지하는 도커 이미지들을 거기로 옮기기로 했다.

    도커는 기본적으로 /var/lib/docker에 이미지나 볼륨 같은 자료를 저장한다. 그리고 이를 -g로 실행 옵션을 주어 변경할 수 있다.

    자 이제 시작을 해 보자.

    먼저 도커를 실행 중지한다.

    sudo systemctl stop docker.service
    sudo systemctl stop docker.socket

    그 다음 /lib/systemd/system/docker.service 파일을 수정한다. 파일을 열어 보면 아래와 같은 부분이 있을 것이다.

    ExecStart=/usr/bin/dockerd -H fd://어쩌구저쩌구

    이제 여기 안에 아래와 같이 -g /원하는/디렉토리 옵션을 넣어 아래와 참고해 파일을 수정한다. 여기서는 /mnt/storage/lib/docker를 쓰겠다.

    ExecStart=/usr/bin/dockerd -g /mnt/storage/lib/docker -H fd://어쩌구저쩌구

    그리고 이제 위에서 설정한 위치에 폴더를 만들어 준다.

    sudo mkdir /mnt/storage/lib/docker

    이제 기존 도커의 위치를 새 위치로 옮겨 준다.

    sudo rsync -aqxP /var/lib/docker/ /mnt/storage/lib/docker

    이제 도커를 시작해 준다.

    sudo systemctl daemon-reload
    sudo systemctl start docker

    제대로 옮겨 졌는지 확인하려면 실행중인 프로그램 목록에서 도커의 옵션을 보면 된다.

    ps aux | grep -i docker | grep -v grep

    위 명령을 입력하고 /usr/bin/dockerd -g /mnt/storage/lib/docker 가 있는지 확인하면 된다.

    참조
    Change Docker root directory /var/lib/docker to another location – Linux Tutorials – Learn Linux Configuration

  • 전화접속 서버 만들기

    이번에는 전화로 인터넷에 접속하는 서버를 만들 것이다.

    우선 가상머신에 우분투 서버를 깔아주고 USB모뎀을 연결해 주었다.

    다음 명령어를 입력하여 mgetty와 ppp를 깔아준다.

    sudo apt update
    sudo apt upgrade
    sudo apt install mgetty ppp

    이제 mgetty가 자동으로 실행 되도록 서비스를 등록해 줄 것이다.

    /lib/systemd/system/mgetty.service 파일을 만들어 준 후 다음 내용을 채워 넣는다.

    [Unit]
    Description=External Modem
    Documentation=man:mgetty(8)
    Requires=systemd-udev-settle.service
    After=systemd-udev-settle.service
    
    [Service]
    Type=simple
    ExecStart=/sbin/mgetty /dev/ttyACM0
    Restart=always
    PIDFile=/var/run/mgetty.pid.ttyACM0
    
    [Install]
    WantedBy=multi-user.target

    그리고 이제 /etc/mgetty/mgetty.config 파일을 열고 맨 아래에 다음 내용을 채워 넣는다.

    debug 9
    
    port ttyACM0
     port-owner root
     port-group dialout
     port-mode 0660
     data-only yes
     ignore-carrier no
     toggle-dtr yes
     toggle-dtr-waittime 500
     rings 2
     #autobauding yes
     speed 57600

    그리고 아래 명령어를 실행해서 부팅시 켜지도록 해 준다.

    sudo systemctl enable mgetty.service

    재부팅 하고나서 서버로 전화를 걸면 터미널에 접속할 수 있다.

    터미널 접속 영상

    이제 ppp를 설정해 줄 것이다 /etc/ppp/options 파일일에서 아래 부분과 같이 주석을 해제하고 수정해 준다

    # Define the DNS server for the client to use
    ms-dns 8.8.8.8
    # async character map should be 0
    asyncmap 0
    # Require authentication
    auth
    # Use hardware flow control
    crtscts
    # We want exclusive access to the modem device
    lock
    # Require the client to authenticate with pap
    +pap
    # Heartbeat for control messages, used to determine if the client connection has dropped
    lcp-echo-interval 30
    lcp-echo-failure 4
    # Cache the client mac address in the arp system table
    proxyarp
    # Disable the IPXCP and IPX protocols.
    noipx

    이제 /etc/ppp/options.ttyACM0 를 아래 내용으로 생성해 준다

    local
    lock
    nocrtscts
    192.168.32.1:192.168.32.105
    netmask 255.255.255.0
    noauth
    proxyarp
    lcp-echo-failure 60

    이제 ppp계정을 만들 것이다. 계정을 만들고 비밀번호를 설정해 주

    sudo useradd -G dialout,dip,users -m -g users -s /usr/sbin/pppd ppp
    sudo passwd ppp

    /etc/ppp/pap-secrets 파일의 맨 아랫부분에 아래와 같이 아까 만든 아이디와 비밀번호를 추가 한다.

    아이디 * "비밀번호" *

    이제 ppp에 사용되는 ip가 외부에 접근할 수 있도록 설정을 해야 한다.

    /etc/systemd/system/ppp-ready.service 파일을 만들고 아래 내용을 넣는다.

    [Unit]
    After=network.target
    
    [Service]
    ExecStart=/usr/local/bin/ppp-ready.sh
    
    [Install]
    WantedBy=default.target

    그리고 /usr/local/bin/ppp-ready.sh 파일을 만들고 아래 내용을 넣는다.

    #!/bin/bash
    iptables -t nat -A POSTROUTING -s 192.168.32.0/24 -o enp0s3 -j MASQUERADE

    아래 명령어를 입력 해 파일의 권한을 수정해 준다

    sudo chmod 744 /usr/local/bin/ppp-ready.sh
    sudo chmod 644 /etc/systemd/system/ppp-ready.service

    마지막으로 /etc/sysctl.conf 파일에서 아래 부분을 주석 해제 한다.

    net.ipv4.ip_forward=1

    이제 다 끝났다 시스템을 껐다가 키면 이제 전화 접속을 할 준비가 됐다.

    아래는 전화 접속으로 Google에 접속하는 영상이다.

    인터넷 연결 영상

    참조
    Dial up server – Doge Microsystems
    How to run script on startup on Ubuntu 22.04 Jammy Jellyfish Server/Desktop – Linux Tutorials – Learn Linux Configuration