Blog

  • Nginx, WebDav, RaiDrive

    요즘 제공되는 nginx는 –with-http_dav_module 옵션이 기본으로 들어가 있어 RaiDrive로 그냥 연결이 되는 줄 알았다. 그런데 자꾸 접속이 되지 않았다. 그래서 nginx의 access_log를 보니 PROPFIND 항목이 보였다. 이것은 dav_ext_methods 에서 설정을 해주어야 한다. 그러기 위해서는 nginx 를 설치할 때 nginx-full로 해야 한다.

    apt install nginx-full

    server 블록의 location 은 다음과 같이 해주면 적어도 읽기는 항상 가능하다.

    location / {
    	autoindex on;
    	autoindex_localtime on;
    	dav_access user:rw group:rw all:r;
    	auth_basic "Restricted";
    	auth_basic_user_file /etc/nginx/sites-available/auth;
    	dav_methods PUT DELETE MKCOL COPY MOVE;
    	dav_ext_methods PROPFIND OPTIONS;
    }
  • 주식

     sudo docker network create work
    
    ## Working container
    sudo docker rm -f stock
    sudo docker run -it --name stock --restart always --network work -p 3838:3838 debian
    #sudo docker run -it --name stock --restart always --network work -p 8888:8888 -p 8787:8787 -p 3838:3838 debian
    echo 'Acquire::http::Proxy "http://rcc.work:3142";' > /etc/apt/apt.conf
    rm -rf /etc/localtime
    ln -s /usr/share/zoneinfo/Asia/Seoul /etc/localtime 
    apt-get -y update && apt-get -y upgrade
    apt-get -y install apt-utils dialog curl nano sudo procps cron
    cd ~; mkdir -p ~/.local; mkdir -p ~/.pip; curl -s http://rcc.work:3143/pip.conf > ~/.pip/pip.conf
    
    apt-get -y install python3 python3-pip
    pip3 install --break-system-packages jupyterlab
    jupyter lab --generate-config
    from jupyter_server.auth import passwd; passwd()
    
    # jupyter-lab --ip=* --allow-root
    
    ###### R
    apt-get -y install r-base gdebi
    curl -O http://rcc.work:3143/rstudio-server-2023.12.0-369-amd64.deb
    curl -O http://rcc.work:3143/libssl1.1_1.1.1w-0+deb11u1_amd64.deb 
    dpkg -i libssl1.1_1.1.1w-0+deb11u1_amd64.deb 
    gdebi rstudio-server-2023.12.0-369-amd64.deb
    
    
    export LD_LIBRARY_PATH = /usr/lib64/x86_64-linux-gnu/:$LD_LIBRARY_PATH
    
    
    ## DB
    sudo docker rm -f db
    sudo docker run -it --name db --restart always --network work --net=host debian
    
    echo 'Acquire::http::Proxy "http://rcc.work:3142";' > /etc/apt/apt.conf
    rm -rf /etc/localtime
    ln -s /usr/share/zoneinfo/Asia/Seoul /etc/localtime 
    apt-get -y update && apt-get -y upgrade
    apt-get -y install apt-utils dialog curl nano sudo procps
    apt-get -y install postgresql
    
    echo 'cd /root' >> ~/.bashrc
    echo 'service postgresql start' >> ~/.bashrc
    echo '/root/postgrest /root/postgrest.conf &' >> ~/.bashrc
    
    echo 'db-uri = "postgres://postgres:postgres@localhost:5432/postgres"' > /root/postgrest.conf
    echo 'db-schema = "db"' >> /root/postgrest.conf
    echo 'db-anon-role = "postgres"' >> /root/postgrest.conf
    
    ###
    sudo -i -u postgres psql postgres
    \password postgres
    
    create schema db;
    create table db.stock_list();
    alter table db.stock_list add name text;
    alter table db.stock_list add market text;
    insert into db.stock_list (name,  market) values ('IBM',  'NYSE');
    insert into db.stock_list (name,  market) values ('PFE',  'NYSE');
    
    create table db.stock_trend();
    alter table db.stock_trend add name text;
    alter table db.stock_trend add date date;
    alter table db.stock_trend add price double precision;
  • FFMpeg in Docker

    tar -cf cuda1.tar /usr/local/cuda
    
    sudo docker rm -f encoder
    
    sudo docker run -itd --name encoder --restart always --gpus all --add-host rcc.work:192.168.126.37 ubuntu
    
    sudo docker cp /usr/local/cuda/. encoder:/usr/local/cuda
    sudo docker cp /usr/lib/x86_64-linux-gnu/. encoder:/usr/lib/x86_64-linux-gnu
    sudo docker cp /etc/alternatives/. encoder:/etc/alternatives
    
    echo 'Acquire::http::Proxy "http://rcc.work:3142";' > /etc/apt/apt.conf
    rm -rf /etc/localtime
    ln -s /usr/share/zoneinfo/Asia/Seoul /etc/localtime 
    apt-get -y update && apt-get -y upgrade
    apt-get -y install apt-utils
    apt-get -y install dialog 
    git build-essential
    
    
    #https://docs.nvidia.com/video-technologies/video-codec-sdk/12.0/ffmpeg-with-nvidia-gpu/index.html
    cd ~
    git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
    cd nv-codec-headers && make install && cd ~
    git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg/
    cd ffmpeg
    
    apt-get -y install yasm pkg-config nasm libx264-dev libx265-dev libnuma-dev libpostproc-dev libass-dev fontconfig libavcodec-dev libavformat-dev software-properties-common libfaac-dev
    
    echo '/usr/local/lib' >> /etc/ld.so.conf 
    echo 'cd /root/' >> ~/.bashrc
    echo 'CUDA_HOME=/usr/local/cuda' >> ~/.bashrc
    echo 'PATH=${CUDA_HOME}/bin:${PATH}' >> ~/.bashrc
    echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64' >> ~/.bashrc
    
    ./configure --enable-nonfree --enable-cuda --enable-cuvid --enable-nvenc --enable-cuda-nvcc --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --disable-static --enable-shared --enable-gpl --enable-libx264 --enable-libx265 --enable-libass --enable-fontconfig --enable-libfribidi --enable-libfontconfig --enable-libfdk-aac
    
    make -j 6 && make install
    
    
    
    mkdir /usr/local/cuda
    mkdir 
    
    #!/bin/bash
    INPUT_MOV='gun.mp4'
    INPUT_SUB='English.srt'
    INPUT_SUB='gun.srt'
    OUTPUT_MOV='gun2.mkv'
    CPU='libx264'
    GPU='hevc_nvenc'
    
    ffmpeg \
            -hwaccel_output_format cuda \
            -i ${INPUT_MOV} -c:v ${GPU} \
            -vf "subtitles=${INPUT_SUB}:force_style='FontName=Malgun Gothic,FontSize=24',scale=hd720" \
            -c:a aac -b:a 192k -ac 2 -y -f matroska \
            ${OUTPUT_MOV}
    
    sshpass -p 1 sftp -P 20536 byun1114@office.work << EOF
    cd TMP
    put ${OUTPUT_MOV}
    EOF
    
    
  • RStudio Server in Docker

    sudo docker rm -f rstudio
    
    sudo docker run -it \
    --name rstudio \
    --restart always \
    --dns 8.8.8.8 \
    -p 8788:8787 \
    --add-host rcc.work:192.168.126.37 \
    debian
    
    echo 'Acquire::http::Proxy "http://rcc.work:3142";' > /etc/apt/apt.conf
    rm -rf /etc/localtime
    ln -s /usr/share/zoneinfo/Asia/Seoul /etc/localtime 
    apt-get -y update && apt-get -y upgrade
    apt-get -y install dialog gpg wget locales
    
    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B8F25A8A73EACF41
    
    gpg --keyserver keyserver.ubuntu.com \
        --recv-key '95C0FAF38DB3CCAD0C080A7BDC78B2DDEABC47B7'
    
    
    
    echo 'deb http://cloud.r-project.org/bin/linux/debian bookworm-cran40/' >> /etc/apt/sources.list
    
    #ttps://debian.pkgs.org/11/debian-main-amd64/libssl1.1_1.1.1w-0+deb11u1_amd64.deb.html
    wget http://ftp.de.debian.org/debian/pool/main/o/openssl/libssl1.1_1.1.1w-0+deb11u1_amd64.deb