apt-get upgrade がコケる

ubuntu 18.04 で apt-get update; apt-get -y upgrade したら以下のエラーでコケる・・・

Unpacking base-files (10.1ubuntu2.4) over (10.1ubuntu2.3) …
Failed to reload daemon: Refusing to reload, not enough space available on /run/systemd. Currently, 14.6M are free, but a safety buffer of 16.0M is enforced.
Failed to reload daemon: Refusing to reload, not enough space available on /run/systemd. Currently, 14.6M are free, but a safety buffer of 16.0M is enforced.
Setting up base-files (10.1ubuntu2.4) …
Installing new version of config file /etc/issue …
Installing new version of config file /etc/issue.net …
Installing new version of config file /etc/lsb-release …
Failed to reload daemon: Refusing to reload, not enough space available on /run/systemd. Currently, 14.6M are free, but a safety buffer of 16.0M is enforced.
Failed to reload daemon: Refusing to reload, not enough space available on /run/systemd. Currently, 14.6M are free, but a safety buffer of 16.0M is enforced.

Unpacking libsystemd0:amd64 (237-3ubuntu10.12) over (237-3ubuntu10.9) …
Setting up libsystemd0:amd64 (237-3ubuntu10.12) …
Setting up systemd (237-3ubuntu10.12) …
Failed to reload daemon: Refusing to reexecute, not enough space available on /run/systemd. Currently, 14.7M are free, but a safety buffer of 16.0M is enforced.
Warning: The unit file, source configuration file or drop-ins of systemd-networkd.service changed on disk. Run ‘systemctl daemon-reload’ to reload units.
Warning: The unit file, source configuration file or drop-ins of systemd-resolved.service changed on disk. Run ‘systemctl daemon-reload’ to reload units.
Warning: The unit file, source configuration file or drop-ins of systemd-timesyncd.service changed on disk. Run ‘systemctl daemon-reload’ to reload units.
Warning: The unit file, source configuration file or drop-ins of systemd-journald.service changed on disk. Run ‘systemctl daemon-reload’ to reload units.
(Reading database … 88712 files and directories currently installed.)
Preparing to unpack …/systemd-sysv_237-3ubuntu10.12_amd64.deb …
Unpacking systemd-sysv (237-3ubuntu10.12) over (237-3ubuntu10.9) …
Preparing to unpack …/kmod_24-1ubuntu3.2_amd64.deb …
Unpacking kmod (24-1ubuntu3.2) over (24-1ubuntu3.1) …
Failed to reload daemon: Refusing to reload, not enough space available on /run/systemd. Currently, 14.6M are free, but a safety buffer of 16.0M is enforced.

調べると以下のコマンドが出て来た。

mount -t tmpfs tmpfs /run -o remount,size=32M,nosuid,noexec,relatime,mode=755

出展:https://plaza.rakuten.co.jp/dogfoods/diary/201708130000/

パッケージが悪いのか?と思ったが、ディスク容量が足りてなかったみたい。

問題の環境のディスク構成(コマンド実行前とコマンド実行後)

root@server00:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 102M 0 102M 0% /dev
tmpfs 23M 4.5M 19M 20% /run
/dev/sda1 9.8G 2.0G 7.4G 21% /
tmpfs 115M 0 115M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 115M 0 115M 0% /sys/fs/cgroup
tmpfs 23M 0 23M 0% /run/user/0
root@server00:~# mount -t tmpfs tmpfs /run -o remount,size=32M,nosuid,noexec,relatime,mode=755
root@server00:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 102M 0 102M 0% /dev
tmpfs 32M 4.5M 28M 14% /run
/dev/sda1 9.8G 2.0G 7.4G 21% /
tmpfs 115M 0 115M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 115M 0 115M 0% /sys/fs/cgroup
tmpfs 23M 0 23M 0% /run/user/0

超激安VPS(月額 $1)だったので、ディスク容量が猛烈に少なかったのが原因かな?

Django に curl でアクセスする

Django に curl でログインして別なページの内容を取得する必要があった

http://stackoverflow.com/questions/21306515/how-to-curl-an-authenticated-django-app

ここを参考にしたけど全く動かん・・・
試行錯誤した結果・・・

#!/bin/bash

SERVER=http://192.168.12.34:8000
LOGIN_URL=${SERVER}/login/
TARGET_URL=${SERVER}/secure/data
YOUR_USER='user'
YOUR_PASS='pass'

COOKIES=/tmp/cookies_${USER}.txt
CURL_BIN="curl -s -c ${COOKIES} -b ${COOKIES} -e ${LOGIN_URL}"

DJANGO_TOKEN_MIDDLE=$($CURL_BIN $LOGIN_URL | grep csrfmiddlewaretoken | sed -e "s/.*value='//" -e "s/'.*//")

${CURL_BIN} \
    --data "csrfmiddlewaretoken=${DJANGO_TOKEN_MIDDLE}&username=${YOUR_USER}&password=${YOUR_PASS}&next=/" \
    ${LOGIN_URL}

${CURL_BIN} \
    ${TARGET_URL}

rm $COOKIES

最終的に http://192.168.12.34:8000/secure/data の内容を取得できる。
Django 1.10.6 で確認済み。

CentOS で yum update がエラーになる

CentOS 5.2 を入れて、

yum -y update

と入力すると・・・

[Errno -1] Metadata file does not match checksum
Trying other mirror.

というエラーが大量に出て、結局アップデート出来なかった。
 
原因不明で、ググッたけど良く分からず。
yum のオプションを見てみると、clear というオプションが使えるらしい。
そこで

yum clear all

とすると、あら不思議。
yum でアップデートが出来るようになった。