[Linux] rsync 간단 사용

$ rsync -av --progress <source> <destination>

Local 로부터 local로의 sync가 아니라면 -z 옵션을 주는 것도 좋다. destination에서 source에 없는 파일은 지우고 싶다면 –delete 옵션을 준다. -h 옵션은 human readable하게 한다. –progress는 progress를 보여준다.

crontab으로 등록

# crontab -e
0 3 * * * rsync -avh --delete /mnt/NAS /media/dasomoli/Elements

나는 이렇게 한다.

#!/bin/bash

if [[ -b /dev/sda1 && -b /dev/sdb1 && -d /media/dasomoli/Elements && -d /mnt/NAS ]] \
       && ! [[ -e /media/dasomoli/Elements1 ]]; then
	rsync -avh --delete /mnt/NAS /media/dasomoli/Elements >> /var/log/rsync/backup_exthdd.log;
else
	echo "`date`: Error: HDDs have not mounted" >> /var/log/rsync/backup_exthdd.err;
	mount >> /var/log/rsync/backup_exthdd.err;
fi

그리고 logrotate 설정을 해둔다.

# vi /etc/logrotate.d/backup_exthdd
/var/log/rsync/backup_exthdd.log /var/log/rsync/backup_exthdd.err {
    weekly
    missingok
    rotate 5
    compress
    notifempty
}

[ffmpeg] 여러 개의 동영상 한꺼번에 합치기

  1. ffmpeg를 https://ffmpeg.org/download.html 에서 받아서 압축을 푼 후, PATH 환경 변수에 해당 경로를 추가해서 커맨드 프롬프트에서 실행 가능하도록 만든다.

  2. 여러 동영상 파일명을 적은 Text file을 하나 만든다.

[code]
file ‘StepByStep/01_1-3/1-3-2.m4v’
file ‘StepByStep/01_1-3/1-3-3.m4v’
file ‘StepByStep/01_1-3/1-3-4.m4v’
file ‘StepByStep/01_1-3/1-3-5.m4v’
file ‘StepByStep/01_1-3/1-3-6.m4v’
file ‘StepByStep/01_1-3/1-3-7.m4v’
file ‘StepByStep/01_1-3/1-3-8.m4v’
file ‘StepByStep/01_1-3/1-3-9.m4v’
file ‘StepByStep/01_1-3/1-3-10.m4v’
file ‘StepByStep/01_1-3/1-3-11.m4v’
file ‘StepByStep/01_1-3/1-3-12.m4v’
file ‘StepByStep/01_1-3/1-3-13.m4v’
file ‘StepByStep/01_1-3/1-3-14.m4v’
file ‘StepByStep/01_1-3/1-3-15.m4v’
file ‘StepByStep/01_1-3/1-3-16.m4v’
file ‘StepByStep/01_1-3/1-3-17.m4v’
file ‘StepByStep/01_1-3/1-3-18.m4v’
file ‘StepByStep/01_1-3/1-3-19.m4v’
file ‘StepByStep/01_1-3/1-3-20.m4v’
file ‘StepByStep/01_1-3/1-3-21.m4v’
file ‘StepByStep/01_1-3/1-3-22.m4v’
file ‘StepByStep/01_1-3/1-3-23.m4v’
file ‘StepByStep/01_1-3/1-3-24.m4v’
file ‘StepByStep/01_1-3/1-3-25.m4v’
file ‘StepByStep/01_1-3/1-3-26.m4v’
file ‘StepByStep/01_1-3/1-3-27.m4v’
file ‘StepByStep/01_1-3/1-3-28.m4v’
file ‘StepByStep/01_1-3/1-3-29.m4v’
file ‘StepByStep/01_1-3/1-3-30.m4v’
file ‘StepByStep/01_1-3/1-3-31.m4v’
file ‘StepByStep/01_1-3/1-3-32.m4v’
file ‘StepByStep/01_1-3/1-3-33.m4v’
file ‘StepByStep/01_1-3/1-3-34.m4v’
file ‘StepByStep/01_1-3/1-3-35.m4v’
file ‘StepByStep/01_1-3/1-3-36.m4v’
[/code]

만드는데 쓴 bash shell 명령은 다음과 같다.

[code]
for DIR in `ls`; do pushd $DIR; for FILE in `ls -tr`; do echo "file ‘StepByStep/`basename \`pwd\“/$FILE’"; done > ../../`basename \`pwd\`.txt`; popd; done
[/code]

