make /var/log readonly

Expect apps to redirect logs of stdout/stderr

Part of #503
This commit is contained in:
Girish Ramakrishnan
2015-10-15 00:43:11 -07:00
parent a977597217
commit 5d389337cd
6 changed files with 6 additions and 71 deletions
-40
View File
@@ -1,40 +0,0 @@
#!/bin/bash
set -eu -o pipefail
# this config matches the docker log-file configuration
# logrotate ignores daily/monthly etc with size directive
readonly logrotate_template=$(cat <<"EOF"
"$LOG_VOLUME/*" "$LOG_VOLUME/*/*" "$LOG_VOLUME/*/*/*" {
missingok
rotate 4
size 5M
nocompress
copytruncate
notifempty
create
su
maxage 7
}
EOF
)
readonly containers=$(docker ps -qa)
for container in $containers; do
echo "Cleaning up $container"
if logdir=$(docker inspect --format='{{index .Volumes "/var/log"}}' $container); then
echo -e "\tLogrotate files under $logdir"
logrotate_config=$(mktemp)
{ echo "$logrotate_template" | LOG_VOLUME="$logdir" envsubst; } > "${logrotate_config}"
logrotate "${logrotate_config}" # -f is not required since we are size based
find "${logdir}" -mindepth 3 -maxdepth 3 -type d -exec rm -rf {} + # since we logrotate only till depth 3
rm "${logrotate_config}"
fi
done
+2 -2
View File
@@ -2,8 +2,8 @@
Description=Cloudron Smart Cloud
Documentation=https://cloudron.io/documentation.html
StopWhenUnneeded=true
Requires=box.service docker_janitor.timer
After=box.service docker_janitor.timer
Requires=box.service
After=box.service
# AllowIsolate=yes
[Install]
@@ -1,14 +0,0 @@
[Unit]
Description=Docker Volumes Janitor
OnFailure=crashnotifier@%n.service
[Service]
Type=simple
Restart=no
ExecStart=/usr/sbin/docker_janitor
KillMode=process
User=root
Group=root
MemoryLimit=50M
WatchdogSec=180
@@ -1,10 +0,0 @@
[Unit]
Description=Docker Volumes Janitor
StopWhenUnneeded=true
[Timer]
# this activates it immediately
OnBootSec=0
OnCalendar=*-*-* 0,6,12,18:00:00
Unit=docker_janitor.service