Don't clutter disk when debug mode is not set

This commit is contained in:
Disassembler 2018-09-02 20:59:48 +02:00
parent 46f212f1d9
commit 765f34f3f4
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
3 changed files with 20 additions and 22 deletions

View File

@ -30,7 +30,11 @@ ${SOURCE_DIR}/seeddms.sh
${SOURCE_DIR}/sigmah.sh
${SOURCE_DIR}/ushahidi.sh
# Perform cleanup only if DEBUG environment variable is not set
if [ ${DEBUG:-0} -eq 0 ]; then
${SOURCE_DIR}/zz-cleanup.sh
fi
# Perform cleanup only if DEBUG mode is not set
[ ${DEBUG:-0} -eq 1 ] && exit 0
# Clean package cache
rm -rf /var/cache/apk/*
# Remove root settings
find /root -mindepth 1 -maxdepth 1 | xargs rm -rf
# Change root password
passwd

View File

@ -4,14 +4,19 @@ set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/basic
# Install packages
apk --no-cache add --virtual .useful git file htop less openssh-server openssh-sftp-server
apk --no-cache add curl docker e2fsprogs-extra gettext kbd-misc libressl python3 py3-bcrypt py3-cffi py3-dnspython py3-jinja2 py3-requests py3-six py3-werkzeug nginx util-linux
if [ ${DEBUG:-0} -eq 1 ]; then
# Install some utilities for DEBUG mode
apk --no-cache add git file htop less openssh-server openssh-sftp-server
fi
# Copy profile files and settings
mkdir -p /root/.config/htop /root/.ssh
cp ${SOURCE_DIR}/root/.profile /root/.profile
cp ${SOURCE_DIR}/root/.ssh/authorized_keys /root/.ssh/authorized_keys
cp ${SOURCE_DIR}/root/.config/htop/htoprc /root/.config/htop/htoprc
# Copy root profile files and settings for DEBUG mode
if [ ${DEBUG:-0} -eq 1 ]; then
mkdir -p /root/.config/htop /root/.ssh
cp ${SOURCE_DIR}/root/.profile /root/.profile
cp ${SOURCE_DIR}/root/.ssh/authorized_keys /root/.ssh/authorized_keys
cp ${SOURCE_DIR}/root/.config/htop/htoprc /root/.config/htop/htoprc
fi
# Copy boot configuration
cp ${SOURCE_DIR}/boot/extlinux.conf /boot/extlinux.conf
@ -30,7 +35,7 @@ cp ${SOURCE_DIR}/etc/conf.d/ntpd /etc/conf.d/ntpd
# Create a self-signed certificate
mkdir /etc/ssl/private
openssl req -x509 -new -out /etc/ssl/certs/services.pem -keyout /etc/ssl/private/services.key -nodes -days 7305 -subj "/CN=$(hostname)"
openssl req -x509 -new -out /etc/ssl/certs/services.pem -keyout /etc/ssl/private/services.key -nodes -days 7305 -subj "/CN=spotter.vm"
chmod 640 /etc/ssl/private/services.key
# Configure nginx

View File

@ -1,11 +0,0 @@
#!/bin/sh
set -e
# Remove packages not necessary for release
apk --no-cache del .useful
# Clean package cache
rm -rf /var/cache/apk/*
# Remove user settings
rm -rf /root/* /root/.*