2017年11月28日 星期二

Bash if

if [[ -n "${VAR}" ]]; then
  echo variable VAR is set and value is ${VAR}
fi

if [[ -z "${VAR}" ]]; then
  echo variable VAR is unset or empty
fi

                        +-------+-------+-----------+
                VAR is: | unset | empty | non-empty |
+-----------------------+-------+-------+-----------+
| [ -z "${VAR}" ]       | true  | true  | false     |
| [ -z "${VAR+set}" ]   | true  | false | false     |
| [ -z "${VAR-unset}" ] | false | true  | false     |
| [ -n "${VAR}" ]       | false | false | true      |
| [ -n "${VAR+set}" ]   | false | true  | true      |
| [ -n "${VAR-unset}" ] | true  | false | true      |
+-----------------------+-------+-------+-----------+

if [[ -e file.txt ]]; then
  echo file.txt is exist
fi

if [[ ! -e file.txt ]]; then
  echo file.txt is NOT exist
fi

http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html

2017年11月20日 星期一

docker jekyll on windows 10

docker run -p 80:4000 -v c:\tmp:/srv/jekyll jekyll/jekyll jekyll s -s ./my-site --watch --force-polling

Browse http://127.0.0.1:4000

on Windows 7  with Docker toolbox:
replace "c:\tmp" to "/c/tmp"

docker run -p 4000:4000 -v /c/Users/Jack_Lin/Documents/abc:/srv/jekyll jekyll/jekyll jekyll s --watch --force-polling

Browse http://192.168.99.100:4000

If your want to customize minima theme. check
https://github.com/jekyll/minima

Setup proxy on Docker Toolbox on Windows7

https://github.com/docker/toolbox/issues/102

Hi!,
Just tested the following steps on Win7 with Docker-toolbox and it works ! Wow!
Split from windows command directory to linux with the following command:
$ docker-machine ssh default
Now the command line start with "docker@default:~$"
Write sudo ..... as the following line
docker@default:~$ sudo vi /var/lib/boot2docker/profile
Write "i" to pass in insert mode and return button.
Add the two http export settings with username and password :
export "HTTP_PROXY=http://username:password@proxy.something.it:port"
export "HTTPS_PROXY=http://username:password@proxy.something.it:port"
Digit esc ": wq!" to save the new line and verify if everithing is ok with the cat command
docker@default:~$ cat /var/lib/boot2docker/profile
Restart the daemon
docker@default:~$ sudo /etc/init.d/docker restart
Now i have restarted the Docker toolbox and the "Docker pull image_name" work fine!
Thanks a lot to everybody!