#!/bin/sh
set -e

# For production builds change to DEBUG=0 or comment the line entirely
export DEBUG=1

SOURCE_DIR=$(realpath $(dirname "${0}"))

# Install shared packages and perform OS customization
${SOURCE_DIR}/basic.sh
${SOURCE_DIR}/basic-runtimes.sh

# Install applications
${SOURCE_DIR}/ckan.sh
# ${SOURCE_DIR}/crisiscleanup.sh
# ${SOURCE_DIR}/cts.sh
${SOURCE_DIR}/frontlinesms.sh
${SOURCE_DIR}/gnuhealth.sh
${SOURCE_DIR}/kanboard.sh
${SOURCE_DIR}/mifosx.sh
${SOURCE_DIR}/motech.sh
${SOURCE_DIR}/opendatakit-build.sh
${SOURCE_DIR}/opendatakit.sh
${SOURCE_DIR}/openmapkit.sh
${SOURCE_DIR}/pandora.sh
${SOURCE_DIR}/sahana.sh
${SOURCE_DIR}/sahana-demo.sh
${SOURCE_DIR}/sambro.sh
${SOURCE_DIR}/seeddms.sh
${SOURCE_DIR}/sigmah.sh
${SOURCE_DIR}/ushahidi.sh

# 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
