summaryrefslogtreecommitdiffstats
path: root/mkosi.postinst
blob: a74282469549ef94b44e68426481d5f3ee43d4e6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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