Skip to content

Instantly share code, notes, and snippets.

@carlessanagustin
Last active May 18, 2016 15:29
Show Gist options
  • Save carlessanagustin/24714b6fb4039a3f8b26c5b639ad9e10 to your computer and use it in GitHub Desktop.
Save carlessanagustin/24714b6fb4039a3f8b26c5b639ad9e10 to your computer and use it in GitHub Desktop.
GNU Health installation script for Fundación Recover
#!/bin/bash
# following: https://en.wikibooks.org/wiki/GNU_Health/Installation
# for Ubuntu 14.04 LTS
### VARIABLES
TIMEZONE="Europe/Andorra"
CRON_COMMAND="ntpdate es.pool.ntp.org"
CRON_LINE="0 5 * * * root bash /etc/cron.daily/ntpdate"
DBUSER="gnuhealth"
GNUH_LOCATION="/home/gnuhealth"
GNUH_URL="http://ftp.gnu.org/gnu/health/gnuhealth-latest.tar.gz"
GNUH_SETUP_URL="ftp://ftp.gnu.org/gnu/health/gnuhealth-setup-latest.tar.gz"
### base
echo "START: Installing system packages..."
apt-get update
apt-get -y upgrade
apt-get -y install ntpdate sed wget git vim
apt-get -y install build-essential python-dev python-pip \
libxml2-dev libxslt1-dev libldap2-dev libsasl2-dev \
python-ldap bsdtar python-imaging python2.7-cracklib libjpeg-dev
echo "END: Installing system packages."
### timezone
echo "START: Setting timezone..."
echo $TIMEZONE > /etc/timezone
echo $CRON_COMMAND > /etc/cron.daily/ntpdate
chmod +x /etc/cron.daily/ntpdate
echo $CRON_LINE >> /etc/crontab
echo "END: Setting timezone."
## postgresql
echo "START: Installing postgresql..."
apt-get -y install postgresql postgresql-server-dev-all
PG_CONF=$(su - postgres -c "psql -t -P format=unaligned -c 'show config_file'")
sed -i "s|#listen_addresses = 'localhost'|listen_addresses = '*'|" $PG_CONF
PG_HBA=$(su - postgres -c "psql -t -P format=unaligned -c 'show hba_file'")
cat > $PG_HBA <<EOF
local all postgres peer
local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 md5
EOF
service postgresql restart
su - postgres -c "createuser --createdb --no-createrole --no-superuser $DBUSER"
echo "END: Installing postgresql..."
### gnuhealth
useradd -m gnuhealth
cd $GNUH_LOCATION
wget $GNUH_URL
tar zxvf gnuhealth-latest.tar.gz
cd gnuhealth-*
ROOT_LOCATION=$(pwd)
wget $GNUH_SETUP_URL -O - | tar -xzv
# mv -f /home/gnuhealth/gnuhealth-3.0.1 /home/gnuhealth/gnuhealth
chown -Rf gnuhealth:gnuhealth $GNUH_LOCATION
su - gnuhealth -c "bash $ROOT_LOCATION/gnuhealth-setup install"
## TODO: left here "source "$HOME"/.gnuhealthrc"
su - gnuhealth -c "source $GNUH_LOCATION/.gnuhealthrc"
## NOTE: not working :(
## NOTE: extra information
#echo "START: Installing GNU Health..."
#pip install trytond_health
#echo "END: Installing GNU Health..."
#
#echo "START: Installing GNU Healthmodules..."
#pip install trytond_health_ntd_dengue trytond_health_disability trytond_health_icd10pcs trytond_health_pediatrics trytond_health_reporting #trytond_health_surgery trytond_health_services trytond_health_history trytond_health_genetics trytond_health_profile trytond_health_ntd #trytond_health_stock trytond_health_archives trytond_health_crypto trytond_health_calendar trytond_health_pediatrics_growth_charts #trytond_health_lifestyle trytond_health_icd9procs trytond_health_icd10 trytond_health_mdg6 trytond_health_qrcodes trytond_health_ophtalmo #trytond_health_icpm trytond_health_imaging trytond_health_ophthalmology trytond_health_inpatient trytond_health_socioeconomics #trytond_health_inpatient_calendar trytond_health_gyneco trytond_health_icu trytond_health_lab trytond_health_iss #trytond_health_pediatrics_growth_charts_who trytond_health_ntd_chagas trytond_health_nursing trytond_health_who_essential_medicines
#echo "END: Installing GNU Healthmodules..."
### tryton - http://www.tryton.org/
#### server
# apt-get -y install tryton-server tryton-modules-all
#### client
# apt-get -y install build-essential python-dev python-pip
# pip install pygtk librsvg python-dateutil chardet simplejson cdecimal GooCalendar
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.provider "virtualbox"
config.vm.box = "ubuntu/trusty64"
config.vm.provider "virtualbox" do |vb|
vb.memory = 512
vb.cpus = 1
vb.gui = false
end
config.vm.boot_timeout = 60
config.vm.define "minimal" do |minimal|
minimal.vm.host_name = "minimal"
minimal.vm.network "forwarded_port", guest: 80, host: 8080, auto_correct: true
minimal.vm.network "private_network", ip: "192.168.32.10"
# minimal.vm.network "public_network", auto_config: true, virtualbox__intnet: true, bridge: "en0: Wi-Fi (AirPort)"
# minimal.vm.provision "shell", inline: "apt-get update && apt-get -y upgrade"
minimal.vm.provision :shell, :path => "bootstrap.sh"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment