Introduce GNU Health, related to #124
This commit is contained in:
parent
ef7eaba899
commit
be158a00d6
98
gnuhealth.sh
Normal file
98
gnuhealth.sh
Normal file
@ -0,0 +1,98 @@
|
||||
#!/bin/bash
|
||||
|
||||
SOURCE_DIR=$(realpath $(dirname "${0}"))
|
||||
|
||||
# Install dependencies for GNU Health
|
||||
apt-get -y --no-install-recommends install python3 python3-virtualenv virtualenv
|
||||
|
||||
# Donwload GNU Health
|
||||
wget http://ftp.gnu.org/gnu/health/gnuhealth-3.2.8.tar.gz -O /tmp/gnuhealth.tgz
|
||||
tar xzf /tmp/gnuhealth.tgz -C /srv
|
||||
mv /srv/gnuhealth-3.2.8 /srv/gnuhealth
|
||||
rm -f /tmp/gnuhealth.tgz
|
||||
|
||||
# Create Python virtualenv
|
||||
virtualenv --system-site-packages -p /usr/bin/python3 /srv/gnuhealth
|
||||
echo '. /srv/gnuhealth/bin/activate' >/srv/gnuhealth/.bash_profile
|
||||
|
||||
# Create database
|
||||
export GNUHEALTH_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '/+=')
|
||||
envsubst <${SOURCE_DIR}/gnuhealth/tmp/gnuhealth-createdb.sql >/tmp/gnuhealth-createdb.sql
|
||||
sudo -u postgres psql -f /tmp/gnuhealth-createdb.sql
|
||||
rm -f /tmp/gnuhealth-createdb.sql
|
||||
|
||||
# Create GNU Health OS user
|
||||
adduser --system --group --home /srv/gnuhealth --shell /bin/bash gnuhealth
|
||||
chown -R gnuhealth:gnuhealth /srv/gnuhealth
|
||||
|
||||
# Install GNU Health
|
||||
sudo -u gnuhealth -i /srv/gnuhealth/gnuhealth-setup install
|
||||
|
||||
# Configure GNU Health
|
||||
envsubst <${SOURCE_DIR}/gnuhealth/srv/gnuhealth/gnuhealth/tryton/server/config/trytond.conf >/srv/gnuhealth/gnuhealth/tryton/server/config/trytond.conf
|
||||
|
||||
# Populate database
|
||||
export GNUHEALTH_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
|
||||
echo ${GNUHEALTH_ADMIN_PWD} >/srv/gnuhealth/.adminpwd
|
||||
sudo -u gnuhealth -i TRYTONPASSFILE=/srv/gnuhealth/.adminpwd /srv/gnuhealth/gnuhealth/tryton/server/trytond-4.2.7/bin/trytond-admin -d gnuhealth --all -v
|
||||
rm -f /srv/gnuhealth/.adminpwd
|
||||
|
||||
# Configure GNU Health service
|
||||
cp ${SOURCE_DIR}/gnuhealth/lib/systemd/system/gnuhealth.service /lib/systemd/system/gnuhealth.service
|
||||
systemctl daemon-reload
|
||||
systemctl enable gnuhealth
|
||||
systemctl start gnuhealth
|
||||
|
||||
# Add portal application definition
|
||||
${SOURCE_DIR}/basic/portal-app-manager.py gnuhealth "https://{host}:8006/" admin "${GNUHEALTH_ADMIN_PWD}"
|
||||
${SOURCE_DIR}/basic/portal-app-manager.py gnuhealth-clients
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Add GNU Health + Tryton repository
|
||||
echo "deb http://debian.tryton.org/debian/ stretch-3.8 main" > /etc/apt/sources.list.d/tryton.list
|
||||
wget http://debian.tryton.org/debian/debian.tryton.org-archive.gpg -O - | apt-key add -
|
||||
apt-get -y update
|
||||
|
||||
# Install GNU Health
|
||||
apt-get -y --no-install-recommends install tryton-modules-health-all -t stretch-3.8
|
||||
|
||||
# Pin the Tryton repository packages
|
||||
cat <<EOF >/etc/apt/preferences.d/debian.tryton.org.pref
|
||||
Package: *
|
||||
Pin: release o=debian.tryton.org
|
||||
Pin-Priority: 999
|
||||
EOF
|
||||
# cp ${SOURCE_DIR}/gnuhealth/etc/apt/preferences.d/debian.tryton.org.pref /etc/apt/preferences.d/debian.tryton.org.pref
|
||||
|
||||
# Create database
|
||||
export GNUHEALTH_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '/+=')
|
||||
cat <<EOF >/tmp/gnuhealth-createdb.sql
|
||||
CREATE ROLE gnuhealth NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT LOGIN ENCRYPTED PASSWORD '${GNUHEALTH_PWD}';
|
||||
CREATE DATABASE gnuhealth;
|
||||
REVOKE ALL ON DATABASE gnuhealth FROM public;
|
||||
ALTER DATABASE gnuhealth OWNER TO gnuhealth;
|
||||
EOF
|
||||
# envsubst <${SOURCE_DIR}/gnuhealth/tmp/gnuhealth-createdb.sql >/tmp/gnuhealth-createdb.sql
|
||||
sudo -u postgres psql -f /tmp/gnuhealth-createdb.sql
|
||||
rm -f /tmp/gnuhealth-createdb.sql
|
||||
|
||||
# Configure GNU Health
|
||||
envsubst <${SOURCE_DIR}/gnuhealth/etc/tryton/trytond.conf >/etc/tryton/trytond.conf
|
||||
|
||||
# Populate database
|
||||
sudo -u tryton trytond -c /etc/tryton/trytond.conf -d gnuhealth --all -v
|
||||
|
||||
|
||||
|
||||
systemctl restart tryton-server.service
|
16
gnuhealth/lib/systemd/system/gnuhealth.service
Normal file
16
gnuhealth/lib/systemd/system/gnuhealth.service
Normal file
@ -0,0 +1,16 @@
|
||||
[Unit]
|
||||
Description=GNU Health Server
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=gnuhealth
|
||||
Environment=TRYTOND_CONFIG=/srv/gnuhealth/gnuhealth/tryton/server/config/trytond.conf
|
||||
Environment=VIRTUAL_ENV=/srv/gnuhealth
|
||||
Environment=PYTHONPATH=/srv/gnuhealth/gnuhealth/tryton/server/trytond-4.2.7:/srv/gnuhealth/gnuhealth/tryton/server/config
|
||||
Environment=PATH=/srv/gnuhealth/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
|
||||
WorkingDirectory=/srv/gnuhealth
|
||||
ExecStart=/srv/gnuhealth/gnuhealth/tryton/server/trytond-4.2.7/bin/trytond
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -0,0 +1,10 @@
|
||||
[database]
|
||||
uri = postgresql://gnuhealth:${GNUHEALTH_PWD}@localhost
|
||||
path = /srv/gnuhealth/attach
|
||||
|
||||
[web]
|
||||
listen = 0.0.0.0:8006
|
||||
|
||||
[webdav]
|
||||
listen = *:8080
|
||||
ssl_webdav = False
|
4
gnuhealth/tmp/gnuhealth-createdb.sql
Normal file
4
gnuhealth/tmp/gnuhealth-createdb.sql
Normal file
@ -0,0 +1,4 @@
|
||||
CREATE ROLE gnuhealth NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT LOGIN ENCRYPTED PASSWORD '${GNUHEALTH_PWD}';
|
||||
CREATE DATABASE gnuhealth;
|
||||
REVOKE ALL ON DATABASE gnuhealth FROM public;
|
||||
ALTER DATABASE gnuhealth OWNER TO gnuhealth;
|
Loading…
Reference in New Issue
Block a user