3.  다음 명령어를 커맨드 프롬프트에서 실행한다.

[code]
ffmpeg -f concat -i filename.txt -c copy -fflags +genpts output.mp4
[/code]

이걸 디렉토리 별로 돌린 bash shell 명령은 다음과  같다

[code]
for TXT in `ls *.txt`; do ffmpeg -f concat -i $TXT -c copy -fflags +genpts `echo $TXT | cut -d. -f1`.mp4; done;
[/code]

 

참고: https://superuser.com/questions/1039678/merge-multiple-video-with-ffmpeg-single-command-line-in-specific-time-without-cu

 

moniwiki 설치

글 정리할 때 익숙한 건 역시 moniwiki다. 다시 설치하려니 github로 옮겨가고, wikiseed 심는 것도 따로 프로젝트를 따로 뒀던데 다시 설치하는 절차를 정리한다.

설치하려는 디렉토리 아래(난 /var/www/)에서 git clone

[code]
git clone https://github.com/wkpark/moniwiki.git
chown -R www-data:www-data moniwiki
cd moniwiki/
git clone https://github.com/wkpark/moniwiki-wikiseed.git wikiseed
cd theme/
git clone https://github.com/wkpark/moniwiki-theme-paper.git paper
git clone https://github.com/wkpark/moniwiki-theme-bootstrap3.git bootstrap3
git clone https://github.com/wkpark/moniwiki-theme-publish.git publish
[/code]

브라우저에서 monisetup.php 접속

  1.  $sitename 설정
  2.  $admin_passwd 설정
  3.  $use_sectionedit 설정
  4.  “Sow wikiseed” 로 wiki seed 심기

추가로 config.php 에서 고치기

http://blog.dasomoli.org/240 참고

쉘에서 secure.sh 실행

[code]
sh secure.sh
[/code]

apache2 설정

/etc/apache2/sites-available/moniwiki.dasomoli.org.conf

[code]
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request’s Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName moniwiki.dasomoli.org

<Directory /var/www/moniwiki>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>

ServerAdmin dasomoli@gmail.com
DocumentRoot /var/www/moniwiki

# Available loglevels: trace8, …, trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/moniwiki_error.log
CustomLog ${APACHE_LOG_DIR}/moniwiki.access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with “a2disconf”.
Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
[/code]

moniwiki 디렉토리에 index.html 생성

/var/www/moniwiki/index.html

[code]
<html>
<head>
<meta http-equiv=”refresh” content=”0; url=./wiki.php”>
</head>
<body onload=”javascript:window.location=’./wiki.php'”>
Please follow <a href=”wiki.php”>this link</a>
</body>
</html>
[/code]

[vi] .vimrc

.vimrc 같은건 대충 필요한 것만 그때 그때 써서 썼는데 새 환경에서 하나하나 쓰려니 귀찮다. 복사해서 쓸 수 있게 여기다 하나 써두고 업데이트하자.

syntax on

set autoindent
set cindent
:set smartindent
set noexpandtab

set nu

set hlsearch

set ts=4
set shiftwidth=4

set laststatus=2
set statusline=\ %<%l:%v\ [%P]%=%a\ %h%m%r\ %F\
set incsearch

colorscheme elflord

set tags=./tags,tags
set tags+=/usr/src/linux/tags
set tags+=../tags
set tags+=../../tags
set tags+=../../../tags

highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/

https://medium.com/sunhyoups-story/vim-%EC%97%90%EB%94%94%ED%84%B0-%EC%9D%B4%EC%81%98%EA%B2%8C-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0-5b6b8d546017

[Windows] Command Prompt의 Current Code page 변경

Windows에서 명령줄을 띄워서 작업할 때, 어떤 에러 메시지 등을 google에서 찾아보고 싶은 경우 같은 때, 나오는 메시지의 언어를 바꾸고 싶을 때가 있다. 이럴 때 “LANG” 환경 변수 등을 바꾸어도 그대로 에러 메시지 등이 우리말로 나온다. 요건 mingw 같은 환경에서 shell을 써도 마찬가지. 한국판 Windows를 깔면 기본이 CP949로 설정되어 에러 메시지 등이 우리말로 나오는 것인데, 다음과 같이 CHCP 명령을 이용하면 된다. 65001은 UTF-8이다.

CHCP 65001

참고: https://superuser.com/questions/269818/change-default-code-page-of-windows-console-to-utf-8