0. Problems

Since Django is rapidly developed, many tutorials about Django could be out-dated. I am learning Django and found that some commands have beed deprecated but the tutorial didn't update them.
So here I am taking notes for some of the deprecated commmands that I have encountered.

1. Can't use "python manage.py validate"

When learning the Django book, you might see this (if it's not updated):

python manage.py validate

It returns:

Unknown command: 'validate'
Type 'manage.py help' for usage.

Use this instead:

python manage.py check

2. Can't use "python manage.py sqlall" or "python manage.py syncdb"

python manage.py sqlall books
python manage.py syncdb

It returns:

Unknown command: 'sqlall'
Type 'manage.py help' for usage.

and

Unknown command: 'syncdb'
Type 'manage.py help' for usage.

Use this instead:

python manage.py makemigrations books
# Returns:
#Migrations for 'books':
#  books/migrations/0001_initial.py:
#    - Create model Author
#    - Create model Book
#    - Create model Publisher
#    - Add field publisher to book

python manage.py migrate
# Returns:
# Operations to perform:
#  Apply all migrations: admin, auth, books, contenttypes, sessions
# Running migrations:
#  Applying books.0001_initial... OK

python manage.py sqlmigrate books 0001
# This will return the sql command executed on the mysql server

1. Intro

This post is to take notes about how I set up auto reload Django environment in docker.

I am learning Django recently, but I don't want to install the Django directly on my vps. As you know, the installation of Django will change the environment a lot, which is not friendly for maintenance. So I will try to keep every thing inside a container.

Unfortunately, the author of the docker image didn't make the Django automatically reload when changing the codes. That's why I did the following things.

With the help of Git hook, it is quite easy to realize it automatically. The strategy is shown as the following figure:
django-git.png

Every time when new commit is pushed to the git server, the git hook will deploy the source files to the mapped volume of the container, and also touch a reload.ini file which tells the uwsgi to gracefully reload the codes without restart the container.

Read more »

MiniDLNA

MiniDLNA is a simple media server software, with the aim of being fully compliant with DLNA/UPnP-AV clients.

MiniDLNA Docker Images

This image is based on Alpine Linux.

Usage

Example:

docker run -d --name minidlna \
      --net=host \
      -p 8200:8200 \
      -p 1900:1900/udp \
      -v <PATH_TO_MUSIC_DIR>:/opt/Music \
      -v <PATH_TO_VIDEOS_DIR>:/opt/Videos \
      -v <PATH_TO_PICUTRES_DIR>:/opt/Pictures \
      geekduck/minidlna

If you want to overwrite a config file:

docker run -d --name minidlna \
      --net=host \
      -p 8200:8200 \
      -p 1900:1900/udp \
      -v <PATH_TO_MUSIC_DIR>:/opt/Music \
      -v <PATH_TO_VIDEOS_DIR>:/opt/Videos \
      -v <PATH_TO_PICUTRES_DIR>:/opt/Pictures \
      -v <PATH_TO_CONFIG_DIR>/minidlna.conf:/etc/minidlna.conf \
      geekduck/minidlna

Problems when build from armhf-alpine

1. Can't find the package: minidlna

Check Build Log

2. Entrypoint should be changed

Previous entrypoint is /usr/sbin/minidlnad -d
After make install, the entrypoint should be changed to /usr/local/sbin/minidlnad -d

1. Intro

Here I introduce a useful plugin that I have searched for long:
rosenfeld/conque-term

This vim plugin can run interactive commands inside a Vim buffer. For example, I need to run python console while using vim. I just need to type this command:
:ConqueTermSplit python
vim-conque-term-screenshot.png

Read more »

Prerequisite

  • VPS
  • Linux
  • Docker

Installation

OVPN_DATA="ovpn-data"

Change ovpn-data to the path you want to store your keys for the OpenVPN.

docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_genconfig -u udp://VPN.SERVERNAME.COM
docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki

Change VPN.SERVERNAME.COM to the IP of the VPS.

docker run -v $OVPN_DATA:/etc/openvpn -d -p 1194:1194/udp --cap-add=NET_ADMIN kylemanna/openvpn

Change the port number 1194 to any available port that you want to use.

docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn easyrsa build-client-full CLIENTNAME nopass
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_getclient CLIENTNAME > CLIENTNAME.ovpn

Change the CLIENTNAME to the users who will connect the VPN.