Skip to content

Instantly share code, notes, and snippets.

View xluffy's full-sized avatar
😶
&>/dev/null

xluffy xluffy

😶
&>/dev/null
View GitHub Profile
@xluffy
xluffy / systemd-sysv.md
Last active August 29, 2015 14:03
systemd - Convert A SysV Init Script Into A systemd Service File

Theo truyền thống, các dịch vụ (services or daemons) trên Linux hoặc Unix được khởi động thông qua một SysV init script. Chúng thực chất là các kịch bản Bourne Shell, thường được đặt trong một thư mục như /etc/rc.d/init.d và được gọi với một vài đối số (động từ) như start, stop hoặc restart, tức là dùng để khỏi động, tắt hoặc khỏi động lại dịch vụ.

Start thường liên quan đến việc gọi một dịch vụ nhị phân , sau đó fork ra một tiến trình nền (chính xác hơn l là daemonizes). Kịch bản shell có xu hướng chậm, khó đọc, dài dòng và mong manh. Mặc dù chúng vô cùng linh hoạt (sau cùng thì cũng chỉ là code), nhưng có một vài điểm rất khó làm đúng với một kịch bản shell, ví dụ ra lệnh thực hiện song song (parallelized), giám sát chính xác các tiến trình hoặc cấu hình các bối cảnh thực hiện một cách chi tiết.

@xluffy
xluffy / Install Gitit on Ubuntu 12.04 server.md
Last active August 29, 2015 14:11
Install Gitit on Ubuntu 12.04 server

Env

Môi trường: Ubuntu 12.04 server, x86_64

Service: Gitit (haskell)

Mirror

Mirror FPT

~$ sudo sed -i 's/vn.archive.ubuntu.com/mirror-fpt-telecom.fpt.net/g' /etc/apt/sources.list
# nginx config for A+ SSL Labs rating as of 9-2014
# Broad legacy compatibility including IE8/XP, Android 2.3+, openssl 0.9.8 clients
# Blocks most bot scans IP probes.
#
# *** Assumes: _HOSTNAME_ is replaced ***
#
# Includes OCSP stapling, HSTS Strict Transport security,
# session resumption, legacy backwards compatibility (XP, Android 2.3-4.3)
#
# Requires nginx 1.6.x. See: http://nginx.org/en/linux_packages.html, e.g.:
1. OpenBox
sudo apt-get install xorg openbox
su - x
vncpasswd ->>>> gitcmnhub
#!/bin/bash
PATH="$PATH:/usr/bin/"
export USER="x"
server {
listen 80;
server_name demo.wp.com;
root /home/wp/public;
index index.php index.html index.htm;
access_log /var/log/nginx/wp_access.log;
error_log /var/log/nginx/wp_error.log;
@xluffy
xluffy / quine1.sh
Created May 5, 2015 03:37
quine1.sh
#!/bin/bash
cat $0
@xluffy
xluffy / quine2.sh
Created May 5, 2015 03:38
quine2.sh
#!/bin/cat
@xluffy
xluffy / supervisord-init.sh
Created June 10, 2015 16:51
supervisord-init
#!/bin/bash
. /etc/init.d/functions
DAEMON=/usr/bin/supervisord
PIDFILE=/var/run/supervisord.pid
[ -x "$DAEMON" ] || exit 0
start() {
@xluffy
xluffy / supervisord.conf
Created June 11, 2015 01:51
supervisord.conf
[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod=0700 ; socket file mode (default 0700)
[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)