====== 미니 서버 문서 ====== ===== 주요 토픽들 ======= [[miniserver:xenial|Ubuntu 16.04 설치와 운영 노트]] [[miniserver:specs|모델과 사양]] ===== 아파치2 SSL 구축 ===== [[ https://www.digitalocean.com/community/tutorials/how-to-create-a-ssl-certificate-on-apache-for-ubuntu-12-04 | 참고 자료 ]] # apt-get install apache2 # a2enmod ssl # service apache2 restart # mkdir /etc/apache2/ssl # openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt # Common Name 에서 도메인 이름을 제대로 적어줄 것. default-ssl 파일 조정. ServerAdmin, ServerName 올바르게 조정하고 바로 아래에, SSLEngine On SSLCertificateFile /etc/apache2/ssl/apache.crt SSLCertificateKeyFile /etc/apache2/ssl/apache.key 그리고 사이트 열기. # a2ensite default-ssl # service apache2 restart 여기서 서버가 제대로 동작하지 않으면, 에러 로그를 살펴 보자. ''Server should be SSL-aware but has no certificate configured [Hint: SSLCertificateFile]'' 이런 로그를 발견한다면 제대로 설정이 안 된 것이다. 가상 호스트 설정 또한 위와 마찬가지로 각각의 ServerName 마다 SSLEngine/SSLCertificateFile/SSLCertificateKeyFile 항목을 설정한다. 마지막으로 SSL에서도 VirtualHost를 하도록 NameVirtualHost *:443 Listen 443 설정도 추가한다. 이건 우분투 관련 설정이므로 적당히 고쳐서 써야 한다는 점 주의. ===== 사운드 설정 ===== $ sudo apt-get remove --purge alsa-base pulseaudio $ sudo apt-get install alsa-base pulseaudio $ sudo alsa force-reload alsamixer 에서 MUTED 해제. 'MM'이라고 써져 있음 안됨. ===== 블루투스 사용 ===== # apt-get install bluez python-gobject python-dbus 블루투스 스피커를 사용해 보고 싶어 작업을 진행해 보았다. bluez, bluez-tools 패키지 설치. 설치 후 장비 검색 명령 $ hcitool scan Scanning ... 40:EF:4C:15:DF:B2 IA160 28:E3:47:83:C2:0A laptop ''40:EF:4C:15:DF:B2'' 주소의 'IA160'이 내가 연결하고 싶은 블루투스 스피커이다. 서버에 사운드 설정을 하지 않아서 pulseaudio를 설치했다. $ sudo apt-get install pulseaudio bluez-alsa $ sudo update-rc.d pulseaudio defaults $ sudo update-rc.d bluetooth defaults [[.:bluetooth_sound]] 문서에서 기록 ====== BitTorrent Sync 사용 ====== vagrant와 이를 이용한 virtual machine 내역을 공유하기 위하여 NAS에 BitTorrent Sync를 이용해 보았다. 대용량 파일 변화 감지에 매우 유용하므로, 꽤 괜찮은 선택이 될 듯하다. 우선 이전 [[project:btsyncforrpi]] 문서에 많은 내용이 우선 기록되어 있다. 문서를 작성하는 2015년 11월까지도 리눅스는 별도의 GUI는 제공하지 않으므로, 데스크탑에서는 적당히 btsync를 꺼내 쓰면 될 것 같다. ===== NAS Config ===== 별도의 사용자 btsync를 만들고 홈디렉토리에 .sync 디렉토리를 생성하고 여기에 모든 설정 파일등을 집어 넣는 식으로 작성하였다 이와 관련해서는 이전 문서를 참고. { "device_name": "MiniServer", "listening_port" : 0, // 0 - randomize port /* storage_path dir contains auxilliary app files if no storage_path field: .sync dir created in the directory where binary is located. otherwise user-defined directory will be used */ "storage_path" : "/home/btsync/.sync", /* set location of pid file */ "pid_file" : "/home/btsync/.sync/btsync.pid", /* use UPnP for port mapping */ "use_upnp" : true, /* limits in kB/s. 0 - no limit */ "download_limit" : 0, "upload_limit" : 0, /* proxy configuration */ // "proxy_type" : "socks4", // Valid types: "socks4", "socks5", "http_connect". Any other value means no proxy // "proxy_addr" : "192.168.1.2", // IP address of proxy server. // "proxy_port" : 1080, // "proxy_auth" : false, // Use authentication for proxy. Note: only username/password for socks5 (RFC 1929) is supported, and it is not really secure // "proxy_username" : "user", // "proxy_password" : "password", "webui" : { "listen" : "0.0.0.0:8888" // remove field to disable WebUI /* preset credentials. Use password or password_hash */ // ,"login" : "admin" // ,"password" : "password" // ,"password_hash" : "some_hash" // password hash in crypt(3) format // ,"allow_empty_password" : false // Defaults to true /* ssl configuration */ // ,"force_https" : true // disable http // ,"ssl_certificate" : "/path/to/cert.pem" // ,"ssl_private_key" : "/path/to/private.key" /* directory_root path defines where the WebUI Folder browser starts (linux only). Default value is / */ // ,"directory_root" : "/home/user/MySharedFolders/" /* directory_root_policy defines how directory_root is used (linux only). Valid values are: "all" - accepts directory_root and its subdirectories for 'getdir' and 'adddir' actions "belowroot" - accepts directory_root's subdirectories for 'getdir' and 'adddir' actions, but denies attempts to use 'adddir' to create directories directly within directory_root Default value is "all". */ // ,"directory_root_policy" : "all" /* dir_whitelist defines which directories can be shown to user or have folders added (linux only) relative paths are relative to directory_root setting */ // ,"dir_whitelist" : [ "/home/user/MySharedFolders/personal", "work" ] } /* !!! if you set shared folders in config file WebUI will be DISABLED !!! shared directories specified in config file override the folders previously added from WebUI. */ , "shared_folders" : [ /* { "secret" : "MY_SECRET_1", // required field - use --generate-secret in command line to create new secret "dir" : "/home/user/bittorrent/sync_test", // * required field "use_relay_server" : true, // use relay server when direct connection fails "use_tracker" : true, "use_dht" : false, "search_lan" : true, "use_sync_trash" : true, // enable SyncArchive to store files deleted on remote devices "overwrite_changes" : false, // restore modified files to original version, ONLY for Read-Only folders "known_hosts" : // specify hosts to attempt connection without additional Dsearch [ "192.168.1.2:44444" ] } */ { "secret" : "", "dir" : "/home/btsync/", "use_relay_server" : true, "use_tracker" : true, "search_lan" : true, "use_sync_trash" : true, "overwrite_changes" : false, "known_hosts" : [ "192.168.0.4:48867" ] } ] /* Advanced preferences can be added to config file. Info is available at "http://help.getsync.com/customer/portal/articles/1902048-sync-advanced-preferences--more-options" For example see folder_rescan_interval below */ // "folder_rescan_interval" : "86400" } 이 정도 예로 만들면 될 것 같다. 아래는 우분투에서 쓸 init script #!/bin/sh ### BEGIN INIT INFO # Provides: btsync # Required-Start: $local_fs $remote_fs # Required-Stop: $local_fs $remote_fs # Should-Start: $network # Should-Stop: $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Multi-user daemonized version of btsync. # Description: Starts the btsync daemon for all registered users. ### END INIT INFO # Replace with linux users you want to run BTSync clients for BTSYNC_USERS="btsync" DAEMON=/usr/local/bin/btsync start() { for btsuser in $BTSYNC_USERS; do HOMEDIR=`getent passwd $btsuser | cut -d: -f6` config=$HOMEDIR/.sync/config.json if [ -f $config ]; then echo "Starting BTSync for $btsuser" start-stop-daemon -b -o -c $btsuser -S -u $btsuser -x $DAEMON -- --config $config else echo "Couldn't start BTSync for $btsuser (no $config found)" fi done } stop() { for btsuser in $BTSYNC_USERS; do dbpid=`pgrep -fu $btsuser $DAEMON` if [ ! -z "$dbpid" ]; then echo "Stopping btsync for $btsuser" start-stop-daemon -o -c $btsuser -K -u $btsuser -x $DAEMON fi done } status() { for btsuser in $BTSYNC_USERS; do dbpid=`pgrep -fu $btsuser $DAEMON` if [ -z "$dbpid" ]; then echo "btsync for USER $btsuser: not running." else echo "btsync for USER $btsuser: running (pid $dbpid)" fi done } case "$1" in start) start ;; stop) stop ;; restart|reload|force-reload) stop start ;; status) status ;; *) echo "Usage: /etc/init.d/btsync {start|stop|reload|force-reload|restart|status}" exit 1 esac exit 0