diff options
author | Dennis Eriksen <d@ennis.no> | 2020-09-06 20:45:53 +0200 |
---|---|---|
committer | Dennis Eriksen <d@ennis.no> | 2020-09-06 20:45:53 +0200 |
commit | 56ce7fe4167cce90347039cee357220352a5ac07 (patch) | |
tree | 1067505e0c4bdf3094cd1aff43adbfd9d0008024 /mkosi.postinst | |
download | mkosi-mayan-edms-56ce7fe4167cce90347039cee357220352a5ac07.tar.gz |
Initial commit
Diffstat (limited to 'mkosi.postinst')
-rwxr-xr-x | mkosi.postinst | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/mkosi.postinst b/mkosi.postinst new file mode 100755 index 0000000..a742824 --- /dev/null +++ b/mkosi.postinst @@ -0,0 +1,64 @@ +#export DEBIAN_FRONTEND=noninteractive!/bin/sh +set -ex +export DEBIAN_FRONTEND=noninteractive + +# motd +chmod 644 /etc/update-motd.d/* +systemctl mask motd-news.service +systemctl mask motd-news.timer + +# Add update- and security-repositories, and perform upgrade +RELEASE=$(grep DISTRIB_CODENAME /etc/lsb-release | awk -F'=' '{print $2}') +echo "deb http://no.archive.ubuntu.com/ubuntu ${RELEASE}-security main universe" >> /etc/apt/sources.list +echo "deb http://no.archive.ubuntu.com/ubuntu ${RELEASE}-updates main universe" >> /etc/apt/sources.list +apt-get update && apt-get --yes full-upgrade && apt-get --yes autoremove + +# locales +sed -i 's/# en_IE.UTF-8 UTF-8/en_IE.UTF-8 UTF-8/' /etc/locale.gen +locale-gen + + +# Installing +# From https://docs.mayan-edms.com/chapters/deploying.html + +apt-get install exiftool g++ gcc coreutils ghostscript gnupg1 graphviz libfuse2 libjpeg-dev libmagic1 libpq-dev libpng-dev libreoffice libtiff-dev poppler-utils postgresql-client python3-dev python3-virtualenv redis-server sane-utils supervisor tesseract-ocr zlib1g-dev -y + +# Create user +groupadd --system mayan +useradd --system --home-dir /opt/mayan-edms --create-home --shell /usr/sbin/nologin --gid mayan mayan +mv /root/env /opt/mayan-edms/ +virtualenv /opt/mayan-edms -p /usr/bin/python3 +chown mayan:mayan /opt/mayan-edms -R + +# variables +export MAYAN_MEDIA_ROOT=/opt/mayan-edms/media +export MAYAN_STATIC_ROOT=/opt/mayan-edms/static +. /opt/mayan-edms/env + +# Install application +sudo -u mayan /opt/mayan-edms/bin/pip install -U pip +sudo -u mayan /opt/mayan-edms/bin/pip install --use-feature=2020-resolver mayan-edms +sudo -u mayan /opt/mayan-edms/bin/pip install psycopg2==2.8.4 redis==3.4.1 + +# Bootstrap mayan +#sudo --preserve-env -u mayan /opt/mayan-edms/bin/mayan-edms.py initialsetup +sudo --preserve-env -u mayan /opt/mayan-edms/bin/mayan-edms.py installdependencies +sudo --preserve-env -u mayan /opt/mayan-edms/bin/mayan-edms.py preparestatic + +# supervisor +sudo --preserve-env -u mayan /opt/mayan-edms/bin/mayan-edms.py platformtemplate supervisord | sudo sh -c "cat > /etc/supervisor/conf.d/mayan.conf" +sed -i "/MAYAN_MEDIA_ROOT/a \ \ \ \ MAYAN_STATIC_ROOT=\"${MAYAN_STATIC_ROOT}\"," /etc/supervisor/conf.d/mayan.conf +sed -i 's/8000/8311/' /etc/supervisor/conf.d/mayan.conf + +systemctl enable supervisor + +# Redis +sed -i "s/mayanredispassword/${MAYAN_REDIS_PASSWORD}/" /etc/supervisor/conf.d/mayan.conf +echo "maxmemory-policy allkeys-lru" >> /etc/redis/redis.conf +echo "save \"\"" >> /etc/redis/redis.conf +echo "databases 2" >> /etc/redis/redis.conf +echo "requirepass ${MAYAN_REDIS_PASSWORD}" >> /etc/redis/redis.conf + +# Some cleanup +apt remove --yes --purge libjpeg-dev libpq-dev libpng-dev libtiff-dev zlib1g-dev +rm /opt/mayan-edms/env |